feat(index): 添加单次消费选项和支付功能

新增单次消费档位选择弹窗及支付功能
移除未使用的组件和配置文件
This commit is contained in:
2025-12-14 12:18:24 +08:00
parent 2affab534c
commit 85ceb86058
16 changed files with 109 additions and 709 deletions

View File

@@ -16,7 +16,10 @@ Page({
tabStatus: {
coupon: !1,
shop: !1
}
},
showOneTimeOptions: !1,
oneTimeOptions: [],
oneTimeLoading: !1
},
bindViewTap: function () {
wx.navigateTo({
@@ -184,24 +187,100 @@ Page({
e.globalData.needJumpUrl = !1, this.isneedUpload = !0;
var t = this;
if (console.log("this.isSubmit", this.isSubmit), this.isSubmit) return !1;
if (t.data.user.money <= 0) return t.startup(), !1;
if (t.data.user.money < 10) {
if (this.isshowModal) return t.startup(), !1;
this.isshowModal = !0, wx.showModal({
wx.showActionSheet({
itemList: ["单次消费", "立即启动"],
success: function (res) {
if (res.tapIndex === 0) {
t.openOneTimeOptions();
} else {
if (t.data.user.money == 0) {
wx.showModal({
title: "提示",
content: "您的洗车金额为0元是否需要购买洗车金额",
confirmText: "去购买",
cancelText: "取消",
success: function (m) {
if (m.confirm) {
wx.navigateTo({
url: "/pages/voucher/voucher"
}), t.isneedUpload = !0;
}
}
});
return;
}
else if (t.data.user.money < 10) {
wx.showModal({
title: "提示",
content: "洗车金额不足10元是否需要购买洗车金额还是直接开机",
confirmText: "去购买",
cancelText: "直接开机",
success: function (m) {
if (m.confirm) {
wx.navigateTo({
url: "/pages/voucher/voucher"
}), t.isneedUpload = !0;
} else {
t.startup();
}
}
});
return;
}
t.startup();
}
}
});
},
openOneTimeOptions: function () {
var a = this;
if (a.data.oneTimeLoading) return !1;
a.setData({ oneTimeLoading: !0 });
t.request('/v2/miniprogram/recharge/once', e.globalData.deviceData || {}, !0).then(function (res) {
a.setData({
oneTimeOptions: res.data && res.data.list ? res.data.list : (res.data || []),
showOneTimeOptions: !0,
oneTimeLoading: !1
});
}).catch(function () {
a.setData({ oneTimeLoading: !1 });
});
},
closeOneTimeOptions: function () {
this.setData({ showOneTimeOptions: !1 });
},
payOneTime: function (evt) {
var a = this, i = evt.currentTarget.dataset.id;
if (!i) return !1;
wx.showLoading({ title: "" });
t.request('/v2/miniprogram/recharge/once/create', {
id: i,
devicecode: e.globalData.devicecode
}, !0).then(function (res) {
if (wx.hideLoading(), 200 != res.code) return wx.showModal({
title: "提示",
content: "账户余额小于10元是否立即购买洗车金额",
confirmText: "去购买",
cancelText: "立即启动",
success: function (e) {
e.confirm ? (wx.navigateTo({
url: "/pages/voucher/voucher"
}), t.isneedUpload = !0) : t.startup();
},
fail: function (e) {
console.log("fail:", e);
content: res.message || ""
}), !1;
var r = res.data.result;
wx.requestPayment({
timeStamp: r.timeStamp,
nonceStr: r.nonceStr,
package: r.package,
signType: r.signType,
paySign: r.paySign,
success: function () {
a.setData({ showOneTimeOptions: !1 });
wx.showModal({
title: "提示",
content: "限单次洗车"
});
a.getData();
a.startup();
}
});
} else t.startup();
}).catch(function () {
wx.hideLoading();
});
},
startup: function () {
var a = this;
@@ -242,4 +321,4 @@ Page({
});
},
onShareAppMessage: function () { }
});
});

View File

@@ -24,4 +24,16 @@
<view bindtap="toStart" class="scan-btn" wx:if="{{isScan}}">
<view class="sha">立即启动</view>
</view>
</view>
<view class="one-time-modal" wx:if="{{showOneTimeOptions}}">
<view class="one-time-inner">
<view class="one-time-title">选择单次消费档位</view>
<view class="one-time-tip">限单次洗车</view>
<view class="one-time-list">
<view class="one-time-item" wx:for="{{oneTimeOptions}}" wx:key="index" bindtap="payOneTime" data-id="{{item.id}}">
<view>支付{{item.paymentamount}}元 后到账{{item.arrivalamount}}元洗车金</view>
</view>
</view>
<view bindtap="closeOneTimeOptions" class="one-time-cancel">取消</view>
</view>
</view>
</view>