Forráskód Böngészése

支付成功即时逻辑修改

licc 1 hónapja
szülő
commit
22c206f0ee
2 módosított fájl, 16 hozzáadás és 14 törlés
  1. 8 7
      src/views/order/console.vue
  2. 8 7
      src/views/order/index.vue

+ 8 - 7
src/views/order/console.vue

@@ -432,7 +432,14 @@ const handleScanInput = (event: KeyboardEvent) => {
         orderPay({ oid: params.number, code: code })
           .then((res) => {
             console.log(res)
-            if (res != null) {
+            // 实际上支付成功之后,res返回的是[],如果不是实时成功,返回的是个对象, 形如:{orderId: '123456789', sn: '7895004131583689'}
+            if (res == null || res.length == 0) {
+              feedback.notifySuccess('成功结账' + orderData.payAmount + '元')
+              scanDialogVisible.value = false
+              payingDialogVisible.value = false // 隐藏支付中对话框
+              showOrderConsole.value = false
+              emit('init')
+            } else {
               console.log('支付中')
               return queryPayStatusWithRetry(res)
                   .then((paySuccess) => {
@@ -443,12 +450,6 @@ const handleScanInput = (event: KeyboardEvent) => {
                       emit('init')
                     }
                   })
-            } else {
-              feedback.notifySuccess('成功结账' + orderData.payAmount + '元')
-              scanDialogVisible.value = false
-              payingDialogVisible.value = false // 隐藏支付中对话框
-              showOrderConsole.value = false
-              emit('init')
             }
           })
           .catch(() => {

+ 8 - 7
src/views/order/index.vue

@@ -215,7 +215,14 @@ const handleScanInput = (event: KeyboardEvent) => {
         orderPay({ oid: currentDesk.oid, code: code })
           .then((res) => {
             console.log(res)
-            if (res != null) {
+            // 实际上支付成功之后,res返回的是[],如果不是实时成功,返回的是个对象, 形如:{orderId: '123456789', sn: '7895004131583689'}
+            if (res == null || res.length == 0) {
+              feedback.notifySuccess('成功结账' + currentDesk.amount + '元')
+              scanDialogVisible.value = false
+              dialogVisible.value = false
+              payingDialogVisible.value = false // 隐藏支付中对话框
+              init()
+            } else {
               console.log('支付中')
               return queryPayStatusWithRetry(res)
                   .then((paySuccess) => {
@@ -226,12 +233,6 @@ const handleScanInput = (event: KeyboardEvent) => {
                       init()
                     }
                   })
-            } else {
-              feedback.notifySuccess('成功结账' + currentDesk.amount + '元')
-              scanDialogVisible.value = false
-              dialogVisible.value = false
-              payingDialogVisible.value = false // 隐藏支付中对话框
-              init()
             }
           })
           .catch(() => {