|
|
@@ -37,26 +37,26 @@ const http = (params) => {
|
|
|
// console.log(params)
|
|
|
//返回promise 对象
|
|
|
return new Promise((resolve, reject) => {
|
|
|
- wx.showToast({
|
|
|
- icon: 'loading',
|
|
|
- title: '加载中...',
|
|
|
+ // wx.showToast({
|
|
|
+ // icon: 'loading',
|
|
|
+ // title: '加载中...',
|
|
|
+ // mask: true,
|
|
|
+ // duration: 10000,
|
|
|
+ // success: res => {
|
|
|
+ // console.log(new Date())
|
|
|
+ // loading = false
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ if (loading) {
|
|
|
+
|
|
|
+ }
|
|
|
+ wx.showLoading({
|
|
|
+ title: 'loading',
|
|
|
mask: true,
|
|
|
- duration: 10000,
|
|
|
success: res => {
|
|
|
- console.log(new Date())
|
|
|
loading = false
|
|
|
}
|
|
|
- })
|
|
|
- if (loading) {
|
|
|
-
|
|
|
- // wx.showLoading({
|
|
|
- // title: 'loading',
|
|
|
- // mask: true,
|
|
|
- // success: res => {
|
|
|
- // loading = false
|
|
|
- // }
|
|
|
- // });
|
|
|
- }
|
|
|
+ });
|
|
|
console.log(params.url)
|
|
|
wx.request({
|
|
|
url: apiUrl + params.url, //服务器url+参数中携带的接口具体地址
|
|
|
@@ -69,16 +69,20 @@ const http = (params) => {
|
|
|
responseType: params.responseType, //响应的数据类型
|
|
|
success: function(res) {
|
|
|
console.log("res=>", res.data)
|
|
|
- // wx.hideLoading();
|
|
|
+ wx.hideLoading({
|
|
|
+ success: res => {
|
|
|
+ loading = true
|
|
|
+ }
|
|
|
+ });
|
|
|
if (res.statusCode == 200) {
|
|
|
var errorCode = res.data.errcode
|
|
|
if (errorCode == 0) {
|
|
|
- wx.hideToast()
|
|
|
- wx.showToast({
|
|
|
- icon: 'loading',
|
|
|
- title: '加载中...',
|
|
|
- duration: 0
|
|
|
- })
|
|
|
+ // wx.hideToast()
|
|
|
+ // wx.showToast({
|
|
|
+ // icon: 'loading',
|
|
|
+ // title: '加载中...',
|
|
|
+ // duration: 0
|
|
|
+ // })
|
|
|
return resolve(res.data)
|
|
|
} else if (errorCode == 1014) {
|
|
|
wx.setStorageSync('openId', res.data.data.openId);
|
|
|
@@ -133,7 +137,7 @@ const http = (params) => {
|
|
|
} else if (errorCode == 2006) {
|
|
|
//后台接口异常
|
|
|
}
|
|
|
- showToast(res.data.errmsg);
|
|
|
+ params.data.task_id !== 10 && showToast(res.data.errmsg);
|
|
|
reject(res.data);
|
|
|
} else {
|
|
|
//2. 操作不成功返回数据,以toast方式弹出响应信息,如后端未格式化非操作成功异常信息,则可以统一定义异常提示
|
|
|
@@ -147,12 +151,12 @@ const http = (params) => {
|
|
|
}
|
|
|
},
|
|
|
fail: function(e) {
|
|
|
- // wx.hideLoading()
|
|
|
console.log('error=>', e)
|
|
|
wx.showToast({
|
|
|
icon: "none",
|
|
|
title: "网络异常",
|
|
|
success: () => {
|
|
|
+ loading = true
|
|
|
reject()
|
|
|
}
|
|
|
})
|