zhaoli 3 роки тому
батько
коміт
0813332a01
4 змінених файлів з 44 додано та 26 видалено
  1. 15 15
      src/api/index.js
  2. 1 1
      src/components/header.vue
  3. 24 7
      src/view/pay.vue
  4. 4 3
      src/view/reader.vue

+ 15 - 15
src/api/index.js

@@ -350,19 +350,19 @@ export function getProductList(bid) {
 export function recharge({ product_id, bid, cid, use_coupon }) {
   const a = document.createElement("a");
   const redirect =
-    bid && cid
-      ? {
-          host: location.origin,
-          pathname: "/reader",
-          query: {
-            bid,
-            cid
-          }
+  bid && cid
+    ?{
+        host: location.origin,
+        pathname: "/pay",
+        query: {
+          bid,
+          cid
         }
-      : {
-          host: location.origin,
-          pathname: "/recent"
-        };
+      }
+    : {
+        host: location.origin,
+        pathname: "/pay"
+      };
   const token = localStorage.getItem("token");
 
   const href = {
@@ -379,9 +379,9 @@ export function recharge({ product_id, bid, cid, use_coupon }) {
       pay_redirect_url: encodeURIComponent(urlFormat(redirect))
     }
   };
-  //window.open(urlFormat(href),'微信支付',true)
-  a.href = urlFormat(href);
-  a.click();
+  window.open(urlFormat(href),'微信支付',true)
+  // a.href = urlFormat(href);
+  // a.click();
 }
 
 //单本消费记录

+ 1 - 1
src/components/header.vue

@@ -3,7 +3,7 @@
     <header>
       <a href="javascript:history.back();"> <img src="../assets/书库-返回.png"> </a>
       <slot>
-        <span>{{$route.meta.Chinese}}</span>
+        <span>{{$route.meta.Chinese || '追书云'}}</span>
       </slot>
       <router-link :to="home"
                    v-if="!hidden_reader_menus"><img src="../assets/书库-首页.png"></router-link>

+ 24 - 7
src/view/pay.vue

@@ -406,7 +406,7 @@
   </div>
 </template>
 <script>
-import { Pay, HelpPayQrcode } from "./namespace.js";
+import { Pay, HelpPayQrcode, Reader } from "./namespace.js";
 // import product from "../mock/pay.js";
 import { MessageBox } from "mint-ui";
 import {
@@ -516,17 +516,34 @@ export default {
         cid: this.$route.query.chapter_id,
         use_coupon: this.currentCoupon.id
       });
+      const from_where = this.$route.query.from_where;
       const msg = "";
-      MessageBox({
+      // this.setTimeout(() => {
+        MessageBox({
         title: "支付确认",
         message:
           '1.请在微信内完成支付,如果您已经支付成功,请点击"已完成支付"按钮</br>2.请确保微信版本高于6.0.2',
-        confirmButtonText: "已完成支付",
-        confirmButtonHighlight: true,
-        showCancelButton: true
+        confirmButtonText: "已完成支付", //确认按钮的文本
+        cancelButtonText: "取消", //取消按钮的文本
+        confirmButtonHighlight: true, // 是否将确认按钮的文本加粗显示
+        showCancelButton: true,//是否显示取消按钮
+        showConfirmButton: true //是否显示确认按钮
       }).then(action => {
-        if (action === "confirm") this.$router.back();
-      });
+        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;

+ 4 - 3
src/view/reader.vue

@@ -494,6 +494,7 @@ export default {
         .catch(r => {
           this.loading = false;
           const data = r.data.data;
+          const from_where = 1; // from_where判断从(阅读器or个人中心)到充值页,1代表从阅读器到充值页,不传代表从个人中心到充值页
           switch (r.data.code) {
             case 10012:
               if (this.is_update) {
@@ -522,7 +523,7 @@ export default {
               break;
             case 10015:
               Chapter1(data).then(r => {
-                this.$router.push({ name: Pay.name, query: data });
+                this.$router.push({ name: Pay.name, query: data, from_where });
               });
               break;
             case 10016:
@@ -555,7 +556,7 @@ export default {
             case 10019:
               Book3(r.data.data)
                 .then(r => {
-                  this.$router.push({ name: Pay.name, query: data });
+                  this.$router.push({ name: Pay.name, query: data, from_where });
                 })
                 .catch(e => {
                   if (e === "close") {
@@ -570,7 +571,7 @@ export default {
             case 10021:
               this.$router.push({
                 name: Pay.name,
-                query: { ...data, code: r.data.code }
+                query: { ...data, code: r.data.code, from_where }
               });
               break;
             case 10022: