Przeglądaj źródła

提交支付页AB测试

XiaBx 2 lat temu
rodzic
commit
4ce07dc88f
6 zmienionych plików z 135 dodań i 56 usunięć
  1. 5 3
      src/App.vue
  2. 11 5
      src/api/index.js
  3. 1 0
      src/components/gologin/GoLogin.vue
  4. 2 1
      src/router/index.js
  5. 84 40
      src/view/pay.vue
  6. 32 7
      src/view/reader.vue

+ 5 - 3
src/App.vue

@@ -127,15 +127,17 @@ export default {
     },
     testToken() {
       const token = getKeyByWay("token");
+
       //非加桌模式下,并且没有token 并且不是访问派单落地页和阅读器直接白屏
-      if (!window.navigator.standalone) {
+      if (!window.navigator.standalone && this.$route.name != "Pay") {
         if (!token) {
-          if (this.$route.name == "Pay") {
+          /* if (this.$route.name == "Pay") {
             this.showBlank = true;
             this.toastMsg = "支付完成后,请从桌面应用重新打开,畅享阅读~";
           }else{
             this.showBlank = true;
-          }
+          } */
+          this.showBlank = true;
         }
       }
     },

+ 11 - 5
src/api/index.js

@@ -357,10 +357,11 @@ export function recharge({
   last_cid,
   sequence,
   send_order_id,
-  yun
+  yun,
+  token,
+  hashuser
 }) {
   const a = document.createElement("a");
-  const token = getKeyByWay('token');
   const redirect =
     bid && cid
       ? {
@@ -373,6 +374,8 @@ export function recharge({
             last_bid,
             last_cid,
             sequence,
+            token: token ? `${token}` : "token",
+            hashuser: hashuser ? `${hashuser}` : "hashuser",
             send_order_id,
             yun,
             isRecharge: true // 微信充值完回到充值中心,如果从目录或阅读页跳转过来,回去时需要传入上一页id或目录进行判断
@@ -382,16 +385,18 @@ export function recharge({
           host: location.origin,
           pathname: "/pay",
           query: {
-            isRecharge: true // 微信充值完回到充值中心,如果从个人中心来充值,无需传入其他参数
+            isRecharge: true, // 微信充值完回到充值中心,如果从个人中心来充值,无需传入其他参数
+            token: token ? `${token}` : "token",
+            hashuser: hashuser ? `${hashuser}` : "hashuser"
           }
         };
-  
 
   const href = {
     host: window.options.pay_url,
     query: {
       product_id: product_id,
-      token: token ? `${token}` : "",
+      token: token ? `${token}` : "token",
+      hashuser: hashuser ? `${hashuser}` : "hashuser",
       use_coupon,
       distribution_channel_id: window.options.distribution_channel_id,
       send_order_id: window.options.send_order_id,
@@ -676,6 +681,7 @@ export function newRegister(data) {
   return axios.post("/register", data);
 }
 
+
 //新版刷新token
 export function newRefreshToken(params) {
   return axios("/refreshToken", { params });

+ 1 - 0
src/components/gologin/GoLogin.vue

@@ -72,6 +72,7 @@ export default {
   background: #fff;
   top: 40%;
   left: 50%;
+  z-index: 8000;
   -webkit-transform: translate3d(-50%, -50%, 0);
   transform: translate3d(-50%, -50%, 0);
   -webkit-backface-visibility: hidden;

+ 2 - 1
src/router/index.js

@@ -144,7 +144,7 @@ router.beforeEach(async (to, from, next) => {
   const token = to.query.token || getKeyByWay("token");
   const hashuser = to.query.hashuser || getKeyByWay("hashuser");
   const send_order_id = to.query.send_order_id || getKeyByWay("send_order_id");
-
+  const yun = to.query.yun || getKeyByWay("yun");
   if (!window.firstName) {
     window.firstName = to.name;
     //获取token
@@ -162,6 +162,7 @@ router.beforeEach(async (to, from, next) => {
     let toQuery = JSON.parse(JSON.stringify(to.query));
     toQuery.send_order_id = from.send_order_id || send_order_id || "send_order_id";
     toQuery.hashuser = from.hashuser || hashuser || "hashuser";
+    toQuery.yun = from.yun || yun || 0;
     to.meta ? (to.meta.behavior = behavior) : (to.meta = { behavior });
     next({
       path: to.path,

+ 84 - 40
src/view/pay.vue

@@ -406,7 +406,14 @@
   </div>
 </template>
 <script>
-import { Pay, HelpPayQrcode, Reader, Person, BookDetail, BookCatalog } from "./namespace.js";
+import {
+  Pay,
+  HelpPayQrcode,
+  Reader,
+  Person,
+  BookDetail,
+  BookCatalog
+} from "./namespace.js";
 // import product from "../mock/pay.js";
 import { MessageBox } from "mint-ui";
 import {
@@ -414,8 +421,11 @@ import {
   subscribeByRMB,
   recharge,
   getUserInfo,
-  getOrderCoupon
+  getOrderCoupon,
+  newRefreshTokenF,
+  newDestoryToken
 } from "../api";
+import { getKeyByWay, setKeyByWay } from "../util/index.js";
 
 export default {
   name: Pay.name,
@@ -475,7 +485,7 @@ export default {
     }
   },
   mounted() {
-    this.popup()
+    this.popup();
   },
   methods: {
     changeCoupon() {
@@ -512,16 +522,40 @@ export default {
         Number(this.product[this.selectedProduct].price.replace("元", ""))
       );
     },
-    popup() {
+    async popup() {
       const from_detail_catalog = this.$route.query.from_detail_catalog; //判断是否是从详情页BookDetail or 目录BookCatalog 跳转到页面  1详情页  2目录  3阅读页
       const last_bid = this.$route.query.last_bid; //如果是从上一页跳转,获取上一页bid和cid,跳转到上一页
-      const last_cid = this.$route.query.last_cid; 
+      const last_cid = this.$route.query.last_cid;
       const bid = this.$route.query.bid;
       const cid = this.$route.query.cid;
-      const send_order_id = this.$route.query.send_order_id || localStorage.getItem("send_order_id");
+      const send_order_id = this.$route.query.send_order_id;
       const yun = this.$route.query.yun;
-      const sequence = this.$route.query.sequence
-      if(this.$route.query.isRecharge){
+      const sequence = this.$route.query.sequence;
+      if (this.$route.query.isRecharge) {
+        let urlToken = this.$route.query.token;
+        let hashUser = this.$route.query.hashuser;
+        if (urlToken) {
+          //先存本地
+          setKeyByWay("token", urlToken);
+          setKeyByWay("hashuser", hashUser);
+          /*        try {
+            const { token, hashuser } = await newrefreshToken({
+              hashuser: hashUser,
+              token: urlToken
+            });
+            setKeyByWay("token", token);
+            setKeyByWay("hashuser", hashuser);
+          } catch (e) {
+            this.$Toast(e.data.msg);
+          }
+          //拿到token 先作废旧token在保存新token;
+          try {
+            await newDestoryToken({ destroy_token: urlToken });
+          } catch (e) {
+            this.$Toast(e.data.msg);
+          }
+          */
+        }
         MessageBox({
           title: "支付确认",
           message:
@@ -529,46 +563,57 @@ export default {
           confirmButtonText: "已完成支付", //确认按钮的文本
           cancelButtonText: "取消", //取消按钮的文本
           confirmButtonHighlight: true, // 是否将确认按钮的文本加粗显示
-          showCancelButton: true,//是否显示取消按钮
+          showCancelButton: true, //是否显示取消按钮
           showConfirmButton: true //是否显示确认按钮
         }).then(action => {
           if (action === "confirm") {
-            if (bid && cid){
-              if(from_detail_catalog === '1'){
-                this.$router.replace({ // 跳回书籍详情页
-                    name: BookDetail.name,
-                    query: {
-                      id: bid
-                    }
-                  })
-              }else if (from_detail_catalog === '2') {
-                this.$router.replace({ // 跳回目录
-                    name: BookCatalog.name,
-                    query: {
-                      id: bid,
-                      sequence,
-                      yun
-                    }
-                  })
-              }else {
-                this.$router.replace({ // 跳回上一章
+            if ((bid && cid) || (last_bid && last_cid)) {
+              if (from_detail_catalog === "1") {
+                this.$router.replace({
+                  // 跳回书籍详情页
+                  name: BookDetail.name,
+                  query: {
+                    id: bid,
+                    yun
+                  }
+                });
+              } else if (from_detail_catalog === "2") {
+                this.$router.replace({
+                  // 跳回目录
+                  name: BookCatalog.name,
+                  query: {
+                    id: bid,
+                    sequence,
+                    yun
+                  }
+                });
+              } else {
+                this.$router.replace({
+                  // 跳回上一章
                   name: Reader.name,
                   query: {
                     bid: last_bid,
                     cid: last_cid,
                     send_order_id,
                     yun,
+                    token: urlToken,
+                    hashuser: hashUser
                   }
-                })
+                });
               }
-            }else {
-              this.$router.replace({ // 跳回个人中心
+            } else {
+              this.$router.replace({
+                // 跳回个人中心
                 name: Person.name,
+                yun
               });
             }
           }
-        })
-      } 
+        });
+      }
+      getUserInfo().then(r => {
+        this.balance = r.balance;
+      });
     },
     pay() {
       recharge({
@@ -580,9 +625,11 @@ export default {
         last_bid: this.$route.query.last_bid,
         last_cid: this.$route.query.last_cid,
         sequence: this.$route.query.sequence,
-        send_order_id: this.$route.query.send_order_id,
-        yun: this.$route.query.yun
-      })
+        send_order_id: getKeyByWay("send_order_id"),
+        yun: this.$route.query.yun,
+        token: getKeyByWay("token"),
+        hashuser: getKeyByWay("hashuser")
+      });
     },
     payForYear() {
       let product_id = this.product[this.product.length - 1].product_id;
@@ -659,9 +706,6 @@ export default {
       });
     });
 
-    getUserInfo().then(r => {
-      this.balance = r.balance;
-    });
     //用户优惠券
   }
 };
@@ -683,7 +727,7 @@ export default {
 }
 
 .pay-box__fixed {
-  position: fixed;  
+  position: fixed;
   bottom: 0;
   left: 0;
   right: 0;

+ 32 - 7
src/view/reader.vue

@@ -123,9 +123,19 @@
         </div>
       </transition>
     </div>
-    <!-- -->
-    <div class="add_desk" @touchmove.prevent v-if="addDesktop && !isStandalone">
-      <template v-if="modes == 'B'">
+    <!-- addDesktop && !isStandalone && userWhenAddDesktop -->
+    <div
+      class="add_desk"
+      @touchmove.prevent
+      v-if="!isStandalone && userWhenAddDesktop"
+    >
+      <div class="global-img">
+        <img
+          src="https://zhuishuyun.oss-cn-hangzhou.aliyuncs.com/zsy_ios_app/zsy_ios_img/guide/add_global.png"
+          width="100%"
+        />
+      </div>
+      <!--  <template v-if="modes == 'B'">
         <div class="addgif">
           <div class="addpng">
             <img
@@ -157,7 +167,7 @@
             width="100%"
           />
         </div>
-      </template>
+      </template> -->
     </div>
     <div
       class="share"
@@ -297,12 +307,14 @@ export default {
       subscribeQrcodeImg: window.options.special_bottom_sub_banner,
       chooseTap: "",
       canTap: true,
+      useInfo: null,
       hideGuide: window.options.hidden_reader_bootstrap,
       showComment: false,
       showGift: false,
       isshowshare: false,
       bookdetail: {},
       href: "",
+      userWhenAddDesktop: "",
       showAdStatus: false,
       showAdIframe: false,
       canBeClickToNext: true,
@@ -425,9 +437,10 @@ export default {
     },
     async getInfo() {
       //获取AB测试
-      let modes = await changeAddMode();
-      this.modes = modes.type;
+      /* let modes = await changeAddMode();
+      this.modes = modes.type; */
       let data = await getUserInfo();
+      this.useInfo = data;
       //老逻辑 没有绑定手机弹窗绑定并且是加桌模式
       if (!data.bind_phone && window.navigator.standalone) {
         //付费用户直接强加桌非付费用户弱加桌
@@ -444,6 +457,17 @@ export default {
         }
       }
 
+      //A类用户 直接需要加桌 -均为非全屏模式下
+      if (!window.navigator.standalone) {
+        if (data.adddesk_ab_type == "A") {
+          this.userWhenAddDesktop = true;
+        } else {
+          if (data.paymented && data.paymented >= 1) {
+            this.userWhenAddDesktop = true;
+          }
+        }
+      }
+
       // 获取书籍详情
 
       getDetail(this.$route.query.bid).then(m => {
@@ -883,7 +907,7 @@ export default {
     //获取
     //是否从派单链接进来的标识
     if (yun) this.yun = yun;
-
+    setKeyByWay("yun", yun);
     /*    let addDestops = getKeyByWay("addDestop");
     if (addDestops == "true" || addDestops == true) {
       this.addDestops = true;
@@ -1087,6 +1111,7 @@ export default {
   left: 0;
   display: flex;
   align-items: center;
+  z-index: 9990;
   img {
     margin: auto;
     display: block;