微信小程序页面迁移校验之前 P5任务处理之前

This commit is contained in:
Neo
2026-03-09 01:19:21 +08:00
parent 263bf96035
commit 6e20987d2f
1112 changed files with 153824 additions and 219694 deletions

View File

@@ -0,0 +1,99 @@
import { request } from "../../utils/request"
Page({
data: {
statusBarHeight: 0,
loading: true,
status: "pending" as "pending" | "rejected",
application: null as null | {
id: number
site_code: string
role_type: string
phone: string
status: string
reject_reason: string | null
created_at: string
},
},
onLoad() {
const { statusBarHeight } = wx.getSystemInfoSync()
this.setData({ statusBarHeight })
this.fetchStatus()
},
onShow() {
this.fetchStatus()
},
onPullDownRefresh() {
this.fetchStatus().finally(() => {
wx.stopPullDownRefresh()
})
},
async fetchStatus() {
try {
const data = await request({
url: "/api/xcx/me",
method: "GET",
needAuth: true,
})
// 同步 globalData 和 Storage
const app = getApp<IAppOption>()
app.globalData.authUser = {
userId: data.user_id,
status: data.status,
nickname: data.nickname,
}
wx.setStorageSync("userId", data.user_id)
wx.setStorageSync("userStatus", data.status)
// 已通过 → 跳转主页
if (data.status === "approved") {
wx.reLaunch({ url: "/pages/mvp/mvp" })
return
}
// 已禁用 → 跳转无权限页
if (data.status === "disabled") {
wx.reLaunch({ url: "/pages/no-permission/no-permission" })
return
}
// 已拒绝 → 跳转无权限页
if (data.status === "rejected") {
wx.reLaunch({ url: "/pages/no-permission/no-permission" })
return
}
// 全新用户(尚未提交申请)→ 跳回申请页
if (data.status === "new") {
wx.reLaunch({ url: "/pages/apply/apply" })
return
}
this.setData({
loading: false,
status: data.status,
application: data.latest_application || null,
})
} catch (err: any) {
this.setData({ loading: false })
wx.showToast({ title: "获取状态失败", icon: "none" })
}
},
onSwitchAccount() {
const app = getApp<IAppOption>()
app.globalData.token = undefined
app.globalData.refreshToken = undefined
app.globalData.authUser = undefined
wx.removeStorageSync("token")
wx.removeStorageSync("refreshToken")
wx.removeStorageSync("userId")
wx.removeStorageSync("userStatus")
wx.reLaunch({ url: "/pages/login/login" })
},
})