增加测试环境,预发布环境

This commit is contained in:
GaoHao
2024-12-11 09:12:23 +08:00
parent 5586573ff1
commit f21d98bc51
17 changed files with 34 additions and 788 deletions

View File

@@ -10,12 +10,13 @@
// 导入全局属性
import appConfig from '@/config/appConfig.js'
import storageManage from '@/commons/utils/storageManage.js'
import {
sm4DecryptByResData
} from '@/commons/utils/encryptUtil.js'
import infoBox from "@/commons/utils/infoBox.js"
// let baseUrl = ''
let baseUrl = 'https://cashier-client.sxczgkj.cn/cashier-client'
// let baseUrl = '' //测试
// let baseUrl = 'https://cashier-client.sxczgkj.cn/cashier-client' //测试环境
// let baseUrl = 'https://pre-cashierclient.sxczgkj.cn/cashier-client' //预发布环境
// let baseUrl = 'https://cashierclient.sxczgkj.cn/cashier-client' //线上环境
let baseUrl = appConfig.ENV_ENUM.VITE_API_URL
// 多少 ms 以内, 不提示loading
const loadingShowTime = 200
@@ -45,7 +46,7 @@ function commonsProcess(showLoading, httpReqCallback) {
let reqFinishFunc = () => {
if (reqState == 'ingLoading') { // 关闭loading弹层
infoBox.hideLoading()
uni.hideLoading()
}
reqState = 'finish' // 请求完毕
}
@@ -56,7 +57,7 @@ function commonsProcess(showLoading, httpReqCallback) {
setTimeout(() => {
if (reqState == 'ing') {
reqState = 'ingLoading'
infoBox.showLoading()
uni.showLoading({ title: '请稍后', mask: true })
}
}, loadingShowTime)
}
@@ -87,7 +88,10 @@ function commonsProcess(showLoading, httpReqCallback) {
// http响应码不正确
if (statusCode != 200 && statusCode != 204 && statusCode != 201) {
isShowErrorToast = true
infoBox.showErrorToast(data.message || '服务器异常')
uni.showToast({
title: data.message || '服务器异常',
icon: 'none'
})
return Promise.reject(bodyData) // 跳转到catch函数
}
@@ -97,19 +101,25 @@ function commonsProcess(showLoading, httpReqCallback) {
}).catch(res => {
if(res.status==401){
infoBox.showToast(`登录失效`)
uni.showToast({
title: '登录失效',
icon: 'none'
})
}
if(res.status==500){
infoBox.showToast(`网络异常`)
uni.showToast({
title: '网络异常',
icon: 'none'
})
}
// if(res&&res.msg){
// infoBox.showErrorToast(res.msg)
// }
reqFinishFunc(); // 请求完毕的动作
// 如果没有提示错误, 那么此处提示 异常。
if (!isShowErrorToast) {
infoBox.showErrorToast(`请求网络异常`)
uni.showToast({
title: '请求网络异常',
icon: 'none'
})
}
return Promise.reject(res)