请求处理代理
商品管理 商品分类 用户管理 桌台 代客下单 进销存 交班 预定座位 充值管理 存酒管理
This commit is contained in:
@@ -13,6 +13,13 @@ import storageManage from '@/commons/utils/storageManage.js'
|
||||
import { sm4DecryptByResData } from '@/commons/utils/encryptUtil.js'
|
||||
import infoBox from "@/commons/utils/infoBox.js"
|
||||
import go from '@/commons/utils/go.js';
|
||||
let baseUrl = 'http://101.37.12.135:8080'
|
||||
// #ifdef H5
|
||||
baseUrl = '/server3/mch'
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
baseUrl = 'http://101.37.12.135:8080/mch'
|
||||
// #endif
|
||||
|
||||
// 多少 ms 以内, 不提示loading
|
||||
const loadingShowTime = 200
|
||||
@@ -82,6 +89,9 @@ function commonsProcess(showLoading, httpReqCallback){
|
||||
if(bodyData.code == 5005){ // 密码已过期, 直接跳转到更改密码页面
|
||||
uni.reLaunch({url: '/pageUser/setting/updatePwd'})
|
||||
}
|
||||
if(bodyData.code == 500){ // 密码已过期, 直接跳转到更改密码页面
|
||||
uni.redirectTo({url: '/pages/login/index'})
|
||||
}
|
||||
return Promise.reject(bodyData)
|
||||
}
|
||||
|
||||
@@ -118,10 +128,11 @@ function req(uri, data, method = "GET", showLoading = true, extParams = {}){
|
||||
// 放置token
|
||||
let headerObject = {}
|
||||
headerObject[appConfig.tokenKey] = storageManage.token()
|
||||
headerObject["satoken"] = storageManage.token()
|
||||
|
||||
return commonsProcess(showLoading, () => {
|
||||
return uni.request(
|
||||
Object.assign({url: appConfig.env.JEEPAY_BASE_URL + uri, data: data, method: method, header: headerObject}, extParams )
|
||||
Object.assign({url: baseUrl + uri, data: data, method: method, header: headerObject}, extParams )
|
||||
)
|
||||
}
|
||||
)
|
||||
@@ -137,7 +148,7 @@ function upload(uri, data, file, showLoading = true, extParams = {}){
|
||||
|
||||
return commonsProcess(showLoading, () => {
|
||||
return uni.uploadFile(
|
||||
Object.assign({url: appConfig.env.JEEPAY_BASE_URL + uri, formData: data, name: "file", filePath: file.path, header: headerObject}, extParams )
|
||||
Object.assign({url: baseUrl + uri, formData: data, name: "file", filePath: file.path, header: headerObject}, extParams )
|
||||
).then((httpData) => {
|
||||
// uni.upload 返回bodyData 的是 string类型。 需要解析。
|
||||
httpData.data = JSON.parse(httpData.data)
|
||||
|
||||
Reference in New Issue
Block a user