settings.vue
2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<template>
<div class="settings-page">
<!-- 顶部标题区域 -->
<div class="header">
<img src="@/assets/images/setting.png">
</div>
<!-- 设置选项列表 -->
<div class="settings-list">
<!-- 展业周报 -->
<div class="setting-item">
<span class="item-label">展业周报</span>
<van-switch
v-model="weeklyReport"
active-color="#0088FF"
size="18"
@change="switchChange($event, '展业周报', 'updateWeeklySubscribeStatus')"
inactive-color="#E6E6E6"
/>
</div>
<!-- 展业月报 -->
<div class="setting-item">
<span class="item-label">展业月报</span>
<van-switch
v-model="monthlyReport"
active-color="#0088FF"
size="18"
@change="switchChange($event, '展业月报','updateMonthlySubscribeStatus')"
inactive-color="#E6E6E6"
/>
</div>
</div>
</div>
</template>
<script type='text/ecmascript-6'>
import { reportApi } from '@/api'
export default {
name: 'Settings',
data () {
return {
weeklyReport: false,
monthlyReport: false
}
},
mounted () {
reportApi.getUserSubscribeConfig().then(res => {
if(res){
this.weeklyReport = res.weeklyReportSubscribe == 1 || false
this.monthlyReport = res.monthlyReportSubscribe == 1 || false
}
})
},
methods: {
switchChange (e, name, apiName) {
reportApi[apiName]({ subscribeStatus: e ? 1 : 0 }).then(res => {
if (res) {
this.$toast(`已${e ? '开启' : '关闭'}${name}订阅`)
} else {
this.$toast.fail('操作失败')
}
})
}
}
}
</script>
<style scoped lang='scss'>
.settings-page {
min-height: 100vh;
background: linear-gradient(180deg, #f5f7ff 0%, #e8ecff 100%);
padding: 14px 16px;
}
.header {
height: 130px;
}
.settings-list {
background: #ffffff;
border-radius: 16px;
overflow: hidden;
margin-top: -45px;
padding: 0 16px;
}
.setting-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 16px 0;
border-bottom: 1px solid #f5f5f5;
&:last-child {
border-bottom: none;
}
.item-label {
color: #0a3479;
font-size: 15px;
}
}
</style>