代客下单增加扫码支付
This commit is contained in:
parent
24a044427b
commit
2a1422d281
|
|
@ -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;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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: "支付成功",
|
||||
|
|
|
|||
Loading…
Reference in New Issue