Browse Source

将退出登录按钮移动到用户信息卡片右侧

pull/19/head
徐飞洋 2 months ago
parent
commit
2375f544f3
  1. 35
      pages/profile/index.js
  2. 8
      pages/profile/index.wxml

35
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
});
}
}
});
},
}) })

8
pages/profile/index.wxml

@ -13,6 +13,14 @@
</view> </view>
</view> </view>
<!-- 退出登录按钮 -->
<button
wx:if="{{userInfo.phoneNumber}}"
style="background-color: #ff4d4f; color: white; padding: 12rpx 4rpx; border-radius: 20rpx; font-size: 20rpx; width: 176rpx; display: block; box-sizing: border-box; left: 62rpx; top: 0rpx; position: relative"
bindtap="logout"
>
退出登录
</button>
</view> </view>
<!-- 手机号授权按钮 --> <!-- 手机号授权按钮 -->

Loading…
Cancel
Save