Initial commit

This commit is contained in:
admin
2025-12-09 14:31:16 +08:00
parent c34b63b8da
commit b8648c2861
82 changed files with 1896 additions and 46 deletions

View File

@@ -13,8 +13,11 @@ Page({
},
onLoad() {
this.fetchHonors()
this.fetchProjects()
const app = getApp()
if (app.globalData.token) {
this.fetchHonors()
this.fetchProjects()
}
},
onShow() {
@@ -23,6 +26,12 @@ Page({
getUserInfo() {
const app = getApp()
if (!app.globalData.token) {
// Not logged in, clear data
this.setData({ user: {}, honors: [], projects: [] })
return
}
// Try to get from globalData first to speed up rendering
if (app.globalData.userInfo) {
this.setData({ user: app.globalData.userInfo })
@@ -36,10 +45,21 @@ Page({
// this.fetchProjects();
}).catch(err => {
console.error('Failed to fetch user info', err)
if (err && (err.code === 401 || err.code === 403)) {
// Token invalid, clear it
app.globalData.token = null;
app.globalData.userInfo = null;
this.setData({ user: {}, honors: [], projects: [] });
}
})
},
onPullDownRefresh() {
const app = getApp()
if (!app.globalData.token) {
wx.stopPullDownRefresh()
return
}
Promise.all([this.fetchHonors(), this.fetchProjects()]).then(() => {
wx.stopPullDownRefresh()
})