添加onPageLoadInitAuth函数判断登录

This commit is contained in:
zhengw
2026-03-09 17:20:17 +08:00
parent 9033acc56d
commit 511d29281e
18 changed files with 368 additions and 209 deletions

View File

@@ -1,5 +1,5 @@
import { OSSBaseUrl } from '@/utils/config';
import { loginStatusPage, post } from '@/utils/https';
import { onPageLoadInitAuth, post } from '@/utils/https';
import {
cloneLite,
formatFileSize,
@@ -24,24 +24,23 @@ Page({
info: {} as any,
files: [] as any,
detail: [] as any,
isLogin: false,
},
handleLogin(e: any) {
this.setData({ isLogin: e.detail });
if (e.detail) {
this.init();
this.getList();
}
},
init() {
this.setData({ authInfo: getAuthInfo() });
this.getList();
},
getList() {
this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params);
post('ErpDepot/depotItemList', temp).then((res: any) => {
this.setData({ detail: toArray(res.data) });
});
post('ErpDepot/fileList', { head_id: temp.head_id }).then((res: any) => {
this.setData({
files: toArray(res.data).map((el) => {
@@ -52,6 +51,18 @@ Page({
}),
});
});
return new Promise<void>((resolve, reject) => {
post('ErpDepot/depotItemList', temp)
.then((res: any) => {
this.setData({ detail: toArray(res.data), isLogin: true });
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
onPreview(e: any) {
const data = getDataSet(e);
@@ -78,10 +89,10 @@ Page({
const record = toObject(res.data);
wx.setNavigationBarTitle({ title: `${record.bill_no} 详情` });
this.setData({ info: record });
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
});
} else {
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
}
},