Sfoglia il codice sorgente

余额结账,偶现二维码过期提示bug修改

licc 1 mese fa
parent
commit
5caee5e692
1 ha cambiato i file con 51 aggiunte e 14 eliminazioni
  1. 51 14
      src/views/order/console.vue

+ 51 - 14
src/views/order/console.vue

@@ -675,22 +675,59 @@ const confirmBalancePayment = () => {
 
   feedback.loading('正在处理余额支付...')
 
-  orderPay({ oid: params.number, code: balancePayCode.value })
-      .then((res) => {
-        console.log(res)
-        // 实际上支付成功之后,res返回的是[],如果不是实时成功,返回的是个对象, 形如:{orderId: '123456789', sn: '7895004131583689'}
-        if (res == null || res.length == 0) {
+  getUserIdByMobile({
+    mobile: balancePaymentPhone.value,
+    terminal: 1
+  }).then((response) => {
+    console.log("**getUserIdByMobile**", response)
+    const userIdByMobile = response.success && response.single ? response.single.id : null
+    queryUserMemberInfo({
+      userId: userIdByMobile,
+    }).then((res) => {
+      console.log("**queryUserMemberInfo**", res)
+      // 假设返回的数据结构中有 accountAmount 字段表示余额
+      if (res && res.success && res.single) {
+        balanceAmount.value = res.single.accountAmount || null
+        balancePayCode.value = res.single.payCode
+
+        if (!balanceAmount.value || balanceAmount.value < 0) {
+          feedback.msgError('暂无余额')
           feedback.closeLoading()
-          feedback.notifySuccess('余额结账成功' + orderData.payAmount + '元')
-          balancePaymentDialogVisible.value = false
-          showOrderConsole.value = false
-          emit('init')
+          return
         }
-      })
-      .catch((e) => {
-        console.log('=====---', e)
-        feedback.closeLoading()
-      })
+        if (balanceAmount.value && balanceAmount.value == 0) {
+          feedback.msgError('余额不足')
+          feedback.closeLoading()
+          return
+        }
+        orderPay({ oid: params.number, code: balancePayCode.value })
+            .then((res) => {
+              console.log(res)
+              // 实际上支付成功之后,res返回的是[],如果不是实时成功,返回的是个对象, 形如:{orderId: '123456789', sn: '7895004131583689'}
+              if (res == null || res.length == 0) {
+                feedback.closeLoading()
+                feedback.notifySuccess('余额结账成功' + orderData.payAmount + '元')
+                balancePaymentDialogVisible.value = false
+                showOrderConsole.value = false
+                emit('init')
+              }
+            })
+            .catch((e) => {
+              console.log('=====---', e)
+              feedback.closeLoading()
+            })
+      }
+    }).catch((error) => {
+      console.error('获取余额失败:', error)
+      balanceAmount.value = '-1'
+      balancePayCode.value = ''
+      feedback.msgError('获取余额失败')
+      feedback.closeLoading()
+    })
+  }).catch((error) => {
+    feedback.msgError('手机号查询失败')
+    feedback.closeLoading()
+  })
 }
 
 // 添加扫码事件监听函数