This commit is contained in:
weipengfei 2024-04-05 17:45:32 +08:00
parent 6d21ce159a
commit 8b34814a90
1 changed files with 54 additions and 49 deletions

View File

@ -26,9 +26,10 @@ const open = () => {
const changeActive = (e) => {
active.value = e;
if (active.value == 2) { //
document.addEventListener('keydown', keyboard);
}else document.removeEventListener('keydown', keyboard);
if (active.value == 2) {
//
document.addEventListener("keydown", keyboard);
} else document.removeEventListener("keydown", keyboard);
};
const form = ref({});
@ -191,6 +192,8 @@ const beforeClose = () => {
reLoad.value = false;
loading.value = false;
input.value = "";
collection.value = "";
collectionArray.value = [];
codeRef.value?.blur();
emit("paySuccess");
drawer.value = false;
@ -206,12 +209,13 @@ defineExpose({
const collectionArray = ref([]);
const collection = ref(""); //
const changePrice = computed(()=>{ //
if(+collection.value>0){
const changePrice = computed(() => {
//
if (+collection.value > 0) {
return (collection.value - form.value.order_price).toFixed(2);
}
return -1;
})
});
const defaultcalc = ref(false);
//
@ -246,45 +250,43 @@ const numTap = (item) => {
};
//
const cashBnt = () => {
console.log("结算");
orderCreateApi({
address_id: "",
key: form.value.key,
cart_id: cart_id.value,
pay_type: "cash_payment",
source: 300,
})
.then((res) => {
if (res.status == 200 && res.message == "支付成功") {
drawer.value = false;
ElMessage({
message: res.message,
type: "success",
});
audioplay(res.data.message);
beforeClose();
} else {
if (!res.data.group_order_sn) {
order_id.value = res.data.result.order_id;
loading.value = false;
return ElMessage({
message: res.message,
type: "error",
});
} else {
order_id.value = res.data.group_order_id;
count.value = 0;
timecount = 0;
getOrderStatus(res.data.group_order_sn);
}
}
})
.catch((err) => {
loading.value = false;
nextTick(() => {
codeRef.value?.focus();
if(changePrice.value!=''&&changePrice.value>=0) orderCreateApi({
address_id: "",
key: form.value.key,
cart_id: cart_id.value,
pay_type: "cash_payment",
source: 300,
})
.then((res) => {
if (res.status == 200 && res.message == "支付成功") {
drawer.value = false;
ElMessage({
message: res.message,
type: "success",
});
});
audioplay(res.data.message);
beforeClose();
} else {
if (!res.data.group_order_sn) {
order_id.value = res.data.result.order_id;
collection.value = "";
collectionArray.value = [];
loading.value = false;
return ElMessage({
message: res.message,
type: "error",
});
} else {
order_id.value = res.data.group_order_id;
count.value = 0;
timecount = 0;
getOrderStatus(res.data.group_order_sn);
}
}
})
.catch((err) => {
loading.value = false;
});
};
//
@ -345,6 +347,9 @@ const keyboard = (event) => {
case 8:
delNum();
break;
case 13:
cashBnt();
break;
}
};
</script>
@ -403,9 +408,11 @@ const keyboard = (event) => {
<div class="counter">
<div class="received">
<span v-if="collection">{{ collection }}</span>
<span v-else style="font-size: 1rem;color: #999;">按下键盘输入客户支付金额</span>
<span v-else style="font-size: 1rem; color: #999"
>按下键盘输入客户支付金额</span
>
</div>
<div class="balance" v-if="changePrice>=0">
<div class="balance" v-if="changePrice >= 0">
需找零()<span class="money">{{ changePrice }}</span>
</div>
<div class="balance" v-else>不够找零, 请支付更多金额</div>
@ -433,9 +440,7 @@ const keyboard = (event) => {
</template>
<template #footer>
<div style="width: 100%; display: flex; justify-content: center">
<el-button class="cancel-btn" @click="cancelClick"
>取消收款</el-button
>
<el-button class="cancel-btn" @click="cancelClick">取消收款</el-button>
</div>
</template>
</el-drawer>