完善功能
This commit is contained in:
@ -19,7 +19,8 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="title2 d-b-c">
|
||||
<view>场地费(¥{{ bill.cdf.price }}元/小时)</view>
|
||||
<!-- <view>场地费(¥{{ bill.cdf.price }}元/小时)</view> -->
|
||||
<view>小时</view>
|
||||
<view>x{{ bill.cdf.nums }}</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -46,7 +47,8 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="title2 d-b-c">
|
||||
<view>灯光费(¥{{ bill.dgf.price }}元/小时)</view>
|
||||
<!-- <view>灯光费(¥{{ bill.dgf.price }}元/小时)</view> -->
|
||||
<view>小时</view>
|
||||
<view>x{{ bill.dgf.nums }}</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -56,7 +58,7 @@
|
||||
<view class="title1 d-b-c">
|
||||
<view>折扣优惠</view>
|
||||
<view>
|
||||
<price-format color="#FA2B21" :subscript-size="30" :first-size="30" :second-size="30" :price="bill.dis" :showSubscript="false"></price-format>
|
||||
<text style="color: #FA2B21;"> -</text> <price-format color="#FA2B21" :subscript-size="30" :first-size="30" :second-size="30" :price="bill.dis"></price-format>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -76,7 +78,7 @@
|
||||
<view class="d-f d-c j-c-b">
|
||||
<view>
|
||||
合计: <price-format color="#FF5951" :subscript-size="26" :first-size="40" :second-size="40" :price="bill.total"></price-format>
|
||||
<text style="margin-left: 10rpx;color: #FA2B21;font-size: 26rpx;">{{ userDiscount }}折</text>
|
||||
<text style="margin-left: 10rpx;color: #FA2B21;font-size: 26rpx;" v-if="userDiscount > 0">{{ userDiscount }}折</text>
|
||||
</view>
|
||||
<view class="d-f j-c-c a-i-c" style="margin-top: 10rpx;" @click="closeBillPopup">
|
||||
<view class="price-detail">费用明细</view>
|
||||
@ -360,7 +362,17 @@
|
||||
},
|
||||
|
||||
onLoad(args) {
|
||||
console.log("🚀 ~ args:", args)
|
||||
// let bill = uni.getStorageSync('billDetail');
|
||||
// // if (!bill) {
|
||||
// // uni.showToast({ title: '获取订单信息失败,请重试', icon: 'none' });
|
||||
// // return
|
||||
// // }
|
||||
// if (bill) {
|
||||
// bill = JSON.parse(bill);
|
||||
// this.bill = bill
|
||||
// }
|
||||
|
||||
// console.log("🚀 ~ args:", this.bill)
|
||||
this.orderId = args.orderId || 0; // 订单ID
|
||||
this.venueId = args.venueId || 0; // 场馆ID
|
||||
this.typeId = args.typeId || 1; // 网球场1 篮球场2
|
||||
@ -371,6 +383,7 @@
|
||||
},
|
||||
|
||||
onUnload() {
|
||||
uni.removeStorageSync('billDetail')
|
||||
switch(this.result) {
|
||||
case 'success':
|
||||
uni.$emit('payment', { result: true, order_id: this.orderId })
|
||||
@ -380,7 +393,6 @@
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
methods: {
|
||||
// 判断 payType 是否为整数
|
||||
isPayTypeInt() {
|
||||
@ -446,7 +458,6 @@
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
// 获取订单详情
|
||||
self._post(
|
||||
'order.groundOrder/orderGroundDetails',
|
||||
@ -459,7 +470,22 @@
|
||||
self.order = res.data.lists;
|
||||
self.countSelectedTime = self.order.hours
|
||||
|
||||
self.countPrice()
|
||||
// 缓存不存在则直接从订单详情中获取费用明细
|
||||
// if (!uni.getStorageSync('billDetail')) {
|
||||
for (const key in self.order.trade) {
|
||||
const value = self.order.trade[key];
|
||||
for (const item of value) {
|
||||
self.bill.cdf.nums = self.order.hours;
|
||||
self.bill.cdf.price = 0; // 假设每个时间段的价格相同
|
||||
self.bill.cdf.total += Number(item.room_price);
|
||||
self.bill.dgf.nums = self.order.hours;
|
||||
self.bill.dgf.price = 0; // 假设每个时间段的灯光价格相同
|
||||
self.bill.dgf.total += Number(item.light_price);
|
||||
}
|
||||
}
|
||||
self.bill.total = self.bill.cdf.total + self.bill.dgf.total;
|
||||
// }
|
||||
// self.countPrice()
|
||||
}
|
||||
|
||||
self.loadding = false;
|
||||
@ -528,6 +554,13 @@
|
||||
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
|
||||
this.balancePopup = false;
|
||||
}
|
||||
},
|
||||
@ -581,7 +614,22 @@
|
||||
},
|
||||
function(res) {
|
||||
const data = res.data
|
||||
console.log("🚀 ~ pay data:", data)
|
||||
// 支付订单为0的情况下直接返回成功
|
||||
if (data.pay_success && data.pay_success == 1) {
|
||||
self.result = 'success'
|
||||
uni.showToast({
|
||||
title: '支付成功',
|
||||
icon: 'none'
|
||||
});
|
||||
self.loadding = false;
|
||||
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({delta: 1})
|
||||
}, 500);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
uni.requestPayment({
|
||||
provider: 'wxpay',
|
||||
timeStamp: data.payment.timeStamp,
|
||||
@ -646,8 +694,8 @@
|
||||
'ground.ground/yuePay',
|
||||
{
|
||||
app_id: self.getAppId(),
|
||||
order_id: this.orderId,
|
||||
pay_type: this.currentType
|
||||
order_id: self.orderId,
|
||||
pay_type: self.currentType
|
||||
},
|
||||
function(res) {
|
||||
if (res.code == 1) {
|
||||
@ -730,9 +778,9 @@
|
||||
}
|
||||
},
|
||||
|
||||
// 确认选择
|
||||
// 确认选择充值卡
|
||||
confirmCard() {
|
||||
if (this.userBalance['balance' + this.currentType] <= 0) {
|
||||
if (this.userBalance['balance' + this.currentType] <= 0 && this.bill.total > 0) {
|
||||
uni.showToast({
|
||||
title: '余额不足,请选择其他会员卡',
|
||||
icon: 'none'
|
||||
@ -742,8 +790,17 @@
|
||||
|
||||
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));
|
||||
this.bill.total = finalPrice;
|
||||
|
||||
this.payType = this.currentType;
|
||||
this.countPrice();
|
||||
// this.countPrice();
|
||||
this.balancePopup = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,7 +26,8 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="title2 d-b-c">
|
||||
<view>场地费(¥{{ bill.cdf.price }}元/小时)</view>
|
||||
<!-- <view>场地费(¥{{ bill.cdf.price }}元/小时)</view> -->
|
||||
<view>小时</view>
|
||||
<view>x{{ bill.cdf.nums }}</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -53,7 +54,8 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="title2 d-b-c">
|
||||
<view>灯光费(¥{{ bill.dgf.price }}元/小时)</view>
|
||||
<!-- <view>灯光费(¥{{ bill.dgf.price }}元/小时)</view> -->
|
||||
<view>小时</view>
|
||||
<view>x{{ bill.dgf.nums }}</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -161,7 +163,7 @@
|
||||
<view class="" style="margin-bottom: 6rpx; text-align: center;">{{ item2.title }}</view>
|
||||
<view
|
||||
v-for="(item3, index3) in item2.time" :key="index3"
|
||||
@click="handleSelectTime(item2.title, item3.t, item3.status, item2.room_id)"
|
||||
@click="handleSelectTime(item2.title, item3.t, item3.status, item2.room_id, item3.price, item3.light_price)"
|
||||
class="cg-info-time" :class="[
|
||||
item3.status == 1
|
||||
? 'cg-info-time-none'
|
||||
@ -169,8 +171,10 @@
|
||||
? 'cg-info-time-select'
|
||||
: 'cg-info-time-normal'
|
||||
]" >
|
||||
<!-- <template v-if="item3.t != '22:00'"> -->
|
||||
<template v-if="item3.price > 0">¥{{ item3.price }}</template>
|
||||
<template v-else>免费</template>
|
||||
<!-- </template> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -281,6 +285,7 @@ export default {
|
||||
selectedWeekDay: '',
|
||||
selectedReserveTime: [],
|
||||
countSelectedTime: 0,
|
||||
roomSelectList: []
|
||||
};
|
||||
},
|
||||
|
||||
@ -392,35 +397,40 @@ export default {
|
||||
|
||||
// 计算费用明细
|
||||
totalPrice() {
|
||||
let self = this
|
||||
// let self = this
|
||||
|
||||
self._post(
|
||||
'ground.ground/countPrice',
|
||||
{
|
||||
app_id: self.getAppId(),
|
||||
room_id: self.id,
|
||||
nums: this.countSelectedTime,
|
||||
type_id: self.venue.type_id,
|
||||
},
|
||||
function(res) {
|
||||
const result = res.data.lists
|
||||
self.bill = {
|
||||
total: result.order_amount,
|
||||
cdf: {
|
||||
nums: result.nums,
|
||||
price: result.room_price,
|
||||
total: result.room_all_price
|
||||
},
|
||||
dgf: {
|
||||
nums: result.nums,
|
||||
price: result.light_price,
|
||||
total: result.light_all_price
|
||||
}
|
||||
}
|
||||
// self._post(
|
||||
// 'ground.ground/countPrice',
|
||||
// {
|
||||
// app_id: self.getAppId(),
|
||||
// room_id: self.id,
|
||||
// nums: this.countSelectedTime,
|
||||
// type_id: self.venue.type_id,
|
||||
// day: this.selectedWeekTimes,
|
||||
// room_msg: JSON.stringify(this.roomSelectList)
|
||||
// },
|
||||
// function(res) {
|
||||
// const result = res.data.lists
|
||||
// self.bill = {
|
||||
// total: result.order_amount,
|
||||
// cdf: {
|
||||
// nums: result.nums,
|
||||
// price: result.room_price,
|
||||
// total: result.room_all_price
|
||||
// },
|
||||
// dgf: {
|
||||
// nums: result.nums,
|
||||
// price: result.light_price,
|
||||
// total: result.light_all_price
|
||||
// }
|
||||
// }
|
||||
|
||||
// self.loadding = false;
|
||||
// }
|
||||
// )
|
||||
|
||||
// TODO 暂时前端写
|
||||
|
||||
self.loadding = false;
|
||||
}
|
||||
)
|
||||
},
|
||||
|
||||
// 显示费用明细
|
||||
@ -434,7 +444,7 @@ export default {
|
||||
this.showPrice = true;
|
||||
},
|
||||
|
||||
// 篮球场-立即预约
|
||||
// 立即预约
|
||||
toReserve() {
|
||||
let self = this
|
||||
// 一进来就锁定,彻底防止高频点击
|
||||
@ -451,6 +461,12 @@ export default {
|
||||
mask: true,
|
||||
});
|
||||
try {
|
||||
const start = self.selectedReserveTime[0].day_time + ' ' + self.selectedReserveTime[0].end_time;
|
||||
const end = self.selectedReserveTime[self.selectedReserveTime.length -1].day_time + ' ' + self.selectedReserveTime[self.selectedReserveTime.length -1].end_time;
|
||||
// 转换为时间戳
|
||||
const startTimestamp = Math.floor(Date.parse(start.replace(/-/g, '/')) / 1000);;
|
||||
const endTimestamp = Math.floor(Date.parse(end.replace(/-/g, '/')) / 1000);;
|
||||
|
||||
// 订单提交
|
||||
self._post(
|
||||
'order.groundOrder/submitStoreOrder',
|
||||
@ -458,12 +474,16 @@ export default {
|
||||
app_id: self.getAppId(),
|
||||
ground_id: self.id,
|
||||
room_list: JSON.stringify(self.selectedReserveTime),
|
||||
type: this.typeId,
|
||||
start_end: self.selectedReserveTime[0].start_time + '-' + self.selectedReserveTime[self.selectedReserveTime.length -1].end_time
|
||||
type: self.typeId,
|
||||
start_end: startTimestamp + '-' + endTimestamp,
|
||||
amount_price: self.bill.total
|
||||
},
|
||||
function(res) {
|
||||
self.loadding = false;
|
||||
if(res.code) {
|
||||
// 记录费用明细到缓存中
|
||||
// uni.setStorageSync('billDetail', JSON.stringify(self.bill));
|
||||
|
||||
uni.$on('payment', params => {
|
||||
console.log("🚀 ~ params:", params)
|
||||
uni.showLoading({
|
||||
@ -511,10 +531,16 @@ export default {
|
||||
url: `/bundle/reserve/confirm?venueId=${self.venue.id}&roomId=${self.id}&typeId=${self.typeId}`
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @param title
|
||||
* @param time
|
||||
* @param status
|
||||
*/
|
||||
handleSelectTime(title, time, status) {
|
||||
let self = this
|
||||
if (status == 1) {
|
||||
return;
|
||||
}
|
||||
@ -530,16 +556,27 @@ export default {
|
||||
// 未选中则添加
|
||||
this.selectedTime[title].push(time);
|
||||
}
|
||||
|
||||
this.countSelectedTime = Object.values(this.selectedTime).reduce((acc, times) => acc + times.length, 0);
|
||||
this.totalPrice()
|
||||
|
||||
// 遍历所有已选时间,生成 room_list
|
||||
const room_list = [];
|
||||
|
||||
let totalPrice = 0;
|
||||
let totalLightPrice = 0;
|
||||
let amount_price = 0;
|
||||
|
||||
Object.keys(this.selectedTime).forEach(roomTitle => {
|
||||
const roomId = this.cdList.find(cd => cd.title === roomTitle)?.room_id;
|
||||
const room = this.cdList.find(cd => cd.title === roomTitle);
|
||||
|
||||
this.selectedTime[roomTitle].forEach(t => {
|
||||
const timeObj = room?.time?.find(item => item.t === t);
|
||||
if (timeObj) {
|
||||
totalPrice += Number(timeObj.price) || 0;
|
||||
totalLightPrice += Number(timeObj.light_price) || 0;
|
||||
amount_price = Number(timeObj.price) + Number(timeObj.light_price);
|
||||
}
|
||||
|
||||
// t 可能是 '09:00-10:00' 或 '09:00', 需拆分
|
||||
let start_time = t, end_time = '';
|
||||
if (t.includes('-')) {
|
||||
@ -557,24 +594,73 @@ export default {
|
||||
day_time: this.selectedWeekTimes,
|
||||
start_time,
|
||||
end_time,
|
||||
room_price: timeObj ? timeObj.price : 0,
|
||||
light_price: timeObj ? timeObj.light_price : 0,
|
||||
amount_price,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
this.selectedReserveTime = room_list;
|
||||
console.log('🚀 ~ room_list:', this.selectedReserveTime);
|
||||
|
||||
// 计算场地费用
|
||||
self.bill = {
|
||||
total: Number(totalPrice) + Number(totalLightPrice),
|
||||
cdf: {
|
||||
nums: this.countSelectedTime,
|
||||
price: 0, // 假设单价100元/小时,实际应从后端获取
|
||||
total: totalPrice
|
||||
},
|
||||
dgf: {
|
||||
nums: this.countSelectedTime,
|
||||
price: 0,
|
||||
total: totalLightPrice
|
||||
}
|
||||
};
|
||||
|
||||
// 新增:生成 roomSelectList 变量
|
||||
const roomSelectList = Object.keys(this.selectedTime).map(roomTitle => {
|
||||
const roomId = this.cdList.find(cd => cd.title === roomTitle)?.room_id;
|
||||
const select_time = (this.selectedTime[roomTitle] || []).join(',');
|
||||
return {
|
||||
room_id: roomId,
|
||||
select_time
|
||||
};
|
||||
});
|
||||
this.roomSelectList = roomSelectList;
|
||||
this.totalPrice()
|
||||
console.log('🚀 ~ roomSelectList:', roomSelectList);
|
||||
},
|
||||
|
||||
// 选择日期
|
||||
selectWeek(item, index) {
|
||||
let self = this
|
||||
self.currentWeek = index
|
||||
self.selectedWeekDay = item.value[1] + '' + item.value[0]
|
||||
self.selectedWeekTimes = item.times
|
||||
|
||||
// 重置费用明细
|
||||
self.bill = {
|
||||
total: 0,
|
||||
cdf: {
|
||||
nums: 0,
|
||||
price: 0, // 假设单价100元/小时,实际应从后端获取
|
||||
total: 0
|
||||
},
|
||||
dgf: {
|
||||
nums: 0,
|
||||
price: 0,
|
||||
total: 0
|
||||
}
|
||||
};
|
||||
|
||||
// 重置已选时间
|
||||
self.selectedTime = []
|
||||
self.selectedReserveTime = []
|
||||
self.getReserveTime()
|
||||
},
|
||||
|
||||
// 获取预定时间
|
||||
getReserveTime() {
|
||||
let self = this;
|
||||
let params = {}
|
||||
@ -601,8 +687,13 @@ export default {
|
||||
self.timeList = res.data.lists3
|
||||
|
||||
// 初始化选择的时间
|
||||
if (!self.selectedWeekDay) {
|
||||
self.selectedWeekDay = res.data.lists2[0].value[1] + '' + res.data.lists2[0].value[0]
|
||||
}
|
||||
|
||||
if (!self.selectedWeekTimes) {
|
||||
self.selectedWeekTimes = res.data.lists2[0].times
|
||||
}
|
||||
|
||||
self.loadding = false
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name" : "星及茗茶",
|
||||
"appid" : "__UNI__0C79E17",
|
||||
"description" : "星及茗茶",
|
||||
"name" : "秀湖网球中心",
|
||||
"appid" : "__UNI__A95F43A",
|
||||
"description" : "秀湖网球中心",
|
||||
"versionName" : "2.0.1",
|
||||
"versionCode" : 201,
|
||||
"transformPx" : false,
|
||||
|
||||
@ -440,13 +440,17 @@
|
||||
self.cancelReservePopup = false;
|
||||
|
||||
if(res.code) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
duration: 2000,
|
||||
icon: 'success'
|
||||
});
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
self.getData();
|
||||
}, 500);
|
||||
} else {
|
||||
uni.hideLoading();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user