Files
app-govern/pages/mine/setupMessage.vue

147 lines
4.3 KiB
Vue
Raw Normal View History

2023-01-13 16:32:56 +08:00
<template>
2023-08-23 16:22:08 +08:00
<Cn-page :loading="loading">
<view class="mine" slot="body">
2023-08-10 09:18:17 +08:00
<view class="mine-nav" style="margin-top: 20rpx">
<view class="mine-nav-label">稳态越限</view>
2023-08-29 16:14:09 +08:00
<switch style="transform: scale(0.8)" color="#376cf3" @change="change('dataInfo')" :checked="config.dataInfo === 1"/>
2023-01-13 16:32:56 +08:00
</view>
2023-08-10 09:18:17 +08:00
<view class="mine-nav" style="border-bottom: none">
<view class="mine-nav-label">暂态事件</view>
2023-08-29 16:14:09 +08:00
<switch style="transform: scale(0.8)" color="#376cf3" @change="change('eventInfo')" :checked="config.eventInfo === 1"/>
2023-08-10 09:18:17 +08:00
</view>
<view class="mine-nav" style="border-bottom: none">
<view class="mine-nav-label">设备状态</view>
2023-08-29 16:14:09 +08:00
<switch style="transform: scale(0.8)" color="#376cf3" @change="change('deviceInfo')" :checked="config.deviceInfo === 1"/>
2023-08-10 09:18:17 +08:00
</view>
<view class="mine-nav" style="border-bottom: none">
<view class="mine-nav-label">设备消息</view>
2023-08-29 16:14:09 +08:00
<switch style="transform: scale(0.8)" color="#376cf3" @change="change('systemInfo')" :checked="config.systemInfo === 1"/>
2023-01-13 16:32:56 +08:00
</view>
</view>
2023-08-23 16:22:08 +08:00
</Cn-page>
2023-01-13 16:32:56 +08:00
</template>
<script>
2023-08-23 16:22:08 +08:00
import {queryUserPushConfig, updatePushConfig} from '@/common/api/mine'
2023-01-13 16:32:56 +08:00
export default {
2023-08-10 09:18:17 +08:00
data() {
2023-01-13 16:32:56 +08:00
return {
2023-08-23 16:22:08 +08:00
loading: true,
config: {},
2023-01-13 16:32:56 +08:00
}
},
methods: {
2023-08-23 16:22:08 +08:00
init() {
queryUserPushConfig().then(res => {
this.config = res.data
console.log(this.config)
this.loading = false
})
},
change(type) {
this.config[type] = this.config[type] === 1 ? 0 : 1
updatePushConfig(this.config).then(res => {
let str = ''
switch (type){
case 'dataInfo':
str = '稳态越限'
break
case 'eventInfo':
str = '暂态事件'
break
case 'deviceInfo':
str = '设备状态'
break
case 'systemInfo':
str = '设备消息'
break
}
this.$util.toast(`${str}推送${this.config[type] === 1 ? '开启' : '关闭'}成功`)
})
},
2023-08-10 09:18:17 +08:00
jump(type) {
2023-01-13 16:32:56 +08:00
switch (type) {
case 'changePwd':
uni.navigateTo({
2023-08-10 09:18:17 +08:00
url: `/pages/user/changePwd`,
2023-01-13 16:32:56 +08:00
})
2023-08-10 09:18:17 +08:00
break
2023-01-13 16:32:56 +08:00
case 'changePhone':
uni.navigateTo({
2023-08-10 09:18:17 +08:00
url: `/pages/user/changePhone`,
2023-01-13 16:32:56 +08:00
})
2023-08-10 09:18:17 +08:00
break
2023-01-13 16:32:56 +08:00
default:
uni.navigateTo({
2023-08-10 09:18:17 +08:00
url: `/pages/mine/${type}`,
2023-01-13 16:32:56 +08:00
})
2023-08-10 09:18:17 +08:00
break
2023-01-13 16:32:56 +08:00
}
2023-08-10 09:18:17 +08:00
},
2023-01-13 16:32:56 +08:00
},
2023-08-10 09:18:17 +08:00
onLoad() {
2023-01-13 16:32:56 +08:00
this.init()
},
}
</script>
<style lang="scss">
.mine {
2023-08-10 09:18:17 +08:00
.title {
padding: 0 20rpx;
font-size: 28rpx;
font-weight: 500;
}
2023-08-23 16:22:08 +08:00
2023-01-13 16:32:56 +08:00
.mine-header {
padding: 200rpx 34rpx 34rpx;
display: flex;
align-items: center;
background: $uni-theme-white;
margin-bottom: 20rpx;
box-shadow: 0 4rpx 8rpx #e7e7e74c;
.mine-header-head {
margin-right: 30rpx;
height: 128rpx;
width: 128rpx;
border-radius: $uni-theme-radius;
overflow: hidden;
}
.mine-header-name {
margin-right: 30rpx;
flex: 1;
font-size: 36rpx;
color: #111;
font-weight: 700;
}
}
.mine-nav {
2023-08-10 09:18:17 +08:00
padding: 34rpx;
2023-01-13 16:32:56 +08:00
display: flex;
align-items: center;
background: $uni-theme-white;
border-bottom: 1rpx solid #e8e8e8;
&-icon {
margin-right: 30rpx;
height: 44rpx;
width: 44rpx;
border-radius: $uni-theme-radius;
overflow: hidden;
}
&-label {
margin-right: 30rpx;
flex: 1;
font-size: 28rpx;
color: #111;
}
}
}
2023-08-10 09:18:17 +08:00
</style>