You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.2 KiB
57 lines
1.2 KiB
export default (params) => { |
|
return new Promise((relove, reject) => { |
|
function qinqiu(){ |
|
let token = '' |
|
if(params.isfa){ |
|
token = 'Bearer '+ uni.getStorageSync('token'); |
|
} |
|
uni.request({ |
|
url: params.url, |
|
data: params.data, |
|
method: params.method, |
|
dataType: "json", |
|
header: { |
|
// "content-type": "application/json", |
|
"Accept": "application/json", |
|
Authorization:token |
|
} |
|
}).then(res => { |
|
// console.log(res); |
|
let data = res.data; |
|
// console.log(data.code); |
|
switch (data.code) { |
|
case 200: |
|
relove(data); |
|
break; |
|
case 1002: |
|
uni.showModal({ |
|
title: '提示', |
|
content: '您还未登录,是否前往登录?', |
|
success: function (res) { |
|
if (res.confirm) { |
|
uni.navigateTo({ |
|
url: '/pages/login/login' |
|
}) |
|
} else if (res.cancel) { |
|
console.log('用户点击取消'); |
|
} |
|
} |
|
}); |
|
|
|
break; |
|
case 500: |
|
relove(data); |
|
break; |
|
case 1000: |
|
uni.setStorageSync('token',data.data.token) |
|
qinqiu(); |
|
break; |
|
default: |
|
relove(data) |
|
break |
|
} |
|
}); |
|
} |
|
qinqiu() |
|
}) |
|
}
|
|
|