职业素养功能修改
This commit is contained in:
@@ -1,14 +1,4 @@
|
||||
import {
|
||||
baseUrl,
|
||||
baseUrl1,
|
||||
baseUrl2,
|
||||
baseUrl3,
|
||||
baseUrl4,
|
||||
baseUrl5,
|
||||
baseUrl6,
|
||||
baseUrl7,
|
||||
baseUrl8
|
||||
} from './config.js'
|
||||
import { baseUrl} from './config.js'
|
||||
|
||||
const request = {}
|
||||
const headers = {}
|
||||
@@ -18,77 +8,20 @@ request.globalRequest = (url, method, data, power, type) => {
|
||||
// 1 == 不通过access_token校验的接口
|
||||
// 2 == 文件下载接口列表
|
||||
const userInfo = uni.getStorageSync('CAuserInfo')
|
||||
// console.log('缓存userinfo:',userInfo);
|
||||
switch (power) {
|
||||
case 1:
|
||||
case 3:
|
||||
headers['Token'] = userInfo.token
|
||||
// if(power == 3){
|
||||
// const deviceInfo = wx.getDeviceInfo()
|
||||
// let data = {
|
||||
// model: deviceInfo.model,
|
||||
// system: deviceInfo.system,
|
||||
// platform: deviceInfo.platform
|
||||
// }
|
||||
// headers['DeviceInfo'] = JSON.stringify(data)
|
||||
// }
|
||||
break;
|
||||
case 2:
|
||||
headers['Authorization'] = userInfo.userToken
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
let host = "";
|
||||
let key = "";
|
||||
if (type == 1) {
|
||||
host = baseUrl1;
|
||||
} else if (type == 2) {
|
||||
host = baseUrl2;
|
||||
} else if (type == 3) {
|
||||
host = baseUrl3;
|
||||
} else if (type == 4) {
|
||||
host = baseUrl4;
|
||||
} else if (type == 5) {
|
||||
host = baseUrl5;
|
||||
} else if (type == 7) {
|
||||
host = baseUrl7;
|
||||
key = `?PartnerKey=51xuanxiao&PartnerSecret=mC6XRjDWUzGAdxcCqRBWGb88uR`;
|
||||
} else if (type == 8) {
|
||||
host = baseUrl8;
|
||||
//key = `?AppKey=51xuanxiao&AppSecret=mC6XRjDWUzGAdxcCqRBWGb88uR`;
|
||||
} else {
|
||||
host = baseUrl;
|
||||
}
|
||||
headers['Token'] = userInfo.token
|
||||
return uni.request({
|
||||
timeout: 60000,
|
||||
url: host + url + key,
|
||||
url: baseUrl + url,
|
||||
method,
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
header: headers
|
||||
}).then(res => {
|
||||
//console.log("ressss===="+JSON.stringify(res.data));
|
||||
// console.log("type===="+type);
|
||||
if (type == 7) {
|
||||
if (res[1].data.code == 0) {
|
||||
return res[1].data
|
||||
} else {
|
||||
throw res[1].data
|
||||
}
|
||||
} else if (type == 8) {
|
||||
if (res[1].data.Code == 0) {
|
||||
return res[1].data
|
||||
} else {
|
||||
throw res[1].data
|
||||
}
|
||||
} else {
|
||||
if (res.data.Result) {
|
||||
return res.data
|
||||
} else {
|
||||
throw res.data
|
||||
}
|
||||
}
|
||||
if (res.data.Result) {
|
||||
return res.data
|
||||
} else {
|
||||
throw res.data
|
||||
}
|
||||
}).catch(parmas => {
|
||||
switch (parmas.status) {
|
||||
case 401:
|
||||
|
||||
Reference in New Issue
Block a user