Merge branch 'main' of http://124.243.245.42:3000/sdz/ks-app-employment-service
This commit is contained in:
48
packageCa/utilCa/request.js
Normal file
48
packageCa/utilCa/request.js
Normal file
@@ -0,0 +1,48 @@
|
||||
import { baseUrl} from './config.js'
|
||||
|
||||
const request = {}
|
||||
const headers = {}
|
||||
|
||||
request.globalRequest = (url, method, data, power, type) => {
|
||||
// 权限判断 因为有的接口请求头可能需要添加的参数不一样,所以这里做了区分
|
||||
// 1 == 不通过access_token校验的接口
|
||||
// 2 == 文件下载接口列表
|
||||
const userInfo = uni.getStorageSync('CAuserInfo')
|
||||
headers['Token'] = userInfo.token
|
||||
return uni.request({
|
||||
timeout: 60000,
|
||||
url: baseUrl + url,
|
||||
method,
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
header: headers
|
||||
}).then(res => {
|
||||
if (res.data.Result) {
|
||||
return res.data
|
||||
} else {
|
||||
throw res.data
|
||||
}
|
||||
}).catch(parmas => {
|
||||
switch (parmas.status) {
|
||||
case 401:
|
||||
uni.showToast({
|
||||
title: parmas.msg,
|
||||
icon: 'none',
|
||||
duration: 3500
|
||||
})
|
||||
uni.removeStorageSync("CAuserInfo");
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({
|
||||
url: "/pages/index/index"
|
||||
})
|
||||
}, 2800)
|
||||
break
|
||||
default:
|
||||
console.error(parmas);
|
||||
return Promise.reject()
|
||||
break
|
||||
}
|
||||
})
|
||||
}
|
||||
export default request
|
||||
|
||||
Reference in New Issue
Block a user