添加onPageLoadInitAuth函数判断登录
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { loginStatusPage, post } from '@/utils/https';
|
||||
import { onPageLoadInitAuth, post } from '@/utils/https';
|
||||
import {
|
||||
cloneLite,
|
||||
getAuthInfo,
|
||||
@@ -27,11 +27,11 @@ Page({
|
||||
this.setData({ isLogin: e.detail });
|
||||
if (e.detail) {
|
||||
this.init();
|
||||
this.getList();
|
||||
}
|
||||
},
|
||||
init() {
|
||||
this.setData({ authInfo: getAuthInfo() });
|
||||
this.getList();
|
||||
},
|
||||
searchChange(e: any) {
|
||||
const key = getDataSet(e).key;
|
||||
@@ -62,16 +62,24 @@ Page({
|
||||
this.data.params.curr_page = curr;
|
||||
this.setData({ params: this.data.params });
|
||||
const temp = cloneLite(this.data.params);
|
||||
|
||||
post('ErpCrm/list', temp).then((res: any) => {
|
||||
const list = toArray(res.data?.list);
|
||||
if (list.length == 0 && this.data.params.curr_page > 1) {
|
||||
this.getList(this.data.params.curr_page - 1);
|
||||
}
|
||||
this.setData({
|
||||
count: toNumber(res.data?.count),
|
||||
list: list,
|
||||
});
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
post('ErpCrm/list', temp)
|
||||
.then((res: any) => {
|
||||
const list = toArray(res.data?.list);
|
||||
if (list.length == 0 && this.data.params.curr_page > 1) {
|
||||
this.getList(this.data.params.curr_page - 1);
|
||||
}
|
||||
this.setData({
|
||||
count: toNumber(res.data?.count),
|
||||
list: list,
|
||||
isLogin: true,
|
||||
});
|
||||
resolve(res);
|
||||
})
|
||||
.catch((res) => {
|
||||
this.setData({ isLogin: false });
|
||||
reject(res);
|
||||
});
|
||||
});
|
||||
},
|
||||
onOrderEdit(e: any) {
|
||||
@@ -114,7 +122,7 @@ Page({
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
loginStatusPage(this);
|
||||
onPageLoadInitAuth(this, () => this.getList());
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user