添加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,5 +1,5 @@
import { OSSBaseUrl } from '@/utils/config';
import { loginStatusPage, post } from '@/utils/https';
import { onPageLoadInitAuth, post } from '@/utils/https';
import {
cloneLite,
formatFileSize,
@@ -29,25 +29,12 @@ Page({
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('ErpFinance/info', temp).then((res: any) => {
const data = toObject(res.data);
const info = toObject(data.info);
wx.setNavigationBarTitle({ title: `${info.bill_no} 详情` });
this.setData({
detail: toArray(info.rows),
info: info,
});
});
post('ErpFinance/fileList', temp).then((res: any) => {
this.setData({
files: toArray(res.data).map((el) => {
@@ -59,6 +46,29 @@ Page({
});
});
},
getList() {
this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params);
return new Promise<void>((resolve, reject) => {
post('ErpFinance/info', temp)
.then((res: any) => {
const data = toObject(res.data);
const info = toObject(data.info);
wx.setNavigationBarTitle({ title: `${info.bill_no} 详情` });
this.setData({
detail: toArray(info.rows),
info: info,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
onPreview(e: any) {
const data = getDataSet(e);
const index = data.index;
@@ -78,7 +88,7 @@ Page({
onLoad(options) {
const { head_id } = options;
this.data.params.head_id = head_id;
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**