添加onPageLoadInitAuth函数判断登录
This commit is contained in:
@@ -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());
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user