From f11f4c80001ff9f8dc329e33db2dcf7e3d4e43b7 Mon Sep 17 00:00:00 2001 From: zhengw <247276359@qq.com> Date: Fri, 6 Feb 2026 15:30:07 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E7=AE=80=E9=A1=B5=E9=9D=A2=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- miniprogram/pages/base/account/account.ts | 13 ++----------- miniprogram/pages/base/customer/customer.ts | 13 ++----------- miniprogram/pages/base/supplier/supplier.ts | 13 ++----------- .../pages/base/viewAttachment/viewAttachment.ts | 13 ++----------- miniprogram/pages/finance/flow/flow.ts | 13 ++----------- miniprogram/pages/finance/giro/giro.ts | 13 ++----------- miniprogram/pages/finance/income/income.ts | 13 ++----------- miniprogram/pages/finance/outcome/outcome.ts | 13 ++----------- miniprogram/pages/index/index.ts | 13 ++----------- miniprogram/pages/logs/loginLog/loginLog.ts | 13 ++----------- miniprogram/pages/logs/operateLog/operateLog.ts | 13 ++----------- .../pages/manage/department/department.ts | 13 ++----------- miniprogram/pages/manage/group/group.ts | 13 ++----------- .../pages/manage/groupDetail/groupDetail.ts | 13 ++----------- miniprogram/pages/manage/my/my.ts | 13 ++----------- miniprogram/pages/manage/staff/staff.ts | 13 ++----------- miniprogram/pages/my/my.ts | 14 ++------------ miniprogram/pages/orders/orderSort/orderSort.ts | 13 ++----------- .../ordersList/orderPayment/orderPayment.ts | 15 ++------------- .../pages/orders/ordersList/ordersList.ts | 13 ++----------- miniprogram/pages/other/batch/batch.ts | 13 ++----------- .../pages/other/batchDetail/batchDetail.ts | 13 ++----------- miniprogram/pages/other/goods/goods.ts | 13 ++----------- .../pages/other/goodsDetail/goodsDetail.ts | 13 ++----------- miniprogram/pages/other/outbound/outbound.ts | 13 ++----------- miniprogram/pages/other/transfer/transfer.ts | 13 ++----------- miniprogram/pages/processEntry/processEntry.ts | 12 ++---------- .../pages/produce/orderTask/orderTask.ts | 13 ++----------- .../produce/processManage/processManage.ts | 13 ++----------- .../processManageDetail/processManageDetail.ts | 13 ++----------- .../pages/purchase/backOrder/backOrder.ts | 13 ++----------- .../pages/purchase/buyInOrder/buyInOrder.ts | 13 ++----------- miniprogram/pages/purchase/buyOrder/buyOrder.ts | 13 ++----------- .../pages/purchase/requestOrder/requestOrder.ts | 13 ++----------- miniprogram/utils/https.ts | 17 +++++++++++++++++ 35 files changed, 85 insertions(+), 376 deletions(-) diff --git a/miniprogram/pages/base/account/account.ts b/miniprogram/pages/base/account/account.ts index 28426e8..f8663cc 100644 --- a/miniprogram/pages/base/account/account.ts +++ b/miniprogram/pages/base/account/account.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { cloneLite, getAuthInfo, @@ -130,16 +130,7 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/base/customer/customer.ts b/miniprogram/pages/base/customer/customer.ts index 5bed1f4..5ee63e5 100644 --- a/miniprogram/pages/base/customer/customer.ts +++ b/miniprogram/pages/base/customer/customer.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { cloneLite, getAuthInfo, @@ -102,16 +102,7 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/base/supplier/supplier.ts b/miniprogram/pages/base/supplier/supplier.ts index ba3cc80..fa3c2e2 100644 --- a/miniprogram/pages/base/supplier/supplier.ts +++ b/miniprogram/pages/base/supplier/supplier.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { cloneLite, getAuthInfo, @@ -102,16 +102,7 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/base/viewAttachment/viewAttachment.ts b/miniprogram/pages/base/viewAttachment/viewAttachment.ts index 069b282..ce7c087 100644 --- a/miniprogram/pages/base/viewAttachment/viewAttachment.ts +++ b/miniprogram/pages/base/viewAttachment/viewAttachment.ts @@ -1,5 +1,5 @@ import { OSSBaseUrl } from '@/utils/config'; -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { formatFileSize, getAuthInfo, @@ -76,16 +76,7 @@ Page({ this.data.order_no = order_no; this.data.head_id = head_id; this.data.head_id2 = head_id2; - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/finance/flow/flow.ts b/miniprogram/pages/finance/flow/flow.ts index ee054be..8f031dc 100644 --- a/miniprogram/pages/finance/flow/flow.ts +++ b/miniprogram/pages/finance/flow/flow.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { cloneLite, getAuthInfo, @@ -118,16 +118,7 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/finance/giro/giro.ts b/miniprogram/pages/finance/giro/giro.ts index e442b86..bc173f2 100644 --- a/miniprogram/pages/finance/giro/giro.ts +++ b/miniprogram/pages/finance/giro/giro.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { cloneLite, getAuthInfo, @@ -128,16 +128,7 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/finance/income/income.ts b/miniprogram/pages/finance/income/income.ts index ab6ad99..53fe96d 100644 --- a/miniprogram/pages/finance/income/income.ts +++ b/miniprogram/pages/finance/income/income.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { cloneLite, getAuthInfo, @@ -128,16 +128,7 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/finance/outcome/outcome.ts b/miniprogram/pages/finance/outcome/outcome.ts index 3c52096..1831f12 100644 --- a/miniprogram/pages/finance/outcome/outcome.ts +++ b/miniprogram/pages/finance/outcome/outcome.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { cloneLite, getAuthInfo, @@ -128,16 +128,7 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/index/index.ts b/miniprogram/pages/index/index.ts index c1b8fbc..bedbd86 100644 --- a/miniprogram/pages/index/index.ts +++ b/miniprogram/pages/index/index.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { menuConfig } from '@/utils/menuConfig'; import { getDataSet, toArray, toObject } from '@/utils/util'; @@ -107,16 +107,7 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad() { - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/logs/loginLog/loginLog.ts b/miniprogram/pages/logs/loginLog/loginLog.ts index cbced03..e627fbb 100644 --- a/miniprogram/pages/logs/loginLog/loginLog.ts +++ b/miniprogram/pages/logs/loginLog/loginLog.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { cloneLite, getAuthInfo, @@ -96,16 +96,7 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/logs/operateLog/operateLog.ts b/miniprogram/pages/logs/operateLog/operateLog.ts index b41844a..bf003e3 100644 --- a/miniprogram/pages/logs/operateLog/operateLog.ts +++ b/miniprogram/pages/logs/operateLog/operateLog.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { cloneLite, getAuthInfo, @@ -86,16 +86,7 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/manage/department/department.ts b/miniprogram/pages/manage/department/department.ts index cafa75e..3c987fa 100644 --- a/miniprogram/pages/manage/department/department.ts +++ b/miniprogram/pages/manage/department/department.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { cloneLite, getAuthInfo, @@ -113,16 +113,7 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/manage/group/group.ts b/miniprogram/pages/manage/group/group.ts index 8473143..9d7f587 100644 --- a/miniprogram/pages/manage/group/group.ts +++ b/miniprogram/pages/manage/group/group.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { cloneLite, getAuthInfo, @@ -122,16 +122,7 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/manage/groupDetail/groupDetail.ts b/miniprogram/pages/manage/groupDetail/groupDetail.ts index 220c257..c3859d7 100644 --- a/miniprogram/pages/manage/groupDetail/groupDetail.ts +++ b/miniprogram/pages/manage/groupDetail/groupDetail.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { getAuthInfo, toArray } from '@/utils/util'; Page({ @@ -65,16 +65,7 @@ Page({ this.data.group_id = `${options.group_id}`; wx.setNavigationBarTitle({ title: `${decodeURIComponent(`${options.name}`)} 权限` }); - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/manage/my/my.ts b/miniprogram/pages/manage/my/my.ts index d53c3f6..540a25f 100644 --- a/miniprogram/pages/manage/my/my.ts +++ b/miniprogram/pages/manage/my/my.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { getAuthInfo, toArray } from '@/utils/util'; Page({ @@ -61,16 +61,7 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad(_options) { - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/manage/staff/staff.ts b/miniprogram/pages/manage/staff/staff.ts index 943e52b..1b94d83 100644 --- a/miniprogram/pages/manage/staff/staff.ts +++ b/miniprogram/pages/manage/staff/staff.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { cloneLite, getAuthInfo, @@ -170,16 +170,7 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/my/my.ts b/miniprogram/pages/my/my.ts index bde7fef..84ed9f7 100644 --- a/miniprogram/pages/my/my.ts +++ b/miniprogram/pages/my/my.ts @@ -1,5 +1,5 @@ import { base } from '@/utils/config'; -import { checkSesskey, loginStatus, post } from '@/utils/https'; +import { checkSesskey, loginStatusPage, post } from '@/utils/https'; import { getStorage, toObject } from '@/utils/util'; Page({ @@ -45,17 +45,7 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad() { - this.setData({ loading: true }); - loginStatus() - .then(() => { - console.log('ssss'); - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, loginOut() { wx.showModal({ diff --git a/miniprogram/pages/orders/orderSort/orderSort.ts b/miniprogram/pages/orders/orderSort/orderSort.ts index c7955e0..c268f11 100644 --- a/miniprogram/pages/orders/orderSort/orderSort.ts +++ b/miniprogram/pages/orders/orderSort/orderSort.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { getAuthInfo, getDataSet, showModal, sleep, toArray, toastSuccess } from '@/utils/util'; Page({ @@ -55,16 +55,7 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/orders/ordersList/orderPayment/orderPayment.ts b/miniprogram/pages/orders/ordersList/orderPayment/orderPayment.ts index a7e310e..35dc2e3 100644 --- a/miniprogram/pages/orders/ordersList/orderPayment/orderPayment.ts +++ b/miniprogram/pages/orders/ordersList/orderPayment/orderPayment.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { getAuthInfo, priceRetentionDigits, @@ -100,18 +100,7 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad(_options) { - // console.log(options); - - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/orders/ordersList/ordersList.ts b/miniprogram/pages/orders/ordersList/ordersList.ts index 5ba4227..98cd733 100644 --- a/miniprogram/pages/orders/ordersList/ordersList.ts +++ b/miniprogram/pages/orders/ordersList/ordersList.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { SaleOrderProcessStateOption, PayedStateOption, @@ -184,16 +184,7 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/other/batch/batch.ts b/miniprogram/pages/other/batch/batch.ts index a5a74d2..a2d0c0a 100644 --- a/miniprogram/pages/other/batch/batch.ts +++ b/miniprogram/pages/other/batch/batch.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { cloneLite, getAuthInfo, @@ -124,16 +124,7 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/other/batchDetail/batchDetail.ts b/miniprogram/pages/other/batchDetail/batchDetail.ts index cbd8b1e..026acb6 100644 --- a/miniprogram/pages/other/batchDetail/batchDetail.ts +++ b/miniprogram/pages/other/batchDetail/batchDetail.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { cloneLite, getAuthInfo, @@ -96,16 +96,7 @@ Page({ if (title) { wx.setNavigationBarTitle({ title }); } - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/other/goods/goods.ts b/miniprogram/pages/other/goods/goods.ts index b5c5a73..a287593 100644 --- a/miniprogram/pages/other/goods/goods.ts +++ b/miniprogram/pages/other/goods/goods.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { cloneLite, getAuthInfo, @@ -159,16 +159,7 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad(_options) { - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/other/goodsDetail/goodsDetail.ts b/miniprogram/pages/other/goodsDetail/goodsDetail.ts index 1db70bf..c979e2f 100644 --- a/miniprogram/pages/other/goodsDetail/goodsDetail.ts +++ b/miniprogram/pages/other/goodsDetail/goodsDetail.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { cloneLite, getAuthInfo, @@ -109,16 +109,7 @@ Page({ if (title) { wx.setNavigationBarTitle({ title: decodeURIComponent(title) }); } - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/other/outbound/outbound.ts b/miniprogram/pages/other/outbound/outbound.ts index db88964..dd13757 100644 --- a/miniprogram/pages/other/outbound/outbound.ts +++ b/miniprogram/pages/other/outbound/outbound.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { cloneLite, getAuthInfo, @@ -135,16 +135,7 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/other/transfer/transfer.ts b/miniprogram/pages/other/transfer/transfer.ts index 1ccdb59..152312f 100644 --- a/miniprogram/pages/other/transfer/transfer.ts +++ b/miniprogram/pages/other/transfer/transfer.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { cloneLite, getAuthInfo, @@ -128,16 +128,7 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/processEntry/processEntry.ts b/miniprogram/pages/processEntry/processEntry.ts index 22cc919..edb1450 100644 --- a/miniprogram/pages/processEntry/processEntry.ts +++ b/miniprogram/pages/processEntry/processEntry.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { formatTime, getAuthInfo, getDataSet, isArray, toArray, toObject } from '@/utils/util'; import { voiceRequest } from '@/utils/voiceUtil'; @@ -340,15 +340,7 @@ Page({ loading: true, voice: wx.getStorageSync('processEntryVoice') == 'false' ? false : true, }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/produce/orderTask/orderTask.ts b/miniprogram/pages/produce/orderTask/orderTask.ts index b80b2da..c8df736 100644 --- a/miniprogram/pages/produce/orderTask/orderTask.ts +++ b/miniprogram/pages/produce/orderTask/orderTask.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { SaleOrderProcessStateOption } from '@/utils/config'; import { cloneLite, @@ -111,16 +111,7 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/produce/processManage/processManage.ts b/miniprogram/pages/produce/processManage/processManage.ts index 18d852c..c636de2 100644 --- a/miniprogram/pages/produce/processManage/processManage.ts +++ b/miniprogram/pages/produce/processManage/processManage.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { getAuthInfo, getDataSet, toArray } from '@/utils/util'; Page({ @@ -44,16 +44,7 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad() { - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/produce/processManageDetail/processManageDetail.ts b/miniprogram/pages/produce/processManageDetail/processManageDetail.ts index 133aa12..4b9cff6 100644 --- a/miniprogram/pages/produce/processManageDetail/processManageDetail.ts +++ b/miniprogram/pages/produce/processManageDetail/processManageDetail.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { cloneLite, getAuthInfo, @@ -113,16 +113,7 @@ Page({ title: decodeURIComponent(options.title || ''), }); this.data.params.process_id = `${options.process_id || ''}`; - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/purchase/backOrder/backOrder.ts b/miniprogram/pages/purchase/backOrder/backOrder.ts index af58219..1fd095d 100644 --- a/miniprogram/pages/purchase/backOrder/backOrder.ts +++ b/miniprogram/pages/purchase/backOrder/backOrder.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { cloneLite, getAuthInfo, @@ -123,16 +123,7 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/purchase/buyInOrder/buyInOrder.ts b/miniprogram/pages/purchase/buyInOrder/buyInOrder.ts index 5c98948..3e050b8 100644 --- a/miniprogram/pages/purchase/buyInOrder/buyInOrder.ts +++ b/miniprogram/pages/purchase/buyInOrder/buyInOrder.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { cloneLite, getAuthInfo, @@ -125,16 +125,7 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/purchase/buyOrder/buyOrder.ts b/miniprogram/pages/purchase/buyOrder/buyOrder.ts index 2f33ea4..c1ecc81 100644 --- a/miniprogram/pages/purchase/buyOrder/buyOrder.ts +++ b/miniprogram/pages/purchase/buyOrder/buyOrder.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { cloneLite, getAuthInfo, @@ -128,16 +128,7 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/pages/purchase/requestOrder/requestOrder.ts b/miniprogram/pages/purchase/requestOrder/requestOrder.ts index 208496c..3f452cd 100644 --- a/miniprogram/pages/purchase/requestOrder/requestOrder.ts +++ b/miniprogram/pages/purchase/requestOrder/requestOrder.ts @@ -1,4 +1,4 @@ -import { loginStatus, post } from '@/utils/https'; +import { loginStatusPage, post } from '@/utils/https'; import { cloneLite, getAuthInfo, @@ -128,16 +128,7 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - this.setData({ loading: true }); - loginStatus() - .then(() => { - this.setData({ isLogin: true, loading: false }); - this.init(); - }) - .catch((err) => { - this.setData({ isLogin: false, loading: false }); - console.log('调用登录状态请求失败', err); - }); + loginStatusPage(this); }, /** diff --git a/miniprogram/utils/https.ts b/miniprogram/utils/https.ts index cf06fb9..7f78d61 100644 --- a/miniprogram/utils/https.ts +++ b/miniprogram/utils/https.ts @@ -172,6 +172,23 @@ export const loginStatus = () => { }); }; +export const loginStatusPage = (that: WechatMiniprogram.Page.Instance) => { + that.setData({ loading: true }); + return new Promise((resolve, reject) => { + loginStatus() + .then(() => { + that.setData({ isLogin: true, loading: false }); + that?.init?.(); + resolve(); + }) + .catch((err) => { + that.setData({ isLogin: false, loading: false }); + reject(); + console.log('调用登录状态请求失败', err); + }); + }); +}; + /** * * @param {*} config { showLoading: true, showError: true }