From 37c1c9fa2bd8b75c5513535f414893573c62833d Mon Sep 17 00:00:00 2001 From: YeMingfei666 <1619116647@qq.com> Date: Wed, 4 Sep 2024 17:22:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=89=AB=E7=A0=81=E6=94=AF?= =?UTF-8?q?=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/table/components/pay-type.vue | 1 + .../table-diancan-components/scan-pay.vue | 65 ++++++-- src/views/table/components/table-diancan.vue | 146 +++++++++++------- 3 files changed, 148 insertions(+), 64 deletions(-) diff --git a/src/views/table/components/pay-type.vue b/src/views/table/components/pay-type.vue index 760d909..a2dfc77 100644 --- a/src/views/table/components/pay-type.vue +++ b/src/views/table/components/pay-type.vue @@ -46,6 +46,7 @@ export default { methods: { changeSel(item) { this.sel = item.payType; + this.$emit("itemClick", item); }, async init() { const res = await $getPayType(); diff --git a/src/views/table/components/table-diancan-components/scan-pay.vue b/src/views/table/components/table-diancan-components/scan-pay.vue index 5c039e0..b56c082 100644 --- a/src/views/table/components/table-diancan-components/scan-pay.vue +++ b/src/views/table/components/table-diancan-components/scan-pay.vue @@ -1,7 +1,7 @@ @@ -55,18 +62,26 @@ diff --git a/src/views/table/components/table-diancan.vue b/src/views/table/components/table-diancan.vue index 98c7bfb..a77977b 100644 --- a/src/views/table/components/table-diancan.vue +++ b/src/views/table/components/table-diancan.vue @@ -142,7 +142,7 @@ -
+
@@ -619,7 +619,12 @@
- + +
立即支付 @@ -788,24 +793,21 @@ -
@@ -950,7 +952,14 @@ - + @@ -1004,6 +1013,8 @@ export default { }, data() { return { + //整体点餐页面loading + loading: false, //台桌点餐页面打开时带来的参数 isAddGoods 加菜 isPayOrder结账 key: "", //是否是从挂单里取出来的订单 @@ -1060,7 +1071,7 @@ export default { total: 0, }, order: { - orderId:"", + orderId: "", payType: "", masterId: "", allPack: false, @@ -1133,10 +1144,13 @@ export default { canUpdate: true, //下单 createOrder: { + code: "", status: "", discount: 1, form: {}, - data: {}, + data: { + amount: 0, + }, quan: { list: [], sel: "", @@ -1323,7 +1337,7 @@ export default { }, "order.selIndex": function (val, oldval) { console.log(val); - this.order.old.selIndex=-1 + this.order.old.selIndex = -1; if (val === -1) { // return (this.order.number = 1); this.order.cacheNumber = 1; @@ -1393,6 +1407,18 @@ export default { // this.refToggle("refDiscount", true); }, methods: { + //扫码支付弹窗确认 + scanPayConfirm(code) { + this.createOrder.code = code; + this.payOrder(); + }, + payTypeItemClick(item) { + console.log(item); + if (item.payType == "scanCode") { + //扫码支付 + this.refToggle("refScanCode", true); + } + }, ChangeDiscount(discount) { this.createOrder.discount = discount; }, @@ -1493,15 +1519,22 @@ export default { orderId: this.createOrder.data.id, payType: this.order.payType, }); - 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, - }); - this.payOrderSuccess(); + 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({ @@ -1533,29 +1566,32 @@ export default { this.isCreateOrder = false; }, //生成订单 - toCreateOrderDebounce(isNowPay){ - if(this.createOrder.status!=''&&this.createOrder.status!='success'){ - return + toCreateOrderDebounce(isNowPay) { + if ( + this.createOrder.status != "" && + this.createOrder.status != "success" + ) { + return; } - this.createOrder.status='loading' - this.toCreateOrder(isNowPay) + this.createOrder.status = "loading"; + this.toCreateOrder(isNowPay); }, async toCreateOrder(isNowPay = false) { - console.log(this.order) - console.log(this.order.orderId) + console.log(this.order); + console.log(this.order.orderId); const res = await $createOrder({ masterId: this.order.masterId || this.masterId, vipUserId: this.vipUser.id, tableId: this.table.tableId, note: this.note.content, postPay: this.postPay, - orderld:this.order.orderId + orderld: this.order.orderId, }); //后付款 console.log(this.postPay); console.log(isNowPay); console.log(this.postPay && isNowPay); - this.createOrder.status='success' + this.createOrder.status = "success"; if (this.postPay && !isNowPay) { this.$notify({ title: "下单成功", @@ -1713,12 +1749,12 @@ export default { // masterId:order.carList[0].masterId // }) - const { masterId, tableId, userId, remark,id } = await $cacheOrder({ + const { masterId, tableId, userId, remark, id } = await $cacheOrder({ orderId: this.prveOrder.list[this.prveOrder.sel].orderId, isPending: false, }); this.order.orderId = id; - console.log( this.order.orderId) + console.log(this.order.orderId); this.masterId = masterId; this.isPrverOrder = true; @@ -1739,8 +1775,8 @@ export default { //删除挂单 async delPrveOrder(isRequest = true) { const { sel } = this.prveOrder; - if(this.prveOrder.list<=0||sel<0){ - return + if (this.prveOrder.list <= 0 || sel < 0) { + return; } const order = this.prveOrder.list[sel]; const orderMasterId = order.carList[0].masterId; @@ -1816,7 +1852,7 @@ export default { this.order.list = []; this.order.selIndex = -1; this.note.content = ""; - this.order.orderId="" + this.order.orderId = ""; this.$nextTick(() => { this.getCacheOrder(); }); @@ -2116,13 +2152,13 @@ export default { .filter((v) => v.specSnap.match(i)) .every((v) => { // return isCanBuy(v,this.selGoods.data.isStock) - return isCanBuy(v) + return isCanBuy(v); }); } } return prve; }, {}); - console.log(includeSkuMap) + console.log(includeSkuMap); for (let i in includeSkuMap) { for (let k in skuList) { const index = skuList[k].valueArr.findIndex((val) => val === i); @@ -2155,6 +2191,7 @@ export default { }, reset() { // this.goods.list = []; + this.loading = false; this.order.masterId = ""; this.order.list = []; this.order.query.page = 1; @@ -2162,20 +2199,21 @@ export default { this.order.list = []; this.order.selIndex = -1; this.order.old.list = []; - this.prveOrder.list=[]; - this.prveOrder.selIndex=-1 + this.prveOrder.list = []; + this.prveOrder.selIndex = -1; this.order.old.selIndex = -1; this.isCreateOrder = false; - this.createOrder.status="" + this.createOrder.status = ""; + this.createOrder.code = ""; this.note.content = ""; this.vipUser = { id: "" }; this.allPack = false; this.note.content = ""; this.isPrverOrder = false; this.createOrder.discount = 1; - this.order.cacheNumber=1 + this.order.cacheNumber = 1; this.key = ""; - this.order.orderId='' + this.order.orderId = ""; }, //获取购物车数据 async getCart() { @@ -2294,14 +2332,14 @@ export default { } else { //增加 console.log(item); - const num= item.specList[0].suit + const num = item.specList[0].suit; res = await addCart({ masterId: this.masterId, vipUserId: this.vipUser.id, productId: item.id, skuId: item.specList[0].id, tableId: this.table.tableId, - num:num<=0?1:num, // 0会删除此商品 + num: num <= 0 ? 1 : num, // 0会删除此商品 isPack: false, // 是否打包 }); this.orderListPush(res);