增加线上配置分享功能+用户后台登录,不影响首页渲染

This commit is contained in:
chenglijuan
2026-05-20 14:24:54 +08:00
parent dbfc8011c4
commit 643f37b06e
8 changed files with 153 additions and 157 deletions
+31 -30
View File
@@ -11,45 +11,33 @@ Page({
},
onLoad() {
// 首页不阻塞,直接渲染;有缓存登录态时立即加载数据
if (app.globalData.isLoggedIn) {
this.onLoginReady()
} else if (app.globalData.loginFailed) {
this.onLoginFailed()
} else {
app.loginReadyCallback = (userInfo) => {
if (userInfo) {
this.onLoginReady()
} else {
this.onLoginFailed()
}
}
}
},
onShow() {
if (app.globalData.isLoggedIn) {
this.setData({ isLoggedIn: true })
this.loadLatestRecord()
}
},
onLoginReady() {
this.setData({ isLoggedIn: true, loginFailed: false })
this.loadLatestRecord()
async onShow() {
// 每次显示时等待登录完成,再加载最新数据
const userInfo = await app.waitLogin(true)
if (userInfo) {
this.setData({ isLoggedIn: true, loginFailed: false })
this.loadLatestRecord()
} else {
this.setData({ isLoggedIn: false, loginFailed: true })
}
},
onLoginFailed() {
this.setData({ isLoggedIn: false, loginFailed: true })
},
onRetry() {
async onRetry() {
this.setData({ loginFailed: false })
app.silentLogin()
app.loginReadyCallback = (userInfo) => {
if (userInfo) {
this.onLoginReady()
} else {
this.onLoginFailed()
}
const userInfo = await app.waitLogin()
if (userInfo) {
this.setData({ isLoggedIn: true, loginFailed: false })
this.loadLatestRecord()
} else {
this.setData({ loginFailed: true })
}
},
@@ -85,5 +73,18 @@ Page({
showQrcode(e) {
this.selectComponent('#qrcodeModal').show(e.currentTarget.dataset.id)
},
onShareAppMessage(res) {
return {
title: '访客预约',
path: '/pages/index/index'
}
},
onShareTimeline() {
return {
title: '访客预约'
}
}
})