From ec3d9cdd38a8b5cf288c57129c0fe21769f48496 Mon Sep 17 00:00:00 2001
From: ctw <>
Date: Fri, 24 Jan 2025 16:56:51 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=99=E6=94=BF=E9=92=89?=
=?UTF-8?q?=E7=99=BB=E5=BD=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.env | 16 +-
pnpm-lock.yaml | 132 +++++++++++++-
src/pages/refund/apply.vue | 342 +++++++++++++++++++----------------
src/pages/tabbar/home.vue | 134 +++++++-------
src/pages/tabbar/my.vue | 51 ++++--
src/sheep/api/user.ts | 3 +-
src/sheep/hooks/use-token.ts | 83 ++++-----
src/sheep/utils/isDevEnv.ts | 1 +
src/sheep/utils/request.ts | 3 +-
9 files changed, 484 insertions(+), 281 deletions(-)
create mode 100644 src/sheep/utils/isDevEnv.ts
diff --git a/.env b/.env
index 531e670..628f89b 100644
--- a/.env
+++ b/.env
@@ -19,19 +19,25 @@ VITE_OAUTH2_APP_CLIENT='mini:mini'
# 图片访问基础地址
#VITE_IMAGE_BASE_PATH = http://localhost:9999
# VITE_IMAGE_BASE_PATH = http://192.168.101.29:9999 # 邓-本地
+# VITE_IMAGE_BASE_PATH = http://192.168.101.37:9999 # 邓-本地
+VITE_IMAGE_BASE_PATH = http://123.156.230.15:8089/api # 线上
# VITE_IMAGE_BASE_PATH = http://pjcloud.center.takin.cc # 张
-VITE_IMAGE_BASE_PATH = http://59.202.170.152:81/api # 信创线上
+# VITE_IMAGE_BASE_PATH = http://59.202.170.152:81/api # 信创线上
-# ******************** start 开发环境 start ********************
-VITE_APP_DEV_SERVICE = http://59.202.170.152:81/api # 信创线上
+# ******************** start 开发环境 start ****************
+# VITE_APP_DEV_SERVICE = http://59.202.170.152:81/api # 信创线上
# VITE_APP_DEV_SERVICE = https://stgl.pj.gov.cn/app-api
# VITE_APP_DEV_SERVICE = http://192.168.101.29:9999 # 邓-本地
+# VITE_APP_DEV_SERVICE = http://192.168.101.37:9999 # 邓-本地
# VITE_APP_DEV_SERVICE = http://127.0.0.1:9999
-# VITE_APP_DEV_SERVICE = http://123.156.230.15:8089/api
+VITE_APP_DEV_SERVICE = http://123.156.230.15:8089/api/ # 线上
# VITE_APP_DEV_SERVICE = http://localhost:9999
# ******************** end 开发环境 end ********************
-# ******************** start 生产环境 start ********************
+# ******************** start 生产环境 start ****************
#VITE_APP_PROD_SERVICE = http://123.156.228.134:48080/app-api
VITE_APP_PROD_SERVICE = http://59.202.170.152:81/api
# ******************** end 生产环境 end ********************
+
+# VITE_DEV_ENV = dev
+VITE_DEV_ENV = prod
\ No newline at end of file
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b402c8f..e0e56ad 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -68,6 +68,9 @@ dependencies:
pinia:
specifier: ^2.2.6
version: 2.2.6(typescript@4.9.5)(vue@3.5.12)
+ qs:
+ specifier: ^6.13.1
+ version: 6.14.0
radash:
specifier: ^12.1.0
version: 12.1.0
@@ -4248,6 +4251,14 @@ packages:
engines: {node: '>=8'}
dev: true
+ /call-bind-apply-helpers@1.0.1:
+ resolution: {integrity: sha512-BhYE+WDaywFg2TBWYNXAE+8B1ATnThNBqXHP5nQu0jWJdVvY2hvkpyB3qOmtmDePiS5/BDQ8wASEWGMWRG148g==}
+ engines: {node: '>= 0.4'}
+ dependencies:
+ es-errors: 1.3.0
+ function-bind: 1.1.2
+ dev: false
+
/call-bind@1.0.7:
resolution: {integrity: sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==}
engines: {node: '>= 0.4'}
@@ -4259,6 +4270,14 @@ packages:
set-function-length: 1.2.2
dev: true
+ /call-bound@1.0.3:
+ resolution: {integrity: sha512-YTd+6wGlNlPxSuri7Y6X8tY2dmm12UMH66RpKMhiX6rsk5wXXnYgbUcOt8kiS31/AjfoTOvCsE+w8nZQLQnzHA==}
+ engines: {node: '>= 0.4'}
+ dependencies:
+ call-bind-apply-helpers: 1.0.1
+ get-intrinsic: 1.2.7
+ dev: false
+
/callsites@3.1.0:
resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==}
engines: {node: '>=6'}
@@ -4613,6 +4632,15 @@ packages:
webidl-conversions: 5.0.0
dev: true
+ /dunder-proto@1.0.1:
+ resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==}
+ engines: {node: '>= 0.4'}
+ dependencies:
+ call-bind-apply-helpers: 1.0.1
+ es-errors: 1.3.0
+ gopd: 1.2.0
+ dev: false
+
/duplexer@0.1.2:
resolution: {integrity: sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==}
dev: true
@@ -4673,14 +4701,25 @@ packages:
get-intrinsic: 1.2.4
dev: true
+ /es-define-property@1.0.1:
+ resolution: {integrity: sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==}
+ engines: {node: '>= 0.4'}
+ dev: false
+
/es-errors@1.3.0:
resolution: {integrity: sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==}
engines: {node: '>= 0.4'}
- dev: true
/es-module-lexer@1.5.4:
resolution: {integrity: sha512-MVNK56NiMrOwitFB7cqDwq0CQutbw+0BvLshJSse0MUNU+y1FC3bUS/AQg7oUng+/wKrrki7JfmwtVHkVfPLlw==}
+ /es-object-atoms@1.1.1:
+ resolution: {integrity: sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==}
+ engines: {node: '>= 0.4'}
+ dependencies:
+ es-errors: 1.3.0
+ dev: false
+
/esbuild@0.20.2:
resolution: {integrity: sha512-WdOOppmUNU+IbZ0PaDiTst80zjnrOkyJNHoKupIcVyU8Lvla3Ugx94VzkQ32Ijqd7UhHJy75gNWDMUekcrSJ6g==}
engines: {node: '>=12'}
@@ -5009,11 +5048,35 @@ packages:
hasown: 2.0.2
dev: true
+ /get-intrinsic@1.2.7:
+ resolution: {integrity: sha512-VW6Pxhsrk0KAOqs3WEd0klDiF/+V7gQOpAvY1jVU/LHmaD/kQO4523aiJuikX/QAKYiW6x8Jh+RJej1almdtCA==}
+ engines: {node: '>= 0.4'}
+ dependencies:
+ call-bind-apply-helpers: 1.0.1
+ es-define-property: 1.0.1
+ es-errors: 1.3.0
+ es-object-atoms: 1.1.1
+ function-bind: 1.1.2
+ get-proto: 1.0.1
+ gopd: 1.2.0
+ has-symbols: 1.1.0
+ hasown: 2.0.2
+ math-intrinsics: 1.1.0
+ dev: false
+
/get-package-type@0.1.0:
resolution: {integrity: sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==}
engines: {node: '>=8.0.0'}
dev: true
+ /get-proto@1.0.1:
+ resolution: {integrity: sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==}
+ engines: {node: '>= 0.4'}
+ dependencies:
+ dunder-proto: 1.0.1
+ es-object-atoms: 1.1.1
+ dev: false
+
/get-stream@6.0.1:
resolution: {integrity: sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==}
engines: {node: '>=10'}
@@ -5058,6 +5121,11 @@ packages:
get-intrinsic: 1.2.4
dev: true
+ /gopd@1.2.0:
+ resolution: {integrity: sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==}
+ engines: {node: '>= 0.4'}
+ dev: false
+
/graceful-fs@4.2.11:
resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==}
@@ -5089,6 +5157,11 @@ packages:
engines: {node: '>= 0.4'}
dev: true
+ /has-symbols@1.1.0:
+ resolution: {integrity: sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==}
+ engines: {node: '>= 0.4'}
+ dev: false
+
/hash-sum@2.0.0:
resolution: {integrity: sha512-WdZTbAByD+pHfl/g9QSsBIIwy8IT+EsPiKDs0KNX+zSHhdDLFKdZu0BQHljvO+0QI/BasbMSUa8wYNCZTvhslg==}
@@ -6031,6 +6104,11 @@ packages:
tmpl: 1.0.5
dev: true
+ /math-intrinsics@1.1.0:
+ resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==}
+ engines: {node: '>= 0.4'}
+ dev: false
+
/mdn-data@2.0.30:
resolution: {integrity: sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==}
dev: true
@@ -6208,6 +6286,11 @@ packages:
engines: {node: '>= 0.4'}
dev: true
+ /object-inspect@1.13.3:
+ resolution: {integrity: sha512-kDCGIbxkDSXE3euJZZXzc6to7fCrKHNI/hSRQnRuQ+BWjFNzZwiFF8fj/6o2t2G9/jTj8PSIYTfCLelLZEeRpA==}
+ engines: {node: '>= 0.4'}
+ dev: false
+
/ofetch@1.4.1:
resolution: {integrity: sha512-QZj2DfGplQAr2oj9KzceK9Hwz6Whxazmn85yYeVuS3u9XTMOGMRx0kO95MQ+vLsj/S/NwBDMMLU5hpxvI6Tklw==}
dependencies:
@@ -6586,6 +6669,13 @@ packages:
side-channel: 1.0.6
dev: true
+ /qs@6.14.0:
+ resolution: {integrity: sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==}
+ engines: {node: '>=0.6'}
+ dependencies:
+ side-channel: 1.1.0
+ dev: false
+
/querystringify@2.2.0:
resolution: {integrity: sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==}
dev: true
@@ -6905,6 +6995,35 @@ packages:
engines: {node: '>=8'}
dev: true
+ /side-channel-list@1.0.0:
+ resolution: {integrity: sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==}
+ engines: {node: '>= 0.4'}
+ dependencies:
+ es-errors: 1.3.0
+ object-inspect: 1.13.3
+ dev: false
+
+ /side-channel-map@1.0.1:
+ resolution: {integrity: sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==}
+ engines: {node: '>= 0.4'}
+ dependencies:
+ call-bound: 1.0.3
+ es-errors: 1.3.0
+ get-intrinsic: 1.2.7
+ object-inspect: 1.13.3
+ dev: false
+
+ /side-channel-weakmap@1.0.2:
+ resolution: {integrity: sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==}
+ engines: {node: '>= 0.4'}
+ dependencies:
+ call-bound: 1.0.3
+ es-errors: 1.3.0
+ get-intrinsic: 1.2.7
+ object-inspect: 1.13.3
+ side-channel-map: 1.0.1
+ dev: false
+
/side-channel@1.0.6:
resolution: {integrity: sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==}
engines: {node: '>= 0.4'}
@@ -6915,6 +7034,17 @@ packages:
object-inspect: 1.13.2
dev: true
+ /side-channel@1.1.0:
+ resolution: {integrity: sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==}
+ engines: {node: '>= 0.4'}
+ dependencies:
+ es-errors: 1.3.0
+ object-inspect: 1.13.3
+ side-channel-list: 1.0.0
+ side-channel-map: 1.0.1
+ side-channel-weakmap: 1.0.2
+ dev: false
+
/signal-exit@3.0.7:
resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==}
dev: true
diff --git a/src/pages/refund/apply.vue b/src/pages/refund/apply.vue
index 4480179..447339a 100644
--- a/src/pages/refund/apply.vue
+++ b/src/pages/refund/apply.vue
@@ -1,188 +1,226 @@
-
-
-
-
-
-
-
-
-
- {{ v.productName }}
- ¥ {{ hooks.useMoney(v.productPrice) }}
- x {{ v.productCount }}
-
-
-
- ¥ {{ hooks.useMoney(v.totalPrice) }}
-
-
-
-
- 实付款
-
- ¥
- {{ hooks.useMoney(state.detail.payPrice) }}
-
-
-
-
-
- 售后类型
-
-
-
-
-
-
-
- 退款金额
- ¥{{ hooks.useMoney(state.detail.payPrice) }}
-
-
-
-
- 申请原因
-
- {{ applyForm.reasonStr || '请选择申请原因' }}
-
-
-
-
-
-
- 相关描述
-
-
-
-
-
-
-
- 提交申请
-
-
-
+
+
+
+
+
+
+
+
+ {{ v.productName }}
+ ¥ {{ hooks.useMoney(v.productPrice) }}
+ x {{ v.productCount }}
+
+
+
+ ¥ {{ hooks.useMoney(v.totalPrice) }}
+
+
+
+
+ 实付款
+
+ ¥
+ {{ hooks.useMoney(state.detail.payPrice) }}
+
+
+
+
+
+ 售后类型
+
+
+
+
+
+
+
+ 退款金额
+ ¥{{ hooks.useMoney(state.detail.payPrice) }}
+
+
+
+
+ 申请原因
+
+ {{ applyForm.reasonStr || "请选择申请原因" }}
+
+
+
+
+
+
+ 补充凭证图片
+
+
+
+ 注:图片大小不超过5M,最多上传6张
+
+
+ 相关描述
+
+
+
+
+
+
+
+ 提交申请
+
+
+
-
\ No newline at end of file
+
diff --git a/src/pages/tabbar/home.vue b/src/pages/tabbar/home.vue
index ba9dc0d..8ae2ffd 100644
--- a/src/pages/tabbar/home.vue
+++ b/src/pages/tabbar/home.vue
@@ -1,83 +1,83 @@
-
-
-
-
-
-
-
-
- {{ v.name }}
-
-
- {{ v.deptName }}
-
-
-
- 营业时间
-
- {{ v.jobStartTime }}
- ~
- {{ v.jobEndTime }}
-
-
-
- 食堂地址
- {{ v.addressDes }}
-
-
-
-
-
+
+
+
+
+
+
+
+
+ {{ v.name }}
+
+
+ {{ v.deptName }}
+
+
+
+ 营业时间
+
+ {{ v.jobStartTime }}
+ ~
+ {{ v.jobEndTime }}
+
+
+
+ 食堂地址
+ {{ v.addressDes }}
+
+
+
+
+
diff --git a/src/pages/tabbar/my.vue b/src/pages/tabbar/my.vue
index 86c1b1d..4831488 100644
--- a/src/pages/tabbar/my.vue
+++ b/src/pages/tabbar/my.vue
@@ -5,6 +5,7 @@ import { isEmpty } from "radash"
import { hooks, router, constant } from "@@/index"
import { merchantApi, userApi, walletApi } from "@@/api"
+import isDevEnv from "@/sheep/utils/isDevEnv"
const data = {
serviceList: [
@@ -13,7 +14,6 @@ const data = {
{ text: "外来人员就餐", icon: "/static/icon/service_1.png", router: "/pages/apply/foreign-list" },
{ text: "跨单位就餐", icon: "/static/icon/service_1.png", router: "/pages/apply/stride-list" },
{ text: "人脸管理", icon: "/static/icon/service_5.png", router: "/pages/human-face/list" },
- { text: "测试登录", icon: "/static/icon/login.png", router: "/pages/test/login" },
],
}
@@ -22,9 +22,9 @@ const state = reactive({
userInfo: {},
})
-onLoad((options) => {
+// 开发环境可以账号密码登录,生产环境不可
+const checkAppInfo = () => {
;(window as any).CP2.getAppInfo().then((res) => {
- console.log(res)
if (res.code == 1) {
//诗画
console.log("诗画环境")
@@ -34,17 +34,26 @@ onLoad((options) => {
doLogin(1, null, accountId, sessionId)
})
} else {
- //浙政钉或者h5
+ console.log("浙政钉或者h5环境")
const url = window.location.href
const params = new URL(url).searchParams
const token = params.get("uabaseToken") // 获取 uabaseToken 参数值
- console.log("Token:", token)
+ // const token =
+ // "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjJiZGQzODE1LWFlMWYtNDFmZi04MTE2LTU3OWVkMjY3MDI5OCJ9.nuCBrYAkGh5-FG8S_ZTe8mcVVORAuUT7bl0qUIspL9gCNtwtcae2D6DhOO8Q2RtVhuFO5IKtOQ65Xd2Vd7pAUg"
+ console.log("uabaseToken:", token)
if (null != token) {
//浙政钉
doLogin(2, token, null, null)
}
}
})
+}
+
+onLoad((options) => {
+ if (isDevEnv()) {
+ data.serviceList.push({ text: "测试登录", icon: "/static/icon/login.png", router: "/pages/test/login" })
+ }
+ checkAppInfo()
})
onShow(() => {
getUserInfo()
@@ -80,21 +89,29 @@ const doLogin = async (loginType, token, accountId, sessionId) => {
authData = response.data
} else if (loginType == 2) {
//浙政钉
- const response = await userApi.auth(token)
+ const response: any = await userApi.auth(token)
+ if (!response) return
authData = response.data
} else {
//后期手机号+验证码登录
- router.jump("/pages/test/login")
+ if (isDevEnv()) router.jump("/pages/test/login")
uni.hideLoading()
return
}
// const {data: authData} = await userApi.auth(token);
+ console.log("authData", authData)
+
uni.setStorageSync(tokenKey, authData)
- const { data: userData } = await userApi.userInfo()
- uni.setStorageSync(userInfoKey, userData)
- getUserInfo()
- uni.hideLoading()
- uni.showToast({ title: "登录成功", icon: "none" })
+ try {
+ const { data: userData } = await userApi.userInfo()
+ uni.setStorageSync(userInfoKey, userData)
+ getUserInfo()
+ uni.hideLoading()
+ uni.showToast({ title: "登录成功", icon: "none" })
+ } catch (error) {
+ uni.hideLoading()
+ uni.showToast({ title: "登录失败", icon: "none" })
+ }
}
}
@@ -124,6 +141,14 @@ const doLogout = async () => {
uni.hideLoading()
uni.showToast({ title: "退出登录成功", icon: "none" })
}
+
+const onTabLogin = () => {
+ if (isDevEnv()) {
+ router.jump("/pages/test/login")
+ } else {
+ checkAppInfo()
+ }
+}
@@ -143,7 +168,7 @@ const doLogout = async () => {
ID {{ state.userInfo?.sysUser?.userId }}
-
+
请先登录
diff --git a/src/sheep/api/user.ts b/src/sheep/api/user.ts
index 4ee0591..151cffe 100644
--- a/src/sheep/api/user.ts
+++ b/src/sheep/api/user.ts
@@ -16,7 +16,8 @@ export default {
auth: (str: any) =>
request({
- url: `/sys/auth/zzdsso/${str}`,
+ // url: `/sys/auth/zzdsso/${str}`,
+ url: `/thirdparty/thirdPartyOAth2/zzdsso/${str}`,
method: "GET",
custom: {
showLoading: false,
diff --git a/src/sheep/hooks/use-token.ts b/src/sheep/hooks/use-token.ts
index 06a5dff..03afddd 100644
--- a/src/sheep/hooks/use-token.ts
+++ b/src/sheep/hooks/use-token.ts
@@ -1,49 +1,50 @@
-import storageConstant from "../constant/storage-constant";
-import { jump } from "../router/index";
+import storageConstant from "../constant/storage-constant"
+import { jump } from "../router/index"
+import isDevEnv from "../utils/isDevEnv"
export const useToken = () => {
- const tokenKey = storageConstant.TOKEN;
- const tokenStorage = uni.getStorageSync(tokenKey);
- if (!tokenStorage.access_token) return "";
- return `Bearer ${tokenStorage.access_token}`;
-};
+ const tokenKey = storageConstant.TOKEN
+ const tokenStorage = uni.getStorageSync(tokenKey)
+ if (!tokenStorage.access_token) return ""
+ return `Bearer ${tokenStorage.access_token}`
+}
export const useDefaultHeader = () => {
- const token = useToken();
- return {
- "TENANT-ID": "1",
- "CLIENT-TOC": "Y",
- Authorization: token,
- };
-};
+ const token = useToken()
+ return {
+ "TENANT-ID": "1",
+ "CLIENT-TOC": "Y",
+ Authorization: token,
+ }
+}
export const useStaticCheckLogin = () => {
- const tokenKey = storageConstant.TOKEN;
- const tokenStorage = uni.getStorageSync(tokenKey);
- if (tokenStorage) return true;
- return false;
-};
+ const tokenKey = storageConstant.TOKEN
+ const tokenStorage = uni.getStorageSync(tokenKey)
+ if (tokenStorage) return true
+ return false
+}
export const useCheckLogin = async (): Promise => {
- const tokenKey = storageConstant.TOKEN;
- const tokenStorage = uni.getStorageSync(tokenKey);
- if (tokenStorage) return true;
- uni.showModal({
- title: "提示",
- content: "您还未登录,请先登录",
- confirmColor: "#0094ff",
- cancelText: "取消",
- confirmText: "去登录",
- success: async (res) => {
- if (res.confirm) {
- jump("/pages/test/login", {}, 3);
- return;
- }
- if (!res.confirm) {
- return;
- }
- return;
- },
- });
- return false;
-};
+ const tokenKey = storageConstant.TOKEN
+ const tokenStorage = uni.getStorageSync(tokenKey)
+ if (tokenStorage) return true
+ uni.showModal({
+ title: "提示",
+ content: "您还未登录,请先登录",
+ confirmColor: "#0094ff",
+ cancelText: "取消",
+ confirmText: "去登录",
+ success: async (res) => {
+ if (res.confirm) {
+ isDevEnv() ? jump("/pages/test/login", {}, 3) : jump("/pages/tabbar/my", {}, 3)
+ return
+ }
+ if (!res.confirm) {
+ return
+ }
+ return
+ },
+ })
+ return false
+}
diff --git a/src/sheep/utils/isDevEnv.ts b/src/sheep/utils/isDevEnv.ts
new file mode 100644
index 0000000..9e624c5
--- /dev/null
+++ b/src/sheep/utils/isDevEnv.ts
@@ -0,0 +1 @@
+export default () => import.meta.env.VITE_DEV_ENV === "dev"
diff --git a/src/sheep/utils/request.ts b/src/sheep/utils/request.ts
index 6934d68..3dc2c89 100644
--- a/src/sheep/utils/request.ts
+++ b/src/sheep/utils/request.ts
@@ -3,6 +3,7 @@ import { isEmpty } from "radash"
import { userApi } from "@@/api"
import { router, constant } from "@@/index"
+import isDevEnv from "./isDevEnv"
const options = {
// 显示操作成功消息 默认不显示
@@ -149,7 +150,7 @@ http.interceptors.response.use(
const tokenKey = constant.storageConstant.TOKEN
uni.removeStorageSync(tokenKey)
uni.showToast({ title: "登录已过期,请重新登录", icon: "none" })
- router.jump("/pages/test/login")
+ isDevEnv() ? router.jump("/pages/test/login") : undefined
return false
}
let errorMessage = error.data.msg