添加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 { import {
cloneLite, cloneLite,
getAuthInfo, getAuthInfo,
@@ -27,11 +27,11 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
}, },
searchChange(e: any) { searchChange(e: any) {
const key = getDataSet(e).key; const key = getDataSet(e).key;
@@ -62,16 +62,24 @@ Page({
this.data.params.curr_page = curr; this.data.params.curr_page = curr;
this.setData({ params: this.data.params }); this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params); const temp = cloneLite(this.data.params);
return new Promise<void>((resolve, reject) => {
post('ErpAccount/list', temp).then((res: any) => { post('ErpAccount/list', temp)
const list = toArray(res.data?.list); .then((res: any) => {
if (list.length == 0 && this.data.params.curr_page > 1) { const list = toArray(res.data?.list);
this.getList(this.data.params.curr_page - 1); 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), this.setData({
list: list, count: toNumber(res.data?.count),
}); list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
}); });
}, },
onOrderEdit(e: any) { onOrderEdit(e: any) {
@@ -142,7 +150,7 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { 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 { import {
cloneLite, cloneLite,
getAuthInfo, getAuthInfo,
@@ -27,11 +27,11 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
}, },
searchChange(e: any) { searchChange(e: any) {
const key = getDataSet(e).key; const key = getDataSet(e).key;
@@ -62,16 +62,24 @@ Page({
this.data.params.curr_page = curr; this.data.params.curr_page = curr;
this.setData({ params: this.data.params }); this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params); const temp = cloneLite(this.data.params);
return new Promise<void>((resolve, reject) => {
post('ErpCrm/list', temp).then((res: any) => { post('ErpCrm/list', temp)
const list = toArray(res.data?.list); .then((res: any) => {
if (list.length == 0 && this.data.params.curr_page > 1) { const list = toArray(res.data?.list);
this.getList(this.data.params.curr_page - 1); 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), this.setData({
list: list, count: toNumber(res.data?.count),
}); list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
}); });
}, },
onOrderEdit(e: any) { onOrderEdit(e: any) {
@@ -114,7 +122,7 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { 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 { import {
cloneLite, cloneLite,
getAuthInfo, getAuthInfo,
@@ -27,11 +27,11 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
}, },
searchChange(e: any) { searchChange(e: any) {
const key = getDataSet(e).key; const key = getDataSet(e).key;
@@ -62,16 +62,24 @@ Page({
this.data.params.curr_page = curr; this.data.params.curr_page = curr;
this.setData({ params: this.data.params }); this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params); const temp = cloneLite(this.data.params);
return new Promise<void>((resolve, reject) => {
post('ErpDepot/list', temp).then((res: any) => { post('ErpDepot/list', temp)
const list = toArray(res.data?.list); .then((res: any) => {
if (list.length == 0 && this.data.params.curr_page > 1) { const list = toArray(res.data?.list);
this.getList(this.data.params.curr_page - 1); 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), this.setData({
list: list, count: toNumber(res.data?.count),
}); list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
}); });
}, },
onOrderEdit(e: any) { onOrderEdit(e: any) {
@@ -129,7 +137,7 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { onShow() {
loginStatusPage(this); onPageLoadInitAuth(this, () => this.getList());
}, },
/** /**

View File

@@ -1,5 +1,5 @@
import { FinanceItemTypeArr, FinanceItemTypeObj } from '@/utils/config'; import { FinanceItemTypeArr, FinanceItemTypeObj } from '@/utils/config';
import { loginStatusPage, post } from '@/utils/https'; import { onPageLoadInitAuth, post } from '@/utils/https';
import { import {
cloneLite, cloneLite,
getAuthInfo, getAuthInfo,
@@ -30,11 +30,11 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
}, },
searchChange(e: any) { searchChange(e: any) {
const key = getDataSet(e).key; const key = getDataSet(e).key;
@@ -65,13 +65,20 @@ Page({
this.data.params.curr_page = curr; this.data.params.curr_page = curr;
this.setData({ params: this.data.params }); this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params); const temp = cloneLite(this.data.params);
return new Promise<void>((resolve, reject) => {
post('ErpFinanceItem/list', temp).then((res: any) => { post('ErpFinanceItem/list', temp)
const list = toArray(res.data?.list); .then((res: any) => {
// if (list.length == 0 && this.data.params.curr_page > 1) { const list = toArray(res.data?.list);
// this.getList(this.data.params.curr_page - 1); // 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() { 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 { import {
cloneLite, cloneLite,
getAuthInfo, getAuthInfo,
@@ -27,11 +27,11 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
}, },
searchChange(e: any) { searchChange(e: any) {
const key = getDataSet(e).key; const key = getDataSet(e).key;
@@ -62,13 +62,20 @@ Page({
this.data.params.curr_page = curr; this.data.params.curr_page = curr;
this.setData({ params: this.data.params }); this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params); const temp = cloneLite(this.data.params);
return new Promise<void>((resolve, reject) => {
post('OrderCategory/list', temp).then((res: any) => { post('OrderCategory/list', temp)
const list = toArray(res.data); .then((res: any) => {
// if (list.length == 0 && this.data.params.curr_page > 1) { const list = toArray(res.data);
// this.getList(this.data.params.curr_page - 1); // 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() { 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 { import {
cloneLite, cloneLite,
getAuthInfo, getAuthInfo,
@@ -27,11 +27,11 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
}, },
searchChange(e: any) { searchChange(e: any) {
const key = getDataSet(e).key; const key = getDataSet(e).key;
@@ -62,16 +62,24 @@ Page({
this.data.params.curr_page = curr; this.data.params.curr_page = curr;
this.setData({ params: this.data.params }); this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params); const temp = cloneLite(this.data.params);
return new Promise<void>((resolve, reject) => {
post('OrderStep/list', temp).then((res: any) => { post('OrderStep/list', temp)
const list = toArray(res.data); .then((res: any) => {
// if (list.length == 0 && this.data.params.curr_page > 1) { const list = toArray(res.data);
// this.getList(this.data.params.curr_page - 1); // if (list.length == 0 && this.data.params.curr_page > 1) {
// } // this.getList(this.data.params.curr_page - 1);
this.setData({ // }
count: toNumber(res.count), this.setData({
list: list, count: toNumber(res.count),
}); list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
}); });
}, },
@@ -128,7 +136,7 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { 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'; import { getAuthInfo, toArray } from '@/utils/util';
Page({ Page({
@@ -14,18 +14,24 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
}, },
getList() { getList() {
post('CompanyProcessV2/getChildProcess', { process_id: this.data.process_id }).then( return new Promise<void>((resolve, reject) => {
(res: any) => { post('CompanyProcessV2/getChildProcess', { process_id: this.data.process_id })
this.setData({ list: toArray(res.data) }); .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) }); wx.setNavigationBarTitle({ title: decodeURIComponent(title) });
} }
this.data.process_id = process_id; 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"> <t-cell-group custom-style="margin: 0">
<block wx:for="{{list}}" wx:key="index"> <block wx:for="{{list}}" wx:key="index">
<t-cell title="{{item.process_name}}" note="{{item.process_code}}" data-index="{{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;"> <view slot="left-icon" style="color: #999;line-height: 1.5;">
{{index + 1}} {{index + 1}}
</view> </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'; import { getAuthInfo, getDataSet, toArray } from '@/utils/util';
Page({ Page({
@@ -13,15 +13,23 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
}, },
getList() { getList() {
post('CompanyProcessV2/getParentProcess').then((res: any) => { return new Promise<void>((resolve, reject) => {
this.setData({ list: toArray(res.data) }); 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) { onChildProcess(e: any) {
@@ -38,7 +46,7 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(_options) { 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 { import {
cloneLite, cloneLite,
getAuthInfo, getAuthInfo,
@@ -27,11 +27,11 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
}, },
searchChange(e: any) { searchChange(e: any) {
const key = getDataSet(e).key; const key = getDataSet(e).key;
@@ -62,16 +62,24 @@ Page({
this.data.params.curr_page = curr; this.data.params.curr_page = curr;
this.setData({ params: this.data.params }); this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params); const temp = cloneLite(this.data.params);
return new Promise<void>((resolve, reject) => {
post('ProductType/list', temp).then((res: any) => { post('ProductType/list', temp)
const list = toArray(res.data); .then((res: any) => {
// if (list.length == 0 && this.data.params.curr_page > 1) { const list = toArray(res.data);
// this.getList(this.data.params.curr_page - 1); // if (list.length == 0 && this.data.params.curr_page > 1) {
// } // this.getList(this.data.params.curr_page - 1);
this.setData({ // }
count: toNumber(res.count), this.setData({
list: list, count: toNumber(res.count),
}); list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
}); });
}, },
@@ -130,7 +138,7 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { 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 { import {
cloneLite, cloneLite,
getAuthInfo, getAuthInfo,
@@ -27,11 +27,11 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
}, },
searchChange(e: any) { searchChange(e: any) {
const key = getDataSet(e).key; const key = getDataSet(e).key;
@@ -62,16 +62,24 @@ Page({
this.data.params.curr_page = curr; this.data.params.curr_page = curr;
this.setData({ params: this.data.params }); this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params); const temp = cloneLite(this.data.params);
return new Promise<void>((resolve, reject) => {
post('ErpCrm/list', temp).then((res: any) => { post('ErpCrm/list', temp)
const list = toArray(res.data?.list); .then((res: any) => {
if (list.length == 0 && this.data.params.curr_page > 1) { const list = toArray(res.data?.list);
this.getList(this.data.params.curr_page - 1); 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), this.setData({
list: list, count: toNumber(res.data?.count),
}); list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
}); });
}, },
onOrderEdit(e: any) { onOrderEdit(e: any) {
@@ -114,7 +122,7 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { 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'; import { toArray, toNumber } from '@/utils/util';
Page({ Page({
@@ -14,40 +14,47 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {},
this.getList();
},
getList() { getList() {
post('Index/index') return new Promise<void>((resolve, reject) => {
.then((res: any) => { post('Index/index')
const process_count = toArray(res.process_count).filter((el) => { .then((res: any) => {
el.count = toNumber(el.count); const process_count = toArray(res.process_count).filter((el) => {
return el.count > 0; el.count = toNumber(el.count);
}); return el.count > 0;
const arr = toArray(res.seven_process_count).filter((el) => { });
el.count = toNumber(el.count); const arr = toArray(res.seven_process_count).filter((el) => {
return el.count > 0; el.count = toNumber(el.count);
}); return el.count > 0;
});
const map = new Map<string, any>(); const map = new Map<string, any>();
arr.forEach((el) => { arr.forEach((el) => {
if (!map.has(el.date)) { if (!map.has(el.date)) {
map.set(el.date, []); map.set(el.date, []);
} }
map.get(el.date).push(el); map.get(el.date).push(el);
});
// console.log([...map.values()]);
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();
}); });
// console.log([...map.values()]); });
this.setData({
seven_process_count: [...map.values()],
process_count: process_count,
});
})
.finally(() => {
wx.stopPullDownRefresh();
});
}, },
/** /**
@@ -64,7 +71,7 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { onShow() {
loginStatusPage(this); onPageLoadInitAuth(this, () => this.getList());
}, },
/** /**

View File

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

View File

@@ -1,4 +1,4 @@
import { loginStatusPage, post } from '@/utils/https'; import { onPageLoadInitAuth, post } from '@/utils/https';
import { import {
cloneLite, cloneLite,
getAuthInfo, getAuthInfo,
@@ -35,11 +35,12 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
this.getData(); this.getData();
}, },
searchChange(e: any) { searchChange(e: any) {
@@ -87,16 +88,24 @@ Page({
this.data.params.curr_page = curr; this.data.params.curr_page = curr;
this.setData({ params: this.data.params }); this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params); const temp = cloneLite(this.data.params);
return new Promise<void>((resolve, reject) => {
post('ErpAccount/flow', temp).then((res: any) => { post('ErpAccount/flow', temp)
const list = toArray(res.data); .then((res: any) => {
if (list.length == 0 && this.data.params.curr_page > 1) { const list = toArray(res.data);
this.getList(this.data.params.curr_page - 1); if (list.length == 0 && this.data.params.curr_page > 1) {
} this.getList(this.data.params.curr_page - 1);
this.setData({ }
count: toNumber(res.count), this.setData({
list: list, count: toNumber(res.count),
}); list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
}); });
}, },
@@ -137,7 +146,7 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { 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 { import {
cloneLite, cloneLite,
getAuthInfo, getAuthInfo,
@@ -32,11 +32,11 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
}, },
searchChange(e: any) { searchChange(e: any) {
const key = getDataSet(e).key; const key = getDataSet(e).key;
@@ -78,16 +78,24 @@ Page({
} else { } else {
delete temp.process_state; delete temp.process_state;
} }
return new Promise<void>((resolve, reject) => {
post('ErpFinance/list', temp).then((res: any) => { post('ErpFinance/list', temp)
const list = toArray(res.data?.list); .then((res: any) => {
if (list.length == 0 && this.data.params.curr_page > 1) { const list = toArray(res.data?.list);
this.getList(this.data.params.curr_page - 1); 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), this.setData({
list: list, count: toNumber(res.data?.count),
}); list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
}); });
}, },
onOrderDetail(e: any) { onOrderDetail(e: any) {
@@ -135,7 +143,7 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { onShow() {
loginStatusPage(this); onPageLoadInitAuth(this, () => this.getList());
}, },
/** /**

View File

@@ -1,5 +1,5 @@
import { OSSBaseUrl } from '@/utils/config'; import { OSSBaseUrl } from '@/utils/config';
import { loginStatusPage, post } from '@/utils/https'; import { onPageLoadInitAuth, post } from '@/utils/https';
import { import {
cloneLite, cloneLite,
formatFileSize, formatFileSize,
@@ -29,25 +29,12 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
},
getList() {
this.setData({ params: this.data.params });
const temp = cloneLite(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) => { post('ErpFinance/fileList', temp).then((res: any) => {
this.setData({ this.setData({
files: toArray(res.data).map((el) => { 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) { onPreview(e: any) {
const data = getDataSet(e); const data = getDataSet(e);
const index = data.index; const index = data.index;
@@ -78,7 +88,7 @@ Page({
onLoad(options) { onLoad(options) {
const { head_id } = options; const { head_id } = options;
this.data.params.head_id = head_id; 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 { import {
cloneLite, cloneLite,
getAuthInfo, getAuthInfo,
@@ -32,11 +32,11 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
}, },
searchChange(e: any) { searchChange(e: any) {
const key = getDataSet(e).key; const key = getDataSet(e).key;
@@ -78,16 +78,24 @@ Page({
} else { } else {
delete temp.process_state; delete temp.process_state;
} }
return new Promise<void>((resolve, reject) => {
post('ErpFinance/list', temp).then((res: any) => { post('ErpFinance/list', temp)
const list = toArray(res.data?.list); .then((res: any) => {
if (list.length == 0 && this.data.params.curr_page > 1) { const list = toArray(res.data?.list);
this.getList(this.data.params.curr_page - 1); 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), this.setData({
list: list, count: toNumber(res.data?.count),
}); list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
}); });
}, },
onOrderDetail(e: any) { onOrderDetail(e: any) {
@@ -135,7 +143,7 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { onShow() {
loginStatusPage(this); onPageLoadInitAuth(this, () => this.getList());
}, },
/** /**

View File

@@ -1,5 +1,5 @@
import { OSSBaseUrl } from '@/utils/config'; import { OSSBaseUrl } from '@/utils/config';
import { loginStatusPage, post } from '@/utils/https'; import { onPageLoadInitAuth, post } from '@/utils/https';
import { import {
cloneLite, cloneLite,
formatFileSize, formatFileSize,
@@ -29,25 +29,12 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
},
getList() {
this.setData({ params: this.data.params });
const temp = cloneLite(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) => { post('ErpFinance/fileList', temp).then((res: any) => {
this.setData({ this.setData({
files: toArray(res.data).map((el) => { 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) { onPreview(e: any) {
const data = getDataSet(e); const data = getDataSet(e);
const index = data.index; const index = data.index;
@@ -78,7 +88,7 @@ Page({
onLoad(options) { onLoad(options) {
const { head_id } = options; const { head_id } = options;
this.data.params.head_id = head_id; 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 { import {
cloneLite, cloneLite,
getAuthInfo, getAuthInfo,
@@ -32,11 +32,11 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
}, },
searchChange(e: any) { searchChange(e: any) {
const key = getDataSet(e).key; const key = getDataSet(e).key;
@@ -78,16 +78,24 @@ Page({
} else { } else {
delete temp.process_state; delete temp.process_state;
} }
return new Promise<void>((resolve, reject) => {
post('ErpFinance/list', temp).then((res: any) => { post('ErpFinance/list', temp)
const list = toArray(res.data?.list); .then((res: any) => {
if (list.length == 0 && this.data.params.curr_page > 1) { const list = toArray(res.data?.list);
this.getList(this.data.params.curr_page - 1); 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), this.setData({
list: list, count: toNumber(res.data?.count),
}); list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
}); });
}, },
onOrderDetail(e: any) { onOrderDetail(e: any) {
@@ -135,7 +143,7 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { onShow() {
loginStatusPage(this); onPageLoadInitAuth(this, () => this.getList());
}, },
/** /**

View File

@@ -1,5 +1,5 @@
import { OSSBaseUrl } from '@/utils/config'; import { OSSBaseUrl } from '@/utils/config';
import { loginStatusPage, post } from '@/utils/https'; import { onPageLoadInitAuth, post } from '@/utils/https';
import { import {
cloneLite, cloneLite,
formatFileSize, formatFileSize,
@@ -29,25 +29,12 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
},
getList() {
this.setData({ params: this.data.params });
const temp = cloneLite(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) => { post('ErpFinance/fileList', temp).then((res: any) => {
this.setData({ this.setData({
files: toArray(res.data).map((el) => { 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) { onPreview(e: any) {
const data = getDataSet(e); const data = getDataSet(e);
const index = data.index; const index = data.index;
@@ -78,7 +88,7 @@ Page({
onLoad(options) { onLoad(options) {
const { head_id } = options; const { head_id } = options;
this.data.params.head_id = head_id; 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 { import {
cloneLite, cloneLite,
getAuthInfo, getAuthInfo,
@@ -19,16 +19,17 @@ Page({
list: [] as any[], list: [] as any[],
count: 0, count: 0,
sort: [{ label: '创建日期', value: 'create_date' }], sort: [{ label: '创建日期', value: 'create_date' }],
isLogin: false,
}, },
handleLogin(e: any) { handleLogin(e: any) {
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
}, },
searchChange(e: any) { searchChange(e: any) {
const key = getDataSet(e).key; const key = getDataSet(e).key;
@@ -59,26 +60,34 @@ Page({
this.data.params.curr_page = curr; this.data.params.curr_page = curr;
this.setData({ params: this.data.params }); this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params); const temp = cloneLite(this.data.params);
return new Promise<void>((resolve, reject) => {
post('Log/loginList', temp).then((res: any) => { post('Log/loginList', temp)
const list = toArray(res.data?.list); .then((res: any) => {
if (list.length == 0 && this.data.params.curr_page > 1) { const list = toArray(res.data?.list);
this.getList(this.data.params.curr_page - 1); 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.map((el) => {
el.address = '';
if (el.detail) {
const obj = JSON.parse(el.detail);
const arr = ['province', 'city']
.map((key) => obj[key]) // 取出字段值
.filter(Boolean);
el.address = arr.length ? arr.join(',') : '';
} }
return el; this.setData({
}), count: toNumber(res.data?.count),
}); list: list.map((el) => {
el.address = '';
if (el.detail) {
const obj = JSON.parse(el.detail);
const arr = ['province', 'city']
.map((key) => obj[key]) // 取出字段值
.filter(Boolean);
el.address = arr.length ? arr.join(',') : '';
}
return el;
}),
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
}); });
}, },
@@ -96,7 +105,7 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { 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 { import {
cloneLite, cloneLite,
getAuthInfo, getAuthInfo,
@@ -19,16 +19,17 @@ Page({
list: [] as any[], list: [] as any[],
count: 0, count: 0,
sort: [{ label: '创建日期', value: 'create_date' }], sort: [{ label: '创建日期', value: 'create_date' }],
isLogin: false,
}, },
handleLogin(e: any) { handleLogin(e: any) {
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
}, },
searchChange(e: any) { searchChange(e: any) {
const key = getDataSet(e).key; const key = getDataSet(e).key;
@@ -59,16 +60,24 @@ Page({
this.data.params.curr_page = curr; this.data.params.curr_page = curr;
this.setData({ params: this.data.params }); this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params); const temp = cloneLite(this.data.params);
return new Promise<void>((resolve, reject) => {
post('Log/operateList', temp).then((res: any) => { post('Log/operateList', temp)
const list = toArray(res.data?.list); .then((res: any) => {
if (list.length == 0 && this.data.params.curr_page > 1) { const list = toArray(res.data?.list);
this.getList(this.data.params.curr_page - 1); 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), this.setData({
list: list, 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() { 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 { import {
cloneLite, cloneLite,
getAuthInfo, getAuthInfo,
@@ -30,11 +30,11 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
}, },
searchChange(e: any) { searchChange(e: any) {
const key = getDataSet(e).key; const key = getDataSet(e).key;
@@ -76,13 +76,20 @@ Page({
} else { } else {
delete temp.process_state; delete temp.process_state;
} }
return new Promise<void>((resolve, reject) => {
post('Departments/list', temp).then((res: any) => { post('Departments/list', temp)
const list = toArray(res.data); .then((res: any) => {
if (list.length == 0 && this.data.params.curr_page > 1) { const list = toArray(res.data);
this.getList(this.data.params.curr_page - 1); 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() { 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 { import {
cloneLite, cloneLite,
getAuthInfo, getAuthInfo,
@@ -25,16 +25,17 @@ Page({
{ value: '2', label: '已审核' }, { value: '2', label: '已审核' },
], ],
sort: [{ label: '创建日期', value: 'create_date' }], sort: [{ label: '创建日期', value: 'create_date' }],
isLogin: false,
}, },
handleLogin(e: any) { handleLogin(e: any) {
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
}, },
searchChange(e: any) { searchChange(e: any) {
const key = getDataSet(e).key; const key = getDataSet(e).key;
@@ -76,13 +77,20 @@ Page({
} else { } else {
delete temp.process_state; delete temp.process_state;
} }
return new Promise<void>((resolve, reject) => {
post('Groups/list', temp).then((res: any) => { post('Groups/list', temp)
const list = toArray(res.data); .then((res: any) => {
if (list.length == 0 && this.data.params.curr_page > 1) { const list = toArray(res.data);
this.getList(this.data.params.curr_page - 1); 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) { onGroupTap(e: any) {
@@ -122,7 +130,7 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { 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'; import { getAuthInfo, toArray } from '@/utils/util';
Page({ Page({
@@ -8,53 +8,62 @@ Page({
data: { data: {
list: [] as any[], list: [] as any[],
group_id: '', group_id: '',
isLogin: false,
}, },
handleLogin(e: any) { handleLogin(e: any) {
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
}, },
getList() { getList() {
post('Groups/getGrpRights', { group_id: this.data.group_id }).then((res: any) => { return new Promise<void>((resolve, reject) => {
const list = toArray(res.right_tree); post('Groups/getGrpRights', { group_id: this.data.group_id })
const rights = `${res.rights || ''}`.split(','); .then((res: any) => {
this.data.list.length = 0; const list = toArray(res.right_tree);
const rights = `${res.rights || ''}`.split(',');
this.data.list.length = 0;
toArray(list).forEach((menu) => { toArray(list).forEach((menu) => {
const arr: any[] = []; const arr: any[] = [];
toArray(menu.children).forEach((menu2) => { toArray(menu.children).forEach((menu2) => {
let flag = false; let flag = false;
toArray(menu2.children).forEach((fun) => { toArray(menu2.children).forEach((fun) => {
fun.web_checked = rights.includes(`${fun.function_id}`); fun.web_checked = rights.includes(`${fun.function_id}`);
if (fun.web_checked) { if (fun.web_checked) {
flag = true; flag = true;
}
});
if (flag) {
arr.push({
menu_ch_name: menu2.menu_ch_name,
menu_id: menu2.menu_id,
functions: toArray(menu2.children),
});
}
});
if (arr.length) {
this.data.list.push({
menu_ch_name: menu.menu_ch_name,
menu_id: menu.menu_id,
children: arr,
});
} }
}); });
// console.log(this.data.list);
if (flag) { this.setData({ list: this.data.list, isLogin: true });
arr.push({ resolve(res);
menu_ch_name: menu2.menu_ch_name, })
menu_id: menu2.menu_id, .catch((res) => {
functions: toArray(menu2.children), this.setData({ isLogin: false });
}); reject(res);
}
}); });
if (arr.length) {
this.data.list.push({
menu_ch_name: menu.menu_ch_name,
menu_id: menu.menu_id,
children: arr,
});
}
});
// console.log(this.data.list);
this.setData({ list: this.data.list });
}); });
}, },
@@ -65,7 +74,7 @@ Page({
this.data.group_id = `${options.group_id}`; this.data.group_id = `${options.group_id}`;
wx.setNavigationBarTitle({ title: `${decodeURIComponent(`${options.name}`)} 权限` }); 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'; import { getAuthInfo, toArray } from '@/utils/util';
Page({ Page({
@@ -7,53 +7,62 @@ Page({
*/ */
data: { data: {
list: [] as any[], list: [] as any[],
isLogin: false,
}, },
handleLogin(e: any) { handleLogin(e: any) {
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
}, },
getList() { getList() {
post('Groups/myAuth').then((res: any) => { return new Promise<void>((resolve, reject) => {
const list = toArray(res.right_tree); post('Groups/myAuth')
const rights = `${res.rights || ''}`.split(','); .then((res: any) => {
this.data.list.length = 0; const list = toArray(res.right_tree);
const rights = `${res.rights || ''}`.split(',');
this.data.list.length = 0;
toArray(list).forEach((menu) => { toArray(list).forEach((menu) => {
const arr: any[] = []; const arr: any[] = [];
toArray(menu.children).forEach((menu2) => { toArray(menu.children).forEach((menu2) => {
let flag = false; let flag = false;
toArray(menu2.children).forEach((fun) => { toArray(menu2.children).forEach((fun) => {
fun.web_checked = rights.includes(`${fun.function_id}`); fun.web_checked = rights.includes(`${fun.function_id}`);
if (fun.web_checked) { if (fun.web_checked) {
flag = true; flag = true;
}
});
if (flag) {
arr.push({
menu_ch_name: menu2.menu_ch_name,
menu_id: menu2.menu_id,
functions: toArray(menu2.children),
});
}
});
if (arr.length) {
this.data.list.push({
menu_ch_name: menu.menu_ch_name,
menu_id: menu.menu_id,
children: arr,
});
} }
}); });
// console.log(this.data.list);
if (flag) { this.setData({ list: this.data.list, isLogin: true });
arr.push({ resolve(res);
menu_ch_name: menu2.menu_ch_name, })
menu_id: menu2.menu_id, .catch((res) => {
functions: toArray(menu2.children), this.setData({ isLogin: false });
}); reject(res);
}
}); });
if (arr.length) {
this.data.list.push({
menu_ch_name: menu.menu_ch_name,
menu_id: menu.menu_id,
children: arr,
});
}
});
// console.log(this.data.list);
this.setData({ list: this.data.list });
}); });
}, },
@@ -61,7 +70,7 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(_options) { 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 { import {
cloneLite, cloneLite,
getAuthInfo, getAuthInfo,
@@ -31,16 +31,17 @@ Page({
user_id: wx.getStorageSync('user_id'), user_id: wx.getStorageSync('user_id'),
depOption: [] as any[], depOption: [] as any[],
groupsOption: [] as any[], groupsOption: [] as any[],
isLogin: false,
}, },
handleLogin(e: any) { handleLogin(e: any) {
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
this.getOrderStep(); this.getOrderStep();
}, },
searchChange(e: any) { searchChange(e: any) {
@@ -106,13 +107,20 @@ Page({
this.data.params.curr_page = curr; this.data.params.curr_page = curr;
this.setData({ params: this.data.params }); this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params); const temp = cloneLite(this.data.params);
return new Promise<void>((resolve, reject) => {
post('Users/getStaff', temp).then((res: any) => { post('Users/getStaff', temp)
const list = toArray(res.data); .then((res: any) => {
if (list.length == 0 && this.data.params.curr_page > 1) { const list = toArray(res.data);
this.getList(this.data.params.curr_page - 1); 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) { onReinstatedStaff(e: any) {
@@ -170,7 +178,7 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { onShow() {
loginStatusPage(this); onPageLoadInitAuth(this, () => this.getList());
}, },
/** /**

View File

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

View File

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

View File

@@ -32,9 +32,9 @@
<view slot="header">{{ item.batch_no }}</view> <view slot="header">{{ item.batch_no }}</view>
<view slot="content"> <view slot="content">
<card-item-plugin label="自定义批号" value="{{item.batch_custom_no}}" /> <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_name}}" />
<card-item-plugin label="商品编码" value="{{item.goods_code}}" /> <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.unit_ch_name}}" />
<card-item-plugin label="批次单价" value="{{item.batch_price}}" /> <card-item-plugin label="批次单价" value="{{item.batch_price}}" />
<card-item-plugin label="库存" value="{{item.batch_nums}}" /> <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 { import {
cloneLite, cloneLite,
getAuthInfo, getAuthInfo,
@@ -26,11 +26,12 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
this.getData(); this.getData();
}, },
searchChange(e: any) { searchChange(e: any) {
@@ -74,16 +75,24 @@ Page({
this.data.params.curr_page = curr; this.data.params.curr_page = curr;
this.setData({ params: this.data.params }); this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params); const temp = cloneLite(this.data.params);
return new Promise<void>((resolve, reject) => {
post('GoodsBatch/getBatchLogList', temp).then((res: any) => { post('GoodsBatch/getBatchLogList', temp)
const list = toArray(res.data); .then((res: any) => {
if (list.length == 0 && this.data.params.curr_page > 1) { const list = toArray(res.data);
this.getList(this.data.params.curr_page - 1); if (list.length == 0 && this.data.params.curr_page > 1) {
} this.getList(this.data.params.curr_page - 1);
this.setData({ }
count: toNumber(res.count), this.setData({
list: list, 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) { if (title) {
wx.setNavigationBarTitle({ 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 { import {
cloneLite, cloneLite,
getAuthInfo, getAuthInfo,
@@ -28,11 +28,12 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
this.getData(); this.getData();
}, },
searchChange(e: any) { searchChange(e: any) {
@@ -134,15 +135,24 @@ Page({
if (!temp.goods_class) { if (!temp.goods_class) {
delete temp.goods_class; delete temp.goods_class;
} }
post('ErpGoods/list', temp).then((res: any) => { return new Promise<void>((resolve, reject) => {
const list = toArray(res.data); post('ErpGoods/list', temp)
if (list.length == 0 && this.data.params.curr_page > 1) { .then((res: any) => {
this.getList(this.data.params.curr_page - 1); const list = toArray(res.data);
} if (list.length == 0 && this.data.params.curr_page > 1) {
this.setData({ this.getList(this.data.params.curr_page - 1);
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);
});
}); });
}, },
@@ -180,7 +190,7 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(_options) { 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 { import {
cloneLite, cloneLite,
getAuthInfo, getAuthInfo,
@@ -28,11 +28,11 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getGoodsAttr();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getGoodsAttr();
}, },
searchChange(e: any) { searchChange(e: any) {
const key = getDataSet(e).key; const key = getDataSet(e).key;
@@ -57,19 +57,27 @@ Page({
this.getList(); this.getList();
}, },
getGoodsAttr() { getGoodsAttr() {
post('GoodsAttr/list').then((res: any) => { return new Promise<void>((resolve, reject) => {
this.data.goodsSubAttr = {}; post('GoodsAttr/list')
toArray(res?.data?.list).forEach((el) => { .then((res: any) => {
toArray(el.sub_attr).forEach((ell) => { this.data.goodsSubAttr = {};
this.data.goodsSubAttr[ell.attr_id] = { toArray(res?.data?.list).forEach((el) => {
...ell, toArray(el.sub_attr).forEach((ell) => {
p_attr_name: el.attr_name, this.data.goodsSubAttr[ell.attr_id] = {
}; ...ell,
p_attr_name: el.attr_name,
};
});
});
// console.log(this.data.goodsSubAttr);
this.setData({ goodsSubAttr: this.data.goodsSubAttr, isLogin: true });
this.getList();
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
}); });
});
// console.log(this.data.goodsSubAttr);
this.setData({ goodsSubAttr: this.data.goodsSubAttr });
this.getList();
}); });
}, },
getList() { getList() {
@@ -109,7 +117,7 @@ Page({
if (title) { if (title) {
wx.setNavigationBarTitle({ title: decodeURIComponent(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 { import {
cloneLite, cloneLite,
getAuthInfo, getAuthInfo,
@@ -33,11 +33,11 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
}, },
searchChange(e: any) { searchChange(e: any) {
const key = getDataSet(e).key; const key = getDataSet(e).key;
@@ -79,16 +79,24 @@ Page({
} else { } else {
delete temp.process_state; delete temp.process_state;
} }
return new Promise<void>((resolve, reject) => {
post('ErpDepot/depotHeadList', temp).then((res: any) => { post('ErpDepot/depotHeadList', temp)
const list = toArray(res.data); .then((res: any) => {
if (list.length == 0 && this.data.params.curr_page > 1) { const list = toArray(res.data);
this.getList(this.data.params.curr_page - 1); if (list.length == 0 && this.data.params.curr_page > 1) {
} this.getList(this.data.params.curr_page - 1);
this.setData({ }
count: toNumber(res.count), this.setData({
list: list, count: toNumber(res.count),
}); list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
}); });
}, },
onOrderDetail(e: any) { onOrderDetail(e: any) {
@@ -142,7 +150,7 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { onShow() {
loginStatusPage(this); onPageLoadInitAuth(this, () => this.getList());
}, },
/** /**

View File

@@ -1,5 +1,5 @@
import { OSSBaseUrl } from '@/utils/config'; import { OSSBaseUrl } from '@/utils/config';
import { loginStatusPage, post } from '@/utils/https'; import { onPageLoadInitAuth, post } from '@/utils/https';
import { import {
cloneLite, cloneLite,
formatFileSize, formatFileSize,
@@ -29,29 +29,38 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
}, },
getList() { getList() {
this.setData({ params: this.data.params }); this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params); const temp = cloneLite(this.data.params);
post('ErpDepot/info', temp).then((res: any) => { return new Promise<void>((resolve, reject) => {
const info = toObject(res.info); post('ErpDepot/info', temp)
wx.setNavigationBarTitle({ title: `${info.bill_no} 详情` }); .then((res: any) => {
this.setData({ const info = toObject(res.info);
files: toArray(res.files).map((el) => { wx.setNavigationBarTitle({ title: `${info.bill_no} 详情` });
el._file_type = getFileType(el.file_name); this.setData({
el.file_path = `${OSSBaseUrl}${el.file_path}`; files: toArray(res.files).map((el) => {
el._file_size = formatFileSize(el.file_size); el._file_type = getFileType(el.file_name);
return el; el.file_path = `${OSSBaseUrl}${el.file_path}`;
}), el._file_size = formatFileSize(el.file_size);
detail: toArray(res.rows), return el;
info: info, }),
}); detail: toArray(res.rows),
info: info,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
}); });
}, },
onPreview(e: any) { onPreview(e: any) {
@@ -73,7 +82,7 @@ Page({
onLoad(options) { onLoad(options) {
const { head_id } = options; const { head_id } = options;
this.data.params.head_id = head_id; 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 { import {
cloneLite, cloneLite,
getAuthInfo, getAuthInfo,
@@ -32,11 +32,11 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
}, },
searchChange(e: any) { searchChange(e: any) {
const key = getDataSet(e).key; const key = getDataSet(e).key;
@@ -78,16 +78,24 @@ Page({
} else { } else {
delete temp.process_state; delete temp.process_state;
} }
return new Promise<void>((resolve, reject) => {
post('ErpDepot/depotHeadList', temp).then((res: any) => { post('ErpDepot/depotHeadList', temp)
const list = toArray(res.data); .then((res: any) => {
if (list.length == 0 && this.data.params.curr_page > 1) { const list = toArray(res.data);
this.getList(this.data.params.curr_page - 1); if (list.length == 0 && this.data.params.curr_page > 1) {
} this.getList(this.data.params.curr_page - 1);
this.setData({ }
count: toNumber(res.count), this.setData({
list: list, count: toNumber(res.count),
}); list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
}); });
}, },
onOrderDetail(e: any) { onOrderDetail(e: any) {
@@ -135,7 +143,7 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { onShow() {
loginStatusPage(this); onPageLoadInitAuth(this, () => this.getList());
}, },
/** /**

View File

@@ -1,5 +1,5 @@
import { OSSBaseUrl } from '@/utils/config'; import { OSSBaseUrl } from '@/utils/config';
import { loginStatusPage, post } from '@/utils/https'; import { onPageLoadInitAuth, post } from '@/utils/https';
import { import {
cloneLite, cloneLite,
formatFileSize, formatFileSize,
@@ -29,29 +29,38 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
}, },
getList() { getList() {
this.setData({ params: this.data.params }); this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params); const temp = cloneLite(this.data.params);
post('ErpDepot/info', temp).then((res: any) => { return new Promise<void>((resolve, reject) => {
const info = toObject(res.info); post('ErpDepot/info', temp)
wx.setNavigationBarTitle({ title: `${info.bill_no} 详情` }); .then((res: any) => {
this.setData({ const info = toObject(res.info);
files: toArray(res.files).map((el) => { wx.setNavigationBarTitle({ title: `${info.bill_no} 详情` });
el._file_type = getFileType(el.file_name); this.setData({
el.file_path = `${OSSBaseUrl}${el.file_path}`; files: toArray(res.files).map((el) => {
el._file_size = formatFileSize(el.file_size); el._file_type = getFileType(el.file_name);
return el; el.file_path = `${OSSBaseUrl}${el.file_path}`;
}), el._file_size = formatFileSize(el.file_size);
detail: toArray(res.rows), return el;
info: info, }),
}); detail: toArray(res.rows),
info: info,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
}); });
}, },
onPreview(e: any) { onPreview(e: any) {
@@ -73,7 +82,7 @@ Page({
onLoad(options) { onLoad(options) {
const { head_id } = options; const { head_id } = options;
this.data.params.head_id = head_id; 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 { import {
cloneLite, cloneLite,
getAuthInfo, getAuthInfo,
@@ -30,11 +30,11 @@ Page({
this.setData({ isLogin: e.detail }); this.setData({ isLogin: e.detail });
if (e.detail) { if (e.detail) {
this.init(); this.init();
this.getList();
} }
}, },
init() { init() {
this.setData({ authInfo: getAuthInfo() }); this.setData({ authInfo: getAuthInfo() });
this.getList();
}, },
searchChange(e: any) { searchChange(e: any) {
const key = getDataSet(e).key; const key = getDataSet(e).key;
@@ -64,15 +64,24 @@ Page({
getList(curr: number = 1) { getList(curr: number = 1) {
this.data.params.curr_page = curr; this.data.params.curr_page = curr;
this.setData({ params: this.data.params }); this.setData({ params: this.data.params });
post('CompanyProcessV2/processOrd', this.data.params).then((res: any) => { return new Promise<void>((resolve, reject) => {
const list = toArray(res.data); post('CompanyProcessV2/processOrd', this.data.params)
if (list.length == 0 && this.data.params.curr_page > 1) { .then((res: any) => {
this.getList(this.data.params.curr_page - 1); const list = toArray(res.data);
} if (list.length == 0 && this.data.params.curr_page > 1) {
this.setData({ this.getList(this.data.params.curr_page - 1);
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);
});
}); });
}, },
confirmDialog() { confirmDialog() {
@@ -113,7 +122,7 @@ Page({
title: decodeURIComponent(options.title || ''), title: decodeURIComponent(options.title || ''),
}); });
this.data.params.process_id = `${options.process_id || ''}`; this.data.params.process_id = `${options.process_id || ''}`;
loginStatusPage(this); onPageLoadInitAuth(this, () => this.getList());
}, },
/** /**

View File

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

View File

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