解决登录显示、首页显示bug
This commit is contained in:
@@ -181,15 +181,7 @@
|
||||
|
||||
onShow() {
|
||||
console.log('chat page onShow, chatUserId:', this.chatUserId, 'merchantId:', this.merchantId)
|
||||
if (this.merchantId) {
|
||||
this.loadChatMessages()
|
||||
this.setupRealtimeSubscription()
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
this.loadChatMessages()
|
||||
this.setupRealtimeSubscription()
|
||||
}, 300)
|
||||
}
|
||||
this.handlePageShow()
|
||||
},
|
||||
|
||||
onUnload() {
|
||||
@@ -199,21 +191,27 @@
|
||||
},
|
||||
|
||||
methods: {
|
||||
async initMerchantId() {
|
||||
try {
|
||||
const session = supa.getSession()
|
||||
if (session != null && session.user != null) {
|
||||
this.merchantId = session.user.getString('id') || ''
|
||||
}
|
||||
if (!this.merchantId) {
|
||||
this.merchantId = uni.getStorageSync('user_id') || ''
|
||||
}
|
||||
|
||||
// 加载店铺头像
|
||||
this.loadShopAvatar()
|
||||
} catch (e) {
|
||||
console.error('获取商户ID失败:', e)
|
||||
async ensureMerchantAuth(): Promise<boolean> {
|
||||
const result = await requireMerchantAuth({ redirectOnFail: true, toastOnFail: true })
|
||||
if (!result.ok) {
|
||||
this.merchantId = ''
|
||||
return false
|
||||
}
|
||||
this.merchantId = result.userInfo != null && result.userInfo.id != null ? result.userInfo.id : ''
|
||||
return this.merchantId !== ''
|
||||
},
|
||||
|
||||
async handlePageShow() {
|
||||
const passed = await this.ensureMerchantAuth()
|
||||
if (!passed) return
|
||||
this.loadChatMessages()
|
||||
this.setupRealtimeSubscription()
|
||||
},
|
||||
|
||||
async initMerchantId() {
|
||||
const passed = await this.ensureMerchantAuth()
|
||||
if (!passed) return
|
||||
this.loadShopAvatar()
|
||||
},
|
||||
|
||||
async loadShopAvatar() {
|
||||
|
||||
Reference in New Issue
Block a user