Showing
2 changed files
with
24 additions
and
20 deletions
@@ -59,7 +59,6 @@ function getPrivateKey(){ | @@ -59,7 +59,6 @@ function getPrivateKey(){ | ||
59 | } | 59 | } |
60 | }) | 60 | }) |
61 | } | 61 | } |
62 | -let errorUrl = ''; | ||
63 | function request(method = 'GET') { | 62 | function request(method = 'GET') { |
64 | return function(url, params = {}) { | 63 | return function(url, params = {}) { |
65 | return getPrivateKey() | 64 | return getPrivateKey() |
@@ -135,23 +134,26 @@ function request(method = 'GET') { | @@ -135,23 +134,26 @@ function request(method = 'GET') { | ||
135 | } | 134 | } |
136 | }); | 135 | }); |
137 | } | 136 | } |
138 | - | 137 | + let pages = getCurrentPages() //获取加载的页面 |
138 | + let currentPage = pages[pages.length-1] //获取当前页面的对象 | ||
139 | + let url = currentPage.route //当前页面url | ||
140 | + let errorUrl = wx.getStorageSync('errorUrl') || ''; | ||
139 | if (statusCode == 200) { | 141 | if (statusCode == 200) { |
140 | - errorUrl = ''; | 142 | + if(errorUrl && errorUrl !== url){ |
143 | + wx.removeStorageSync('errorUrl'); | ||
144 | + } | ||
141 | resolve(data); | 145 | resolve(data); |
142 | } else { | 146 | } else { |
143 | let code = statusCode; | 147 | let code = statusCode; |
144 | let message = res.errMsg ? res.errMsg : ''; | 148 | let message = res.errMsg ? res.errMsg : ''; |
145 | if(statusCode === 503) { | 149 | if(statusCode === 503) { |
146 | - let pages = getCurrentPages() //获取加载的页面 | ||
147 | - let currentPage = pages[pages.length-1] //获取当前页面的对象 | ||
148 | - let url = currentPage.route //当前页面url | ||
149 | - if(url !== '/pages/zeroSell/error') | ||
150 | - if(errorUrl !== url) | ||
151 | - errorUrl = url; | 150 | + if(errorUrl !== url) { |
151 | + wx.setStorageSync('errorUrl',url); | ||
152 | wx.navigateTo({ | 152 | wx.navigateTo({ |
153 | url: '/pages/zeroSell/error', | 153 | url: '/pages/zeroSell/error', |
154 | }) | 154 | }) |
155 | + | ||
156 | + } | ||
155 | } | 157 | } |
156 | reject({ code, message }); | 158 | reject({ code, message }); |
157 | } | 159 | } |
@@ -246,24 +248,26 @@ function request(method = 'GET') { | @@ -246,24 +248,26 @@ function request(method = 'GET') { | ||
246 | } | 248 | } |
247 | }); | 249 | }); |
248 | } | 250 | } |
249 | - | 251 | + let pages = getCurrentPages() //获取加载的页面 |
252 | + let currentPage = pages[pages.length-1] //获取当前页面的对象 | ||
253 | + let url = currentPage.route //当前页面url | ||
254 | + let errorUrl = wx.getStorageSync('errorUrl') || ''; | ||
250 | if (statusCode == 200) { | 255 | if (statusCode == 200) { |
251 | - errorUrl = ''; | 256 | + if(errorUrl && errorUrl !== url){ |
257 | + wx.removeStorageSync('errorUrl'); | ||
258 | + } | ||
252 | resolve(data); | 259 | resolve(data); |
253 | } else { | 260 | } else { |
254 | let code = statusCode; | 261 | let code = statusCode; |
255 | let message = res.errMsg ? res.errMsg : ''; | 262 | let message = res.errMsg ? res.errMsg : ''; |
256 | if(statusCode === 503) { | 263 | if(statusCode === 503) { |
257 | - let pages = getCurrentPages() //获取加载的页面 | ||
258 | - let currentPage = pages[pages.length-1] //获取当前页面的对象 | ||
259 | - let url = currentPage.route //当前页面url | ||
260 | - if(url !== '/pages/zeroSell/error') | ||
261 | - if(errorUrl !== url) | ||
262 | - errorUrl = url; | 264 | + if(errorUrl !== url){ |
265 | + wx.setStorageSync('errorUrl',url); | ||
263 | wx.navigateTo({ | 266 | wx.navigateTo({ |
264 | - url: '/pages/zeroSell/error' | 267 | + url: '/pages/zeroSell/error', |
265 | }) | 268 | }) |
266 | } | 269 | } |
270 | + } | ||
267 | reject({ code, message }); | 271 | reject({ code, message }); |
268 | } | 272 | } |
269 | }, | 273 | }, |
-
Please register or login to post a comment