用户模块
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import config from './config'
|
||||
|
||||
import Qs from 'qs'
|
||||
let arr = []
|
||||
export default (options = {}) => {
|
||||
if (options.data == undefined) {
|
||||
@@ -17,8 +17,12 @@ export default (options = {}) => {
|
||||
})
|
||||
}
|
||||
return new Promise((reslove, reject) => {
|
||||
let url = options.url.indexOf('http') === -1 ? config.domain + options.url : options.url
|
||||
if (options.params) {
|
||||
url = url + '?' + Qs.stringify(options.params)
|
||||
}
|
||||
uni.request({
|
||||
url: options.url.indexOf('http') === -1 ? config.domain + options.url : options.url,
|
||||
url,
|
||||
data: {
|
||||
...options.data,
|
||||
},
|
||||
@@ -50,9 +54,6 @@ export default (options = {}) => {
|
||||
icon: 'none',
|
||||
title: '网络异常,请稍后再试',
|
||||
})
|
||||
uni.reLaunch({
|
||||
url: '/pages/user/login',
|
||||
})
|
||||
},
|
||||
})
|
||||
})
|
||||
@@ -64,16 +65,10 @@ export default (options = {}) => {
|
||||
*/
|
||||
function errHandler(res) {
|
||||
switch (res.code) {
|
||||
case '401':
|
||||
// #ifdef MP
|
||||
uni.clearStorageSync()
|
||||
// #endif
|
||||
case 'A0024':
|
||||
uni.reLaunch({ url: '/pages/user/login' })
|
||||
break
|
||||
case 'A0202':
|
||||
// #ifdef MP
|
||||
uni.clearStorageSync()
|
||||
// #endif
|
||||
uni.reLaunch({ url: '/pages/user/login' })
|
||||
break
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user