替换人脸拍照

This commit is contained in:
wangxiaowei
2026-02-02 02:37:58 +08:00
parent 1d773081ea
commit 18e0423699
4 changed files with 117 additions and 83 deletions

View File

@ -1,46 +1,36 @@
<template>
<view>
<face-bio-assay :isDev="false" :action="['StraightenHead']" ref="faceDetect" @detectFailed="photoChange" @photoChange="photoChange">
</face-bio-assay>
</view>
<!-- <@devicePosition: 摄像头位置 前置或后置摄像头值为front, back
@quality: 成像质量值为high高质量normal普通质量low低质量 -->
<view>
<hao-camera
:devicePosition="back"
:quality="low"
@confirmPhoto="confirmPhoto"
></hao-camera>
</view>
</template>
<script>
import faceBioAssay from '@/uni_modules/face-bio-assay/components/face-bio-assay/face-bio-assay.vue'
export default {
components: {
faceBioAssay,
},
data() {
import haoCamera from '@/uni_modules/hao-camera/components/hao-camera/hao-camera.vue';
export default {
components: {
haoCamera
},
data() {
return {
order_id: 0,
}
},
onLoad(args) {
this.order_id = args.order_id || 0;
this.$refs.faceDetect.initData()
},
methods: {
detectFailed() {
uni.showToast({
title: "人脸核验失败~",
icon: 'none'
})
uni.navigateBack()
},
photoChange(path) {
methods: {
confirmPhoto(filePath){
console.log("🚀 ~ filePath:", filePath)
let self = this
uni.navigateBack()
this.getOpenerEventChannel().emit('data',{path: path, order_id: self.order_id});
}
}
}
this.getOpenerEventChannel().emit('data',{path: filePath, order_id: self.order_id});
}
}
}
</script>
<style>
</style>

View File

@ -501,6 +501,7 @@
self.bill.dgf.nums = 0;
self.bill.dgf.price = 0;
self.bill.dgf.total = 0;
self.bill.unLightTotal = 0;
for (const key in self.order.trade) {
const value = self.order.trade[key];
for (const item of value) {
@ -510,6 +511,11 @@
self.bill.dgf.nums = self.order.hours;
self.bill.dgf.price = 0; // 假设每个时间段的灯光价格相同
self.bill.dgf.total += Number(item.light_price);
// 将非灯光费用累加到 unLightTotal
// if (Number(item.light_price) > 0) {
// self.bill.unLightTotal += Number(item.room_price) - Number(item.light_price);
// console.log("🚀 ~ Number(item.room_price):", Number(item.room_price), Number(item.light_price))
// }
}
}
// 保留两位小数但不四舍五入
@ -519,10 +525,17 @@
if (idx === -1) return str + (decimal > 0 ? '.' + '0'.repeat(decimal) : '');
return str.substring(0, idx + decimal + 1).padEnd(idx + decimal + 1, '0');
}
// self.bill.unLightTotal = Number(toFixedNoRound(self.bill.cdf.total - self.bill.dgf.total, 2));
console.log("🚀 ~ self.bill.unLightTotal:", self.bill.unLightTotal)
self.bill.cdf.total = Number(toFixedNoRound(self.bill.cdf.total - self.bill.dgf.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; // 记录原始总价
console.log("🚀 ~ self.bill:", self.bill)
console.log("🚀 ~ self.bill.unLightTotal:", self.bill.unLightTotal)
// }
// self.countPrice()
}
@ -847,17 +860,17 @@
return;
}
this.userAccount = this.userBalance['balance' + this.currentType];
this.userDiscount = this.balance['discount' + this.currentType];
const discount = Number(this.userDiscount) || 10; // 折扣默认10不打折
// 始终基于原始金额打折
const baseTotal = Number(this.originalTotal) || 0;
// const baseTotal = Number(this.originalTotal) || 0;
const baseTotal = Number(this.bill.cdf.total) || 0;
const finalPrice = Number((baseTotal * (discount / 10)).toFixed(2));
this.bill.dis = Number((baseTotal - finalPrice).toFixed(2));
this.bill.total = finalPrice;
this.bill.total = finalPrice + Number(this.bill.dgf.total);
console.log("🚀 ~ finalPrice:", finalPrice)
// this.payType = this.currentType;

View File

@ -484,6 +484,15 @@ export default {
} else {
// 未选中则添加
this.selectedTime[title].push(time);
// 添加后进行升序排序
this.selectedTime[title].sort((a, b) => {
// 假设时间格式为 "HH:mm" 或 "HH:mm-HH:mm"
// 只取开始时间进行比较
const getStart = t => t.includes('-') ? t.split('-')[0] : t;
const [ah, am] = getStart(a).split(":").map(Number);
const [bh, bm] = getStart(b).split(":").map(Number);
return ah !== bh ? ah - bh : am - bm;
});
}
this.countSelectedTime = Object.values(this.selectedTime).reduce((acc, times) => acc + times.length, 0);
@ -493,6 +502,7 @@ export default {
let totalPrice = 0;
let totalLightPrice = 0;
let amount_price = 0;
console.log("🚀 ~ selectedTime:", this.selectedTime)
Object.keys(this.selectedTime).forEach(roomTitle => {
const roomId = this.cdList.find(cd => cd.title === roomTitle)?.room_id;
@ -536,6 +546,11 @@ export default {
// const total = Number((totalPrice + totalLightPrice).toFixed(2)); 2025-12-30要求显示灯光费用但是不显示在总价中
const total = Number((totalPrice - 0).toFixed(2));
// 按 room_id 升序排序
room_list.sort((a, b) => {
// room_id 可能为字符串或数字,统一转为数字比较
return Number(a.room_id) - Number(b.room_id);
});
this.selectedReserveTime = room_list;
// 计算场地费用
@ -640,6 +655,7 @@ export default {
toReserve() {
let self = this
// 一进来就锁定,彻底防止高频点击
if (self.typeId == 1) {
if (self.selectedReserveTime.length === 0) {
@ -654,11 +670,20 @@ export default {
mask: true,
});
try {
const start = self.selectedReserveTime[0].day_time + ' ' + self.selectedReserveTime[0].end_time;
const start = self.selectedReserveTime[0].day_time + ' ' + self.selectedReserveTime[0].start_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);;
const startTimestamp = Math.floor(Date.parse(start.replace(/-/g, '/')) / 1000);
const endTimestamp = Math.floor(Date.parse(end.replace(/-/g, '/')) / 1000);
// let p = {
// app_id: self.getAppId(),
// ground_id: self.id,
// room_list: JSON.stringify(self.selectedReserveTime),
// type: self.typeId,
// start_end: startTimestamp + '-' + endTimestamp,
// amount_price: self.bill.total
// }
// console.log("🚀 ~ p:", p)
// 订单提交
self._post(

View File

@ -106,18 +106,13 @@
</view>
</view>
</view>
<!-- <view class="d-f a-i-c open-light" @click="buyLight" v-if="detail.order_status == 1 || detail.order_status == 2">
<image style="width: 48rpx;height: 48rpx;" src="https://xh.stnav.com/uploads/sport/light.png" ></image>
<view>购买灯光</view>
</view> -->
</template>
</view>
</view>
</view>
<!-- 购买灯光 -->
<view class="cg-order" style="margin-bottom: 20rpx;" v-if="detail.order_status == 1 || detail.order_status == 2 && ballType == 1">
<view class="cg-order" style="margin-bottom: 20rpx;" v-if="(detail.order_status == 1 || detail.order_status == 2 || detail.order_status == 3) && ballType == 1">
<view class="cg-order-title d-f a-i-c open-light">
<!-- <image style="width: 48rpx;height: 48rpx;" src="https://xh.stnav.com/uploads/sport/light.png" ></image> -->
<view>购买灯光</view>
@ -129,9 +124,9 @@
v-for="(item2, index2) in item"
:key="index2"
:class="isSelected(index, index2) ? 'date-time-btn' : 'date-time-btn-normal'"
@click="toggleSelect(index, index2, item2.room_id)"
@click="toggleSelect(index, index2, item2.room_id, item2.light_status)"
>
{{ item2.start_time }}-{{ item2.end_time }}
{{ item2.light_status == 1 ? '已购买' : `${item2.start_time}-${item2.end_time}`}}
</view>
</view>
</view>
@ -338,35 +333,6 @@
</view>
</Popup>
<!-- 开灯弹窗 -->
<Popup :show="openLightPopup" radius="16rpx">
<view class="light-popup">
<view class="title">提示</view>
<view class="desc">
<view class="rule">请选择要开灯的场地</view>
<scroll-view scroll-y="true" enhanced="true" :show-scrollbar="false" style="height: 500rpx;">
<view class="desc" v-for="(item, index) in detail.trade" :key="index">
<view class="fb" style="margin: 20rpx 0;">{{ index }}</view>
<view class="date-grid">
<view
:class="isSelected(index, index2) ? 'date-time-btn' : 'date-time-btn-normal'"
v-for="(item2, index2) in item"
:key="index2"
@click="toggleSelect(index, index2, item2.room_id)"
>
{{ item2.start_time }}-{{ item2.end_time }}
</view>
</view>
</view>
</scroll-view>
</view>
<view class="btn">
<view class="btn1" @click="openLightPopup = false">取消</view>
<view class="btn2" @click="getSelectedContent">确定</view>
</view>
</view>
</Popup>
<!-- 会员卡选择弹窗 -->
<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">
@ -481,8 +447,9 @@
userBalance: {},
currentType: '', // 选择的会员卡类型
userAccount: 0,
userDiscount: 0
userDiscount: 0,
lightDateTime: '',
lightPrice: 0,
};
},
onLoad(e) {
@ -829,12 +796,36 @@
return this.selectedTimes.some(sel => sel.group === groupIdx && sel.idx === idx);
},
toggleSelect(groupIdx, idx, roomId) {
toggleSelect(groupIdx, idx, roomId, status) {
if (status == 1) {
uni.showToast({
icon: 'none',
title: '已支付过灯光费用',
mask: false,
duration: 1000
});
return;
}
const found = this.selectedTimes.findIndex(sel => sel.group === groupIdx && sel.idx === idx);
if (found > -1) {
this.selectedTimes.splice(found, 1);
} else {
this.selectedTimes.push({ group: groupIdx, idx, roomId });
let self = this
self.loadding = true
self._post(
'ground.ground/groundRoomDetails',
{
app_id: self.getAppId(),
id: roomId, // 场馆包间ID
},
function(res) {
console.log("🚀 ~ res:", res)
self.detail.trade[groupIdx][idx].light_price = res.data.lists.set_light_price
self.selectedTimes.push({ group: groupIdx, idx, roomId });
}
)
self.loadding = false
}
},
@ -848,19 +839,31 @@
const result = [];
const trade = self.detail.trade || [];
const roomMap = {};
self.lightDateTime = ''
self.lightPrice = 0
self.selectedTimes.forEach(sel => {
if (!roomMap[sel.roomId]) roomMap[sel.roomId] = [];
// 获取时间段
const item = trade[sel.group] && trade[sel.group][sel.idx];
console.log("🚀 ~ item:", item)
if (item) {
roomMap[sel.roomId].push(`${item.start_time}-${item.end_time}`);
self.lightDateTime = item.day_time
self.lightPrice += parseFloat(item.light_price)
}
});
Object.keys(roomMap).forEach(roomId => {
result.push({ room_id: roomId, arr: roomMap[roomId].join(',') });
});
self.content = result;
console.log("🚀 ~ item lightDateTime:", self.lightDateTime)
console.log("🚀 ~ item lightPrice:", self.lightPrice)
console.log("🚀 ~ self.content:", self.content)
if (self.detail.light_order == 1) {
uni.showModal({
title: '提示',
@ -915,12 +918,15 @@
uni.showLoading({
title: '正在处理'
});
console.log(123123)
self._post(
'order.GroundOrder/addLightStoreOrder', {
order_id: self.order_id,
room_id: '',
ground_id: self.detail.ground_id,
content: JSON.stringify(self.content)
content: JSON.stringify(self.content),
day_time: self.lightDateTime,
light_price: self.lightPrice,
},
function(res) {
uni.hideLoading();