chore: 首次纳入版本控制(审查前基线,v1.2.0)

This commit is contained in:
errortopic
2026-11-18 20:13:37 +08:00
commit f7b28e1740
441 changed files with 31220 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
const api = require("../../utils/api");
Page({
data: { loading: false, apiBase: "" },
onLoad() {
const app = getApp();
this.setData({ apiBase: app.globalData.apiBase });
if (app.globalData.token) {
wx.reLaunch({ url: "/pages/home/home" });
}
},
onLogin() {
if (this.data.loading) return;
this.setData({ loading: true });
wx.login({
success: (res) => {
if (!res.code) {
this.setData({ loading: false });
wx.showToast({ title: "没拿到登录 code", icon: "none" });
return;
}
api
.post("/api/auth/wx-login", { code: res.code })
.then((d) => {
getApp().setToken(d.token, d.guardian);
wx.showToast({ title: "登录成功", icon: "success", duration: 800 });
setTimeout(() => {
if (d.needs_consent) {
wx.reLaunch({ url: "/pages/consent/consent" });
} else {
wx.reLaunch({ url: "/pages/home/home" });
}
}, 500);
})
.catch((e) => {
api.toastError(e);
this.setData({ loading: false });
});
},
fail: () => {
this.setData({ loading: false });
wx.showToast({ title: "微信登录失败", icon: "none" });
},
});
},
});