接口对接
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
export default {
|
||||
config: 'config', // 全剧配置
|
||||
userInfo: 'userInfo', // 用户信息
|
||||
}
|
||||
engineering: 'engineering', // 工程信息
|
||||
access_token: 'access_token', // token
|
||||
refresh_token: 'refresh_token', // 刷新token
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ export default (options = {}) => {
|
||||
header: {
|
||||
// 'Content-Type': 'application/json;charset=UTF-8',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
Authorization: uni.getStorageSync('token'),
|
||||
Authorization: uni.getStorageSync('access_token'),
|
||||
...options.header,
|
||||
},
|
||||
method: options.method || 'GET',
|
||||
@@ -63,17 +63,22 @@ export default (options = {}) => {
|
||||
* @param {Number} code 错误码
|
||||
*/
|
||||
function errHandler(res) {
|
||||
switch (res.resultCode) {
|
||||
switch (res.code) {
|
||||
case '401':
|
||||
// #ifdef MP
|
||||
uni.removeStorageSync('Cookie')
|
||||
uni.clearStorageSync()
|
||||
// #endif
|
||||
uni.reLaunch({ url: '/pages/user/login' })
|
||||
break
|
||||
case 'A0202':
|
||||
// #ifdef MP
|
||||
uni.clearStorageSync()
|
||||
// #endif
|
||||
uni.reLaunch({ url: '/pages/user/login' })
|
||||
break
|
||||
default:
|
||||
uni.showToast({
|
||||
title: res.message || res.msg || '服务端未知错误',
|
||||
title: res.message || res.msg || '网络异常,请稍后再试',
|
||||
duration: 2000,
|
||||
icon: 'none',
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user