diff --git a/pages/washing/washing.js b/pages/washing/washing.js index 20d8038..3c50578 100644 --- a/pages/washing/washing.js +++ b/pages/washing/washing.js @@ -17,10 +17,39 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad(options) { - const orderInfo = wx.getStorageSync('progressorder'); - if (!orderInfo) { + var a = this; + e.request('/miniprogram/index/balance', {}, !0).then(function(res) { + if (!res.data || !res.data.progressorder) { + wx.showToast({ + title: '没有进行中的订单', + icon: 'none', + duration: 2000 + }); + setTimeout(() => { + wx.switchTab({ + url: '/pages/index/index' + }); + }, 2000); + return; + } + + const orderInfo = res.data.progressorder; + const currentTime = Math.floor(Date.now() / 1000); + const remainingTime = Math.max(0, orderInfo.timestamp + orderInfo.siteoccupationTime * 60 - currentTime); + + a.setData({ + agentname: orderInfo.agentname, + devicecode: orderInfo.devicecode, + remainingTime: remainingTime, + orderid: orderInfo.id + }); + + if (remainingTime > 0) { + a.countdown(); + } + }).catch(function(err) { wx.showToast({ - title: '没有进行中的订单', + title: '获取订单信息失败', icon: 'none', duration: 2000 }); @@ -29,22 +58,7 @@ Page({ url: '/pages/index/index' }); }, 2000); - return; - } - - const currentTime = Math.floor(Date.now() / 1000); - const remainingTime = Math.max(0, orderInfo.timestamp + orderInfo.siteoccupationTime * 60 - currentTime); - - this.setData({ - agentname: orderInfo.agentname, - devicecode: orderInfo.devicecode, - remainingTime: remainingTime, - orderid: orderInfo.id }); - - if (remainingTime > 0) { - this.countdown(); - } }, /**