Ver Fonte

支付强制绑定

xiabx há 5 anos atrás
pai
commit
8ca402c91c
6 ficheiros alterados com 32 adições e 6 exclusões
  1. 9 3
      src/api/fly.js
  2. 3 1
      src/app.ux
  3. 8 1
      src/helper/interface.js
  4. 1 1
      src/views/My/index.ux
  5. 7 0
      src/views/Pay/index.ux
  6. 4 0
      src/views/Phone/index.ux

+ 9 - 3
src/api/fly.js

@@ -10,9 +10,10 @@ import Fly from "flyio/dist/npm/hap";
 import apiConfig from "./config";
 import prompt from '@system.prompt';
 import { getToken, clearToken } from "./utils";
-
+import it from "../helper/interface.js";
 var fly = new Fly(fetch);
 var qs = require('qs');
+var appInfo = it.getAppInfo();
 fly.config.baseURL = apiConfig.baseURL;
 fly.config.headers["Content-Type"] =
   "application/x-www-form-urlencoded;charset=utf-8";
@@ -23,8 +24,13 @@ fly.interceptors.request.use(async config => {
   // 过滤一些不需要登录的路由d
   if (filterNoToken.indexOf(config.url) === -1) {
     let token = await getToken();
-    if (config.headers) config.headers.Authorization = token;
-    else config.headers = { Authorization: token };
+    if (config.headers){
+      config.headers.Authorization = token;
+      config.headers["X-Version"] = appInfo.versionName;
+    } 
+    else{
+      config.headers = { Authorization: token,'X-Version':appInfo.versionName };
+    } 
     if (config.method === "POST") {
       config.body = qs.stringify(config.body);
     }

+ 3 - 1
src/app.ux

@@ -23,6 +23,7 @@ export default {
         else this.$def.data.backClickCount = 1;
       }
     })
+
   },
   showMenu: it.showMenu,
   getDeviceInfo: it.getDeviceInfo,
@@ -30,7 +31,8 @@ export default {
   data: {
     backClickCount: 0,
     cutomerQrcode: "",
-    weChat: "wxlxf1099"
+    weChat: "wxlxf1099",
+    appVersion:'',
   }
 };
 </script>

+ 8 - 1
src/helper/interface.js

@@ -14,6 +14,12 @@ const getDeviceInfo = () => {
     }
   })
 }
+//获取应用信息
+const getAppInfo = () => {
+  const appInfo = app.getInfo();
+  return appInfo;
+}
+
 //获取是否创建图标
 const getShortCut = (fn) => {
   shortcut.hasInstalled({
@@ -81,5 +87,6 @@ export default {
   getDeviceInfo,
   hasCreateShortCut,
   showMenu,
-  getShortCut
+  getShortCut,
+  getAppInfo
 }

+ 1 - 1
src/views/My/index.ux

@@ -99,7 +99,7 @@ export default {
       prompt.showToast({
         message: '您已绑定过手机号'
       })
-      return false;
+      return false;  
     }
     router.push({
       uri: `/views/${page}`

+ 7 - 0
src/views/Pay/index.ux

@@ -98,6 +98,7 @@ export default {
     loadingText: "订单查询中...",
     isInPay: false,
     showLoading: false,
+    checked: false,
     payType: [
       {
         name: "支付宝",
@@ -123,6 +124,12 @@ export default {
     let userinfo = await getUserInfo();
     this.balance = userinfo.balance;
     this.send_order_id = userinfo.send_order_id;
+    if (userinfo.is_check) {
+      router.push({
+        uri: '/views/Phone'
+      })
+    }
+
   },
   async initChargeList() {
     this.rechargeList = await getChargeList();

+ 4 - 0
src/views/Phone/index.ux

@@ -16,6 +16,7 @@
 <script>
 import { validatePhone } from '../../api/utils';
 import { sendCode, userBind } from '../../api/index';
+import router from '@system.router';
 import prompt from '@system.prompt';
 export default {
   private: {
@@ -79,6 +80,9 @@ export default {
     prompt.showToast({
       message: '绑定成功!'
     })
+    setTimeout(()=>{
+      router.back();
+    },1500)
 
   }