|
|
@@ -121,6 +121,14 @@
|
|
|
<text class="menu-text">关于我们</text>
|
|
|
<uni-icons type="right" size="16" color="#cccccc"></uni-icons>
|
|
|
</view>
|
|
|
+ <view class="menu-divider"></view>
|
|
|
+ <view class="menu-item" @click="logout" style="color: #ff4d4f;">
|
|
|
+ <view class="menu-icon-wrapper icon-red">
|
|
|
+ <uni-icons type="close" size="24" color="#ff4d4f"></uni-icons>
|
|
|
+ </view>
|
|
|
+ <text class="menu-text">退出登录</text>
|
|
|
+ <uni-icons type="right" size="16" color="#cccccc"></uni-icons>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
|
|
|
<!-- 底部占位 -->
|
|
|
@@ -201,6 +209,41 @@
|
|
|
url: '/pages/mine/card'
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+ // 退出登录
|
|
|
+ const logout = () => {
|
|
|
+ uni.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '确定要退出登录吗?',
|
|
|
+ success: (res) => {
|
|
|
+ if (res.confirm) {
|
|
|
+ console.log('用户确认退出登录')
|
|
|
+
|
|
|
+ // 1. 清除 token
|
|
|
+ uni.removeStorageSync('token')
|
|
|
+
|
|
|
+ // 2. 清除 store 中的用户数据
|
|
|
+ userStore.$reset()
|
|
|
+
|
|
|
+ // 3. 清除其他可能存储的数据
|
|
|
+ uni.removeStorageSync('userInfo')
|
|
|
+ uni.removeStorageSync('companyInfo')
|
|
|
+
|
|
|
+ console.log('已清除所有登录数据')
|
|
|
+
|
|
|
+ // 4. 跳转到登录页
|
|
|
+ uni.reLaunch({
|
|
|
+ url: '/pages/login/login'
|
|
|
+ })
|
|
|
+
|
|
|
+ uni.showToast({
|
|
|
+ title: '已退出登录',
|
|
|
+ icon: 'success'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
@@ -456,6 +499,10 @@
|
|
|
&.icon-blue {
|
|
|
background: rgba(74, 144, 226, 0.1);
|
|
|
}
|
|
|
+
|
|
|
+ &.icon-red {
|
|
|
+ background: rgba(255, 77, 79, 0.1);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
.menu-text {
|