|
@@ -20,17 +20,17 @@ const httpInterceptor = {
|
|
|
uni.addInterceptor('request', httpInterceptor);
|
|
|
|
|
|
export const http = (options) => {
|
|
|
- // uni.showLoading({
|
|
|
- // title: "加载中...",
|
|
|
- // mask: true
|
|
|
- // })
|
|
|
+ uni.showLoading({
|
|
|
+ title: "加载中...",
|
|
|
+ mask: true
|
|
|
+ })
|
|
|
return new Promise((resolve, reject) => {
|
|
|
uni.request({
|
|
|
...options,
|
|
|
customUrl: options.url,
|
|
|
success(result) {
|
|
|
const { data: res } = result;
|
|
|
- // uni.hideLoading();
|
|
|
+ uni.hideLoading();
|
|
|
|
|
|
switch(res.code){
|
|
|
case 200:
|
|
@@ -42,7 +42,7 @@ export const http = (options) => {
|
|
|
break;
|
|
|
case 401:
|
|
|
uni.showToast({ icon: 'none', title: '登录失效, 请重新登录', duration: 2 * 1000, mask: true});
|
|
|
- setTimeout(_ => uni.navigateTo({ url: "/pages/login/index" }), 2000);
|
|
|
+ setTimeout(_ => uni.redirectTo({ url: "/pages/login/index" }), 2000);
|
|
|
userStore.clearUserInfo();
|
|
|
reject(res)
|
|
|
break;
|
|
@@ -53,7 +53,7 @@ export const http = (options) => {
|
|
|
}
|
|
|
},
|
|
|
fail(err) {
|
|
|
- // uni.hideLoading();
|
|
|
+ uni.hideLoading();
|
|
|
uni.showToast({
|
|
|
icon: 'none',
|
|
|
title: '网络错误,换个网络试试',
|