接口对接

This commit is contained in:
仲么了
2023-07-03 20:29:24 +08:00
parent 5f67499e57
commit 77fd768acf
32 changed files with 587 additions and 1319 deletions

View File

@@ -1,4 +1,7 @@
export default {
config: 'config', // 全剧配置
userInfo: 'userInfo', // 用户信息
}
engineering: 'engineering', // 工程信息
access_token: 'access_token', // token
refresh_token: 'refresh_token', // 刷新token
}

View File

@@ -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',
})