feat: 新增商品详情搭配优惠组件和客服弹窗
refactor: 优化页面样式和交互逻辑 fix: 修复洗车券列表和详情页的数据展示问题 style: 调整用户页面按钮样式和布局 chore: 移除无用页面和代码,更新项目配置 docs: 更新单次启动页面的使用说明和注意事项 perf: 优化网络请求和数据处理逻辑 build: 更新依赖和配置文件 test: 更新测试用例以适应新功能 ci: 调整CI配置以适应新项目结构
This commit is contained in:
@@ -1,179 +0,0 @@
|
||||
var t = getApp(), e = require("../../utils/login.js");
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
countdown: '',
|
||||
agentname: '',
|
||||
devicecode: '',
|
||||
remainingTime: 0,
|
||||
orderid: '',
|
||||
title: getApp().globalData.deviceData.title || getApp().globalData.deviceData.devicecode
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
var a = this;
|
||||
e.request('/miniprogram/index/balance', getApp().globalData.deviceData, !0).then(function (res) {
|
||||
if (!res.data || !res.data.progressorder) {
|
||||
wx.showToast({
|
||||
title: '没有进行中的订单',
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
});
|
||||
setTimeout(() => {
|
||||
// 跳转到首页
|
||||
wx.redirectTo({
|
||||
url: '/pages/index/index'
|
||||
});
|
||||
}, 1000);
|
||||
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: '获取订单信息失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
setTimeout(() => {
|
||||
wx.redirectTo({
|
||||
url: '/pages/index/index'
|
||||
});
|
||||
}, 1000);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
},
|
||||
handleSettlement() {
|
||||
wx.showModal({
|
||||
title: '确认结算',
|
||||
content: '确定要结算此次洗车订单吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
e.request('/miniprogram/' + getApp().globalData.deviceData.type + '/shutdown', {
|
||||
orderid: this.data.orderid
|
||||
}, true).then((res) => {
|
||||
if (res.code === 200) {
|
||||
wx.showToast({
|
||||
title: res.message || '结算成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
});
|
||||
setTimeout(() => {
|
||||
wx.removeStorageSync('progressorder');
|
||||
wx.redirectTo({
|
||||
url: '/pages/index/index'
|
||||
});
|
||||
}, 2000);
|
||||
}
|
||||
}).catch((err) => {
|
||||
// setTimeout(() => {
|
||||
// wx.removeStorageSync('progressorder');
|
||||
// wx.reLaunch({
|
||||
// url: '/pages/index/index'
|
||||
// });
|
||||
// }, 2000);
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
countdown() {
|
||||
|
||||
// 没有 Cannot read property 'remainingTime' of undefined
|
||||
if (!this.data.remainingTime) {
|
||||
this.setData({
|
||||
countdown: '00:00'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (this.data.remainingTime <= 0) {
|
||||
this.setData({
|
||||
countdown: '00:00'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const minute = Math.floor(this.data.remainingTime / 60);
|
||||
const second = this.data.remainingTime % 60;
|
||||
const formattedMinute = minute < 10 ? '0' + minute : minute;
|
||||
const formattedSecond = second < 10 ? '0' + second : second;
|
||||
|
||||
this.setData({
|
||||
countdown: formattedMinute + ':' + formattedSecond,
|
||||
remainingTime: this.data.remainingTime - 1
|
||||
});
|
||||
|
||||
setTimeout(this.countdown, 1000);
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user