代客下单增加扫码支付
This commit is contained in:
@@ -50,7 +50,7 @@ export default {
|
|||||||
},
|
},
|
||||||
async init() {
|
async init() {
|
||||||
const res = await $getPayType();
|
const res = await $getPayType();
|
||||||
this.list = res;
|
this.list = res.filter(v=>v.isDisplay);
|
||||||
console.log(res[0]);
|
console.log(res[0]);
|
||||||
this.sel = this.sel ? this.sel : res[0].payType;
|
this.sel = this.sel ? this.sel : res[0].payType;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -52,6 +52,19 @@
|
|||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<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 {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
title: {
|
title: {
|
||||||
@@ -113,9 +126,7 @@ export default {
|
|||||||
this.form.reduceMoney = money;
|
this.form.reduceMoney = money;
|
||||||
}
|
}
|
||||||
this.form.curretnMoney = (money - this.form.reduceMoney).toFixed(2);
|
this.form.curretnMoney = (money - this.form.reduceMoney).toFixed(2);
|
||||||
this.form.discount = ((this.form.curretnMoney / money) * 100).toFixed(
|
this.form.discount =toFixedNoRounding(((this.form.curretnMoney / money) * 100).toFixed(3) )
|
||||||
2
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (key == "discount") {
|
if (key == "discount") {
|
||||||
@@ -146,9 +157,7 @@ export default {
|
|||||||
this.form.curretnMoney = 0;
|
this.form.curretnMoney = 0;
|
||||||
}
|
}
|
||||||
this.form.reduceMoney = (money - this.form.curretnMoney).toFixed(2);
|
this.form.reduceMoney = (money - this.form.curretnMoney).toFixed(2);
|
||||||
this.form.discount = ((this.form.curretnMoney / money) * 100).toFixed(
|
this.form.discount =toFixedNoRounding( ((this.form.curretnMoney / money) * 100).toFixed(3) );
|
||||||
2
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.form.curretnMoney = ((money * discount) / 100).toFixed(2);
|
this.form.curretnMoney = ((money * discount) / 100).toFixed(2);
|
||||||
@@ -165,7 +174,7 @@ export default {
|
|||||||
open(data) {
|
open(data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
this.form.money = data.amount;
|
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.show = true;
|
||||||
this.init();
|
this.init();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -950,8 +950,16 @@
|
|||||||
<!-- 支付时的键盘弹窗 -->
|
<!-- 支付时的键盘弹窗 -->
|
||||||
<money-keyboard ref="refMoneyKeyboard" :title="moneyKeyboard.title">
|
<money-keyboard ref="refMoneyKeyboard" :title="moneyKeyboard.title">
|
||||||
</money-keyboard>
|
</money-keyboard>
|
||||||
|
|
||||||
<!-- 扫码支付 -->
|
<!-- 扫码支付 -->
|
||||||
|
<scan-pay
|
||||||
|
ref="refWxScanCode"
|
||||||
|
defaultTips="请使用扫码枪扫描微信/支付宝收款码"
|
||||||
|
title="扫码支付"
|
||||||
|
:openSwitch="false"
|
||||||
|
:price="createOrder.data.amount * createOrder.discount"
|
||||||
|
@confirm="scanPayConfirm"
|
||||||
|
></scan-pay>
|
||||||
|
<!-- 储值卡支付 -->
|
||||||
<scan-pay
|
<scan-pay
|
||||||
ref="refScanCode"
|
ref="refScanCode"
|
||||||
title="扫码支付"
|
title="扫码支付"
|
||||||
@@ -1410,14 +1418,26 @@ export default {
|
|||||||
//扫码支付弹窗确认
|
//扫码支付弹窗确认
|
||||||
scanPayConfirm(code) {
|
scanPayConfirm(code) {
|
||||||
this.createOrder.code = code;
|
this.createOrder.code = code;
|
||||||
this.payOrder();
|
if(!code){
|
||||||
|
return this.$message.error("请输入或扫付款码")
|
||||||
|
}
|
||||||
|
this.pays();
|
||||||
},
|
},
|
||||||
payTypeItemClick(item) {
|
payTypeItemClick(item) {
|
||||||
console.log(item);
|
console.log(item);
|
||||||
if (item.payType == "deposit") {
|
console.log(this.vipUser.id);
|
||||||
//扫码支付
|
if(item.payType=='vipPay'){
|
||||||
this.refToggle("refScanCode", true);
|
return this.refChooseUserOpen()
|
||||||
}
|
}
|
||||||
|
if (item.payType == "deposit") {
|
||||||
|
//储值卡支付
|
||||||
|
return this.refToggle("refScanCode", true);
|
||||||
|
}
|
||||||
|
if (item.payType == "scanCode") {
|
||||||
|
//扫码支付
|
||||||
|
return this.refToggle("refWxScanCode", true);
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
ChangeDiscount(discount) {
|
ChangeDiscount(discount) {
|
||||||
this.createOrder.discount = discount;
|
this.createOrder.discount = discount;
|
||||||
@@ -1513,12 +1533,26 @@ export default {
|
|||||||
refNoteShow() {
|
refNoteShow() {
|
||||||
this.$refs.refOrderNote.open(this.note.content);
|
this.$refs.refOrderNote.open(this.note.content);
|
||||||
},
|
},
|
||||||
// 支付订单
|
// 支付订单前的处理
|
||||||
async payOrder() {
|
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({
|
console.log({
|
||||||
orderId: this.createOrder.data.id,
|
orderId: this.createOrder.data.id,
|
||||||
payType: this.order.payType,
|
payType: this.order.payType,
|
||||||
});
|
});
|
||||||
|
this.pays()
|
||||||
|
},
|
||||||
|
// 支付订单
|
||||||
|
async pays() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
try {
|
try {
|
||||||
const res = await $payOrder({
|
const res = await $payOrder({
|
||||||
|
|||||||
Reference in New Issue
Block a user