添加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,
@@ -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,16 +87,24 @@ 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) => {
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,
});
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);
}
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,16 +75,24 @@ 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) => {
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,
});
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);
}
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,15 +135,24 @@ Page({
if (!temp.goods_class) {
delete temp.goods_class;
}
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);
}
this.setData({
count: toNumber(res.count),
list: list,
});
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);
}
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,19 +57,27 @@ Page({
this.getList();
},
getGoodsAttr() {
post('GoodsAttr/list').then((res: any) => {
this.data.goodsSubAttr = {};
toArray(res?.data?.list).forEach((el) => {
toArray(el.sub_attr).forEach((ell) => {
this.data.goodsSubAttr[ell.attr_id] = {
...ell,
p_attr_name: el.attr_name,
};
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) => {
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() {
@@ -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,16 +79,24 @@ Page({
} else {
delete temp.process_state;
}
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);
}
this.setData({
count: toNumber(res.count),
list: list,
});
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);
}
this.setData({
count: toNumber(res.count),
list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
onOrderDetail(e: any) {
@@ -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,29 +29,38 @@ 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) => {
const info = toObject(res.info);
wx.setNavigationBarTitle({ title: `${info.bill_no} 详情` });
this.setData({
files: toArray(res.files).map((el) => {
el._file_type = getFileType(el.file_name);
el.file_path = `${OSSBaseUrl}${el.file_path}`;
el._file_size = formatFileSize(el.file_size);
return el;
}),
detail: toArray(res.rows),
info: info,
});
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({
files: toArray(res.files).map((el) => {
el._file_type = getFileType(el.file_name);
el.file_path = `${OSSBaseUrl}${el.file_path}`;
el._file_size = formatFileSize(el.file_size);
return el;
}),
detail: toArray(res.rows),
info: info,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
onPreview(e: any) {
@@ -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,16 +78,24 @@ Page({
} else {
delete temp.process_state;
}
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);
}
this.setData({
count: toNumber(res.count),
list: list,
});
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);
}
this.setData({
count: toNumber(res.count),
list: list,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
onOrderDetail(e: any) {
@@ -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,29 +29,38 @@ 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) => {
const info = toObject(res.info);
wx.setNavigationBarTitle({ title: `${info.bill_no} 详情` });
this.setData({
files: toArray(res.files).map((el) => {
el._file_type = getFileType(el.file_name);
el.file_path = `${OSSBaseUrl}${el.file_path}`;
el._file_size = formatFileSize(el.file_size);
return el;
}),
detail: toArray(res.rows),
info: info,
});
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({
files: toArray(res.files).map((el) => {
el._file_type = getFileType(el.file_name);
el.file_path = `${OSSBaseUrl}${el.file_path}`;
el._file_size = formatFileSize(el.file_size);
return el;
}),
detail: toArray(res.rows),
info: info,
isLogin: true,
});
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
});
},
onPreview(e: any) {
@@ -73,7 +82,7 @@ Page({
onLoad(options) {
const { head_id } = options;
this.data.params.head_id = head_id;
loginStatusPage(this);
onPageLoadInitAuth(this, () => this.getList());
},
/**