添加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,34 +24,44 @@ 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/info', temp).then((res: any) => {
const info = toObject(res.info);
wx.setNavigationBarTitle({ title: `${info.bill_no} 详情` });
this.setData({
files: toArray(res.files).map((el) => {
el._file_type = getFileType(el.file_name);
el.file_path = `${OSSBaseUrl}${el.file_path}`;
el._file_size = formatFileSize(el.file_size);
return el;
}),
detail: toArray(res.rows),
info: info,
});
return new Promise<void>((resolve, reject) => {
post('ErpDepot/info', temp)
.then((res: any) => {
const info = toObject(res.info);
wx.setNavigationBarTitle({ title: `${info.bill_no} 详情` });
this.setData({
files: toArray(res.files).map((el) => {
el._file_type = getFileType(el.file_name);
el.file_path = `${OSSBaseUrl}${el.file_path}`;
el._file_size = formatFileSize(el.file_size);
return el;
}),
detail: toArray(res.rows),
info: info,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
onPreview(e: any) {
@@ -73,7 +83,7 @@ Page({
onLoad(options) {
const { head_id } = options;
this.data.params.head_id = head_id;
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**