Files
RentWeAppFront/pages-biz/profile/setting.vue

144 lines
3.1 KiB
Vue
Raw Normal View History

2026-01-15 17:18:24 +08:00
<template>
<view>
<u-navbar :is-back="true" title="设置" :border-bottom="false">
</u-navbar>
<view class="setting-content">
<u-cell-group>
<u-cell-item title="账号实名信息" @click="profile"></u-cell-item>
2026-05-14 14:42:51 +08:00
<!-- <u-cell-item title="订阅系统消息" :arrow="false">
2026-01-15 17:18:24 +08:00
<u-switch v-model="longSubscribe" @change="toggleLongSubscribe" />
2026-05-14 14:42:51 +08:00
</u-cell-item> -->
2026-01-15 17:18:24 +08:00
</u-cell-group>
</view>
<view class="btn">
<u-button @click="logout" plain>退出登录</u-button>
</view>
<view class="version">Version {{vuex_version}}</view>
</view>
</template>
<script>
export default {
data() {
return {
longSubscribe: false // 开关状态
}
},
onLoad() {
2026-01-30 09:01:38 +08:00
},
onShow(){
let user = uni.getStorageSync('userInfo');
this.longSubscribe = user.subscribe;
2026-01-15 17:18:24 +08:00
},
methods: {
profile() {
this.$u.route('/pages-biz/profile/profile')
},
logout() {
// 登录成功修改token与用户信息
this.$u.vuex('vuex_token', '');
this.$u.vuex('vuex_user', {});
uni.removeStorageSync('userInfo');
return uni.reLaunch({
url: '/pages/index/index'
})
},
toggleLongSubscribe(e) {
this.longSubscribe = e
// 微信小程序专用
// #ifdef MP-WEIXIN
if (this.longSubscribe) {
2026-05-14 14:42:51 +08:00
// const tmplIds = ['9QlNxNONJBICzw3Vcetqbf9yv4lI9q9cR_px8ujlOu8']
// wx.requestSubscribeMessage({
// tmplIds,
// success: (res) => {
// if (Object.values(res).some((v) => v === 'accept')) {
// uni.showToast({
// title: '长期订阅开启成功',
// icon: 'success'
// })
// this.saveLongSubscribeStatus(true)
// } else {
// uni.showToast({
// title: '未授权订阅',
// icon: 'none'
// })
// this.longSubscribe = false
// }
// },
// fail: (err) => {
// console.error(err)
// this.longSubscribe = false
// },
// })
this.saveLongSubscribeStatus(true)
2026-01-15 17:18:24 +08:00
} else {
// 取消订阅
uni.showToast({
title: '已关闭系统消息订阅',
icon: 'none'
})
this.saveLongSubscribeStatus(false)
}
// #endif
},
saveLongSubscribeStatus(enable) {
// TODO: 后端保存用户长期订阅状态
console.log('保存长期订阅状态到后端', enable)
2026-01-30 09:01:38 +08:00
let token = this.$getToken();
let url = `/login/subscribeMsg?subscribe=${enable}`;
this.$u.get(url, {}, {
'WT': token
}).then(obj => {
});
2026-01-15 17:18:24 +08:00
}
}
}
</script>
<style lang="scss">
.setting-content {
padding: 0rpx 20rpx;
border-radius: 10rpx;
background: #FFFFFF;
width: 94%;
margin: 20rpx auto;
&::v-deep .u-cell {
color: #222222 !important;
}
&::v-deep .u-cell_title {
font-size: 30rpx !important;
}
}
.btn {
width: 94%;
margin: 30rpx auto;
&::v-deep .u-btn {
border-radius: 10rpx;
font-size: 36rpx !important;
color: #EA4047 !important;
border: 0 !important;
}
&::v-deep .u-hairline-border:after {
border: 0 !important;
}
}
.version {
position: absolute;
bottom: 20rpx;
width: 100%;
text-align: center;
}
</style>