增加线上配置分享功能+用户后台登录,不影响首页渲染
This commit is contained in:
+31
-30
@@ -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: '访客预约'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user