From fb809790d865c5ec0a107c752f1a8c0be151cb9b Mon Sep 17 00:00:00 2001
From: 石广澎 <shiguangpeng@163.com>
Date: 星期五, 07 三月 2025 11:27:13 +0800
Subject: [PATCH] feat(支付):折扣券最大减免金额支持

---
 pay/scanpay.vue |   24 ++++++++++++++++++++----
 1 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/pay/scanpay.vue b/pay/scanpay.vue
index e45f7fe..e3f3f53 100644
--- a/pay/scanpay.vue
+++ b/pay/scanpay.vue
@@ -166,6 +166,7 @@
   data() {
     return {
       tips: '璇ュ晢鎴锋殏鏈紑閫氭敮浠樺姛鑳�',
+      payLoading: false,
       loading: false,
       remark: '',
       buyerNote: '',
@@ -198,12 +199,14 @@
       couponInfo: {
         id: '',
         discount: 0,
-        thresholdValue: 0
+        thresholdValue: 0,
+        discountMax: 0,
       }, // 浼樻儬鍒稿唴瀹�
       checkCoupon: {
         id: null,
         discount: 0,
-        thresholdValue: 0
+        thresholdValue: 0,
+        discountMax: 0,
       },
     };
   },
@@ -223,7 +226,10 @@
         return parseFloat(num);
       }
       const dis = 1 - parseFloat(this.checkCoupon.discount)
-      const dic = Math.floor(this.$utils.accMul(this.money,100) * dis)
+      let dic = Math.floor(this.$utils.accMul(this.money,100) * dis)
+      if(dic>this.checkCoupon.discountMax){
+        dic = this.checkCoupon.discountMax
+      }
       return this.$utils.fenToYuan(dic).toFixed(2);
     },
     discount() {
@@ -235,7 +241,10 @@
         return parseFloat(num);
       }
       const dis = 1 - parseFloat(this.couponInfo.discount)
-      const dic = Math.floor(this.$utils.accMul(this.money,100) * dis)
+      let dic = Math.floor(this.$utils.accMul(this.money,100) * dis)
+      if(dic>this.couponInfo.discountMax){
+        dic = this.couponInfo.discountMax
+      }
       return this.$utils.fenToYuan(dic).toFixed(2);
     },
     payMoney() {
@@ -427,6 +436,7 @@
               thresholdValue: res.thresholdValue,
               discount: res.discount,
               discountType: res.discountType,
+              discountMax: res.discountMax
             }
           }
         }
@@ -593,6 +603,8 @@
         return
       }
       this.bordShow = false
+      if (this.payLoading) return
+      this.payLoading = true
       // 閲戦 this.money
       uni.showLoading({
         title: '涓嬪崟涓�',
@@ -634,10 +646,12 @@
             this.aliPay(res.paymentUrl)
           }
         } catch (e) {
+          this.payLoading = false
           //TODO handle the exception
           console.error(e);
         }
       }).catch(() => {
+        this.payLoading = false
         uni.hideLoading()
       })
     },
@@ -654,6 +668,7 @@
               "paySign": res.paySign //寰俊绛惧悕
             },
             (res) => {
+              this.payLoading = false
               if (res.err_msg == "get_brand_wcpay_request:ok") {
                 // 浣跨敤浠ヤ笂鏂瑰紡鍒ゆ柇鍓嶇杩斿洖,寰俊鍥㈤槦閮戦噸鎻愮ず锛�
                 //res.err_msg灏嗗湪鐢ㄦ埛鏀粯鎴愬姛鍚庤繑鍥瀘k锛屼絾骞朵笉淇濊瘉瀹冪粷瀵瑰彲闈犮��
@@ -671,6 +686,7 @@
       ap.tradePay({
         tradeNO: res.tradeNO
       }, (res) => {
+        this.payLoading = false
         if (res.resultCode == 9000) {
           uni.navigateTo({
             url: `/pay/paySuccess?orderId=${this.orderId}&youHuiInfo=${JSON

--
Gitblit v1.9.1