完善登录逻辑和个人资料完善

This commit is contained in:
2026-05-26 11:29:06 +08:00
parent cecb51a8e2
commit 9680276b3f
27 changed files with 3934 additions and 1572 deletions

View File

@@ -205,6 +205,14 @@
<view class="profile-bottom-safe"></view>
</view>
</scroll-view>
<view v-if="!isLoggedIn" class="guest-login-bar">
<view class="guest-login-left">
<image class="guest-login-avatar" src="/static/images/default.png" mode="aspectFit" />
<text class="guest-login-text">登录一下,康养权益和订单记录同步保存~</text>
</view>
<button class="guest-login-btn" @click.stop="goProfileLogin">立即登录</button>
</view>
</view>
</template>
@@ -332,6 +340,7 @@ export default {
recommendBottomLocked: false,
recommendViewportHeight: 0,
pageWindowHeight: 0,
isLoggedIn: false,
guessLoadMoreKey: 0,
statusBarHeight: 0,
isAndroidApp: false,
@@ -362,6 +371,7 @@ export default {
},
onLoad() {
this.initPage()
this.refreshLoginState()
this.loadUserProfile()
this.loadOrders()
@@ -370,6 +380,7 @@ export default {
uni.$on('authChanged', this.handleAuthChanged)
},
onShow() {
this.refreshLoginState()
this.refreshData()
},
onUnload() {
@@ -413,6 +424,11 @@ export default {
}
},
methods: {
refreshLoginState() {
const userId = supabaseService.getCurrentUserId()
this.isLoggedIn = userId != null && userId !== ''
},
toRecommendScrollJson(value: any | null): UTSJSONObject | null {
if (value == null) {
return null
@@ -851,6 +867,7 @@ export default {
return 'height:' + this.pageWindowHeight + 'px;min-height:' + this.pageWindowHeight + 'px;'
},
async loadUserProfile() {
this.refreshLoginState()
const userId = supabaseService.getCurrentUserId()
if (userId == null || userId === '') {
this.resetGuestProfileState()
@@ -969,6 +986,7 @@ export default {
},
refreshData() {
this.refreshLoginState()
const userId = supabaseService.getCurrentUserId()
if (userId == null || userId === '') {
this.resetGuestProfileState()
@@ -1391,13 +1409,17 @@ export default {
editProfile() {
const userId = supabaseService.getCurrentUserId()
if (userId == null || userId === '') {
goToLogin('/pages/user/profile')
this.goProfileLogin()
return
}
uni.navigateTo({
url: '/pages/user/profile'
})
},
goProfileLogin() {
goToLogin('/pages/main/profile')
},
// 跳转设置
goToSettings() {
@@ -1667,6 +1689,7 @@ export default {
},
handleAuthChanged(data: any) {
this.refreshLoginState()
let payload: UTSJSONObject | null = null
if (data instanceof UTSJSONObject) {
@@ -1687,6 +1710,11 @@ export default {
}
const loggedIn = payload.getBoolean('loggedIn')
if (loggedIn === true) {
this.refreshData()
return
}
if (loggedIn === false) {
this.resetGuestProfileState()
}
@@ -2492,7 +2520,65 @@ export default {
}
.profile-bottom-safe {
height: 90px;
height: 156px;
}
.guest-login-bar {
position: fixed;
left: 12px;
right: 12px;
bottom: calc(var(--window-bottom) + 12px);
height: 48px;
padding: 0 8px 0 10px;
border-radius: 24px;
background-color: rgba(45, 38, 42, 0.72);
box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
backdrop-filter: blur(10px);
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
z-index: 998;
}
.guest-login-left {
flex: 1;
min-width: 0;
display: flex;
flex-direction: row;
align-items: center;
}
.guest-login-avatar {
width: 32px;
height: 32px;
border-radius: 16px;
margin-right: 8px;
background-color: rgba(255, 255, 255, 0.85);
}
.guest-login-text {
flex: 1;
min-width: 0;
font-size: 12px;
color: #ffffff;
lines: 1;
}
.guest-login-btn {
height: 32px;
line-height: 32px;
padding: 0 14px;
border-radius: 16px;
background-color: #ff6a4d;
color: #ffffff;
font-size: 12px;
font-weight: 600;
margin-left: 8px;
}
.guest-login-btn::after {
border: none;
}
.pending {