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