Browse Source

调试 h5 token

John-Hong 2 years ago
parent
commit
355b1c6a00
4 changed files with 90 additions and 9 deletions
  1. 12 7
      public/index.html
  2. 74 1
      src/App.vue
  3. 2 0
      src/main.js
  4. 2 1
      src/store/index.js

+ 12 - 7
public/index.html

@@ -14,13 +14,18 @@
   </title>
   <script>
     // CONFIGURATIONS_PLACEHOLDER
-    window.injectConfig = {
-      api: 'https://qa-crm-kpl.kerryprops.com.cn/',
-      TRACKING_API_URL:
-        'https://qa-tracking-cip.kerryplus.com/sa?project=kerry_tracking',
-      profileApi: 'https://qa-apim.kerryplus.com/c/api',
-      qaPayment: 'https://qa-payment.kerryonvip.com',
-    };
+    
+    if (window.injectConfig) {
+      window.injectConfig = {
+        ...window.injectConfig,
+        api: 'https://qa-crm-kpl.kerryprops.com.cn/',
+        TRACKING_API_URL:
+          'https://qa-tracking-cip.kerryplus.com/sa?project=kerry_tracking',
+        profileApi: 'https://qa-apim.kerryplus.com/c/api',
+        qaPayment: 'https://qa-payment.kerryonvip.com',
+      };
+    }
+    
   </script>
   <script>
       // var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))

+ 74 - 1
src/App.vue

@@ -15,6 +15,7 @@ import Stomp from '@/lib/stompjs/index';
 import { Encrypt, Decrypt } from '@/utils/crypto';
 import CacheTool from '@/utils/cache-tool';
 import uni from '@/utils/uniHooks';
+import { mapState } from 'vuex';
 import {initWxJsSdkConfig} from '@/utils/login.js';
 
 export default {
@@ -30,6 +31,18 @@ export default {
   created() {
     this.init();
   },
+  computed: {
+    disabledBtn() {
+      return this.numArr.findIndex((val) => !val) !== -1;
+    },
+    ...mapState({
+      groupId: (state) => state.groupId,
+      openid: (state) => state.openid,
+      mallId: (state) => state.mallId,
+      kipUserId: (state) => state.kipUserId,
+      userInfo: (state) => state.userInfo,
+    }),
+  },
   methods: {
     async init() {
       // console.log(33333333)
@@ -45,6 +58,7 @@ export default {
         return
       }
       CacheTool.init()
+      console.log(484848);
       if (window.location.href.search(/pageId=|token=/g) < 0) {
         return;
       }
@@ -52,11 +66,19 @@ export default {
         /.*token=([0-9A-Za-z]*).*/g,
         '$1'
       );
+      console.log(55);
+      // this.getTicket()
       this.wss(() => {
+        console.log(565656);
         this.$store.dispatch('baseInit', {
           pageId: window.location.href.replace(/.*pageId=([0-9A-Z]*).*/g, '$1'),
-          callback: this.wss,
+          // callback: this.wss,
+          callback: () => {
+            // 当所有的数据都初始化之后再次执行
+            this.getTicket()
+          },
         });
+        
       });
     },
     send() {
@@ -164,6 +186,57 @@ export default {
       // prod
       CacheTool.setEnv('prod');
     },
+    // h5获取配置---公众号支付
+    getTicket() {
+      console.log(173);
+        let self = this
+        var datas = {
+          groupId: this.groupId,
+          mallid: this.mallId,
+          url: window.location.href.split("#")[0]
+        }
+        self.$md(datas)
+        console.log(199, datas);
+        uni.request({
+          url: self.$baseURL + "api/1.0/login/getTicket",
+          method: 'POST',
+          data: datas,
+          header: JSON.parse(uni.getStorageSync('handleUser')),
+          success: (res) => {
+            console.log(206, res);
+            if (res.data.code == 0) {
+              self.$wx.config({
+                debug: false, // 开启调试模式
+                appId: res.data.data.appId, // 必填,公众号的唯一标识
+                timestamp: res.data.data.timestamp, // 必填,生成签名的时间戳
+                nonceStr: res.data.data.nonceStr, // 必填,生成签名的随机串
+                signature: res.data.data.signature, // 必填,签名
+                jsApiList: ['chooseWXPay'] // 必填,需要使用的JS接口列表
+              });
+              self.$wx.ready(function() {
+                self.$wx.checkJsApi({
+                  jsApiList: ['chooseWXPay'],
+                  success: res => {
+                    console.log('checked api:', res)
+                  },
+                  fail: err => {
+                    console.log('check api fail:', err)
+                  }
+                })
+              });
+              self.$wx.error(function(res) {
+                console.log('err', res)
+              });
+            } else {
+              uni.showToast({
+                title: res.data.msg,
+                duration: 2000,
+                icon: 'none'
+              })
+            }
+          }
+        });
+      },
   },
 };
 </script>

+ 2 - 0
src/main.js

@@ -8,6 +8,7 @@ import store from './store/index.js';
 import VueRouter from 'vue-router';
 import { Icon, Checkbox, CheckboxGroup, RadioGroup, Radio, Field } from 'vant';
 import router from './routes/index.js';
+import wx from '@/utils/js_sdk/weixin';
 
 // import authorize from 'components/authorize/authorize.vue'
 
@@ -25,6 +26,7 @@ import componentsInstall from './components/install';
 // Vue.use(plugins);
 Vue.use(componentsInstall);
 
+Vue.prototype.$wx = wx;
 Vue.prototype.$store = store;
 Vue.prototype.$request = request;
 Vue.prototype.$sensors = sensors;

+ 2 - 1
src/store/index.js

@@ -78,6 +78,7 @@ const store = new Vuex.Store({
         if (!pageId) return;
         const [groupId, kipUserId, mallId, openid, mobile] =
           Decrypt(pageId).split('#');
+          console.log(8181, groupId, kipUserId, mallId, openid, mobile);
         commit('SET_GROUP_ID', groupId);
         commit('SET_KIP_USER_ID', kipUserId);
         commit('SET_MALL_ID', mallId);
@@ -99,7 +100,7 @@ const store = new Vuex.Store({
           // commit('SET_USER_INFO', memberRes.data);
           commit('SET_MEMBER', memberRes.data);
         }
-        console.log(929292, marketListRes);
+        // console.log(929292, marketListRes);
         callback && callback();
       } catch (e) {
         console.log(e);