mirror of
https://gitee.com/niucloud-team/niucloud-admin.git
synced 2025-12-12 19:02:49 +00:00
update uni-app
This commit is contained in:
parent
8035b67c76
commit
55261a17eb
86
uni-app/package-lock.json
generated
86
uni-app/package-lock.json
generated
@ -26,6 +26,7 @@
|
||||
"lodash-es": "^4.17.21",
|
||||
"pinia": "^2.0.36",
|
||||
"qrcode": "^1.5.1",
|
||||
"qs": "^6.11.2",
|
||||
"sortablejs": "^1.15.0",
|
||||
"uview-plus": "^3.1.29",
|
||||
"vue": "^3.3.0",
|
||||
@ -5235,6 +5236,21 @@
|
||||
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/body-parser/node_modules/qs": {
|
||||
"version": "6.11.0",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz",
|
||||
"integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"side-channel": "^1.0.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.6"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/brace-expansion": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-2.0.1.tgz",
|
||||
@ -5334,7 +5350,6 @@
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmmirror.com/call-bind/-/call-bind-1.0.2.tgz",
|
||||
"integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"function-bind": "^1.1.1",
|
||||
"get-intrinsic": "^1.0.2"
|
||||
@ -6155,6 +6170,21 @@
|
||||
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/express/node_modules/qs": {
|
||||
"version": "6.11.0",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz",
|
||||
"integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"side-channel": "^1.0.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.6"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/fast-glob": {
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmmirror.com/fast-glob/-/fast-glob-3.3.1.tgz",
|
||||
@ -6365,7 +6395,6 @@
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmmirror.com/get-intrinsic/-/get-intrinsic-1.2.1.tgz",
|
||||
"integrity": "sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"function-bind": "^1.1.1",
|
||||
"has": "^1.0.3",
|
||||
@ -6481,7 +6510,6 @@
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/has-proto/-/has-proto-1.0.1.tgz",
|
||||
"integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
@ -6490,7 +6518,6 @@
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmmirror.com/has-symbols/-/has-symbols-1.0.3.tgz",
|
||||
"integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
@ -9319,8 +9346,7 @@
|
||||
"node_modules/object-inspect": {
|
||||
"version": "1.12.3",
|
||||
"resolved": "https://registry.npmmirror.com/object-inspect/-/object-inspect-1.12.3.tgz",
|
||||
"integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==",
|
||||
"dev": true
|
||||
"integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g=="
|
||||
},
|
||||
"node_modules/omggif": {
|
||||
"version": "1.0.10",
|
||||
@ -9988,15 +10014,17 @@
|
||||
}
|
||||
},
|
||||
"node_modules/qs": {
|
||||
"version": "6.11.0",
|
||||
"resolved": "https://registry.npmmirror.com/qs/-/qs-6.11.0.tgz",
|
||||
"integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==",
|
||||
"dev": true,
|
||||
"version": "6.11.2",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.11.2.tgz",
|
||||
"integrity": "sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA==",
|
||||
"dependencies": {
|
||||
"side-channel": "^1.0.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.6"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/querystringify": {
|
||||
@ -10457,7 +10485,6 @@
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmmirror.com/side-channel/-/side-channel-1.0.4.tgz",
|
||||
"integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.0",
|
||||
"get-intrinsic": "^1.0.2",
|
||||
@ -16164,6 +16191,15 @@
|
||||
"resolved": "https://registry.npmmirror.com/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
|
||||
"dev": true
|
||||
},
|
||||
"qs": {
|
||||
"version": "6.11.0",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz",
|
||||
"integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"side-channel": "^1.0.4"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -16248,7 +16284,6 @@
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmmirror.com/call-bind/-/call-bind-1.0.2.tgz",
|
||||
"integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"function-bind": "^1.1.1",
|
||||
"get-intrinsic": "^1.0.2"
|
||||
@ -16913,6 +16948,15 @@
|
||||
"resolved": "https://registry.npmmirror.com/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
|
||||
"dev": true
|
||||
},
|
||||
"qs": {
|
||||
"version": "6.11.0",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz",
|
||||
"integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"side-channel": "^1.0.4"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -17085,7 +17129,6 @@
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmmirror.com/get-intrinsic/-/get-intrinsic-1.2.1.tgz",
|
||||
"integrity": "sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"function-bind": "^1.1.1",
|
||||
"has": "^1.0.3",
|
||||
@ -17176,14 +17219,12 @@
|
||||
"has-proto": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/has-proto/-/has-proto-1.0.1.tgz",
|
||||
"integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==",
|
||||
"dev": true
|
||||
"integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg=="
|
||||
},
|
||||
"has-symbols": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmmirror.com/has-symbols/-/has-symbols-1.0.3.tgz",
|
||||
"integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
|
||||
"dev": true
|
||||
"integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A=="
|
||||
},
|
||||
"hash-sum": {
|
||||
"version": "2.0.0",
|
||||
@ -19444,8 +19485,7 @@
|
||||
"object-inspect": {
|
||||
"version": "1.12.3",
|
||||
"resolved": "https://registry.npmmirror.com/object-inspect/-/object-inspect-1.12.3.tgz",
|
||||
"integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==",
|
||||
"dev": true
|
||||
"integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g=="
|
||||
},
|
||||
"omggif": {
|
||||
"version": "1.0.10",
|
||||
@ -19937,10 +19977,9 @@
|
||||
"integrity": "sha512-EXtzRZmC+YGmGlDFbXKxQiMZNwCLEO6BANKXG4iCtSIM0yqc/pappSx3RIKr4r0uh5JsBckOXeKrB3Iz7mdQpQ=="
|
||||
},
|
||||
"qs": {
|
||||
"version": "6.11.0",
|
||||
"resolved": "https://registry.npmmirror.com/qs/-/qs-6.11.0.tgz",
|
||||
"integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==",
|
||||
"dev": true,
|
||||
"version": "6.11.2",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.11.2.tgz",
|
||||
"integrity": "sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA==",
|
||||
"requires": {
|
||||
"side-channel": "^1.0.4"
|
||||
}
|
||||
@ -20325,7 +20364,6 @@
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmmirror.com/side-channel/-/side-channel-1.0.4.tgz",
|
||||
"integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"call-bind": "^1.0.0",
|
||||
"get-intrinsic": "^1.0.2",
|
||||
|
||||
@ -57,6 +57,7 @@
|
||||
"lodash-es": "^4.17.21",
|
||||
"pinia": "^2.0.36",
|
||||
"qrcode": "^1.5.1",
|
||||
"qs": "^6.11.2",
|
||||
"sortablejs": "^1.15.0",
|
||||
"uview-plus": "^3.1.29",
|
||||
"vue": "^3.3.0",
|
||||
@ -81,4 +82,4 @@
|
||||
"vue-tsc": "^1.0.24",
|
||||
"windicss": "^3.5.6"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1
uni-app/src/app/locale/zh-Hans/pages.index.index.json
Normal file
1
uni-app/src/app/locale/zh-Hans/pages.index.index.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
||||
1
uni-app/src/app/locale/zh-Hans/pages.pay.result.json
Normal file
1
uni-app/src/app/locale/zh-Hans/pages.pay.result.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
||||
@ -4,7 +4,7 @@
|
||||
<!-- 日期列表 -->
|
||||
<scroll-view class="scroll-view_H b-t b-b" scroll-x>
|
||||
<block v-for="(item,index) in dateArr" :key="index">
|
||||
<div class="flex-box" @click="selectDateEvent(index,item)" :class="{ borderb: index==dateActive}">
|
||||
<div class="flex-box" @click="selectDateEvent(index,item)" :class="{ borderb: index==dateActive }" :style="{borderColor: selectedBorderColor}">
|
||||
<view class="date-box" :style="{color:index==dateActive?selectedTabColor:'#333'}">
|
||||
<text class="fontw">{{item.week}}</text>
|
||||
<text class="text-xs">{{item.date}}</text>
|
||||
@ -19,7 +19,7 @@
|
||||
<view class="item">
|
||||
<view class="item-box" :class="{'disable':item.disable,
|
||||
'active':isMultiple?item.isActive:_index==timeActive}" :style="{color:isMultiple?item.isActive? selectedItemColor:'#333'
|
||||
:_index==timeActive?selectedItemColor:'#333'}" @click="selectTimeEvent(_index,item)">
|
||||
:_index==timeActive?selectedItemColor:'#333', borderColor:(isMultiple?item.isActive:_index==timeActive? selectedBorderColor:'')}" @click="selectTimeEvent(_index,item)">
|
||||
<text v-if="isQuantum">{{item.begin}}~{{item.end}}</text>
|
||||
<text v-else>{{item.time}}</text>
|
||||
<text class="all">{{item.disable?disableText:undisableText}}</text>
|
||||
@ -104,6 +104,10 @@
|
||||
type: String,
|
||||
default: "#FB4B5C"
|
||||
},
|
||||
selectedBorderColor: { // 时间选中border的颜色
|
||||
type: String,
|
||||
default: "#FB4B5C"
|
||||
},
|
||||
beginTime: {
|
||||
type: String,
|
||||
default: "09:00:00"
|
||||
@ -415,6 +419,6 @@
|
||||
}
|
||||
|
||||
.borderb {
|
||||
border-bottom: 2px solid #FB4B5C;
|
||||
border-bottom: 2px solid;
|
||||
}
|
||||
</style>
|
||||
@ -7,7 +7,7 @@ class Language {
|
||||
constructor(i18n: any) {
|
||||
this.i18n = i18n
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param locale 设置语言
|
||||
@ -29,7 +29,6 @@ class Language {
|
||||
*/
|
||||
public async loadLocaleMessages(path: string, locale: string) {
|
||||
try {
|
||||
|
||||
let route = 'app'; // 默认系统
|
||||
|
||||
// 检测当前访问的是系统(app)还是插件
|
||||
@ -42,11 +41,11 @@ class Language {
|
||||
else file = file.split('.').splice(1).join('.')
|
||||
|
||||
// 是否已加载
|
||||
if (this.loadLocale.includes(`${locale}/${file}`)) {
|
||||
if (this.loadLocale.includes(`${route}/${locale}/${file}`)) {
|
||||
this.setI18nLanguage(locale, file)
|
||||
return nextTick()
|
||||
}
|
||||
this.loadLocale.push(`${locale}/${file}`)
|
||||
this.loadLocale.push(`${route}/${locale}/${file}`)
|
||||
|
||||
// 引入语言包文件
|
||||
const messages = await import(`../${route}/locale/${locale}/${file}.json`)
|
||||
|
||||
@ -4,14 +4,4 @@
|
||||
--primary-color-disabled: #9acafc;
|
||||
--primary-color-light: #ecf5ff;
|
||||
--page-bg-color: #f7f7f7;
|
||||
}
|
||||
|
||||
/* 多行超出隐藏 */
|
||||
.multi-hidden {
|
||||
word-break: break-all;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
@font-face {
|
||||
font-family: "iconfont"; /* Project id 3952239 */
|
||||
src: url('//at.alicdn.com/t/c/font_3952239_d5svxl1mnu5.woff2?t=1693022806663') format('woff2'),
|
||||
url('//at.alicdn.com/t/c/font_3952239_d5svxl1mnu5.woff?t=1693022806663') format('woff'),
|
||||
url('//at.alicdn.com/t/c/font_3952239_d5svxl1mnu5.ttf?t=1693022806663') format('truetype');
|
||||
src: url('//at.alicdn.com/t/c/font_3952239_8vg0d3zzqa7.woff2?t=1694674505913') format('woff2'),
|
||||
url('//at.alicdn.com/t/c/font_3952239_8vg0d3zzqa7.woff?t=1694674505913') format('woff'),
|
||||
url('//at.alicdn.com/t/c/font_3952239_8vg0d3zzqa7.ttf?t=1694674505913') format('truetype');
|
||||
}
|
||||
|
||||
.iconfont {
|
||||
@ -13,6 +13,30 @@
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.iconkaidian:before {
|
||||
content: "\e6fb";
|
||||
}
|
||||
|
||||
.icongouwuche:before {
|
||||
content: "\e699";
|
||||
}
|
||||
|
||||
.iconliebiaoxingshi:before {
|
||||
content: "\e742";
|
||||
}
|
||||
|
||||
.iconshangpinliebiao:before {
|
||||
content: "\e61c";
|
||||
}
|
||||
|
||||
.iconjiahao1:before {
|
||||
content: "\e84f";
|
||||
}
|
||||
|
||||
.iconjianhao:before {
|
||||
content: "\e850";
|
||||
}
|
||||
|
||||
.iconfenxiang1:before {
|
||||
content: "\e64d";
|
||||
}
|
||||
|
||||
@ -1,3 +1,15 @@
|
||||
@import 'uview-plus/index.scss';
|
||||
@import 'common.scss';
|
||||
@import 'iconfont.css';
|
||||
|
||||
|
||||
|
||||
/* 多行超出隐藏 */
|
||||
.multi-hidden {
|
||||
word-break: break-all;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
|
||||
@ -13,7 +13,6 @@ export const redirectInterceptor = () => {
|
||||
uni.addInterceptor(name, {
|
||||
invoke(args) {
|
||||
const route = urlDeconstruction(args.url)
|
||||
|
||||
// 加载语言包
|
||||
language.loadLocaleMessages(route.path, uni.getLocale())
|
||||
|
||||
@ -34,7 +33,6 @@ export const redirectInterceptor = () => {
|
||||
export const launchInterceptor = () => {
|
||||
const launch = uni.getLaunchOptionsSync()
|
||||
launch.path = `/${launch.path}`
|
||||
|
||||
// 加载语言包
|
||||
language.loadLocaleMessages(launch.path, uni.getLocale())
|
||||
|
||||
|
||||
@ -1,171 +1,180 @@
|
||||
import useMemberStore from '@/stores/member'
|
||||
import { t } from '@/locale'
|
||||
import { getToken, getAppChannel } from './common'
|
||||
import {t} from '@/locale'
|
||||
import {getToken, getAppChannel} from './common'
|
||||
import qs from 'qs';
|
||||
|
||||
|
||||
interface RequestConfig {
|
||||
showSuccessMessage ?: boolean
|
||||
showSuccessMessage?: boolean
|
||||
}
|
||||
|
||||
interface RequestOptions extends UniNamespace.RequestOptions, RequestOptions { }
|
||||
interface RequestOptions extends UniNamespace.RequestOptions, RequestOptions {
|
||||
}
|
||||
|
||||
class Request {
|
||||
private baseUrl : string
|
||||
private baseUrl: string
|
||||
|
||||
private config : RequestOptions = {
|
||||
url: '',
|
||||
header: {}
|
||||
}
|
||||
private config: RequestOptions = {
|
||||
url: '',
|
||||
header: {}
|
||||
}
|
||||
|
||||
constructor() {
|
||||
// #ifdef H5
|
||||
this.baseUrl = import.meta.env.VITE_APP_BASE_URL || `${location.origin}/api/`
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
this.baseUrl = import.meta.env.VITE_APP_BASE_URL
|
||||
// #endif
|
||||
this.baseUrl.substr(-1) != '/' && (this.baseUrl += '/')
|
||||
constructor() {
|
||||
// #ifdef H5
|
||||
this.baseUrl = import.meta.env.VITE_APP_BASE_URL || `${location.origin}/api/`
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
this.baseUrl = import.meta.env.VITE_APP_BASE_URL
|
||||
// #endif
|
||||
this.baseUrl.substr(-1) != '/' && (this.baseUrl += '/')
|
||||
|
||||
try {
|
||||
this.config.header[import.meta.env.VITE_REQUEST_HEADER_CHANNEL_KEY] = getAppChannel()
|
||||
} catch (e) {
|
||||
}
|
||||
try {
|
||||
this.config.header[import.meta.env.VITE_REQUEST_HEADER_CHANNEL_KEY] = getAppChannel()
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求拦截器
|
||||
*/
|
||||
private requestInterceptors() {
|
||||
// 携带token
|
||||
try {
|
||||
getToken() && (this.config.header[import.meta.env.VITE_REQUEST_HEADER_TOKEN_KEY] = getToken())
|
||||
this.config.header[import.meta.env.VITE_REQUEST_HEADER_CHANNEL_KEY] = getAppChannel()
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 请求拦截器
|
||||
*/
|
||||
private requestInterceptors() {
|
||||
// 携带token
|
||||
try {
|
||||
getToken() && (this.config.header[import.meta.env.VITE_REQUEST_HEADER_TOKEN_KEY] = getToken())
|
||||
this.config.header[import.meta.env.VITE_REQUEST_HEADER_CHANNEL_KEY] = getAppChannel()
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
public get(url : string, data : AnyObject = {}, config : RequestConfig = {}) {
|
||||
config.showSuccessMessage == undefined && (config.showSuccessMessage = false)
|
||||
Object.assign(this.config, config)
|
||||
return this.request('GET', url, data)
|
||||
}
|
||||
public get(url: string, data: AnyObject = {}, config: RequestConfig = {}) {
|
||||
config.showSuccessMessage == undefined && (config.showSuccessMessage = false)
|
||||
Object.assign(this.config, config)
|
||||
console.log('get request', url, data)
|
||||
return this.request('GET', url, data)
|
||||
}
|
||||
|
||||
public post(url : string, data : AnyObject = {}, config : RequestConfig = {}) {
|
||||
config.showSuccessMessage == undefined && (config.showSuccessMessage = false)
|
||||
Object.assign(this.config, config)
|
||||
return this.request('POST', url, data)
|
||||
}
|
||||
public post(url: string, data: AnyObject = {}, config: RequestConfig = {}) {
|
||||
config.showSuccessMessage == undefined && (config.showSuccessMessage = false)
|
||||
Object.assign(this.config, config)
|
||||
return this.request('POST', url, data)
|
||||
}
|
||||
|
||||
public put(url : string, data : AnyObject = {}, config : RequestConfig = {}) {
|
||||
config.showSuccessMessage == undefined && (config.showSuccessMessage = false)
|
||||
Object.assign(this.config, config)
|
||||
return this.request('PUT', url, data)
|
||||
}
|
||||
public put(url: string, data: AnyObject = {}, config: RequestConfig = {}) {
|
||||
config.showSuccessMessage == undefined && (config.showSuccessMessage = false)
|
||||
Object.assign(this.config, config)
|
||||
return this.request('PUT', url, data)
|
||||
}
|
||||
|
||||
public delete(url : string, config : RequestConfig = {}) {
|
||||
config.showSuccessMessage == undefined && (config.showSuccessMessage = false)
|
||||
Object.assign(this.config, config)
|
||||
return this.request('DELETE', url)
|
||||
}
|
||||
public delete(url: string, config: RequestConfig = {}) {
|
||||
config.showSuccessMessage == undefined && (config.showSuccessMessage = false)
|
||||
Object.assign(this.config, config)
|
||||
return this.request('DELETE', url)
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送上传请求
|
||||
*/
|
||||
public upload(url : string, data : AnyObject = {}, config : RequestConfig = {}) {
|
||||
this.requestInterceptors()
|
||||
/**
|
||||
* 发送上传请求
|
||||
*/
|
||||
public upload(url: string, data: AnyObject = {}, config: RequestConfig = {}) {
|
||||
this.requestInterceptors()
|
||||
|
||||
const params = Object.assign(uni.$u.deepClone(this.config), {
|
||||
url: this.baseUrl + url,
|
||||
...data
|
||||
})
|
||||
const params = Object.assign(uni.$u.deepClone(this.config), {
|
||||
url: this.baseUrl + url,
|
||||
...data
|
||||
})
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.uploadFile({
|
||||
...params,
|
||||
success: res => {
|
||||
const data = JSON.parse(res.data)
|
||||
if (data.code == 1) {
|
||||
this.config.showSuccessMessage && uni.showToast({ title: data.msg, icon: 'none' })
|
||||
resolve(data)
|
||||
} else {
|
||||
if (data.code == 0) {
|
||||
uni.showToast({ title: data.msg, icon: 'none' })
|
||||
} else {
|
||||
this.handleAuthError(data.code)
|
||||
}
|
||||
reject(data)
|
||||
}
|
||||
},
|
||||
fail: res => {
|
||||
reject(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送请求
|
||||
*/
|
||||
private request(method : string, url : string, data ?: AnyObject) {
|
||||
this.requestInterceptors()
|
||||
|
||||
const params = Object.assign(uni.$u.deepClone(this.config), {
|
||||
url: this.baseUrl + url,
|
||||
method,
|
||||
data
|
||||
})
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
...params,
|
||||
success: res => {
|
||||
const data = res.data
|
||||
if (data.code == 1) {
|
||||
this.config.showSuccessMessage && uni.showToast({ title: data.msg, icon: 'none' })
|
||||
resolve(data)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.uploadFile({
|
||||
...params,
|
||||
success: res => {
|
||||
const data = JSON.parse(res.data)
|
||||
if (data.code == 1) {
|
||||
this.config.showSuccessMessage && uni.showToast({title: data.msg, icon: 'none'})
|
||||
resolve(data)
|
||||
} else {
|
||||
if (data.code == 0) {
|
||||
uni.showToast({ title: data.msg, icon: 'none' })
|
||||
uni.showToast({title: data.msg, icon: 'none'})
|
||||
} else {
|
||||
this.handleAuthError(data.code)
|
||||
}
|
||||
reject(data)
|
||||
}
|
||||
},
|
||||
fail: res => {
|
||||
reject(res)
|
||||
},
|
||||
complete: (res) => {
|
||||
this.handleRequestFail(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
reject(data)
|
||||
}
|
||||
},
|
||||
fail: res => {
|
||||
reject(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
private handleAuthError(code : number) {
|
||||
switch (code) {
|
||||
case 401:
|
||||
useMemberStore().logout()
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 发送请求
|
||||
*/
|
||||
private request(method: string, url: string, data ?: AnyObject) {
|
||||
this.requestInterceptors()
|
||||
|
||||
private handleRequestFail(res) {
|
||||
if (res.errMsg && res.errMsg == "request:ok") {
|
||||
if (typeof res.data == 'string') {
|
||||
uni.showToast({ icon: 'none', title: this.baseUrl + t('requestFail') })
|
||||
return
|
||||
}
|
||||
}
|
||||
if (res.errMsg == 'request:fail') {
|
||||
uni.showToast({ icon: 'none', title: this.baseUrl + t('requestFail') })
|
||||
return
|
||||
}
|
||||
if (res.errMsg && res.errMsg == 'request:fail url not in domain list') {
|
||||
uni.showToast({ icon: 'none', title: this.baseUrl + t('notInDomainList') });
|
||||
return
|
||||
}
|
||||
}
|
||||
let source = {
|
||||
url: this.baseUrl + url,
|
||||
method,
|
||||
};
|
||||
if (source.method.toUpperCase() == 'GET') {
|
||||
source.url += '?' + qs.stringify(data);
|
||||
} else {
|
||||
source.data = data;
|
||||
}
|
||||
const params = Object.assign(uni.$u.deepClone(this.config), source)
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
...params,
|
||||
success: res => {
|
||||
const data = res.data
|
||||
if (data.code == 1) {
|
||||
this.config.showSuccessMessage && uni.showToast({title: data.msg, icon: 'none'})
|
||||
resolve(data)
|
||||
} else {
|
||||
if (data.code == 0) {
|
||||
uni.showToast({title: data.msg, icon: 'none'})
|
||||
} else {
|
||||
this.handleAuthError(data.code)
|
||||
}
|
||||
reject(data)
|
||||
}
|
||||
},
|
||||
fail: res => {
|
||||
reject(res)
|
||||
},
|
||||
complete: (res) => {
|
||||
this.handleRequestFail(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
private handleAuthError(code: number) {
|
||||
switch (code) {
|
||||
case 401:
|
||||
useMemberStore().logout()
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private handleRequestFail(res) {
|
||||
if (res.errMsg && res.errMsg == "request:ok") {
|
||||
if (typeof res.data == 'string') {
|
||||
uni.showToast({icon: 'none', title: this.baseUrl + t('requestFail')})
|
||||
return
|
||||
}
|
||||
}
|
||||
if (res.errMsg == 'request:fail') {
|
||||
uni.showToast({icon: 'none', title: this.baseUrl + t('requestFail')})
|
||||
return
|
||||
}
|
||||
if (res.errMsg && res.errMsg == 'request:fail url not in domain list') {
|
||||
uni.showToast({icon: 'none', title: this.baseUrl + t('notInDomainList')});
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default new Request()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user