|
|
@@ -6,7 +6,7 @@
|
|
|
<image class="avatar" :src="userInfo.avatar" mode="aspectFill"></image>
|
|
|
<view class="user-details">
|
|
|
<view class="nickname-row">
|
|
|
- <text class="nickname">{{ userInfo.nickname }}</text>
|
|
|
+ <text class="nickname" @click="goLogin">{{ userInfo.nickname }}</text>
|
|
|
<!-- VIP标志 -->
|
|
|
<view class="vip-badge" v-if="userInfo.isVip">
|
|
|
<text class="vip-badge-text">VIP</text>
|
|
|
@@ -302,30 +302,13 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
onLoad() {
|
|
|
-
|
|
|
+
|
|
|
|
|
|
// 立即检查登录状态
|
|
|
const token = uni.getStorageSync('token')
|
|
|
const userInfo = uni.getStorageSync('userInfo')
|
|
|
|
|
|
- if (!token || !userInfo) {
|
|
|
- // 未登录,立即强制跳转到登录页
|
|
|
-
|
|
|
- uni.showModal({
|
|
|
- title: '需要登录',
|
|
|
- content: '请先登录后查看个人信息',
|
|
|
- showCancel: false, // 不允许取消
|
|
|
- confirmText: '去登录',
|
|
|
- success: () => {
|
|
|
- uni.navigateTo({
|
|
|
- url: '/pages/page3/page3'
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- // 已登录,同步登录状态
|
|
|
+ // 直接同步登录状态,不强制弹窗
|
|
|
this.syncLoginStatus()
|
|
|
|
|
|
// 监听VIP购买成功事件
|
|
|
@@ -336,25 +319,25 @@ export default {
|
|
|
// 页面卸载时移除事件监听
|
|
|
uni.$off('vipPurchased', this.handleVipPurchased)
|
|
|
},
|
|
|
-
|
|
|
- onShow() {
|
|
|
-
|
|
|
- // 检查登录状态
|
|
|
- const token = uni.getStorageSync('token')
|
|
|
- const userInfo = uni.getStorageSync('userInfo')
|
|
|
-
|
|
|
- if (!token || !userInfo) {
|
|
|
- // 未登录,直接跳转(不显示弹窗,因为onLoad已经显示过了)
|
|
|
-
|
|
|
- uni.navigateTo({
|
|
|
- url: '/pages/page3/page3'
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- // 已登录,同步登录状态
|
|
|
- this.syncLoginStatus()
|
|
|
- },
|
|
|
+ //
|
|
|
+ // onShow() {
|
|
|
+ //
|
|
|
+ // // 检查登录状态
|
|
|
+ // const token = uni.getStorageSync('token')
|
|
|
+ // const userInfo = uni.getStorageSync('userInfo')
|
|
|
+ //
|
|
|
+ // if (!token || !userInfo) {
|
|
|
+ // // 未登录,直接跳转(不显示弹窗,因为onLoad已经显示过了)
|
|
|
+ //
|
|
|
+ // uni.navigateTo({
|
|
|
+ // url: '/pages/page3/page3'
|
|
|
+ // })
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // // 已登录,同步登录状态
|
|
|
+ // this.syncLoginStatus()
|
|
|
+ // },
|
|
|
methods: {
|
|
|
// 同步登录状态并更新页面数据
|
|
|
syncLoginStatus() {
|
|
|
@@ -419,7 +402,7 @@ export default {
|
|
|
// 设置未登录状态的用户信息
|
|
|
this.userInfo = {
|
|
|
userId: null,
|
|
|
- nickname: '未登录',
|
|
|
+ nickname: '立即登录',
|
|
|
avatar: 'https://via.placeholder.com/100?text=未登录',
|
|
|
phone: '',
|
|
|
email: '',
|
|
|
@@ -442,21 +425,6 @@ export default {
|
|
|
|
|
|
// 强制页面更新
|
|
|
this.$forceUpdate()
|
|
|
-
|
|
|
- // 提示需要登录
|
|
|
- setTimeout(() => {
|
|
|
- uni.showModal({
|
|
|
- title: '需要登录',
|
|
|
- content: '请先登录后查看完整功能',
|
|
|
- showCancel: false,
|
|
|
- confirmText: '去登录',
|
|
|
- success: () => {
|
|
|
- uni.navigateTo({
|
|
|
- url: '/pages/page3/page3'
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- }, 500)
|
|
|
}
|
|
|
},
|
|
|
|
|
|
@@ -626,7 +594,7 @@ export default {
|
|
|
setDefaultUserInfo() {
|
|
|
this.userInfo = {
|
|
|
userId: null,
|
|
|
- nickname: '未登录用户',
|
|
|
+ nickname: '立即登录',
|
|
|
avatar: 'https://via.placeholder.com/100?text=未登录',
|
|
|
phone: '',
|
|
|
email: '',
|
|
|
@@ -652,27 +620,6 @@ export default {
|
|
|
hobby: null,
|
|
|
authenticityScore: 0
|
|
|
}
|
|
|
-
|
|
|
- // 显示登录提示(仅在没有登录时显示)
|
|
|
- const token = uni.getStorageSync('token')
|
|
|
- if (!token) {
|
|
|
- setTimeout(() => {
|
|
|
- uni.showModal({
|
|
|
- title: '提示',
|
|
|
- content: '请先登录以查看完整功能',
|
|
|
- showCancel: true,
|
|
|
- cancelText: '稍后',
|
|
|
- confirmText: '去登录',
|
|
|
- success: (res) => {
|
|
|
- if (res.confirm) {
|
|
|
- uni.navigateTo({
|
|
|
- url: '/pages/page3/page3?redirect=' + encodeURIComponent('/pages/mine/index')
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- }, 1000) // 延迟1秒显示,避免页面刚加载就弹窗
|
|
|
- }
|
|
|
},
|
|
|
|
|
|
// 加载签到信息
|
|
|
@@ -1345,6 +1292,15 @@ export default {
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
+ },
|
|
|
+
|
|
|
+ // 跳转到登录页面
|
|
|
+ goLogin() {
|
|
|
+ if (this.userInfo.nickname === '立即登录') {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/pages/page3/page3?redirect=' + encodeURIComponent('/pages/mine/index')
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|