Explorar o código

充值跳转2

zhaoli %!s(int64=3) %!d(string=hai) anos
pai
achega
9173338cfe
Modificáronse 2 ficheiros con 39 adicións e 30 borrados
  1. 6 2
      src/api/index.js
  2. 33 28
      src/view/pay.vue

+ 6 - 2
src/api/index.js

@@ -356,12 +356,16 @@ export function recharge({ product_id, bid, cid, use_coupon }) {
         pathname: "/pay",
         query: {
           bid,
-          cid
+          cid,
+          isRecharge: true // 是否从充值页面回去
         }
       }
     : {
         host: location.origin,
-        pathname: "/pay"
+        pathname: "/pay",
+        query: {
+          isRecharge: true // 是否从充值页面回去
+        }
       };
   const token = localStorage.getItem("token");
 

+ 33 - 28
src/view/pay.vue

@@ -474,6 +474,9 @@ export default {
       return Number(special_value.replace("元", ""));
     }
   },
+  mounted() {
+    this.popup()
+  },
   methods: {
     changeCoupon() {
       if (this.availdCouponList.length <= 0) {
@@ -509,41 +512,43 @@ export default {
         Number(this.product[this.selectedProduct].price.replace("元", ""))
       );
     },
+    popup() {
+      const from_where = this.$route.query.from_where;
+      const msg = "";
+      if(this.$route.query.isRecharge){
+        MessageBox({
+          title: "支付确认",
+          message:
+            '1.请在微信内完成支付,如果您已经支付成功,请点击"已完成支付"按钮</br>2.请确保微信版本高于6.0.2',
+          confirmButtonText: "已完成支付", //确认按钮的文本
+          cancelButtonText: "取消", //取消按钮的文本
+          confirmButtonHighlight: true, // 是否将确认按钮的文本加粗显示
+          showCancelButton: true,//是否显示取消按钮
+          showConfirmButton: true //是否显示确认按钮
+        }).then(action => {
+          if (action === "confirm") {
+            if (from_where && from_where === 1){
+              this.$router.replace({
+                name: Reader.name,
+                query: {
+                  bid: this.$route.query.book_id,
+                  cid: this.$route.query.chapter_id
+                }
+              });
+            }else {
+              this.$router.back();
+            }
+          }
+        })
+      } 
+    },
     pay() {
       recharge({
         product_id: this.product[this.selectedProduct].product_id,
         bid: this.$route.query.book_id,
         cid: this.$route.query.chapter_id,
         use_coupon: this.currentCoupon.id
-      });
-      const from_where = this.$route.query.from_where;
-      const msg = "";
-      // this.setTimeout(() => {
-        MessageBox({
-        title: "支付确认",
-        message:
-          '1.请在微信内完成支付,如果您已经支付成功,请点击"已完成支付"按钮</br>2.请确保微信版本高于6.0.2',
-        confirmButtonText: "已完成支付", //确认按钮的文本
-        cancelButtonText: "取消", //取消按钮的文本
-        confirmButtonHighlight: true, // 是否将确认按钮的文本加粗显示
-        showCancelButton: true,//是否显示取消按钮
-        showConfirmButton: true //是否显示确认按钮
-      }).then(action => {
-        if (action === "confirm") {
-          if (from_where && from_where === 1){
-            this.$router.replace({
-              name: Reader.name,
-              query: {
-                bid: this.$route.query.book_id,
-                cid: this.$route.query.chapter_id
-              }
-            });
-          }else {
-            this.$router.back();
-          }
-        }
       })
-      // }, 0);
     },
     payForYear() {
       let product_id = this.product[this.product.length - 1].product_id;