代客下单增加扫码支付

This commit is contained in:
YeMingfei666 2024-09-05 10:56:38 +08:00
parent 24a044427b
commit 2a1422d281
3 changed files with 75 additions and 32 deletions

View File

@ -50,7 +50,7 @@ export default {
},
async init() {
const res = await $getPayType();
this.list = res;
this.list = res.filter(v=>v.isDisplay);
console.log(res[0]);
this.sel = this.sel ? this.sel : res[0].payType;
},

View File

@ -52,6 +52,19 @@
</el-dialog>
</template>
<script>
function toFixedNoRounding(num) {
//
var numStr = num.toString();
//
var parts = numStr.split('.');
// 2
if (parts[1] && parts[1].length > 2) {
parts[1] = parts[1].slice(0, 2);
}
//
return parts.join('.');
}
export default {
props: {
title: {
@ -113,9 +126,7 @@ export default {
this.form.reduceMoney = money;
}
this.form.curretnMoney = (money - this.form.reduceMoney).toFixed(2);
this.form.discount = ((this.form.curretnMoney / money) * 100).toFixed(
2
);
this.form.discount =toFixedNoRounding(((this.form.curretnMoney / money) * 100).toFixed(3) )
return;
}
if (key == "discount") {
@ -145,10 +156,8 @@ export default {
this.$message.error("实收金额不能大于总金额");
this.form.curretnMoney = 0;
}
this.form.reduceMoney = (money - this.form.curretnMoney).toFixed(2);
this.form.discount = ((this.form.curretnMoney / money) * 100).toFixed(
2
);
this.form.reduceMoney = (money - this.form.curretnMoney).toFixed(2);
this.form.discount =toFixedNoRounding( ((this.form.curretnMoney / money) * 100).toFixed(3) );
return;
}
this.form.curretnMoney = ((money * discount) / 100).toFixed(2);
@ -165,7 +174,7 @@ export default {
open(data) {
console.log(data);
this.form.money = data.amount;
this.form.discount = data.discount||100;
this.form.discount = data.discount?toFixedNoRounding(data.discount.toFixed(3)):100;
this.show = true;
this.init();
},

View File

@ -950,8 +950,16 @@
<!-- 支付时的键盘弹窗 -->
<money-keyboard ref="refMoneyKeyboard" :title="moneyKeyboard.title">
</money-keyboard>
<!-- 扫码支付 -->
<!-- 扫码支付 -->
<scan-pay
ref="refWxScanCode"
defaultTips="请使用扫码枪扫描微信/支付宝收款码"
title="扫码支付"
:openSwitch="false"
:price="createOrder.data.amount * createOrder.discount"
@confirm="scanPayConfirm"
></scan-pay>
<!-- 储值卡支付 -->
<scan-pay
ref="refScanCode"
title="扫码支付"
@ -1410,14 +1418,26 @@ export default {
//
scanPayConfirm(code) {
this.createOrder.code = code;
this.payOrder();
if(!code){
return this.$message.error("请输入或扫付款码")
}
this.pays();
},
payTypeItemClick(item) {
console.log(item);
if (item.payType == "deposit") {
//
this.refToggle("refScanCode", true);
console.log(this.vipUser.id);
if(item.payType=='vipPay'){
return this.refChooseUserOpen()
}
if (item.payType == "deposit") {
//
return this.refToggle("refScanCode", true);
}
if (item.payType == "scanCode") {
//
return this.refToggle("refWxScanCode", true);
}
},
ChangeDiscount(discount) {
this.createOrder.discount = discount;
@ -1513,29 +1533,43 @@ export default {
refNoteShow() {
this.$refs.refOrderNote.open(this.note.content);
},
//
//
async payOrder() {
if(this.order.payType=='vipPay'&&!this.vipUser.id){
return this.refChooseUserOpen()
}
if(this.order.payType=='scanCode'){
return this.refToggle("refWxScanCode", true);
}
if(this.order.payType=='deposit'){
return this.refToggle("refScanCode", true);
}
console.log({
orderId: this.createOrder.data.id,
payType: this.order.payType,
});
this.loading = true;
try {
const res = await $payOrder({
tableId: this.table.tableId,
masterId: this.masterId,
orderId: this.createOrder.data.id,
payType: this.order.payType,
vipUserId: this.vipUser.id,
discount: this.createOrder.discount,
code: this.createOrder.code,
});
this.loading = false;
this.payOrderSuccess();
} catch (error) {
this.loading = false;
}
this.pays()
},
//
async pays() {
this.loading = true;
try {
const res = await $payOrder({
tableId: this.table.tableId,
masterId: this.masterId,
orderId: this.createOrder.data.id,
payType: this.order.payType,
vipUserId: this.vipUser.id,
discount: this.createOrder.discount,
code: this.createOrder.code,
});
this.loading = false;
this.payOrderSuccess();
} catch (error) {
this.loading = false;
}
},
payOrderSuccess() {
this.$notify({
title: "支付成功",