添加onPageLoadInitAuth函数判断登录

This commit is contained in:
zhengw
2026-03-10 11:33:42 +08:00
parent 511d29281e
commit 76c28f8d78
40 changed files with 816 additions and 526 deletions

View File

@@ -1,4 +1,4 @@
import { loginStatusPage, post } from '@/utils/https';
import { onPageLoadInitAuth, post } from '@/utils/https';
import { toArray, toNumber } from '@/utils/util';
Page({
@@ -14,40 +14,47 @@ Page({
this.setData({ isLogin: e.detail });
if (e.detail) {
this.init();
this.getList();
}
},
init() {
this.getList();
},
init() {},
getList() {
post('Index/index')
.then((res: any) => {
const process_count = toArray(res.process_count).filter((el) => {
el.count = toNumber(el.count);
return el.count > 0;
});
const arr = toArray(res.seven_process_count).filter((el) => {
el.count = toNumber(el.count);
return el.count > 0;
});
return new Promise<void>((resolve, reject) => {
post('Index/index')
.then((res: any) => {
const process_count = toArray(res.process_count).filter((el) => {
el.count = toNumber(el.count);
return el.count > 0;
});
const arr = toArray(res.seven_process_count).filter((el) => {
el.count = toNumber(el.count);
return el.count > 0;
});
const map = new Map<string, any>();
arr.forEach((el) => {
if (!map.has(el.date)) {
map.set(el.date, []);
}
map.get(el.date).push(el);
const map = new Map<string, any>();
arr.forEach((el) => {
if (!map.has(el.date)) {
map.set(el.date, []);
}
map.get(el.date).push(el);
});
// console.log([...map.values()]);
this.setData({
seven_process_count: [...map.values()],
process_count: process_count,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
})
.finally(() => {
wx.stopPullDownRefresh();
});
// console.log([...map.values()]);
this.setData({
seven_process_count: [...map.values()],
process_count: process_count,
});
})
.finally(() => {
wx.stopPullDownRefresh();
});
});
},
/**
@@ -64,7 +71,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**