diff --git a/pages/profile/index.js b/pages/profile/index.js index 04558a2..b2085dd 100644 --- a/pages/profile/index.js +++ b/pages/profile/index.js @@ -1023,4 +1023,39 @@ Page({ }); }, + // 退出登录 + logout() { + wx.showModal({ + title: '退出登录', + content: '确定要退出登录吗?', + success: (res) => { + if (res.confirm) { + // 清除本地缓存 + wx.clearStorageSync(); + + // 重置全局用户信息 + const app = getApp(); + app.globalData.userInfo = {}; + app.globalData.userType = ''; + + // 重新加载页面 + this.setData({ + userInfo: {}, + userType: '', + userTags: [], + needPhoneAuth: true, + locationInfo: '', + hasLocationAuth: false + }); + + wx.showToast({ + title: '退出登录成功', + icon: 'success', + duration: 2000 + }); + } + } + }); + }, + }) diff --git a/pages/profile/index.wxml b/pages/profile/index.wxml index 64e1692..4ccc763 100644 --- a/pages/profile/index.wxml +++ b/pages/profile/index.wxml @@ -12,7 +12,15 @@ - + + +