Browse Source

修复充值页面超额

Joe 4 years ago
parent
commit
c378859a92
1 changed files with 27 additions and 18 deletions
  1. 27 18
      pages/charge/index.vue

+ 27 - 18
pages/charge/index.vue

@@ -126,7 +126,7 @@ export default {
     }),
   },
   created() {
-    this.init()
+    this.init();
   },
   methods: {
     onInput(value) {
@@ -141,12 +141,29 @@ export default {
     switchMask() {
       this.mask = !this.mask;
     },
+    getDiscount() {
+      this.discountList = [];
+      // 拉取折扣
+      this.$axios
+        .$get("/getCardRechargeSettingList", {
+          params: {
+            stationId: this.stationId,
+            cardOilsType: this.chargeItem.cardOilsType,
+          },
+        })
+        .then((res) => {
+          if (res.retCode === 0) {
+            this.discountList = res.data[0].customerCardSettingDetailList;
+          }
+        });
+    },
     goCharge(ele) {
       this.chargeItem = ele;
+      this.getDiscount();
       this.switchMask();
     },
     charge() {
-      this.chargeAmount = this.chargeAmount.replace(/\.$/g, "");
+      this.chargeAmount = this.chargeAmount.toString().replace(/\.$/g, "");
       this.pay();
     },
     init() {
@@ -173,19 +190,6 @@ export default {
         .then((res) => {
           this.stationInfo = res.data;
         });
-      // 拉取折扣
-      this.$axios
-        .$get("/getCardRechargeSettingList", {
-          params: {
-            stationId: this.stationId,
-          },
-        })
-        .then((res) => {
-          if (res.retCode === 0) {
-            this.discountList = res.data[0].customerCardSettingDetailList;
-            console.log(this.discountList);
-          }
-        });
     },
     async pay() {
       try {
@@ -211,7 +215,6 @@ export default {
             : this.chargeItem.cardOilsType == 2
             ? "柴油电子卡充值"
             : "");
-        console.log(subject);
         const payInfoData = await this.$axios.$post("/rechargeBalanceSXFPay", {
           amt: this.chargeAmount,
           openId: this.openId,
@@ -226,6 +229,12 @@ export default {
         if (payInfoData.data.code !== "0000") {
           throw new Error(payInfoData.data.msg);
         }
+        if (payInfoData.data.code !== "0000") {
+          throw new Error(payInfoData.data.msg);
+        }
+        if (payInfoData.data.respData.bizCode !== "0000") {
+          throw new Error(payInfoData.data.respData.bizMsg);
+        }
         const timestamp = payInfoData.data.respData.payTimeStamp;
         const nonceStr = payInfoData.data.respData.paynonceStr;
         const packageOrg = payInfoData.data.respData.payPackage;
@@ -304,7 +313,7 @@ export default {
   top: 1.6rem;
   color: #8e9aae;
   font-size: 0.3rem;
-  font-weight:600;
+  font-weight: 600;
 }
 .charge-index .background .headline .text2 {
   position: absolute;
@@ -312,7 +321,7 @@ export default {
   top: 2.2rem;
   color: #8e9aae;
   font-size: 0.3rem;
-  font-weight:600;
+  font-weight: 600;
 }
 .charge-index .content {
   position: absolute;