Authored by huangyCode

503url更改

... ... @@ -59,7 +59,6 @@ function getPrivateKey(){
}
})
}
let errorUrl = '';
function request(method = 'GET') {
return function(url, params = {}) {
return getPrivateKey()
... ... @@ -135,23 +134,26 @@ function request(method = 'GET') {
}
});
}
let pages = getCurrentPages() //获取加载的页面
let currentPage = pages[pages.length-1] //获取当前页面的对象
let url = currentPage.route //当前页面url
let errorUrl = wx.getStorageSync('errorUrl') || '';
if (statusCode == 200) {
errorUrl = '';
if(errorUrl && errorUrl !== url){
wx.removeStorageSync('errorUrl');
}
resolve(data);
} else {
let code = statusCode;
let message = res.errMsg ? res.errMsg : '';
if(statusCode === 503) {
let pages = getCurrentPages() //获取加载的页面
let currentPage = pages[pages.length-1] //获取当前页面的对象
let url = currentPage.route //当前页面url
if(url !== '/pages/zeroSell/error')
if(errorUrl !== url)
errorUrl = url;
if(errorUrl !== url) {
wx.setStorageSync('errorUrl',url);
wx.navigateTo({
url: '/pages/zeroSell/error',
})
}
}
reject({ code, message });
}
... ... @@ -246,23 +248,25 @@ function request(method = 'GET') {
}
});
}
let pages = getCurrentPages() //获取加载的页面
let currentPage = pages[pages.length-1] //获取当前页面的对象
let url = currentPage.route //当前页面url
let errorUrl = wx.getStorageSync('errorUrl') || '';
if (statusCode == 200) {
errorUrl = '';
if(errorUrl && errorUrl !== url){
wx.removeStorageSync('errorUrl');
}
resolve(data);
} else {
let code = statusCode;
let message = res.errMsg ? res.errMsg : '';
if(statusCode === 503) {
let pages = getCurrentPages() //获取加载的页面
let currentPage = pages[pages.length-1] //获取当前页面的对象
let url = currentPage.route //当前页面url
if(url !== '/pages/zeroSell/error')
if(errorUrl !== url)
errorUrl = url;
wx.navigateTo({
url: '/pages/zeroSell/error'
})
if(errorUrl !== url){
wx.setStorageSync('errorUrl',url);
wx.navigateTo({
url: '/pages/zeroSell/error',
})
}
}
reject({ code, message });
}
... ...
... ... @@ -2,8 +2,8 @@ Page({
data: {
},
onLoad: function () {
onShow: function () {
wx.removeStorageSync('errorUrl')
},
back: function () {
wx.navigateBack({
... ...