用户模块

This commit is contained in:
仲么了
2023-07-10 20:20:00 +08:00
parent 69063cb241
commit 2104bc0c4c
17 changed files with 4764 additions and 381 deletions

View File

@@ -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: