完善功能
This commit is contained in:
@ -46,11 +46,11 @@
|
||||
<price-format color="#303133" :subscript-size="30" :first-size="30" :second-size="30" :price="bill.dgf.total"></price-format>
|
||||
</view>
|
||||
</view>
|
||||
<view class="title2 d-b-c">
|
||||
<!-- <view class="title2 d-b-c"> -->
|
||||
<!-- <view>灯光费(¥{{ bill.dgf.price }}元/小时)</view> -->
|
||||
<view>小时</view>
|
||||
<!-- <view>小时</view>
|
||||
<view>x{{ bill.dgf.nums }}</view>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
<!-- 使用余额支付优惠的折扣 -->
|
||||
@ -94,7 +94,7 @@
|
||||
<!-- 会员卡选择弹窗 -->
|
||||
<Popup :show="balancePopup" :width='750' :padding="0" type="bottom" backgroundColor="#fff" radius="32rpx 32rpx 0 0">
|
||||
<view class="ww100 box-s-b pop-improt typeof pr">
|
||||
<image style="width: 64rpx;height: 64rpx;position: absolute; top: 26rpx;right: 30rpx;" src="@/static/icon/close2.png" mode="" @click="balancePopup = false"></image>
|
||||
<image style="width: 64rpx;height: 64rpx;position: absolute; top: 26rpx;right: 30rpx;" src="@/static/icon/close2.png" mode="" @click="closeBalancePopup"></image>
|
||||
|
||||
<view class="d-c-c pt44">
|
||||
<text class="f34 fb">会员卡选择</text>
|
||||
@ -234,11 +234,7 @@
|
||||
<template v-if="typeId == 1">
|
||||
<view class="desc2">
|
||||
<view class="dot"></view>
|
||||
<view class="">17点前预约100元/小时</view>
|
||||
</view>
|
||||
<view class="desc2">
|
||||
<view class="dot"></view>
|
||||
<view class="">17点后需要加收灯光费,120元/小时</view>
|
||||
<view class="">18点后需要加收灯光费</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-if="typeId == 2">
|
||||
@ -276,7 +272,7 @@
|
||||
</view>
|
||||
<view class="icon-box d-c-c"><span class="icon iconfont icon-xuanze"></span></view>
|
||||
</view>
|
||||
<view :class="payType >= 1 ? 'item active' : 'item'" @tap="payTypeFunc('balance')">
|
||||
<view :class="payType == 'balance' ? 'item active' : 'item'" @tap="payTypeFunc('balance')">
|
||||
<view class="d-s-c">
|
||||
<view class="icon-box d-c-c mr10"><span class="icon iconfont icon-yue"></span></view>
|
||||
<text class="key">平台余额</text>
|
||||
@ -299,6 +295,9 @@
|
||||
<view class="d-f d-c j-c-b">
|
||||
<view class="">
|
||||
合计: <price-format color="#FF5951" :subscript-size="26" :first-size="40" :second-size="40" :price="bill.total"></price-format>
|
||||
<template v-if="userAccount > 0">
|
||||
<text style="color: #FF5951; margin-left: 10rpx;font-size: 26rpx;">{{ userDiscount }}折</text>
|
||||
</template>
|
||||
</view>
|
||||
<view class="d-f j-c-c a-i-c" style="margin-top: 10rpx;" @tap="handleShowBill">
|
||||
<view class="price-detail">费用明细</view>
|
||||
@ -328,7 +327,7 @@
|
||||
typeId: 1, // 网球场1 篮球场2
|
||||
billPopup: false,
|
||||
showPrice: true,
|
||||
adding: true,
|
||||
adding: true,
|
||||
basketballDate: null,
|
||||
venue: {},
|
||||
room: {},
|
||||
@ -347,6 +346,7 @@
|
||||
dis: 0, // 折扣优惠
|
||||
total: 0 // 总价
|
||||
},
|
||||
originalTotal: 0, // 原始总价(未打折)
|
||||
payType: 'wxpay', // 支付方式 wxpay\balance
|
||||
order: {},
|
||||
result: '',
|
||||
@ -472,6 +472,12 @@
|
||||
|
||||
// 缓存不存在则直接从订单详情中获取费用明细
|
||||
// if (!uni.getStorageSync('billDetail')) {
|
||||
self.bill.cdf.nums = 0;
|
||||
self.bill.cdf.price = 0;
|
||||
self.bill.cdf.total = 0;
|
||||
self.bill.dgf.nums = 0;
|
||||
self.bill.dgf.price = 0;
|
||||
self.bill.dgf.total = 0;
|
||||
for (const key in self.order.trade) {
|
||||
const value = self.order.trade[key];
|
||||
for (const item of value) {
|
||||
@ -483,7 +489,17 @@
|
||||
self.bill.dgf.total += Number(item.light_price);
|
||||
}
|
||||
}
|
||||
self.bill.total = self.bill.cdf.total + self.bill.dgf.total;
|
||||
// 保留两位小数但不四舍五入
|
||||
function toFixedNoRound(num, decimal) {
|
||||
const str = num.toString();
|
||||
const idx = str.indexOf('.');
|
||||
if (idx === -1) return str + (decimal > 0 ? '.' + '0'.repeat(decimal) : '');
|
||||
return str.substring(0, idx + decimal + 1).padEnd(idx + decimal + 1, '0');
|
||||
}
|
||||
self.bill.cdf.total = Number(toFixedNoRound(self.bill.cdf.total, 2));
|
||||
self.bill.dgf.total = Number(toFixedNoRound(self.bill.dgf.total, 2));
|
||||
self.bill.total = Number(toFixedNoRound(self.bill.cdf.total + self.bill.dgf.total, 2));
|
||||
self.originalTotal = self.bill.total; // 记录原始总价
|
||||
// }
|
||||
// self.countPrice()
|
||||
}
|
||||
@ -550,25 +566,32 @@
|
||||
|
||||
// 选择支付方式
|
||||
payTypeFunc(n) {
|
||||
this.payType = n;
|
||||
this.payType = n;
|
||||
if (n == 'balance') {
|
||||
this.balancePopup = true;
|
||||
} else {
|
||||
// 切换到微信支付时还原价格
|
||||
this.userAccount = 0;
|
||||
this.userDiscount = 0;
|
||||
this.currentType = '';
|
||||
// 如果是微信支付的话则重新获取订单信息
|
||||
let bill = uni.getStorageSync('billDetail') || {};
|
||||
bill = JSON.parse(bill);
|
||||
this.bill = bill
|
||||
if (typeof this.originalTotal === 'number' && !isNaN(this.originalTotal)) {
|
||||
this.bill.total = this.originalTotal;
|
||||
this.bill.dis = 0;
|
||||
}
|
||||
this.balancePopup = false;
|
||||
}
|
||||
},
|
||||
|
||||
// 去支付
|
||||
toConfirm() {
|
||||
if (this.payType == '') {
|
||||
uni.showToast({title: '请选择支付方式', icon: 'none'});
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._submitting) return;
|
||||
this._submitting = true;
|
||||
|
||||
if (this.countSelectedTime === 0) {
|
||||
uni.showToast({title: '请选择时间后再预定', icon: 'none'});
|
||||
this._submitting = false;
|
||||
@ -584,7 +607,12 @@
|
||||
};
|
||||
oldWxPay.call(this);
|
||||
setTimeout(finish, 3000); // 兜底3秒自动解锁
|
||||
} else if (this.payType >= 1) {
|
||||
} else if (this.payType == 'balance') {
|
||||
if (this.currentType == '') {
|
||||
uni.showToast({title: '请选择会员卡类型', icon: 'none'});
|
||||
setTimeout(finish, 3000); // 兜底3秒自动解锁
|
||||
return;
|
||||
}
|
||||
const oldBalancePay = this.balancePay;
|
||||
this.balancePay = (...args) => {
|
||||
oldBalancePay.apply(this, args);
|
||||
@ -655,10 +683,10 @@
|
||||
self.result = 'fail'
|
||||
self.loadding = false;
|
||||
|
||||
uni.showToast({
|
||||
title: '支付失败',
|
||||
icon: 'none'
|
||||
});
|
||||
// uni.showToast({
|
||||
// title: '支付失败',
|
||||
// icon: 'none'
|
||||
// });
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({delta: 1})
|
||||
}, 500);
|
||||
@ -780,6 +808,14 @@
|
||||
|
||||
// 确认选择充值卡
|
||||
confirmCard() {
|
||||
if (this.currentType == '') {
|
||||
uni.showToast({
|
||||
title: '请选择会员卡类型',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.userBalance['balance' + this.currentType] <= 0 && this.bill.total > 0) {
|
||||
uni.showToast({
|
||||
title: '余额不足,请选择其他会员卡',
|
||||
@ -788,22 +824,32 @@
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
this.userAccount = this.userBalance['balance' + this.currentType];
|
||||
this.userDiscount = this.balance['discount' + this.currentType];
|
||||
|
||||
const discount = Number(this.userDiscount) || 10; // 折扣,默认10(不打折)
|
||||
|
||||
const total = Number(this.bill.total) || 0;
|
||||
// 保留两位小数,不四舍五入
|
||||
const finalPrice = Number((total * (discount / 10)).toFixed(2));
|
||||
this.bill.dis = Number((total - finalPrice).toFixed(2));
|
||||
// 始终基于原始金额打折
|
||||
const baseTotal = Number(this.originalTotal) || 0;
|
||||
const finalPrice = Number((baseTotal * (discount / 10)).toFixed(2));
|
||||
this.bill.dis = Number((baseTotal - finalPrice).toFixed(2));
|
||||
this.bill.total = finalPrice;
|
||||
console.log("🚀 ~ finalPrice:", finalPrice)
|
||||
|
||||
this.payType = this.currentType;
|
||||
// this.payType = this.currentType;
|
||||
// this.countPrice();
|
||||
this.balancePopup = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// 关闭余额支付弹窗
|
||||
closeBalancePopup() {
|
||||
this.payType = 'wxpay';
|
||||
this.balancePopup = false;
|
||||
},
|
||||
},
|
||||
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@ -53,11 +53,11 @@
|
||||
<price-format color="#303133" :subscript-size="30" :first-size="30" :second-size="30" :price="bill.dgf.total"></price-format>
|
||||
</view>
|
||||
</view>
|
||||
<view class="title2 d-b-c">
|
||||
<!-- <view class="title2 d-b-c"> -->
|
||||
<!-- <view>灯光费(¥{{ bill.dgf.price }}元/小时)</view> -->
|
||||
<view>小时</view>
|
||||
<!-- <view>小时</view>
|
||||
<view>x{{ bill.dgf.nums }}</view>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
<view class="line"></view>
|
||||
@ -602,11 +602,16 @@ export default {
|
||||
});
|
||||
});
|
||||
|
||||
// 保留2位小数,不四舍五入
|
||||
totalPrice = Number(totalPrice.toFixed(2));
|
||||
totalLightPrice = Number(totalLightPrice.toFixed(2));
|
||||
const total = Number((totalPrice + totalLightPrice).toFixed(2));
|
||||
|
||||
this.selectedReserveTime = room_list;
|
||||
|
||||
// 计算场地费用
|
||||
self.bill = {
|
||||
total: Number(totalPrice) + Number(totalLightPrice),
|
||||
total: total,
|
||||
cdf: {
|
||||
nums: this.countSelectedTime,
|
||||
price: 0,
|
||||
|
||||
@ -66,10 +66,10 @@
|
||||
<price-format color="#303133" :subscript-size="30" :first-size="30" :second-size="30" price="100"></price-format>
|
||||
</view>
|
||||
</view>
|
||||
<view class="title2 d-b-c">
|
||||
<!-- <view class="title2 d-b-c">
|
||||
<view>灯光费(¥50元/小时)</view>
|
||||
<view>x3</view>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
<view class="line"></view>
|
||||
|
||||
Reference in New Issue
Block a user