|
|
@@ -1,5 +1,6 @@ |
|
|
|
import { |
|
|
|
appId,envs |
|
|
|
appId, |
|
|
|
envs |
|
|
|
} from "./api"; |
|
|
|
import { |
|
|
|
encryption |
|
|
@@ -26,10 +27,10 @@ export function request(code, options = {}) { |
|
|
|
staffId: "54623263cb4d4a289dccbc983b22a4af", |
|
|
|
terminalId: "999999999999", |
|
|
|
loginSource: "69af303ba2eb4608a099163f0d2a5dbd", |
|
|
|
rbacSource:'MINI_PROGRAM' |
|
|
|
rbacSource: 'MINI_PROGRAM' |
|
|
|
} |
|
|
|
//Url 地址 /api/interfaceMidGroundIn |
|
|
|
options.url = 'http://'+ envs[process.env.NODE_ENV].baseUrl +'/ifzt/api/interfaceMidGroundIn' |
|
|
|
options.url = 'http://' + envs[process.env.NODE_ENV].baseUrl + '/ifzt/api/interfaceMidGroundIn' |
|
|
|
//判断baseUri是否为空 |
|
|
|
if (options.baseUrl) { |
|
|
|
options.url = options.baseUrl |
|
|
@@ -62,26 +63,28 @@ export function request(code, options = {}) { |
|
|
|
mask: true |
|
|
|
}); |
|
|
|
} |
|
|
|
console.log('请求参数:', options.data) |
|
|
|
//参数返回 |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
options.success = (res) => { |
|
|
|
console.log('请求成功返回参数:', res) |
|
|
|
// 请求返回后,隐藏loading(如果请求返回快的话,可能会没有loading) |
|
|
|
wx.hideLoading() |
|
|
|
if (res.data.statusCode !== 0) { |
|
|
|
if (res.data.statusCode == 600) { |
|
|
|
resolve(res.data) |
|
|
|
} else if(res.data.statusCode == 401){ |
|
|
|
} else if (res.data.statusCode == 401) { |
|
|
|
wx.showModal({ |
|
|
|
title: '提示', |
|
|
|
content: res.data.errorMsg, |
|
|
|
confirmText:'去登录', |
|
|
|
confirmText: '去登录', |
|
|
|
showCancel: false, |
|
|
|
success: function(res) { |
|
|
|
if (res.confirm) { |
|
|
|
uni.navigateTo({ |
|
|
|
url: '/login/login', |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
@@ -100,7 +103,7 @@ export function request(code, options = {}) { |
|
|
|
reject(res.data.errorMsg) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let content = res |
|
|
|
// let content = s4.decryptData_CBC(res, sm4Key) |
|
|
|
// console.log(content); |
|
|
@@ -109,6 +112,7 @@ export function request(code, options = {}) { |
|
|
|
resolve(content.data) |
|
|
|
} |
|
|
|
options.fail = (err) => { |
|
|
|
console.log('请求失败返回参数:', res) |
|
|
|
wx.hideLoading() |
|
|
|
console.log('请求错误', err) |
|
|
|
//处理请求错误 |
|
|
@@ -116,4 +120,4 @@ export function request(code, options = {}) { |
|
|
|
} |
|
|
|
wx.request(options) |
|
|
|
}); |
|
|
|
} |
|
|
|
} |