feat: 新增商品详情搭配优惠组件和客服弹窗
refactor: 优化页面样式和交互逻辑 fix: 修复洗车券列表和详情页的数据展示问题 style: 调整用户页面按钮样式和布局 chore: 移除无用页面和代码,更新项目配置 docs: 更新单次启动页面的使用说明和注意事项 perf: 优化网络请求和数据处理逻辑 build: 更新依赖和配置文件 test: 更新测试用例以适应新功能 ci: 调整CI配置以适应新项目结构
This commit is contained in:
@@ -1,199 +0,0 @@
|
||||
var t = getApp(), e = require("../../utils/login.js");
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
userInfo: {},
|
||||
balance: 0,
|
||||
loading: true,
|
||||
paySuccess: false,
|
||||
orderInfo: {},
|
||||
token: '',
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onShow(options) {
|
||||
var a = this;
|
||||
// 等待全局接口执行完成后再初始化页面
|
||||
e.pageStart(t).then(function () {
|
||||
a.initPage();
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 初始化页面数据
|
||||
*/
|
||||
initPage() {
|
||||
var a = this;
|
||||
a.setData({
|
||||
loading: true
|
||||
});
|
||||
|
||||
e.request('/miniprogram/substituteWash/index', {}, true).then(function (res) {
|
||||
a.setData({
|
||||
loading: false
|
||||
});
|
||||
|
||||
if (res.code === 200 && res.data) {
|
||||
a.setData({
|
||||
orderInfo: res.data.orderInfo || {},
|
||||
balance: res.data.balance || 0,
|
||||
token: res.data.token || '',
|
||||
});
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: res.message || '获取数据失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
}).catch(function (err) {
|
||||
a.setData({
|
||||
loading: false
|
||||
});
|
||||
|
||||
wx.showToast({
|
||||
title: '获取数据失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 确认洗车
|
||||
*/
|
||||
confirmWash() {
|
||||
var a = this;
|
||||
|
||||
wx.showModal({
|
||||
title: '确认洗车',
|
||||
content: '确定要进行帮洗服务吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
a.payForWash();
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 支付洗车费用
|
||||
*/
|
||||
payForWash() {
|
||||
var a = this;
|
||||
|
||||
wx.showLoading({
|
||||
title: '处理中',
|
||||
mask: true
|
||||
});
|
||||
|
||||
e.request('/miniprogram/substituteWash/pay', { token: a.data.token }, true).then(function (res) {
|
||||
wx.hideLoading();
|
||||
|
||||
if (res.code === 200) {
|
||||
wx.showToast({
|
||||
title: '支付成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
});
|
||||
|
||||
// 更新余额信息和支付状态
|
||||
let updateData = {
|
||||
paySuccess: true
|
||||
};
|
||||
|
||||
if (res.data && res.data.balance !== undefined) {
|
||||
updateData.balance = res.data.balance;
|
||||
}
|
||||
|
||||
if (res.data && res.data.orderInfo) {
|
||||
updateData.orderInfo = res.data.orderInfo;
|
||||
}
|
||||
|
||||
a.setData(updateData);
|
||||
|
||||
// 可以在这里添加支付成功后的其他操作
|
||||
} else {
|
||||
wx.showModal({
|
||||
title: '支付失败',
|
||||
content: res.message || '请稍后再试',
|
||||
showCancel: false
|
||||
});
|
||||
}
|
||||
}).catch(function (err) {
|
||||
wx.hideLoading();
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
// 如果不是支付成功状态,则重新初始化页面
|
||||
if (!this.data.paySuccess) {
|
||||
var a = this;
|
||||
e.pageStart(t).then(function () {
|
||||
a.initPage();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
var a = this;
|
||||
e.pageStart(t).then(function () {
|
||||
a.initPage();
|
||||
wx.stopPullDownRefresh();
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 禁止页面分享
|
||||
*/
|
||||
onShareAppMessage: null,
|
||||
|
||||
/**
|
||||
* 返回首页
|
||||
*/
|
||||
backToIndex() {
|
||||
wx.redirectTo({
|
||||
url: '/pages/index/index'
|
||||
});
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user