刘翔宇-旅管家 3 years ago
parent 73c1ac919e
commit 70ec63f416

@ -650,21 +650,31 @@
} }
}, },
utilFail: res => { utilFail: res => {
console.log(res)
uni.showToast({ uni.showToast({
title: res, title: res,
duration: 5000 duration: 5000
}) })
console.log(res);
} }
}) })
} }
}, },
utilFail: r => { utilFail: r => {
uni.showToast({ uni.showModal({
title: r, title: '',
duration: 5000 content: r,
showCancel: false,
success() {
if (r == "重复购买") {
uni.redirectTo({
url: "../../../packageOrder/pages/myOrder/myOrder"
}) })
console.log(r);
}
}
});
} }
}) })

@ -19,7 +19,8 @@ const formatTime = date => {
// 其他更多是格式化有如下: // 其他更多是格式化有如下:
// yyyy:mm:dd|yyyy:mm|yyyy年mm月dd日|yyyy年mm月dd日 hh时MM分等,可自定义组合 // yyyy:mm:dd|yyyy:mm|yyyy年mm月dd日|yyyy年mm月dd日 hh时MM分等,可自定义组合
function timeFormat(dateTime = null, fmt = 'yyyy-mm-dd') {try { function timeFormat(dateTime = null, fmt = 'yyyy-mm-dd') {
try {
// 如果为null,则格式化当前时间 // 如果为null,则格式化当前时间
if (!dateTime) dateTime = Number(new Date()); if (!dateTime) dateTime = Number(new Date());
@ -135,6 +136,7 @@ const request = options => {
uni.request({ uni.request({
...options, ...options,
success: function(res) { success: function(res) {
uni.hideLoading();
if (res.statusCode != 200) { if (res.statusCode != 200) {
if (options.utilFail != undefined) { if (options.utilFail != undefined) {
if (res.statusCode == 401) { if (res.statusCode == 401) {
@ -160,11 +162,14 @@ const request = options => {
} }
} }
}, },
fail: options.utilFail, fail: function(res) {
uni.hideLoading();
options.utilFail(res);
},
complete: function(res) { complete: function(res) {
if (!options.customLoading) { if (!options.customLoading) {
uni.hideNavigationBarLoading(); uni.hideNavigationBarLoading();
uni.hideLoading();
} else { } else {
// 当前页面请求数量-1 // 当前页面请求数量-1
if (options.bindThis) { if (options.bindThis) {

Loading…
Cancel
Save