|
@@ -292,8 +292,8 @@
|
|
|
:class="{
|
|
|
'is-selected': params.couponId === coupon.ticketRecordId,
|
|
|
'is-disabled':
|
|
|
- orderData.sumPriceSum < coupon.consumeScore / 100 ||
|
|
|
- orderData.sumPriceSum < coupon.useThreshold / 100
|
|
|
+ (orderData.sumPriceSum <= coupon.consumeScore / 100) ||
|
|
|
+ (orderData.sumPriceSum <= coupon.useThreshold / 100)
|
|
|
}"
|
|
|
@click="handleCouponClick(coupon)"
|
|
|
>
|
|
@@ -605,8 +605,6 @@ const selectPaymentMethod = (method: string) => {
|
|
|
checkout()
|
|
|
break
|
|
|
case 'balance':
|
|
|
- balancePaymentPhone.value = ''
|
|
|
- balanceAmount.value = ''
|
|
|
// 显示余额支付对话框
|
|
|
balancePaymentDialogVisible.value = true
|
|
|
break
|
|
@@ -656,14 +654,21 @@ const confirmBalancePayment = () => {
|
|
|
feedback.msgError('请输入手机号')
|
|
|
return
|
|
|
}
|
|
|
+ if (data.phone && balancePaymentPhone.value != data.phone){
|
|
|
+ feedback.msgError('用券的手机号和支付的手机号不一致')
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
// 验证手机号格式
|
|
|
if (!/^1[3-9]\d{9}$/.test(balancePaymentPhone.value)) {
|
|
|
feedback.msgError('请输入正确的手机号')
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- if (!balanceAmount.value || balanceAmount.value <= 0) {
|
|
|
+ if (!balanceAmount.value || balanceAmount.value < 0) {
|
|
|
+ feedback.msgError('暂无余额')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (balanceAmount.value && balanceAmount.value == 0) {
|
|
|
feedback.msgError('余额不足')
|
|
|
return
|
|
|
}
|
|
@@ -847,6 +852,7 @@ const handleCouponClick = (coupon: any) => {
|
|
|
orderData.payAmount = orderData.sumPriceSum
|
|
|
return
|
|
|
}
|
|
|
+ balancePaymentPhone.value = data.phone
|
|
|
params.couponId = coupon.ticketRecordId
|
|
|
params.couponNo = coupon.ticketNo
|
|
|
params.couponName = coupon.productName
|
|
@@ -871,7 +877,8 @@ const open = (item: any, num?: number, orderNumber?: any) => {
|
|
|
params.couponId = ''
|
|
|
params.couponNo = ''
|
|
|
params.couponName = ''
|
|
|
- //查询当前订单下的所有菜品
|
|
|
+ balancePaymentPhone.value = ''
|
|
|
+ //查询当前订单下的所有菜品
|
|
|
deskOrderedDishListAll({ id: params.number }).then((res) => {
|
|
|
res.forEach((good: { id: number; ordersDishId: number }) => {
|
|
|
good.ordersDishId = good.id
|
|
@@ -881,6 +888,7 @@ const open = (item: any, num?: number, orderNumber?: any) => {
|
|
|
data.oldGoods = JSON.parse(JSON.stringify(res)) //记录下进入时当前餐桌已有的食物
|
|
|
if (res.length > 0) {
|
|
|
data.phone = res[0].mobile
|
|
|
+ balancePaymentPhone.value = data.phone
|
|
|
params.remark = res[0].remark
|
|
|
params.userId = res[0].userId || null
|
|
|
params.couponId = res[0].ticketId || null
|
|
@@ -1018,9 +1026,10 @@ watch(balancePaymentPhone, (newVal) => {
|
|
|
terminal: 1
|
|
|
}).then((response) => {
|
|
|
console.log("**getUserIdByMobile**", response)
|
|
|
- const userIdByMobile = response.success ? response.single.id : null
|
|
|
+ const userIdByMobile = response.success && response.single ? response.single.id : null
|
|
|
if (!userIdByMobile) {
|
|
|
- feedback.msgError('手机号无效')
|
|
|
+ balanceAmount.value = null
|
|
|
+ balancePayCode.value = ''
|
|
|
return
|
|
|
}
|
|
|
queryUserMemberInfo({
|
|
@@ -1032,12 +1041,12 @@ watch(balancePaymentPhone, (newVal) => {
|
|
|
balanceAmount.value = res.single.accountAmount || null
|
|
|
balancePayCode.value = res.single.payCode
|
|
|
} else {
|
|
|
- balanceAmount.value = null
|
|
|
+ balanceAmount.value = '-1'
|
|
|
balancePayCode.value = ''
|
|
|
}
|
|
|
}).catch((error) => {
|
|
|
console.error('获取余额失败:', error)
|
|
|
- balanceAmount.value = -1
|
|
|
+ balanceAmount.value = '-1'
|
|
|
balancePayCode.value = ''
|
|
|
feedback.msgError('获取余额失败')
|
|
|
}).finally(() => {
|
|
@@ -1395,8 +1404,22 @@ const searchUserCoupons = () => {
|
|
|
params.userId = res ? res.userId || null : null
|
|
|
if (data.couponList.length == 0) {
|
|
|
feedback.msgError('暂无可用优惠券')
|
|
|
+ params.couponId = null
|
|
|
+ params.couponNo = ''
|
|
|
+ params.couponName = ''
|
|
|
+ params.couponAmount = '-'
|
|
|
+ params.userId = null
|
|
|
+ // 计算支付金额
|
|
|
+ orderData.payAmount = Number(orderData.sumPriceSum).toFixed(2)
|
|
|
+ balancePaymentPhone.value = data.phone
|
|
|
return false
|
|
|
}
|
|
|
+ data.couponList.sort((a, b) => {
|
|
|
+ // 判断优惠券是否可用
|
|
|
+ const aAvailable = orderData.sumPriceSum > a.consumeScore / 100 && (!a.useThreshold || orderData.sumPriceSum > a.useThreshold / 100);
|
|
|
+ const bAvailable = orderData.sumPriceSum > b.consumeScore / 100 && (!b.useThreshold || orderData.sumPriceSum > b.useThreshold / 100);
|
|
|
+ return bAvailable - aAvailable; // 可用的排在前面
|
|
|
+ })
|
|
|
if (params.couponId) {
|
|
|
const currentTicket = data.couponList.filter(el=>el.ticketRecordId === params.couponId)
|
|
|
if (currentTicket && currentTicket.length > 0) {
|