登录修改

This commit is contained in:
weiwei committed 2025-04-24 14:28:11 +08:00
1 parent 70a9be238f
commit e871efadd9
14 files changed
+452 -586

No files matched your search

+10 -13
View File
@@ -17,17 +17,17 @@ VITE_PWD_ENC_KEY='pigxpigxpigxpigx'
VITE_OAUTH2_APP_CLIENT='mini:mini'
# 图片访问基础地址
VITE_IMAGE_BASE_PATH = http://localhost:9999
VITE_IMAGE_BASE_PATH = http://localhost:9999
# VITE_IMAGE_BASE_PATH = http://192.168.101.64:9999 # 邓-本地
# VITE_IMAGE_BASE_PATH = https://123.156.230.15:8089/api # 线上
# VITE_IMAGE_BASE_PATH = http://220.191.229.171:8090/api # 线上
#VITE_IMAGE_BASE_PATH = https://stgl.pj.gov.cn/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 = https://stgl.pj.gov.cn/api # 线上
# VITE_IMAGE_BASE_PATH = http://pjcloud.center.takin.cc # 张
# VITE_IMAGE_BASE_PATH = 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/api
# VITE_APP_DEV_SERVICE = http://59.202.170.152:81/api # 信创线上
# VITE_APP_DEV_SERVICE = https://stgl.pj.gov.cn/api
# VITE_APP_DEV_SERVICE = http://192.168.101.64:9999 # 邓-本地
# VITE_APP_DEV_SERVICE = http://127.0.0.1:9999
VITE_APP_DEV_SERVICE = http://123.156.230.15:8089/api/ # 访客线上
@@ -35,12 +35,9 @@ VITE_APP_DEV_SERVICE = http://123.156.230.15:8089/api/ # 访客线上
# ******************** end 开发环境 end ********************
# ******************** 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
#VITE_APP_PROD_SERVICE = https://stgl.pj.gov.cn/api
# VITE_APP_PROD_SERVICE = http://123.156.228.134:48080/app-api
# VITE_APP_PROD_SERVICE = http://59.202.170.152:81/api
# VITE_APP_PROD_SERVICE = https://stgl.pj.gov.cn/api
VITE_APP_PROD_SERVICE = http://123.156.230.15:8089/api
#VITE_APP_PROD_SERVICE = http://59.202.170.152:81/api # 信创线上
# VITE_APP_PROD_SERVICE = http://59.202.170.152:81/api # 信创线上
# ******************** end 生产环境 end ********************
#VITE_DEV_ENV = dev
VITE_DEV_ENV = prod
+105
View File
@@ -53,6 +53,9 @@ importers:
'@dcloudio/uni-quickapp-webview':
specifier: 3.0.0-4020920240930001
version: 3.0.0-4020920240930001(postcss@8.5.1)(rollup@4.34.2)(vue@3.5.13(typescript@4.9.5))
'@vant/weapp':
specifier: ^1.11.7
version: 1.11.7
'@vue/compiler-core':
specifier: ^3.5.11
version: 3.5.13
@@ -74,6 +77,9 @@ importers:
pinia:
specifier: ^2.2.6
version: 2.3.1(typescript@4.9.5)(vue@3.5.13(typescript@4.9.5))
qrcode:
specifier: ^1.5.4
version: 1.5.4
qs:
specifier: ^6.13.1
version: 6.14.0
@@ -1565,6 +1571,9 @@ packages:
peerDependencies:
vite: ^2.9.0 || ^3.0.0-0 || ^4.0.0 || ^5.0.0-0
'@vant/weapp@1.11.7':
resolution: {integrity: sha512-Rwn9BBnb4kHSV4XmvBicwtd42J+amEUfnFDcXJsGNPNX4a9c/DoT6YLsm4X1wB2+sQbdiQsbFBLAvGRBxCkD8g==}
'@vitejs/plugin-legacy@5.3.2':
resolution: {integrity: sha512-8moCOrIMaZ/Rjln0Q6GsH6s8fAt1JOI3k8nmfX4tXUxE5KAExVctSyOBk+A25GClsdSWqIk2yaUthH3KJ2X4tg==}
engines: {node: ^18.0.0 || >=20.0.0}
@@ -2001,6 +2010,9 @@ packages:
cjs-module-lexer@1.4.3:
resolution: {integrity: sha512-9z8TZaGM1pfswYeXrUpzPrkx8UnWYdhJclsiYMm6x/w5+nN+8Tf/LnAgfLGQCm59qAOxU8WwHEq2vNwF6i4j+Q==}
cliui@6.0.0:
resolution: {integrity: sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==}
cliui@7.0.4:
resolution: {integrity: sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==}
@@ -2150,6 +2162,10 @@ packages:
supports-color:
optional: true
decamelize@1.2.0:
resolution: {integrity: sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==}
engines: {node: '>=0.10.0'}
decimal.js@10.5.0:
resolution: {integrity: sha512-8vDa8Qxvr/+d94hSh5P3IJwI5t8/c0KsMp+g8bNw9cY2icONa5aPfvKeieW1WlG0WQYwwhJ7mjui2xtiePQSXw==}
@@ -2190,6 +2206,9 @@ packages:
resolution: {integrity: sha512-k1gCAXAsNgLwEL+Y8Wvl+M6oEFj5bgazfZULpS5CneoPPXRaCCW7dm+q21Ky2VEE5X+VeRDBVg1Pcvvsr4TtNQ==}
engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0}
dijkstrajs@1.0.3:
resolution: {integrity: sha512-qiSlmBq9+BCdCA/L46dw8Uy93mloxsPSbwnm5yrKn2vMPiy8KyAskTF6zuV/j5BMsmOGZDPs7KjU+mjb670kfA==}
dom-walk@0.1.2:
resolution: {integrity: sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w==}
@@ -3205,6 +3224,10 @@ packages:
resolution: {integrity: sha512-NCrCHhWmnQklfH4MtJMRjZ2a8c80qXeMlQMv2uVp9ISJMTt562SbGd6n2oq0PaPgKm7Z6pL9E2UlLIhC+SHL3w==}
engines: {node: '>=4.0.0'}
pngjs@5.0.0:
resolution: {integrity: sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==}
engines: {node: '>=10.13.0'}
postcss-import@14.1.0:
resolution: {integrity: sha512-flwI+Vgm4SElObFVPpTIT7SU7R3qk2L7PyduMcokiaVKuWv9d/U+Gm/QAd8NDLuykTWTkcrjOeD2Pp1rMeBTGw==}
engines: {node: '>=10.0.0'}
@@ -3297,6 +3320,11 @@ packages:
resolution: {integrity: sha512-EXtzRZmC+YGmGlDFbXKxQiMZNwCLEO6BANKXG4iCtSIM0yqc/pappSx3RIKr4r0uh5JsBckOXeKrB3Iz7mdQpQ==}
hasBin: true
qrcode@1.5.4:
resolution: {integrity: sha512-1ca71Zgiu6ORjHqFBDpnSMTR2ReToX4l1Au1VFLyVeBTFavzQnv5JxMFr3ukHVKpSrSA2MCk0lNJSykjUfz7Zg==}
engines: {node: '>=10.13.0'}
hasBin: true
qs@6.13.0:
resolution: {integrity: sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==}
engines: {node: '>=0.6'}
@@ -3371,6 +3399,9 @@ packages:
resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==}
engines: {node: '>=0.10.0'}
require-main-filename@2.0.0:
resolution: {integrity: sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==}
requires-port@1.0.0:
resolution: {integrity: sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==}
@@ -3476,6 +3507,9 @@ packages:
resolution: {integrity: sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==}
engines: {node: '>= 0.8.0'}
set-blocking@2.0.0:
resolution: {integrity: sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==}
setprototypeof@1.2.0:
resolution: {integrity: sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==}
@@ -3919,11 +3953,18 @@ packages:
resolution: {integrity: sha512-gAojqb/m9Q8a5IV96E3fHJM70AzCkgt4uXYX2O7EmuyOnLrViCQlsEBmF9UQIu3/aeAIp2U17rtbpZWNntQqdg==}
engines: {node: '>=10'}
which-module@2.0.1:
resolution: {integrity: sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==}
which@2.0.2:
resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==}
engines: {node: '>= 8'}
hasBin: true
wrap-ansi@6.2.0:
resolution: {integrity: sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==}
engines: {node: '>=8'}
wrap-ansi@7.0.0:
resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==}
engines: {node: '>=10'}
@@ -3989,6 +4030,9 @@ packages:
resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==}
engines: {node: '>=0.4'}
y18n@4.0.3:
resolution: {integrity: sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==}
y18n@5.0.8:
resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==}
engines: {node: '>=10'}
@@ -4000,10 +4044,18 @@ packages:
resolution: {integrity: sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==}
engines: {node: '>= 6'}
yargs-parser@18.1.3:
resolution: {integrity: sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==}
engines: {node: '>=6'}
yargs-parser@20.2.9:
resolution: {integrity: sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==}
engines: {node: '>=10'}
yargs@15.4.1:
resolution: {integrity: sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==}
engines: {node: '>=8'}
yargs@16.2.0:
resolution: {integrity: sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==}
engines: {node: '>=10'}
@@ -6268,6 +6320,8 @@ snapshots:
transitivePeerDependencies:
- rollup
'@vant/weapp@1.11.7': {}
'@vitejs/plugin-legacy@5.3.2(terser@5.37.0)(vite@5.2.8(@types/node@18.19.75)(sass@1.71.1)(terser@5.37.0))':
dependencies:
'@babel/core': 7.26.7
@@ -6833,6 +6887,12 @@ snapshots:
cjs-module-lexer@1.4.3: {}
cliui@6.0.0:
dependencies:
string-width: 4.2.3
strip-ansi: 6.0.1
wrap-ansi: 6.2.0
cliui@7.0.4:
dependencies:
string-width: 4.2.3
@@ -6946,6 +7006,8 @@ snapshots:
dependencies:
ms: 2.1.3
decamelize@1.2.0: {}
decimal.js@10.5.0: {}
dedent@0.7.0: {}
@@ -6970,6 +7032,8 @@ snapshots:
diff-sequences@27.5.1: {}
dijkstrajs@1.0.3: {}
dom-walk@0.1.2: {}
domexception@2.0.1:
@@ -8176,6 +8240,8 @@ snapshots:
pngjs@3.4.0: {}
pngjs@5.0.0: {}
postcss-import@14.1.0(postcss@8.5.1):
dependencies:
postcss: 8.5.1
@@ -8269,6 +8335,12 @@ snapshots:
qrcode-terminal@0.12.0: {}
qrcode@1.5.4:
dependencies:
dijkstrajs: 1.0.3
pngjs: 5.0.0
yargs: 15.4.1
qs@6.13.0:
dependencies:
side-channel: 1.1.0
@@ -8339,6 +8411,8 @@ snapshots:
require-from-string@2.0.2: {}
require-main-filename@2.0.0: {}
requires-port@1.0.0: {}
resolve-cwd@3.0.0:
@@ -8469,6 +8543,8 @@ snapshots:
transitivePeerDependencies:
- supports-color
set-blocking@2.0.0: {}
setprototypeof@1.2.0: {}
shebang-command@2.0.0:
@@ -8935,10 +9011,18 @@ snapshots:
tr46: 2.1.0
webidl-conversions: 6.1.0
which-module@2.0.1: {}
which@2.0.2:
dependencies:
isexe: 2.0.0
wrap-ansi@6.2.0:
dependencies:
ansi-styles: 4.3.0
string-width: 4.2.3
strip-ansi: 6.0.1
wrap-ansi@7.0.0:
dependencies:
ansi-styles: 4.3.0
@@ -8984,14 +9068,35 @@ snapshots:
xtend@4.0.2: {}
y18n@4.0.3: {}
y18n@5.0.8: {}
yallist@3.1.1: {}
yaml@1.10.2: {}
yargs-parser@18.1.3:
dependencies:
camelcase: 5.3.1
decamelize: 1.2.0
yargs-parser@20.2.9: {}
yargs@15.4.1:
dependencies:
cliui: 6.0.0
decamelize: 1.2.0
find-up: 4.1.0
get-caller-file: 2.0.5
require-directory: 2.1.1
require-main-filename: 2.0.0
set-blocking: 2.0.0
string-width: 4.2.3
which-module: 2.0.1
y18n: 4.0.3
yargs-parser: 18.1.3
yargs@16.2.0:
dependencies:
cliui: 7.0.4
+14 -14
View File
@@ -164,14 +164,14 @@
"disableScroll": true
}
},
{
"path": "food",
"style": {
"navigationBarTitleText": "菜谱",
"navigationBarBackgroundColor": "#1777FF",
"disableScroll": true
}
},
// {
// "path": "food",
// "style": {
// "navigationBarTitleText": "菜谱",
// "navigationBarBackgroundColor": "#1777FF",
// "disableScroll": true
// }
// },
{
"path": "product-detail",
"style": {
@@ -260,12 +260,12 @@
"iconPath": "/static/tabbar/my.png",
"selectedIconPath": "/static/tabbar/my-select.png"
},
{
"pagePath": "pages/integrated/visitor/verify",
"text": "访客核销",
"iconPath": "/static/tabbar/my.png",
"selectedIconPath": "/static/tabbar/my-select.png"
},
// {
// "pagePath": "pages/integrated/visitor/verify",
// "text": "访客核销",
// "iconPath": "/static/tabbar/my.png",
// "selectedIconPath": "/static/tabbar/my-select.png"
// },
{
"pagePath": "pages/tabbar/my",
"text": "我的",
+115 -106
View File
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { ref, reactive } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { ref, reactive } from "vue"
import { onLoad, onShow } from "@dcloudio/uni-app"
import { isEmpty } from "radash"
import dayjs from "dayjs"
@@ -8,129 +8,138 @@ import { hooks, router } from "@@/index"
import { applyApi } from "@@/api"
const state = reactive<any>({
detailType: "add",
detailId: null,
detail: null,
detailType: "add",
detailId: null,
detail: null,
})
const applyForm = reactive<any>({
displayTimeRange: "",
displayTimeRangeStr: "",
count: 1,
remark: "",
let applyForm = reactive<any>({
displayTimeRange: "",
displayTimeRangeStr: "",
count: 1,
remark: "",
})
const applyFormRules = reactive<any>({
displayTimeRangeStr: [
{ required: true, message: '请选择使用时间' }
],
count: [
{ required: true, message: '请输入申请数量' },
{ required: true, min: 1, message: '最少申请1张' },
{ required: true, max: 20, message: '最多申请20张' },
]
displayTimeRangeStr: [{ required: true, message: "请选择使用时间" }],
count: [
{ required: true, message: "请输入申请数量" },
{ required: true, min: 1, message: "最少申请1张" },
{ required: true, max: 20, message: "最多申请20张" },
],
})
onLoad((options: any) => {
const { type, id } = options
if (!isEmpty(type)) state.detailType = type
if (!isEmpty(id)) state.detailId = id
if (type === 'view') {
getDetail()
}
});
onShow(() => {
const { type, id } = options
if (!isEmpty(type)) state.detailType = type
if (!isEmpty(id)) state.detailId = id
if (type === "view") {
getDetail()
}
})
onShow(() => {})
const getDetail = async () => {
if (isEmpty(state.detailId)) return
const _pa = { id: state.detailId }
const { data } = await applyApi.foreignDetail(_pa)
if (!isEmpty(data)) {
state.detail = data
const startTime = hooks.useTime(data.applyStartTime, "{y}-{m}-{d}")
const endTime = hooks.useTime(data.applyEndTime, "{y}-{m}-{d}")
applyForm.displayTimeRangeStr = startTime + "~" + endTime
applyForm.count = data.count
if (isEmpty(data.remark)) {
applyForm.remark = "无"
} else {
applyForm.remark = data.remark
}
}
if (isEmpty(state.detailId)) return
const _pa = { id: state.detailId }
const { data } = await applyApi.foreignDetail(_pa)
if (!isEmpty(data)) {
state.detail = data
const startTime = hooks.useTime(data.applyStartTime, "{y}-{m}-{d}")
const endTime = hooks.useTime(data.applyEndTime, "{y}-{m}-{d}")
applyForm.displayTimeRangeStr = startTime + "~" + endTime
applyForm.count = data.count
if (isEmpty(data.remark)) {
applyForm.remark = "无"
} else {
applyForm.remark = data.remark
}
}
}
const applyFormRef = ref<any>(null)
const doSubmit = async () => {
applyFormRef.value.submit()
const { isPass } = applyFormRef.value.validate()
if (!isPass) return
const range = applyForm.displayTimeRange
console.log(range);
try {
uni.showLoading({ title: '申请中...', mask: false });
const _pa = {
applyStartTime: hooks.useTime(range[0], "{y}-{m}-{d}"),
applyEndTime: hooks.useTime(range[1], "{y}-{m}-{d}"),
count: applyForm.count,
remark: applyForm.remark,
}
const { data, code }: any = await applyApi.foreignApply(_pa)
if (code != 0) throw new Error()
uni.hideLoading()
uni.showToast({ title: '申请成功', icon: "none" });
router.back()
} catch (error) {
console.error(error);
uni.hideLoading()
}
applyFormRef.value.submit()
const { isPass } = applyFormRef.value.validate()
if (!isPass) return
const range = applyForm.displayTimeRange
console.log(range)
try {
uni.showLoading({ title: "申请中...", mask: false })
const _pa = {
applyStartTime: hooks.useTime(range[0], "{y}-{m}-{d}"),
applyEndTime: hooks.useTime(range[1], "{y}-{m}-{d}"),
count: applyForm.count,
remark: applyForm.remark,
}
const { data, code }: any = await applyApi.foreignApply(_pa)
if (code != 0) throw new Error()
uni.hideLoading()
uni.showToast({ title: "申请成功", icon: "none" })
router.back()
} catch (error) {
console.error(error)
uni.hideLoading()
}
}
</script>
<template>
<crud-layout title="外来人员就餐" bg="/static/page/blue-bg.png">
<view class="h-30rpx" />
<view class="card p-x-30rpx p-y-40rpx">
<tm-form ref="applyFormRef" v-model="applyForm" :rules="applyFormRules" direction="vertical">
<tm-form-item name="displayTimeRangeStr" label="使用时间" :showBottom="false">
<tm-between-time start="2020-1-1" end="2030-1-1" v-model="applyForm.displayTimeRange"
v-model:model-str="applyForm.displayTimeRangeStr" format="YYYY-MM-DD">
<view :style="{ pointerEvents: state.detailType == 'view' ? 'auto' : 'none' }">
<tm-input v-model="applyForm.displayTimeRangeStr" disabled placeholder="请选择使用时间..">
<template v-slot:rightIcon>
<text v-if="state.detailType != 'view'"
class="p-0.5rem color-#b1b1b1 iconfont icon-xiangxiajiantouxiao"></text>
</template>
</tm-input>
</view>
</tm-between-time>
</tm-form-item>
<view class="h-30rpx" />
<tm-form-item name="count" label="申请数量" :showBottom="false">
<tm-input v-model="applyForm.count" type="number" :disabled="state.detailType == 'view'"
:showClear="state.detailType != 'view'" placeholder="请输入申请数量.." />
</tm-form-item>
<view class="h-30rpx" />
<tm-form-item name="remark" label="备注" :required="false" :showBottom="false">
<tm-input v-model="applyForm.remark" type="textarea" :disabled="state.detailType == 'view'"
:showClear="state.detailType != 'view'"
:placeholder="state.detailType == 'view' ? '' : '请输入备注..'"></tm-input>
</tm-form-item>
</tm-form>
</view>
<view v-if="state.detailType != 'view'"
class="bg-#0094ff p-y-20rpx text-center rounded-40rpx m-x-30rpx m-t-60rpx sub-text-30 color-white!"
@tap="doSubmit">
提交
</view>
</crud-layout>
<crud-layout title="外来人员就餐" bg="/static/page/blue-bg.png">
<view class="h-30rpx" />
<view class="card p-x-30rpx p-y-40rpx">
<tm-form ref="applyFormRef" v-model="applyForm" :rules="applyFormRules" direction="vertical">
<tm-form-item name="displayTimeRangeStr" label="使用时间" :showBottom="false">
<tm-between-time
start="2020-1-1"
end="2030-1-1"
v-model="applyForm.displayTimeRange"
v-model:model-str="applyForm.displayTimeRangeStr"
format="YYYY-MM-DD"
>
<view :style="{ pointerEvents: state.detailType == 'view' ? 'auto' : 'none' }">
<tm-input v-model="applyForm.displayTimeRangeStr" disabled placeholder="请选择使用时间..">
<template v-slot:rightIcon>
<text v-if="state.detailType != 'view'" class="p-0.5rem color-#b1b1b1 iconfont icon-xiangxiajiantouxiao"></text>
</template>
</tm-input>
</view>
</tm-between-time>
</tm-form-item>
<view class="h-30rpx" />
<tm-form-item name="count" label="申请数量" :showBottom="false">
<tm-input
v-model="applyForm.count"
type="number"
:disabled="state.detailType == 'view'"
:showClear="state.detailType != 'view'"
placeholder="请输入申请数量.."
/>
</tm-form-item>
<view class="h-30rpx" />
<tm-form-item name="remark" label="备注" :required="false" :showBottom="false">
<tm-input
v-model="applyForm.remark"
type="textarea"
:disabled="state.detailType == 'view'"
:showClear="state.detailType != 'view'"
:placeholder="state.detailType == 'view' ? '' : '请输入备注..'"
></tm-input>
</tm-form-item>
</tm-form>
</view>
<view
v-if="state.detailType != 'view'"
class="bg-#0094ff p-y-20rpx text-center rounded-40rpx m-x-30rpx m-t-60rpx sub-text-30 color-white!"
@tap="doSubmit"
>
提交
</view>
</crud-layout>
</template>
<style lang="scss" scoped>
:deep() {
.tmFormItemLabel {
padding-bottom: 10rpx !important;
}
.tmFormItemLabel {
padding-bottom: 10rpx !important;
}
}
</style>
</style>
+89 -83
View File
@@ -1,111 +1,117 @@
<script setup lang="ts">
import { ref, reactive } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { ref, reactive } from "vue"
import { onLoad, onShow } from "@dcloudio/uni-app"
import { isEmpty } from "radash"
import { hooks, router } from "@@/index"
import { router } from "@@/index"
import { applyApi } from "@@/api"
const state = reactive<any>({
detailType: "add",
detailId: null,
detail: null,
detailType: "add",
detailId: null,
detail: null,
})
const applyForm = reactive<any>({
count: 1,
remark: "",
let applyForm = reactive<any>({
count: 1,
remark: "",
})
const applyFormRules = reactive<any>({
count: [
{ required: true, message: '请输入申请数量' },
{ required: true, min: 1, message: '最少申请1张' },
{ required: true, max: 20, message: '最多申请20张' },
]
count: [
{ required: true, message: "请输入申请数量" },
{ required: true, min: 1, message: "最少申请1张" },
{ required: true, max: 20, message: "最多申请20张" },
],
})
onLoad((options: any) => {
const { type, id } = options
if (!isEmpty(type)) state.detailType = type
if (!isEmpty(id)) state.detailId = id
if (type === 'view') {
getDetail()
}
});
onShow(() => {
const { type, id } = options
if (!isEmpty(type)) state.detailType = type
if (!isEmpty(id)) state.detailId = id
if (type === "view") {
getDetail()
}
})
onShow(() => {})
const getDetail = async () => {
if (isEmpty(state.detailId)) return
const _pa = { id: state.detailId }
const { data } = await applyApi.strideDetail(_pa)
if (!isEmpty(data)) {
state.detail = data
if (isEmpty(state.detailId)) return
const _pa = { id: state.detailId }
const { data } = await applyApi.strideDetail(_pa)
if (!isEmpty(data)) {
state.detail = data
applyForm.count = data.count
if (isEmpty(data.remark)) {
applyForm.remark = "无"
} else {
applyForm.remark = data.remark
}
}
applyForm.count = data.count
if (isEmpty(data.remark)) {
applyForm.remark = "无"
} else {
applyForm.remark = data.remark
}
}
}
const applyFormRef = ref<any>(null)
const doSubmit = async () => {
applyFormRef.value.submit()
const { isPass } = applyFormRef.value.validate()
if (!isPass) return
const range = applyForm.displayTimeRange
try {
uni.showLoading({ title: '申请中...', mask: false });
const _pa = {
count: applyForm.count,
remark: applyForm.remark,
}
const { data, code }: any = await applyApi.strideApply(_pa)
if (code != 0) throw new Error()
uni.hideLoading()
uni.showToast({ title: '申请成功', icon: "none" });
router.back()
} catch (error) {
console.error(error);
uni.hideLoading()
}
applyFormRef.value.submit()
const { isPass } = applyFormRef.value.validate()
if (!isPass) return
const range = applyForm.displayTimeRange
try {
uni.showLoading({ title: "申请中...", mask: false })
const _pa = {
count: applyForm.count,
remark: applyForm.remark,
}
const { data, code }: any = await applyApi.strideApply(_pa)
if (code != 0) throw new Error()
uni.hideLoading()
uni.showToast({ title: "申请成功", icon: "none" })
router.back()
} catch (error) {
console.error(error)
uni.hideLoading()
}
}
</script>
<template>
<crud-layout title="外来人员就餐" bg="/static/page/blue-bg.png">
<view class="h-30rpx" />
<view class="card p-x-30rpx p-y-40rpx">
<tm-form ref="applyFormRef" v-model="applyForm" :rules="applyFormRules" direction="vertical">
<tm-form-item name="count" label="申请数量" :showBottom="false">
<tm-input v-model="applyForm.count" type="number" :disabled="state.detailType == 'view'"
:showClear="state.detailType != 'view'" placeholder="请输入申请数量.." />
</tm-form-item>
<view class="h-30rpx" />
<tm-form-item name="remark" label="备注" :required="false" :showBottom="false">
<tm-input v-model="applyForm.remark" type="textarea" :disabled="state.detailType == 'view'"
:showClear="state.detailType != 'view'"
:placeholder="state.detailType == 'view' ? '' : '请输入备注..'"></tm-input>
</tm-form-item>
</tm-form>
</view>
<view v-if="state.detailType != 'view'"
class="bg-#0094ff p-y-20rpx text-center rounded-40rpx m-x-30rpx m-t-60rpx sub-text-30 color-white!"
@tap="doSubmit">
提交
</view>
</crud-layout>
<crud-layout title="外来人员就餐" bg="/static/page/blue-bg.png">
<view class="h-30rpx" />
<view class="card p-x-30rpx p-y-40rpx">
<tm-form ref="applyFormRef" v-model="applyForm" :rules="applyFormRules" direction="vertical">
<tm-form-item name="count" label="申请数量" :showBottom="false">
<tm-input
v-model="applyForm.count"
type="number"
:disabled="state.detailType == 'view'"
:showClear="state.detailType != 'view'"
placeholder="请输入申请数量.."
/>
</tm-form-item>
<view class="h-30rpx" />
<tm-form-item name="remark" label="备注" :required="false" :showBottom="false">
<tm-input
v-model="applyForm.remark"
type="textarea"
:disabled="state.detailType == 'view'"
:showClear="state.detailType != 'view'"
:placeholder="state.detailType == 'view' ? '' : '请输入备注..'"
></tm-input>
</tm-form-item>
</tm-form>
</view>
<view
v-if="state.detailType != 'view'"
class="bg-#0094ff p-y-20rpx text-center rounded-40rpx m-x-30rpx m-t-60rpx sub-text-30 color-white!"
@tap="doSubmit"
>
提交
</view>
</crud-layout>
</template>
<style lang="scss" scoped>
:deep() {
.tmFormItemLabel {
padding-bottom: 10rpx !important;
}
.tmFormItemLabel {
padding-bottom: 10rpx !important;
}
}
</style>
</style>
+1 -1
View File
@@ -19,7 +19,7 @@ const state = reactive<any>({
end: "",
},
})
const applyForm = reactive<any>({
let applyForm = reactive<any>({
displayTimeRange: "",
displayTimeRangeStr: "",
bxDate: null,
-201
View File
@@ -1,201 +0,0 @@
<script setup lang="ts">
import { ref, reactive, computed } from "vue"
import { onLoad, onShow } from "@dcloudio/uni-app"
import { isEmpty } from "radash"
import dayjs from "dayjs"
import { hooks, router } from "@@/index"
import { foodApi } from "@@/api"
import zTabs from "@@/components/other/z-tabs/z-tabs.vue"
import { LazyImg, Waterfall } from "vue-waterfall-plugin-next"
import "vue-waterfall-plugin-next/dist/style.css"
// import CustomWaterfallsFlow from "@@/components/other/custom-waterfalls-flow/custom-waterfalls-flow.vue"
import { filePath } from "@@/utils/file"
const menus = {
tabs: [
// { id: null, name: "全部", disabled: false },
{ id: 1, name: "早餐", disabled: false },
{ id: 2, name: "午餐", disabled: false },
{ id: 3, name: "晚餐", disabled: false },
],
weekDays: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],
}
const state = reactive<any>({
dateList: [],
currentDateIndex: 0,
pa: {
merchantId: null,
startTime: null,
hourType: menus.tabs[0].id,
},
})
onLoad((options: any) => {
initDate()
if (!isEmpty(options.merchantId)) {
state.pa.merchantId = options.merchantId
}
})
onShow(() => {
if (pageRef.value && pageRef.value.reload) {
pageRef.value.reload(false)
}
})
const pageRef = ref<any>(null)
const pageHook = hooks.usePage(pageRef, foodApi.page, null, "data.records")
const query = (page: number, pagesize: number) => {
pageHook.startPage(page, pagesize, false, state.pa)
}
// 重新设置图片路径
const foodList = computed(() => {
return pageHook.list.map((item: any) => {
return { ...item, picUrl: filePath(item.picUrl) }
})
})
const initDate = () => {
const list: any = []
const now = new Date()
for (let i = 0; i < 10; i++) {
const date = dayjs(now).add(i, "d")
const weekDayStr = date.isSame(now, "day") ? "今天" : menus.weekDays[date.day()]
list.push({
weekDayStr,
date: date.toDate(),
dayTime: date.format("MM-DD"),
dateTime: date.format("YYYY-MM-DD"),
})
}
state.dateList = list
state.pa.startTime = state.dateList[0].dateTime
pageRef.value?.reload(false)
}
const doDateItem = (v: any, i: any) => {
state.currentDateIndex = i
state.pa.startTime = state.dateList[i].dateTime
pageHook.list = []
pageRef.value.reload(true)
}
const doTab = (e: any) => {
const target = menus.tabs[e]
state.pa.hourType = target.id
pageHook.list = []
pageRef.value.reload(true)
}
const doProduct = (v: any) => {
// router.jump("/pages/merchant/product-detail", { spuId: v.spuId })
}
</script>
<template>
<crud-layout title="每日菜谱" navBgColor="#1777FF" navBgTitleColor="white" bg="/static/page/blue-bg.png">
<z-paging
ref="pageRef"
height="100%"
:fixed="false"
v-model="pageHook.list"
:default-page-size="8"
safe-area-inset-bottom
:loading-more-enabled="true"
:show-scrollbar="false"
@query="query"
:auto-clean-list-when-reload="false"
:auto-scroll-to-top-when-reload="false"
@scroll="pageHook.scroll"
>
<template #top>
<view class="bg-#1777FF p-15rpx">
<scroll-view scroll-x class="whitespace-nowrap">
<view class="flex-row items-center space-x-15rpx">
<view
:class="{ active_date: state.currentDateIndex == i }"
class="flex-col-center flex-shrink-0 size-95rpx color-white rounded-8rpx font-size-24rpx font-700"
v-for="(v, i) in state.dateList"
:key="i"
@tap="doDateItem(v, i)"
>
<view>{{ v.dayTime }}</view>
<view>{{ v.weekDayStr }}</view>
</view>
</view>
</scroll-view>
</view>
<view class="bg-white rounded-16rpx px-20rpx m-x-10rpx m-t-15rpx">
<z-tabs :list="menus.tabs" @change="doTab" />
</view>
</template>
<view class="h-20rpx" />
<view class="m-x-20rpx">
<Waterfall
v-if="foodList.length"
:list="foodList"
:gutter="10"
:breakpoints="{
1800: { rowPerView: 4 },
1400: { rowPerView: 3 },
975: { rowPerView: 2 },
}"
:hasAroundGutter="false"
backgroundColor="#ffffff00"
:crossOrigin="false"
:animationDuration="100"
>
<template #default="{ item, url, index }">
<div class="card">
<LazyImg class="rounded-2" :url="item.picUrl" />
<view class="p-x-15rpx p-y-25rpx flex items-center justify-between">
<view class="sub-text-28 show-line">{{ item.name }}</view>
<!-- <view class="m-t-10rpx flex-row items-center"> -->
<view class="second-text-32 color-#f63a36!"> ¥{{ hooks.useMoney(item.price) }} </view>
<!-- <view class="m-l-20rpx mt-1 second-text-24 line-through">¥{{ hooks.useMoney(item.marketPrice) }}</view> -->
<!-- </view> -->
<!-- <view class="flex-col items-start"> -->
<!-- <view class="second-text-24">{{ hooks.useFormatNum("库存", "", item.stock) }}</view> -->
<!-- <view class="w-1px h-20rpx m-x-5rpx bg-#999" /> -->
<!-- <view class="second-text-24">{{ hooks.useFormatNum("销量", "", item.salesCount) }}</view> -->
<!-- </view> -->
</view>
</div>
</template>
</Waterfall>
<!-- <custom-waterfalls-flow v-model="foodList" imageKey="picUrl" :columnSpace="1" @wapperClick="doProduct" @imageClick="doProduct">
<template v-slot:default="v">
<view class="p-x-15rpx p-y-25rpx">
<view class="sub-text-28 show-line">{{ v.name }}</view>
<view class="m-t-10rpx flex-row items-center">
<view class="second-text-32 color-#f63a36!"> ¥{{ hooks.useMoney(v.price) }} </view>
<view class="m-l-20rpx second-text-24 line-through"> ¥{{ hooks.useMoney(v.marketPrice) }} </view>
</view>
<view class="flex-row items-center MT 10rpx">
<view class="second-text-24">{{ hooks.useFormatNum("库存", "", v.stock) }}</view>
<view class="w-1px h-20rpx m-x-5rpx bg-#999" />
<view class="second-text-24">{{ hooks.useFormatNum("销量", "", v.salesCount) }}</view>
</view>
</view>
</template>
</custom-waterfalls-flow> -->
</view>
</z-paging>
</crud-layout>
</template>
<style lang="scss" scoped>
:deep() {
.layout_main > scroll-view {
padding: 0 !important;
}
}
.active_date {
background-color: white;
color: #1679ff !important;
}
</style>
+80 -18
View File
@@ -11,9 +11,13 @@
</tm-form-item>
</tm-form>
</view>
<tm-button class="my-3" block @tap="doSubmit">登录</tm-button>
<tm-button block @tap="doSubmit">登录</tm-button>
<button style="background-color: #0779fd; border-radius: 20rpx; color: white; font-size: 32rpx" @click="getUserInfo">
<button
style="background-color: #0779fd; border-radius: 20rpx; color: white; font-size: 32rpx; margin: 10rpx 0"
open-type="getUserInfo"
@click="getUserInfo"
>
微信登录测试
</button>
</crud-layout>
@@ -23,8 +27,9 @@
import { ref, reactive } from "vue"
import { constant, router } from "@@/index"
import { userApi } from "@@/api"
import request from "@/sheep/utils/request"
const applyForm = reactive<any>({
let applyForm = reactive<any>({
username: "",
password: "",
})
@@ -64,15 +69,15 @@ const doSubmit = async () => {
// import { useUserStore } from "@/store/user.js"
// 使用store仓库
// const userStore = useUserStore()
// 获取用户信息的方法
// 获取用户信息
const getUserInfo = () => {
uni.getUserInfo({
success: (res) => {
// 存储用户信息
// console.log(res.userInfo);
// userStore.updateUserInfo(res.userInfo)
console.log(res)
getToken(res)
login()
},
fail: (res) => {
return uni.showToast({ title: "API调用失败", icon: "error" })
@@ -81,27 +86,84 @@ const getUserInfo = () => {
}
// 请求获取token
const getToken = async (info: any) => {
const login = async () => {
const result = await uni.login().catch((error) => error)
// 判断是否调用失败
if (result.errMsg === "login:ok") {
const params = {
mobile: "MINI@" + result.code,
code: result.code,
}
const res: any = await userApi.login(params)
if (res == 0) {
// const token = "Bearer 123456789"
// 更新获取的token
// userStore.updateToken(token)
router.back()
return uni.showToast({ title: "登录成功", icon: "none" })
} else {
return uni.showToast({ title: "获取token失败,登录失败", icon: "error" })
}
console.log("result.code", result.code) // 0e3XvSll2ptntf4bg3ol2BdVFH1XvSlM
console.log("params", params)
const res: any = await request({
url: "/auth/oauth2/token?grant_type=mobile",
method: "post",
data: params,
header: {
Authorization: "Basic bWluaTptaW5p",
"Content-Type": "application/x-www-form-urlencoded",
},
})
console.log("xx", res)
// if (res == 0) {
// // const token = "Bearer 123456789"
// // 更新获取的token
// // userStore.updateToken(token)
// router.back()
// return uni.showToast({ title: "登录成功", icon: "none" })
// } else {
// return uni.showToast({ title: "获取token失败,登录失败", icon: "error" })
// }
} else {
uni.showToast({ title: "获取登录code失败", icon: "error" })
}
}
// 绑定
const bind = async (mobile?: string, code?: string) => {
// 1. 使用验证码登录获取token
const params = {
mobile: "SMS@" + "17319791971",
code: "0e3XvSll2ptntf4bg3ol2BdVFH1XvSlM",
grant_type: "mobile",
}
const res = await request({
url: "/auth/oauth2/token",
method: "post",
data: params,
header: {
Authorization: "Basic bWluaTptaW5p",
"Content-Type": "application/x-www-form-urlencoded",
},
})
console.log(res)
const token = res.data.access_token
// 2. 获取新的小程序code并完成绑定
// uni.login({
// success(loginRes) {
// wx.request({
// url: "${BASE_URL}/admin/social/bind?state=MINI&code=" + loginRes.code,
// method: "post",
// header: {
// Authorization: "Bearer " + token,
// },
// success() {
// wx.showToast({
// title: "绑定成功",
// success() {
// wx.navigateBack()
// },
// })
// },
// })
// },
// })
}
</script>
+9 -7
View File
@@ -2,16 +2,18 @@ import request from "@/sheep/utils/request"
import { encryption } from "@/sheep/utils/encryption"
// 将 Basic Auth 字符串提取为常量
const BASIC_AUTH = "Basic " + window.btoa(import.meta.env.VITE_OAUTH2_APP_CLIENT)
// const BASIC_AUTH = "Basic " + window.btoa(import.meta.env.VITE_OAUTH2_APP_CLIENT)
const BASIC_AUTH = "Basic " + import.meta.env.VITE_OAUTH2_APP_CLIENT
// 定义接口类型
interface LoginParams {
username: string
password: string
randomStr: string
code: string
grant_type: string
scope: string
username?: string
password?: string
randomStr?: string
mobile?: string
code?: string
grant_type?: string
scope?: string
}
export default {
@@ -1,5 +1,5 @@
<script setup>
import { defineProps, computed } from "vue"
import { computed } from "vue"
import { router } from "@@/index"
const props = defineProps({
@@ -1,5 +1,5 @@
<script setup>
import { defineProps, computed } from "vue"
import { computed } from "vue"
import { router } from "@@/index"
const props = defineProps({
@@ -1,31 +1,31 @@
<script setup lang="ts">
import { defineProps, withDefaults } from "vue";
import { withDefaults } from "vue"
export interface Props {
type: "top" | "bottom";
bgColor: string;
type: "top" | "bottom"
bgColor: string
}
const props = withDefaults(defineProps<Props>(), {
type: "top",
bgColor: "transparent",
});
type: "top",
bgColor: "transparent",
})
function getHeight() {
const { top, bottom } = uni.getSystemInfoSync().safeAreaInsets!;
if (props.type && props.type === "bottom") {
return bottom + "px";
}
return top + "px";
const { top, bottom } = uni.getSystemInfoSync().safeAreaInsets!
if (props.type && props.type === "bottom") {
return bottom + "px"
}
return top + "px"
}
</script>
<template>
<view class="safe" :style="{ backgroundColor: props.bgColor, height: getHeight() }"></view>
<view class="safe" :style="{ backgroundColor: props.bgColor, height: getHeight() }"></view>
</template>
<style lang="scss">
.safe-top {
width: 100%;
width: 100%;
}
</style>
</style>
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { defineProps, withDefaults, watch, ref, reactive, onMounted } from "vue"
import { withDefaults, watch, ref, reactive, onMounted } from "vue"
import { router } from "@@/index"
export type Props = {
+12 -126
View File
@@ -1,8 +1,6 @@
import Request from "luch-request"
import { isEmpty } from "radash"
import isDevEnv from "./isDevEnv"
import { router, constant } from "@@/index"
import { userApi } from "../api"
// 常量定义
const TOKEN_KEY = constant.storageConstant.TOKEN
@@ -40,108 +38,6 @@ const getAuthHeader = (tokenStorage: any) => {
// return tokenStorage?.accessToken?.tokenValue ? `Bearer ${tokenStorage.accessToken.tokenValue}` : null
}
// 浙政钉登录 登录成功返回true,否则返回false
async function handleZzdLogin(): Promise<boolean> {
try {
uni.showLoading({ title: "加载中...", mask: true })
const params = new URL(window.location.href).searchParams
const token = params.get("uabaseToken")
if (!token) return false
const res = await userApi.auth(token)
if (res?.code == 0) {
uni.setStorageSync(TOKEN_KEY, res.data)
const { data: userData } = await userApi.userInfo()
uni.setStorageSync(USER_INFO_KEY, userData)
return true
} else {
uni.removeStorageSync(TOKEN_KEY)
uni.removeStorageSync(USER_INFO_KEY)
if (res.msg == "token已失效") {
uni.showToast({ title: "用户凭证已失效,请退出并重新进入智慧后勤应用", icon: "none", duration: 6000 })
} else {
uni.showToast({ title: res.msg || "登录失败", icon: "none" })
}
return false
}
} catch (error) {
uni.showToast({ title: "登录错误", icon: "none" })
return false
} finally {
uni.hideLoading()
}
}
// 诗画登录 登录成功返回true,否则返回false
async function handleShLogin(): Promise<boolean> {
try {
uni.showLoading({ title: "登录中...", mask: true })
const userInfo = await (window as any).CP2.getUserInfo()
if (userInfo.code == 0) {
uni.showToast({ title: "获取诗画用户信息失败", icon: "none" })
return false
}
const { accountId, sessionId } = userInfo.data
const response = await userApi.authsh({ accountId, sessionId })
if (response.code == 0) {
uni.setStorageSync(TOKEN_KEY, { accessToken: response.data.accessToken })
const { data: userData } = await userApi.userInfo()
uni.setStorageSync(USER_INFO_KEY, userData)
uni.showToast({ title: "登录成功", icon: "none" })
return true
} else {
uni.removeStorageSync(TOKEN_KEY)
uni.removeStorageSync(USER_INFO_KEY)
if (response.msg == "token已失效") {
uni.showToast({ title: "用户凭证已失效,请退出并重新进入智慧后勤应用", icon: "none", duration: 6000 })
} else {
uni.showToast({ title: response.msg || "登录失败", icon: "none" })
}
return false
}
} catch (error) {
uni.showToast({ title: "登录错误", icon: "none" })
return false
} finally {
uni.hideLoading()
}
}
// 根据应用环境自动登录 返回登录结果
async function autoLogin(): Promise<boolean> {
const appInfo = await (window as any).CP2.getAppInfo()
// 浙政钉环境
if (appInfo.code == 0) {
return await handleZzdLogin()
}
// 诗画环境
else {
return await handleShLogin()
}
}
// token过期刷新检查
async function checkAndRefreshToken(tokenStorage: any) {
const { accessToken } = tokenStorage
if (!accessToken) return
const expiresDate = new Date(accessToken.expiresAt).getTime()
// console.log("过期时间", expiresDate)
// console.log("现在时间", new Date().getTime())
// console.log("现在时间大于过期时间吗", new Date().getTime() >= expiresDate)
// token已过期,尝试刷新
if (new Date().getTime() >= expiresDate) {
await autoLogin()
}
}
// 处理错误响应
function handleErrorResponse(response: any) {
if (!response.config?.custom?.showError) return
@@ -156,7 +52,8 @@ function handleErrorResponse(response: any) {
break
case 424:
// 处理token过期
autoLogin()
uni.showToast({ title: "登录已过期,请重新登录", icon: "none" })
router.jump("/pages/test/login")
break
default:
uni.showToast({
@@ -181,7 +78,7 @@ function handleSuccessMessage(response: any) {
// 创建请求实例
const http = new Request({
baseURL: import.meta.env.VITE_API_URL,
timeout: 8000,
timeout: 15000,
method: "GET",
header: {
Accept: "*/*",
@@ -224,22 +121,15 @@ http.interceptors.request.use(async (config) => {
if (needAuth) {
if (!isEmpty(tokenStorage)) {
// token过期刷新检查
await checkAndRefreshToken(tokenStorage)
// await checkAndRefreshToken(tokenStorage)
const authHeader = getAuthHeader(tokenStorage)
if (authHeader) {
config_header.Authorization = authHeader
}
} else {
// token不存在,则发起登录
await autoLogin()
// 登录后重新获取token
const newTokenStorage = uni.getStorageSync(TOKEN_KEY)
const authHeader = getAuthHeader(newTokenStorage)
if (authHeader) {
config_header.Authorization = authHeader
}
uni.showToast({ title: "登录已过期,请重新登录", icon: "none" })
router.jump("/pages/test/login")
}
}
@@ -282,16 +172,12 @@ http.interceptors.response.use(
// 处理 424 错误(token过期)
if (error.statusCode === 424) {
if (isDevEnv()) {
// 开发环境直接清除token并跳转登录
uni.removeStorageSync(TOKEN_KEY)
uni.removeStorageSync(USER_INFO_KEY)
uni.showToast({ title: "登录已过期,请重新登录", icon: "none" })
router.jump("/pages/test/login")
return false
} else {
await autoLogin()
}
// 清除token并跳转登录
uni.removeStorageSync(TOKEN_KEY)
uni.removeStorageSync(USER_INFO_KEY)
uni.showToast({ title: "登录已过期,请重新登录", icon: "none" })
router.jump("/pages/test/login")
return false
}
// 显示错误信息