添加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,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,8 +62,9 @@ Page({
this.data.params.curr_page = curr;
this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params);
post('ErpAccount/list', temp).then((res: any) => {
return new Promise<void>((resolve, reject) => {
post('ErpAccount/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);
@@ -71,6 +72,13 @@ Page({
this.setData({
count: toNumber(res.data?.count),
list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
@@ -142,7 +150,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

View File

@@ -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,8 +62,9 @@ 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) => {
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);
@@ -71,6 +72,13 @@ Page({
this.setData({
count: toNumber(res.data?.count),
list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
@@ -114,7 +122,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

View File

@@ -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,8 +62,9 @@ Page({
this.data.params.curr_page = curr;
this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params);
post('ErpDepot/list', temp).then((res: any) => {
return new Promise<void>((resolve, reject) => {
post('ErpDepot/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);
@@ -71,6 +72,13 @@ Page({
this.setData({
count: toNumber(res.data?.count),
list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
@@ -129,7 +137,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

View File

@@ -1,5 +1,5 @@
import { FinanceItemTypeArr, FinanceItemTypeObj } from '@/utils/config';
import { loginStatusPage, post } from '@/utils/https';
import { onPageLoadInitAuth, post } from '@/utils/https';
import {
cloneLite,
getAuthInfo,
@@ -30,11 +30,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;
@@ -65,13 +65,20 @@ Page({
this.data.params.curr_page = curr;
this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params);
post('ErpFinanceItem/list', temp).then((res: any) => {
return new Promise<void>((resolve, reject) => {
post('ErpFinanceItem/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 });
this.setData({ count: toNumber(res.data?.count), list: list, isLogin: true });
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
@@ -130,7 +137,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

View File

@@ -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,13 +62,20 @@ Page({
this.data.params.curr_page = curr;
this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params);
post('OrderCategory/list', temp).then((res: any) => {
return new Promise<void>((resolve, reject) => {
post('OrderCategory/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 });
this.setData({ count: toNumber(res.count), list: list, isLogin: true });
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
@@ -127,7 +134,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

View File

@@ -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,8 +62,9 @@ Page({
this.data.params.curr_page = curr;
this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params);
post('OrderStep/list', temp).then((res: any) => {
return new Promise<void>((resolve, reject) => {
post('OrderStep/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);
@@ -71,6 +72,13 @@ Page({
this.setData({
count: toNumber(res.count),
list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
@@ -128,7 +136,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

View File

@@ -1,4 +1,4 @@
import { loginStatusPage, post } from '@/utils/https';
import { onPageLoadInitAuth, post } from '@/utils/https';
import { getAuthInfo, toArray } from '@/utils/util';
Page({
@@ -14,18 +14,24 @@ Page({
this.setData({ isLogin: e.detail });
if (e.detail) {
this.init();
this.getList();
}
},
init() {
this.setData({ authInfo: getAuthInfo() });
this.getList();
},
getList() {
post('CompanyProcessV2/getChildProcess', { process_id: this.data.process_id }).then(
(res: any) => {
this.setData({ list: toArray(res.data) });
},
);
return new Promise<void>((resolve, reject) => {
post('CompanyProcessV2/getChildProcess', { process_id: this.data.process_id })
.then((res: any) => {
this.setData({ list: toArray(res.data), isLogin: true });
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
/**
@@ -37,7 +43,7 @@ Page({
wx.setNavigationBarTitle({ title: decodeURIComponent(title) });
}
this.data.process_id = process_id;
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

View File

@@ -3,7 +3,7 @@
<t-cell-group custom-style="margin: 0">
<block wx:for="{{list}}" wx:key="index">
<t-cell title="{{item.process_name}}" note="{{item.process_code}}" data-index="{{index}}"
bind:tap="onChildProcess" description="提成值: {{item.bonus_value || '未配置'}}">
description="提成值: {{item.bonus_value || '未配置'}}">
<view slot="left-icon" style="color: #999;line-height: 1.5;">
{{index + 1}}
</view>

View File

@@ -1,4 +1,4 @@
import { loginStatusPage, post } from '@/utils/https';
import { onPageLoadInitAuth, post } from '@/utils/https';
import { getAuthInfo, getDataSet, toArray } from '@/utils/util';
Page({
@@ -13,15 +13,23 @@ Page({
this.setData({ isLogin: e.detail });
if (e.detail) {
this.init();
this.getList();
}
},
init() {
this.setData({ authInfo: getAuthInfo() });
this.getList();
},
getList() {
post('CompanyProcessV2/getParentProcess').then((res: any) => {
this.setData({ list: toArray(res.data) });
return new Promise<void>((resolve, reject) => {
post('CompanyProcessV2/getParentProcess')
.then((res: any) => {
this.setData({ list: toArray(res.data), isLogin: true });
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
onChildProcess(e: any) {
@@ -38,7 +46,7 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(_options) {
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

View File

@@ -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,8 +62,9 @@ Page({
this.data.params.curr_page = curr;
this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params);
post('ProductType/list', temp).then((res: any) => {
return new Promise<void>((resolve, reject) => {
post('ProductType/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);
@@ -71,6 +72,13 @@ Page({
this.setData({
count: toNumber(res.count),
list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
@@ -130,7 +138,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

View File

@@ -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,8 +62,9 @@ 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) => {
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);
@@ -71,6 +72,13 @@ Page({
this.setData({
count: toNumber(res.data?.count),
list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
@@ -114,7 +122,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

View File

@@ -1,4 +1,4 @@
import { loginStatusPage, post } from '@/utils/https';
import { onPageLoadInitAuth, post } from '@/utils/https';
import { toArray, toNumber } from '@/utils/util';
Page({
@@ -14,13 +14,13 @@ Page({
this.setData({ isLogin: e.detail });
if (e.detail) {
this.init();
this.getList();
}
},
init() {
this.getList();
},
init() {},
getList() {
return new Promise<void>((resolve, reject) => {
post('Index/index')
.then((res: any) => {
const process_count = toArray(res.process_count).filter((el) => {
@@ -43,11 +43,18 @@ Page({
this.setData({
seven_process_count: [...map.values()],
process_count: process_count,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
})
.finally(() => {
wx.stopPullDownRefresh();
});
});
},
/**
@@ -64,7 +71,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

View File

@@ -1,7 +1,7 @@
import { base, defaultAvatarUrl } from '@/utils/config';
import { login } from '@/utils/https';
import { Subscribe } from '@/utils/subscribe';
import { isArray, setStorage } from '@/utils/util';
import { getCurrentPageRoute, isArray } from '@/utils/util';
// import { IStorage } from "@/utils/storage";
// const app = getApp();
@@ -10,26 +10,26 @@ import { isArray, setStorage } from '@/utils/util';
Component({
options: { addGlobalClass: true },
properties: {
isLogin: Boolean,
loading: Boolean,
// isLogin: Boolean,
// loading: Boolean,
isAuth: null,
customStyle: null,
hasTabBar: null,
},
// attached() {
// this.setData({ isLogin: getStorage("isLogin") == 1 });
// console.log("attached");
// Subscribe.on("isLogin", getCurrentPageRoute(), () => {
// this.setData({ isLogin: getStorage("isLogin") == 1 });
// console.log("监听到 isLogin 变化:");
// });
// },
// detached() {
// console.log("detached");
// Subscribe.off("isLogin", getCurrentPageRoute());
// },
attached() {
// this.setData({ isLogin: getStorage('isLogin') == 1 });
// console.log('attached');
Subscribe.on('isLogin', getCurrentPageRoute(), (data: any) => {
// console.log(data);
this.setData({ isLogin: data, loading: false });
// console.log('监听到 isLogin 变化:');
});
},
detached() {
// console.log('detached');
Subscribe.off('isLogin', getCurrentPageRoute());
},
data: {
avatarUrl: defaultAvatarUrl,
@@ -39,14 +39,14 @@ Component({
companyList: [],
encryptedData: '',
iv: '',
isLogin: false,
loading: true,
},
methods: {
handleLogin(e: any) {
this.triggerEvent('handleLogin', e.detail);
},
getPhoneNumberToast() {
setStorage('isLogin', 1);
Subscribe.set('isLogin', 'zzzuz');
wx.showToast({ title: '请先勾选协议', icon: 'none' });
},
changeAgreementCheck(event: any) {

View File

@@ -1,4 +1,4 @@
import { loginStatusPage, post } from '@/utils/https';
import { onPageLoadInitAuth, post } from '@/utils/https';
import {
cloneLite,
getAuthInfo,
@@ -35,11 +35,12 @@ Page({
this.setData({ isLogin: e.detail });
if (e.detail) {
this.init();
this.getList();
}
},
init() {
this.setData({ authInfo: getAuthInfo() });
this.getList();
this.getData();
},
searchChange(e: any) {
@@ -87,8 +88,9 @@ Page({
this.data.params.curr_page = curr;
this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params);
post('ErpAccount/flow', temp).then((res: any) => {
return new Promise<void>((resolve, reject) => {
post('ErpAccount/flow', 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);
@@ -96,6 +98,13 @@ Page({
this.setData({
count: toNumber(res.count),
list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
@@ -137,7 +146,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

View File

@@ -1,4 +1,4 @@
import { loginStatusPage, post } from '@/utils/https';
import { onPageLoadInitAuth, post } from '@/utils/https';
import {
cloneLite,
getAuthInfo,
@@ -32,11 +32,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;
@@ -78,8 +78,9 @@ Page({
} else {
delete temp.process_state;
}
post('ErpFinance/list', temp).then((res: any) => {
return new Promise<void>((resolve, reject) => {
post('ErpFinance/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);
@@ -87,6 +88,13 @@ Page({
this.setData({
count: toNumber(res.data?.count),
list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
@@ -135,7 +143,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

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());
},
/**

View File

@@ -1,4 +1,4 @@
import { loginStatusPage, post } from '@/utils/https';
import { onPageLoadInitAuth, post } from '@/utils/https';
import {
cloneLite,
getAuthInfo,
@@ -32,11 +32,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;
@@ -78,8 +78,9 @@ Page({
} else {
delete temp.process_state;
}
post('ErpFinance/list', temp).then((res: any) => {
return new Promise<void>((resolve, reject) => {
post('ErpFinance/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);
@@ -87,6 +88,13 @@ Page({
this.setData({
count: toNumber(res.data?.count),
list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
@@ -135,7 +143,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

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());
},
/**

View File

@@ -1,4 +1,4 @@
import { loginStatusPage, post } from '@/utils/https';
import { onPageLoadInitAuth, post } from '@/utils/https';
import {
cloneLite,
getAuthInfo,
@@ -32,11 +32,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;
@@ -78,8 +78,9 @@ Page({
} else {
delete temp.process_state;
}
post('ErpFinance/list', temp).then((res: any) => {
return new Promise<void>((resolve, reject) => {
post('ErpFinance/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);
@@ -87,6 +88,13 @@ Page({
this.setData({
count: toNumber(res.data?.count),
list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
@@ -135,7 +143,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

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());
},
/**

View File

@@ -1,4 +1,4 @@
import { loginStatusPage, post } from '@/utils/https';
import { onPageLoadInitAuth, post } from '@/utils/https';
import {
cloneLite,
getAuthInfo,
@@ -19,16 +19,17 @@ Page({
list: [] as any[],
count: 0,
sort: [{ label: '创建日期', value: 'create_date' }],
isLogin: false,
},
handleLogin(e: any) {
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;
@@ -59,8 +60,9 @@ Page({
this.data.params.curr_page = curr;
this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params);
post('Log/loginList', temp).then((res: any) => {
return new Promise<void>((resolve, reject) => {
post('Log/loginList', 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);
@@ -78,6 +80,13 @@ Page({
}
return el;
}),
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
@@ -96,7 +105,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

View File

@@ -1,4 +1,4 @@
import { loginStatusPage, post } from '@/utils/https';
import { onPageLoadInitAuth, post } from '@/utils/https';
import {
cloneLite,
getAuthInfo,
@@ -19,16 +19,17 @@ Page({
list: [] as any[],
count: 0,
sort: [{ label: '创建日期', value: 'create_date' }],
isLogin: false,
},
handleLogin(e: any) {
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;
@@ -59,8 +60,9 @@ Page({
this.data.params.curr_page = curr;
this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params);
post('Log/operateList', temp).then((res: any) => {
return new Promise<void>((resolve, reject) => {
post('Log/operateList', 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);
@@ -68,6 +70,13 @@ Page({
this.setData({
count: toNumber(res.data?.count),
list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
@@ -86,7 +95,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

View File

@@ -1,4 +1,4 @@
import { loginStatusPage, post } from '@/utils/https';
import { onPageLoadInitAuth, post } from '@/utils/https';
import {
cloneLite,
getAuthInfo,
@@ -30,11 +30,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;
@@ -76,13 +76,20 @@ Page({
} else {
delete temp.process_state;
}
post('Departments/list', temp).then((res: any) => {
return new Promise<void>((resolve, reject) => {
post('Departments/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({ list: list });
this.setData({ list: list, isLogin: true });
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
@@ -113,7 +120,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

View File

@@ -1,4 +1,4 @@
import { loginStatusPage, post } from '@/utils/https';
import { onPageLoadInitAuth, post } from '@/utils/https';
import {
cloneLite,
getAuthInfo,
@@ -25,16 +25,17 @@ Page({
{ value: '2', label: '已审核' },
],
sort: [{ label: '创建日期', value: 'create_date' }],
isLogin: false,
},
handleLogin(e: any) {
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;
@@ -76,13 +77,20 @@ Page({
} else {
delete temp.process_state;
}
post('Groups/list', temp).then((res: any) => {
return new Promise<void>((resolve, reject) => {
post('Groups/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({ list: list });
this.setData({ list: list, isLogin: true });
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
onGroupTap(e: any) {
@@ -122,7 +130,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

View File

@@ -1,4 +1,4 @@
import { loginStatusPage, post } from '@/utils/https';
import { onPageLoadInitAuth, post } from '@/utils/https';
import { getAuthInfo, toArray } from '@/utils/util';
Page({
@@ -8,20 +8,23 @@ Page({
data: {
list: [] as any[],
group_id: '',
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('Groups/getGrpRights', { group_id: this.data.group_id }).then((res: any) => {
return new Promise<void>((resolve, reject) => {
post('Groups/getGrpRights', { group_id: this.data.group_id })
.then((res: any) => {
const list = toArray(res.right_tree);
const rights = `${res.rights || ''}`.split(',');
this.data.list.length = 0;
@@ -54,7 +57,13 @@ Page({
}
});
// console.log(this.data.list);
this.setData({ list: this.data.list });
this.setData({ list: this.data.list, isLogin: true });
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
@@ -65,7 +74,7 @@ Page({
this.data.group_id = `${options.group_id}`;
wx.setNavigationBarTitle({ title: `${decodeURIComponent(`${options.name}`)} 权限` });
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

View File

@@ -1,4 +1,4 @@
import { loginStatusPage, post } from '@/utils/https';
import { onPageLoadInitAuth, post } from '@/utils/https';
import { getAuthInfo, toArray } from '@/utils/util';
Page({
@@ -7,20 +7,23 @@ 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('Groups/myAuth').then((res: any) => {
return new Promise<void>((resolve, reject) => {
post('Groups/myAuth')
.then((res: any) => {
const list = toArray(res.right_tree);
const rights = `${res.rights || ''}`.split(',');
this.data.list.length = 0;
@@ -53,7 +56,13 @@ Page({
}
});
// console.log(this.data.list);
this.setData({ list: this.data.list });
this.setData({ list: this.data.list, isLogin: true });
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
@@ -61,7 +70,7 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(_options) {
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

View File

@@ -1,4 +1,4 @@
import { loginStatusPage, post } from '@/utils/https';
import { onPageLoadInitAuth, post } from '@/utils/https';
import {
cloneLite,
getAuthInfo,
@@ -31,16 +31,17 @@ Page({
user_id: wx.getStorageSync('user_id'),
depOption: [] as any[],
groupsOption: [] 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();
this.getOrderStep();
},
searchChange(e: any) {
@@ -106,13 +107,20 @@ Page({
this.data.params.curr_page = curr;
this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params);
post('Users/getStaff', temp).then((res: any) => {
return new Promise<void>((resolve, reject) => {
post('Users/getStaff', 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 });
this.setData({ count: toNumber(res.count), list: list, isLogin: true });
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
onReinstatedStaff(e: any) {
@@ -170,7 +178,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

View File

@@ -1,5 +1,6 @@
import { base } from '@/utils/config';
import { checkSesskey, loginStatusPage, post } from '@/utils/https';
import { Subscribe } from '@/utils/subscribe';
import { getStorage, toObject } from '@/utils/util';
Page({
@@ -59,6 +60,7 @@ Page({
complete: (res: any) => {
if (res.confirm) {
post('Applet/loginOut').then(() => {
Subscribe.set('isLogin', false);
this.setData({ isLogin: false });
checkSesskey({ showLoading: false, showError: false })
.then(() => {})

View File

@@ -1,4 +1,4 @@
import { loginStatusPage, post } from '@/utils/https';
import { onPageLoadInitAuth, post } from '@/utils/https';
import {
cloneLite,
getAuthInfo,
@@ -28,11 +28,12 @@ Page({
this.setData({ isLogin: e.detail });
if (e.detail) {
this.init();
this.getList();
}
},
init() {
this.setData({ authInfo: getAuthInfo() });
this.getList();
this.getData();
},
searchChange(e: any) {
@@ -86,8 +87,9 @@ Page({
this.data.params.curr_page = curr;
this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params);
post('GoodsBatch/goodsBatchList', temp).then((res: any) => {
return new Promise<void>((resolve, reject) => {
post('GoodsBatch/goodsBatchList', 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);
@@ -95,6 +97,13 @@ Page({
this.setData({
count: toNumber(res.count),
list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
@@ -124,7 +133,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

View File

@@ -32,9 +32,9 @@
<view slot="header">{{ item.batch_no }}</view>
<view slot="content">
<card-item-plugin label="自定义批号" value="{{item.batch_custom_no}}" />
<card-item-plugin label="保质期" value="{{item.expire_date}}" />
<card-item-plugin label="商品名称" value="{{item.goods_name}}" />
<card-item-plugin label="商品编码" value="{{item.goods_code}}" />
<card-item-plugin label="保质期" value="{{item.expire_date}}" />
<card-item-plugin label="批次单位" value="{{item.unit_ch_name}}" />
<card-item-plugin label="批次单价" value="{{item.batch_price}}" />
<card-item-plugin label="库存" value="{{item.batch_nums}}" />

View File

@@ -1,4 +1,4 @@
import { loginStatusPage, post } from '@/utils/https';
import { onPageLoadInitAuth, post } from '@/utils/https';
import {
cloneLite,
getAuthInfo,
@@ -26,11 +26,12 @@ Page({
this.setData({ isLogin: e.detail });
if (e.detail) {
this.init();
this.getList();
}
},
init() {
this.setData({ authInfo: getAuthInfo() });
this.getList();
this.getData();
},
searchChange(e: any) {
@@ -74,8 +75,9 @@ Page({
this.data.params.curr_page = curr;
this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params);
post('GoodsBatch/getBatchLogList', temp).then((res: any) => {
return new Promise<void>((resolve, reject) => {
post('GoodsBatch/getBatchLogList', 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);
@@ -83,6 +85,13 @@ Page({
this.setData({
count: toNumber(res.count),
list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
@@ -96,7 +105,7 @@ Page({
if (title) {
wx.setNavigationBarTitle({ title });
}
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

View File

@@ -1,4 +1,4 @@
import { loginStatusPage, post } from '@/utils/https';
import { onPageLoadInitAuth, post } from '@/utils/https';
import {
cloneLite,
getAuthInfo,
@@ -28,11 +28,12 @@ Page({
this.setData({ isLogin: e.detail });
if (e.detail) {
this.init();
this.getList();
}
},
init() {
this.setData({ authInfo: getAuthInfo() });
this.getList();
this.getData();
},
searchChange(e: any) {
@@ -134,7 +135,9 @@ Page({
if (!temp.goods_class) {
delete temp.goods_class;
}
post('ErpGoods/list', temp).then((res: any) => {
return new Promise<void>((resolve, reject) => {
post('ErpGoods/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);
@@ -142,6 +145,13 @@ Page({
this.setData({
count: toNumber(res.count),
list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
@@ -180,7 +190,7 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(_options) {
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

View File

@@ -1,4 +1,4 @@
import { loginStatusPage, post } from '@/utils/https';
import { onPageLoadInitAuth, post } from '@/utils/https';
import {
cloneLite,
getAuthInfo,
@@ -28,11 +28,11 @@ Page({
this.setData({ isLogin: e.detail });
if (e.detail) {
this.init();
this.getGoodsAttr();
}
},
init() {
this.setData({ authInfo: getAuthInfo() });
this.getGoodsAttr();
},
searchChange(e: any) {
const key = getDataSet(e).key;
@@ -57,7 +57,9 @@ Page({
this.getList();
},
getGoodsAttr() {
post('GoodsAttr/list').then((res: any) => {
return new Promise<void>((resolve, reject) => {
post('GoodsAttr/list')
.then((res: any) => {
this.data.goodsSubAttr = {};
toArray(res?.data?.list).forEach((el) => {
toArray(el.sub_attr).forEach((ell) => {
@@ -68,8 +70,14 @@ Page({
});
});
// console.log(this.data.goodsSubAttr);
this.setData({ goodsSubAttr: this.data.goodsSubAttr });
this.setData({ goodsSubAttr: this.data.goodsSubAttr, isLogin: true });
this.getList();
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
getList() {
@@ -109,7 +117,7 @@ Page({
if (title) {
wx.setNavigationBarTitle({ title: decodeURIComponent(title) });
}
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getGoodsAttr());
},
/**

View File

@@ -1,4 +1,4 @@
import { loginStatusPage, post } from '@/utils/https';
import { onPageLoadInitAuth, post } from '@/utils/https';
import {
cloneLite,
getAuthInfo,
@@ -33,11 +33,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;
@@ -79,8 +79,9 @@ Page({
} else {
delete temp.process_state;
}
post('ErpDepot/depotHeadList', temp).then((res: any) => {
return new Promise<void>((resolve, reject) => {
post('ErpDepot/depotHeadList', 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);
@@ -88,6 +89,13 @@ Page({
this.setData({
count: toNumber(res.count),
list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
@@ -142,7 +150,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

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,17 +29,19 @@ 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('ErpDepot/info', temp).then((res: any) => {
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({
@@ -51,6 +53,13 @@ Page({
}),
detail: toArray(res.rows),
info: info,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
@@ -73,7 +82,7 @@ Page({
onLoad(options) {
const { head_id } = options;
this.data.params.head_id = head_id;
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

View File

@@ -1,4 +1,4 @@
import { loginStatusPage, post } from '@/utils/https';
import { onPageLoadInitAuth, post } from '@/utils/https';
import {
cloneLite,
getAuthInfo,
@@ -32,11 +32,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;
@@ -78,8 +78,9 @@ Page({
} else {
delete temp.process_state;
}
post('ErpDepot/depotHeadList', temp).then((res: any) => {
return new Promise<void>((resolve, reject) => {
post('ErpDepot/depotHeadList', 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);
@@ -87,6 +88,13 @@ Page({
this.setData({
count: toNumber(res.count),
list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
@@ -135,7 +143,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

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,17 +29,19 @@ 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('ErpDepot/info', temp).then((res: any) => {
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({
@@ -51,6 +53,13 @@ Page({
}),
detail: toArray(res.rows),
info: info,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
@@ -73,7 +82,7 @@ Page({
onLoad(options) {
const { head_id } = options;
this.data.params.head_id = head_id;
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

View File

@@ -1,4 +1,4 @@
import { loginStatusPage, post } from '@/utils/https';
import { onPageLoadInitAuth, post } from '@/utils/https';
import {
cloneLite,
getAuthInfo,
@@ -30,11 +30,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;
@@ -64,7 +64,9 @@ Page({
getList(curr: number = 1) {
this.data.params.curr_page = curr;
this.setData({ params: this.data.params });
post('CompanyProcessV2/processOrd', this.data.params).then((res: any) => {
return new Promise<void>((resolve, reject) => {
post('CompanyProcessV2/processOrd', this.data.params)
.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);
@@ -72,6 +74,13 @@ Page({
this.setData({
count: toNumber(res.count),
list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
@@ -113,7 +122,7 @@ Page({
title: decodeURIComponent(options.title || ''),
});
this.data.params.process_id = `${options.process_id || ''}`;
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**

View File

@@ -3,6 +3,7 @@
* YangXB 2021.11.24
* */
import { base, http } from './config';
import { Subscribe } from './subscribe';
import { getStorage, isArray, setStorage, toArray, toastError } from './util';
/**
* 请求
@@ -44,12 +45,11 @@ const request = (url: string, options: any, config = { showLoading: true, showEr
resolve(request.data);
} else {
if (config.showError != false) {
wx.showToast({
title: request.data.err_msg,
icon: 'none',
});
wx.showToast({ title: request.data.err_msg, icon: 'none' });
}
if (request.data.err_code == 110000) {
Subscribe.set('isLogin', false);
// const currentPage = getCurrentPage();
// console.log(currentPage);
// if (
@@ -147,6 +147,7 @@ export const loginStatus = () => {
setStorage('auth_info', res.auth_info);
setStorage('session_id', res.session_id);
getUsersConfigList();
Subscribe.set('isLogin', true);
resolve(res);
})
.catch((err: any) => {
@@ -155,7 +156,9 @@ export const loginStatus = () => {
if (isArray(res.data)) {
post('Applet/loginOut').then(() => {
checkSesskey({ showLoading: false, showError: false })
.then(() => {})
.then(() => {
Subscribe.set('isLogin', false);
})
.catch((err) => {
console.log('checkSesskey', err);
});
@@ -201,6 +204,7 @@ export const onPageLoadInitAuth = (
initFun()
.then((_res) => {
// console.log('onPageLoadInitAuth', res);
Subscribe.set('isLogin', true);
that.setData({ isLogin: true, loading: false });
that.init?.();
})

View File

@@ -9,8 +9,8 @@ function triggerEvent(key: string, data: any) {
});
}
// 也可以触发一个通用的 'change' 事件
if (listeners["change"]) {
listeners["change"].forEach((callback: any) => {
if (listeners['change']) {
listeners['change'].forEach((callback: any) => {
callback({ key, data });
});
}
@@ -45,15 +45,15 @@ export const Subscribe = {
* @param functionKey 唯一的函数key(用于取消订阅的)
* @param callback 回调函数
*/
on(key: string, functionKey: string, callback: () => void) {
on(key: string, functionKey: string, callback: (data: any) => void) {
if (!listeners[key]) {
listeners[key] = [];
}
if (typeof callback == "function") {
(callback as IFun)["$$functionKey"] = functionKey;
if (typeof callback == 'function') {
(callback as IFun)['$$functionKey'] = functionKey;
listeners[key].push(callback);
} else {
console.log("订阅事件 callback 必须是函数");
console.log('订阅事件 callback 必须是函数');
}
},