This commit is contained in:
XiaoMo 2025-05-06 08:28:03 +08:00
parent ffcfda1f4b
commit 8a8fb8c16d

View File

@ -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();
}
},
/**