XiaBx vor 3 Jahren
Ursprung
Commit
1d5f8241ee

+ 1 - 1
config/index.js

@@ -65,7 +65,7 @@ module.exports = {
     assetsRoot: path.resolve(__dirname, "../dist"),
     assetsSubDirectory:
       "static" + new Date().toLocaleDateString().replace(/\//g, "-"),
-    assetsPublicPath: "https://cdn-novel.iycdm.com/",
+    assetsPublicPath: "https://cdn-novel.iycdm.com/zsy_ios_app/",
 
     /**
      * Source Maps

+ 1 - 0
package.json

@@ -14,6 +14,7 @@
     "clipboard": "^2.0.4",
     "fundebug-javascript": "^1.2.3",
     "html2canvas": "^1.0.0-rc.4",
+    "js-md5": "^0.7.3",
     "mint-ui": "^2.2.10",
     "qrcodejs2": "0.0.2",
     "vconsole": "^3.2.0",

+ 30 - 13
src/App.vue

@@ -13,7 +13,12 @@
       <img @click.stop="closeWrap" :src="imgs" alt="" />
     </div>
     <div class="package-wrap" @touchmove.prevent v-if="showAd">
-      <img src="" />
+      <div class="close-btn" @click="showAd = false">关闭</div>
+      <img
+        src="https://cdn-novel.iycdm.com/zsy_ios_app/user_privacy/20220221155858.png"
+        width="100%"
+        class="mask-img"
+      />
     </div>
 
     <!-- <template v-if="isTargetChannel&&showIframe">
@@ -26,16 +31,16 @@
 </template>
 
 <script>
+import goLogin from "../src/components/gologin";
 export default {
   name: "app",
   data() {
     return {
       theme: localStorage.getItem("theme") || "girl",
       showRed: window.options.fission,
-      activity_imgs: window.options.channel_activities,
       redImage: require("./assets/red_package.png"),
       imgs: null,
-      showAd: false,
+      showAd: true,
       showWrap: false,
       // todayDate: new Date().toLocaleDateString(),
       isTargetChannel: window.options.is_show_ad_frame,
@@ -56,9 +61,11 @@ export default {
       this.theme = site_gender === "male" ? "boy" : "girl";
     } else this.theme = "girl";
     this.initWrap();
+    setTimeout(() => {
+      this.showAd = false;
+    }, 3000);
 
-    //this.$GoLoginPop().then(()=>{console.log('我真的的去绑定了呢')});
-    //setTimeout(()=>{this.$GoLoginPop.close();},4000)
+    //goLogin().then(res=>{console.log('库哈哈哈')})
   },
   methods: {
     closeWrap() {
@@ -70,7 +77,6 @@ export default {
         }, 500);
       } else {
         this.showWrap = false;
-        window.options.channel_activities.shall_reward = 0;
       }
     },
     initWrap() {
@@ -78,12 +84,6 @@ export default {
         // 红包弹窗弹出
         this.showWrap = true;
         this.imgs = this.redImage;
-      } else {
-        if (window.options.channel_activities.shall_reward) {
-          // 活动弹
-          this.showWrap = true;
-          this.imgs = this.activity_imgs.image;
-        }
       }
     }
   }
@@ -99,7 +99,24 @@ export default {
   width: 100%;
   background: rgba($color: #000000, $alpha: 0.6);
   z-index: 9999;
-
+  .mask-img {
+    width: 100%;
+    z-index: 100;
+  }
+  .close-btn {
+    width: 1.2rem;
+    height: 0.5rem;
+    line-height: 0.5rem;
+    text-align: center;
+    background: rgba(255, 255, 255, 0.6);
+    color: #fff;
+    font-size: 0.28rem;
+    position: absolute;
+    right: 0.5rem;
+    top: 0.5rem;
+    z-index: 101;
+    border-radius: 0.4rem;
+  }
   img {
     position: absolute;
     width: 80%;

+ 24 - 8
src/api/axios.js

@@ -1,8 +1,8 @@
 import axios from "axios";
 import router from "../router/index.js";
 import { Undertheshelf } from "../view/namespace.js";
-import { undefinedCollect } from './index.js'
-
+import { undefinedCollect } from "./index.js";
+import { getToken,refreshToken } from "./config";
 // var instance = axios.create(
 //   process.env.NODE_ENV === "development"
 //     ? {
@@ -13,34 +13,50 @@ import { undefinedCollect } from './index.js'
 //         baseURL: "/api"
 //       }
 // );
+const whiteList = ["/login"];
 
 var instance = axios.create({
   baseURL: "/api"
 });
 
-instance.interceptors.response.use(function (res) {
+instance.interceptors.response.use(async function(res) {
   if (res.data.code === 0) {
     return res.data.data;
   }
+  if (res.data.code === 10001 || res.data.code === 10023 || res.data.code === 10035) {
+    await refreshToken();
+
+  }
   if (res.data.code === 10018) {
     router.replace(Undertheshelf.route);
   } else {
     return Promise.reject(res);
   }
 });
-instance.interceptors.request.use(function (config) {
-  if (config.method === 'get' && config.url && config.url.indexOf('undefined') !== -1) {
+instance.interceptors.request.use(async function(config) {
+  let  token;
+  if (!whiteList.includes(config.url) && !token) {
+    token = await getToken();
+  }
+  if(token){
+    config.headers.Authorization = `bearer ${token}`
+  }
+  if (
+    config.method === "get" &&
+    config.url &&
+    config.url.indexOf("undefined") !== -1
+  ) {
     undefinedCollect({
-      name: 'undefined',
+      name: "undefined",
       content: JSON.stringify({
         current_page: location.href,
         next_page: window.nextPage,
         prev_page: window.prevPage,
         api: config.url,
         user_id: window.options && window.options.uid,
-        channel_id: window.options && window.options.distribution_channel_id,
+        channel_id: window.options && window.options.distribution_channel_id
       })
-    })
+    });
   }
 
   return config;

+ 26 - 0
src/api/config.js

@@ -0,0 +1,26 @@
+import { userLogin } from "./index";
+
+export async function getToken() {
+
+  return localStorage.getItem("token") || (await login());
+}
+
+export async function refreshToken() {
+  localStorage.removeItem("token");
+  await getToken();
+}
+
+export async function login() {
+  const signKey = "a!A&AFRWT65Nb3NlklezUiqHyQAA@Z8M";
+  const timestamp = parseInt(new Date().valueOf() / 1000);
+  let data = {
+    timestamp
+  };
+  let ret = await userLogin(data);
+  if (ret) {
+    localStorage.setItem("token", ret.token);
+    return ret.data;
+  } else {
+    return "";
+  }
+}

+ 21 - 5
src/api/index.js

@@ -85,10 +85,10 @@ function detailUpdate(id, status) {
     book.result.data.is_on_user_shelf = status;
   }
 }
-export function getDetail(id, s = "",pos='') {
+export function getDetail(id, s = "", pos = "") {
   return detail
     .getAsync(id, function() {
-      return axios("/book/" + id + "?s=" + s + '&pos=' + pos).then(r => {
+      return axios("/book/" + id + "?s=" + s + "&pos=" + pos).then(r => {
         return {
           id,
           data: r
@@ -362,19 +362,20 @@ export function recharge({ product_id, bid, cid, use_coupon }) {
           host: location.origin,
           pathname: "/recent"
         };
+  const token = localStorage.getItem("token");
+
   const href = {
     host: window.options.pay_url,
     query: {
       product_id: product_id,
-      uid: window.options.uid,
+      token: token ? `${token}` : '',
       use_coupon,
       distribution_channel_id: window.options.distribution_channel_id,
       send_order_id: window.options.send_order_id,
       from: window.options.from,
       bid,
       cid,
-      pay_redirect_url: encodeURIComponent(urlFormat(redirect)),
-      crm: window.options.crm || ""
+      pay_redirect_url: encodeURIComponent(urlFormat(redirect))
     }
   };
   a.href = urlFormat(href);
@@ -552,6 +553,11 @@ export function phoneBind(data) {
   return axios.post("/bindphone/bind", data);
 }
 
+// 获取验证码
+export function getCode(data) {
+  return axios.post("/bindphone/sendcode", data);
+}
+
 // 获取fakebook详情
 export function getBookDetail(id) {
   return axios("/red_book/getBookDetail?id=" + id);
@@ -604,3 +610,13 @@ export function getUserCoupon() {
 export function getOrderCoupon() {
   return axios("/order/effectiveCoupon");
 }
+
+//登录平台
+export function userLogin(data) {
+  return axios("/login", { params: data });
+}
+
+//绑定手机号新版
+export function bindUserPhone(data) {
+  return axios.post("/bindphone/bind", data);
+}

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

@@ -93,6 +93,7 @@ export default {
     left: 45%;
     bottom: -1rem;
     color: white;
+    margin-top: 0.2rem;
   }
 }
 </style>

+ 5 - 4
src/components/gologin/index.js

@@ -21,9 +21,7 @@ const goLogin = () => {
   if (!instance) {
     initInstance();
   }
-  // console.log(GoLogin,'goLogin')
-  // console.log(instance,'instance')
-  instance.show = false;
+  instance.show = true;
 
   //增加回调访法方便以后异步调用
   instance.callback = action => {
@@ -47,10 +45,13 @@ const goLogin = () => {
 
 //方便直接调用
 goLogin.close = () => {
-  
   if (instance) {
     instance.show = false;
   }
 };
 
+goLogin.install = () => {
+  Vue.use(GoLogin);
+};
+
 export default goLogin;

+ 0 - 4
src/components/index.js

@@ -28,12 +28,10 @@ import XBookInfo from "./book-info.vue";
 import XFooter from "./footer.vue";
 import XHeader from "./header.vue";
 import XShelfCore from "./shelf-core.vue";
-import goLogin from "./goLogin";
 // import XReader from './reader'
 VueClipboard.config.autoSetContainer = true;
 
 Vue.use(vueTouch);
-Vue.use(goLogin);
 Vue.use(VueClipboard);
 Vue.component(Checklist.name, Checklist);
 Vue.component(Button.name, Button);
@@ -50,9 +48,7 @@ Vue.use(Lazyload, {
 });
 Vue.component(TabContainer.name, TabContainer);
 Vue.component(TabContainerItem.name, TabContainerItem);
-Vue.component('GOLOGIN',goLogin);
 Vue.prototype.$Toast = Toast;
-Vue.prototype.$GoLoginPop = goLogin;
 Vue.prototype.$Indicator = Indicator;
 
 Vue.prototype.$MessageBox = MessageBox;

+ 42 - 17
src/view/Login.vue

@@ -65,6 +65,9 @@
 </template>
 <script>
 import { Login } from "./namespace.js";
+import { getCode, bindUserPhone } from "../api/index";
+import qs from "qs";
+import md5 from "js-md5";
 export default {
   name: Login.name,
   data() {
@@ -78,12 +81,13 @@ export default {
       popupVisible: false,
       isPhoneCurrect: 0,
       countTime: "",
-      isGoToLogin: false
+      isGoToLogin: false,
+      timer: null
     };
   },
   mounted() {
     this.$once("hook:beforeDestroy", () => {
-      clearInterval(timer);
+      clearInterval(this.timer);
     });
   },
   methods: {
@@ -92,19 +96,34 @@ export default {
       this.$Toast("请填写正确的手机号码");
     },
     //点击获取二维码
-    getCode() {
-      console.log("获取验证码");
-      this.isPhoneCurrect = 3;
-      this.countTime = 60;
-      //验证码倒计时
-      const timer = setInterval(() => {
-        if (this.countTime == 0) {
-          clearTimeout(timer);
-          this.isPhoneCurrect = 1;
-        } else {
-          this.countTime--;
-        }
-      }, 1000);
+    async getCode() {
+      const signData = {
+        phone: this.phone,
+        timestamp: parseInt(new Date().valueOf() / 1000),
+        key: "zhuishuyun_ios_wap#_2022"
+      };
+
+      const data = {
+        phone: this.phone,
+        timestamp: parseInt(new Date().valueOf() / 1000),
+        sign: md5(qs.stringify(signData, { encode: false }))
+      };
+      try {
+        const res = await getCode(data);
+        this.isPhoneCurrect = 3;
+        this.countTime = 60;
+        //验证码倒计时
+        this.timer = setInterval(() => {
+          if (this.countTime == 0) {
+            clearTimeout(timer);
+            this.isPhoneCurrect = 1;
+          } else {
+            this.countTime--;
+          }
+        }, 1000);
+      } catch (e) {
+        this.$Toast(e.data.msg);
+      }
     },
     isAgreeChange() {
       this.isAgree = !this.isAgree;
@@ -129,8 +148,14 @@ export default {
         return;
       }
       //弹出框
-      this.popupVisible = !this.popupVisible;
-      console.log("goToLogin");
+      bindUserPhone({ phone: this.phone, code: this.code })
+        .then(res => {
+          this.popupVisible = !this.popupVisible;
+        })
+        .catch(e => {
+          console.log(e);
+          this.$Toast(e.data.msg);
+        });
     },
     //返回上级路由
     goBackRouter() {

+ 3 - 3
src/view/pay.vue

@@ -497,17 +497,17 @@ export default {
       popupVisible: false,
       payType: [
         { name: "微信", img: require("../assets/wechat.png"), nickName: "wx" },
-        {
+        /* {
           name: "支付宝",
           img: require("../assets/alipay.png"),
           nickName: "zfb"
-        }
+        } */
       ],
       currentCoupon: {
         id: "",
         price: 0
       },
-      currentPayType: "zfb"
+      currentPayType: "wx"
     };
   },
   computed: {