添加onPageLoadInitAuth函数判断登录
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { loginStatusPage, post } from '@/utils/https';
|
||||
import { onPageLoadInitAuth, post } from '@/utils/https';
|
||||
import { getAuthInfo, getDataSet, showModal, sleep, toArray, toastSuccess } from '@/utils/util';
|
||||
|
||||
Page({
|
||||
@@ -7,26 +7,34 @@ Page({
|
||||
*/
|
||||
data: {
|
||||
list: [] 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() {
|
||||
post('Orders/getLiteOrders')
|
||||
.then((res: any) => {
|
||||
const list = toArray(res.data);
|
||||
this.setData({ list });
|
||||
})
|
||||
.finally(() => {
|
||||
wx.stopPullDownRefresh();
|
||||
});
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
post('Orders/getLiteOrders')
|
||||
.then((res: any) => {
|
||||
const list = toArray(res.data);
|
||||
this.setData({ list, isLogin: true });
|
||||
resolve(res);
|
||||
})
|
||||
.catch((res) => {
|
||||
this.setData({ isLogin: false });
|
||||
reject(res);
|
||||
})
|
||||
.finally(() => {
|
||||
wx.stopPullDownRefresh();
|
||||
});
|
||||
});
|
||||
},
|
||||
onOrderToTop(e: any) {
|
||||
const data = getDataSet(e);
|
||||
@@ -55,7 +63,7 @@ Page({
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
loginStatusPage(this);
|
||||
onPageLoadInitAuth(this, () => this.getList());
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -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,27 +29,36 @@ 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('Orders/saleDetail', temp).then((res: any) => {
|
||||
this.setData({
|
||||
info: toObject(res.info),
|
||||
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.detail),
|
||||
});
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
post('Orders/saleDetail', temp)
|
||||
.then((res: any) => {
|
||||
this.setData({
|
||||
info: toObject(res.info),
|
||||
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.detail),
|
||||
isLogin: true,
|
||||
});
|
||||
resolve(res);
|
||||
})
|
||||
.catch((res) => {
|
||||
this.setData({ isLogin: false });
|
||||
reject(res);
|
||||
});
|
||||
});
|
||||
},
|
||||
onPreview(e: any) {
|
||||
@@ -72,7 +81,7 @@ Page({
|
||||
const { order_no } = options;
|
||||
this.data.params.order_no = order_no;
|
||||
wx.setNavigationBarTitle({ title: `${order_no} 详情` });
|
||||
loginStatusPage(this);
|
||||
onPageLoadInitAuth(this, () => this.getList());
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { loginStatusPage, post } from '@/utils/https';
|
||||
import { onPageLoadInitAuth, post } from '@/utils/https';
|
||||
import {
|
||||
SaleOrderProcessStateOption,
|
||||
PayedStateOption,
|
||||
@@ -59,11 +59,11 @@ Page({
|
||||
this.setData({ isLogin: e.detail });
|
||||
if (e.detail) {
|
||||
this.init();
|
||||
this.getList();
|
||||
}
|
||||
},
|
||||
init() {
|
||||
this.setData({ authInfo: getAuthInfo() });
|
||||
this.getList();
|
||||
this.getOrderStep();
|
||||
},
|
||||
searchChange(e: any) {
|
||||
@@ -116,17 +116,25 @@ Page({
|
||||
} else {
|
||||
delete temp.process_state;
|
||||
}
|
||||
|
||||
post('Orders/list', temp).then((res: any) => {
|
||||
const list = toArray(res.data);
|
||||
if (list.length == 0 && this.data.params.curr_page > 1) {
|
||||
this.getList(this.data.params.curr_page - 1);
|
||||
}
|
||||
this.setData({
|
||||
count: toNumber(res.count),
|
||||
list: list,
|
||||
amount: toObject(res.amount),
|
||||
});
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
post('Orders/list', temp)
|
||||
.then((res: any) => {
|
||||
const list = toArray(res.data);
|
||||
if (list.length == 0 && this.data.params.curr_page > 1) {
|
||||
this.getList(this.data.params.curr_page - 1);
|
||||
}
|
||||
this.setData({
|
||||
count: toNumber(res.count),
|
||||
list: list,
|
||||
amount: toObject(res.amount),
|
||||
isLogin: true,
|
||||
});
|
||||
resolve(res);
|
||||
})
|
||||
.catch((res) => {
|
||||
this.setData({ isLogin: false });
|
||||
reject(res);
|
||||
});
|
||||
});
|
||||
},
|
||||
onOrderPay(e: any) {
|
||||
@@ -192,7 +200,7 @@ Page({
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
loginStatusPage(this);
|
||||
onPageLoadInitAuth(this, () => this.getList());
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user