ソースを参照

Merge pull request #17 from John-Hong/John/Microservices

John/microservices
Tron 2 年 前
コミット
38d9e8e7a5

+ 15 - 7
src/pages/parkingFee/mixins/parkingFee.js

@@ -91,6 +91,20 @@ export default {
         this.getParkInfo();
         this.showSq = false;
       }
+    },
+    unlicensedInfo:{
+      handler(){
+        console.log('用户是扫码进来的97', this.unlicensedInfo);
+        // 不论是否出入场,都使用此函数获取 gateId(闸口机器的ID)
+        if (this.unlicensedInfo?.type && /unlicensedOut|unlicensedIn/.test(this.unlicensedInfo.type) && this.endlessLoop.length === 0) {
+          // 此处记录扫码流程执行次数。如果超过一次则不再执行
+          this.$store.commit('SET_ENDLESS_LOOP', this.unlicensedInfo.type);
+          this.$nextTick(() => {
+            this.qrCodesRule(this.unlicensedInfo.code);
+          })
+        }
+      },
+      immediate:true //true就表示会立即执行
     }
   },
   async mounted() {
@@ -103,13 +117,7 @@ export default {
     if (platform === 'micromessenger') {
       await initWxJsSdkConfig(['checkJsApi', 'scanQRCode']);
     }
-    // 不论是否出入场,都使用此函数获取 gateId(闸口机器的ID)
-    if (this.unlicensedInfo?.type && /unlicensedOut|unlicensedIn/.test(this.unlicensedInfo.type) && this.endlessLoop.length === 0) {
-      console.log('用户是扫码进来的97', this.unlicensedInfo);
-      // 此处记录扫码流程执行次数。如果超过一次则不再执行
-      this.$store.commit('SET_ENDLESS_LOOP', this.unlicensedInfo.type);
-      this.qrCodesRule(this.unlicensedInfo.code)
-    }
+
     if (this.openid) {
       this.getParkInfo();
       this.showSq = false;

+ 8 - 4
src/pages/parkingFee/mixins/parkingFeeDetail.js

@@ -62,8 +62,8 @@ export default {
       usePointsTime: (state) => state.order.usePointsTime,
       enableConsume: (state) => state.order.enableConsume,
       unitAmount: (state) => state.order.unitAmount,
-      unlicensedInfo: state => state.unlicensedInfo
-      // checkedTotal: state => state.order.checkedTotal,
+      unlicensedInfo: state => state.unlicensedInfo,
+      appId: state => state.appId,
     }),
     // 支付按钮状态
     payBtnDisabled() {
@@ -165,8 +165,9 @@ export default {
       let appId = uni.getStorageSync('appid');
       let openId = uni.getStorageSync('openid') || this.openid;
       if (platform === 'miniprogram') {
-        appId = 'wx92c3e55fbef6b2af';
+        // appId = 'wx92c3e55fbef6b2af';
         // appId = 'wxd830fe4d1e04988e';
+        appId = this.appId;
       }
       const params = {
         region: 'cn',
@@ -306,6 +307,8 @@ export default {
       // 应付金额
       // this.$store.commit('order/SET_ORDER_DETAIL', checkOutResponse);
       try {
+        console.log('无牌车扫码出场', this.unlicensedInfo, this.endlessLoop);
+        // return
         this.$store.dispatch('order/orderInit', {
           vehicleNo: this.$route.query.vehicleNo,
           gateId: this.$route.query?.gateId,
@@ -416,7 +419,8 @@ export default {
     // 获取成功缴费之后前往的页面
     getPagePath() {
       let pagePath = 'parkingFeeSuccess?vehicleNo=' + this.$route.query.vehicleNo
-      if (this.$route.query.vehicleNo.indexOf('临') > -1 && this.endlessLoop) {
+      console.log('临时车流程', this.endlessLoop);
+      if (this.$route.query.vehicleNo.indexOf('临') > -1 && this.endlessLoop || this.$route.query.gateId) {
         pagePath = 'parkingFeeMsg?type=pay'
       }
       return pagePath

+ 32 - 3
src/plugins/sensors.js

@@ -3,6 +3,7 @@ import sensors from '@/lib/Sensorsdata-UniPlugin-JS';
 import Vue from 'vue';
 import uni from '@/utils/uniHooks';
 import store from '@/store/index'
+import { getPlatform } from '@/utils/index';
 
 /**
  * 上传埋点数据至神策(第三方埋点平台)
@@ -18,9 +19,28 @@ const normalTrack = (eventName, properites, trackingEnable = true) => {
 
 
 
-// 设置全埋点事件及埋点公共字段
+// 设置全埋点事件及埋点公共字段(仅在小程序中实现,H5另定)
 const trackingInit = () => {
-
+    const platform = getPlatform();
+    if ( platform !== 'miniprogram') {
+        return
+    }
+    // console.log(23, window.toWXSendMsg);
+    // console.log(23, store.state.appId);
+     // 微信小程序
+     if (getPlatform() === 'miniprogram') {
+    //    window.toWXSendMsg({
+    //      type: 'scanQRCode',
+    //    });
+    //    window.subscribe('scanQRCodeOver', (options) => {
+    //      console.log('微信扫码结束之后的返回参数', options);
+    //      runScanFn(options);
+    //    });
+     }
+    if (store.state.appId === '') {
+        // window.toWXSendMsg = 
+    }
+    return
     const project = 'kerryplus';
     const defaultLbs = uni.getStorageSync("DEFAULT_LBS");
     const lbsId = defaultLbs.lbs?.id;
@@ -81,6 +101,15 @@ const trackingInit = () => {
         saglobal_open_id: openId,
         saglobal_profile_id: profileId
     });
+    sensors.registerApp({
+        saglobal_product_name: project,
+        //小程序的brand
+        saglobal_digital_brand_id: uni.getStorageSync('groupId') || '',
+        //小程序的LBS ID
+        saglobal_lbs_id: uni.getStorageSync('mallid') || '',
+        // 小程序的LBS Name
+        saglobal_lbs_name: _this.globalData.marketName || '',
+      })
     //埋点初始化
     sensors.init();
 }
@@ -260,5 +289,5 @@ export default () => {
     // console.log('ENVIRONMENTS', sensors);
     // 埋点参数设置及公共字段初始化
     trackingInit();
-    Vue.prototype.trackFactory = TrackFactory;
+    Vue.prototype.$trackFactory = TrackFactory;
 }

+ 12 - 6
src/store/index.js

@@ -53,7 +53,7 @@ const store = new Vuex.Store({
     curMarket: {},
     isInit: true, // 当内嵌在小程序中的H5页面,没有接收到小程序数据时,默认显示骨架屏幕
     // 无牌车
-    unlicensedInfo: {},
+    unlicensedInfo: '',
     // 防止用户在无牌车流程中卡死
     endlessLoop: ''
   },
@@ -136,7 +136,7 @@ const store = new Vuex.Store({
       state.source = payload;
     },
     SET_APPID(state, payload) {
-      // uni.setStorageSync('appId', payload);
+      uni.setStorageSync('appId', payload);
       state.appId = payload;
     },
     SET_BRAND_INFO(state, payload) {
@@ -159,6 +159,7 @@ const store = new Vuex.Store({
     },
     // 无牌车
     SET_UNLICENSED_INFO(state, payload) {
+      console.log('用户扫码进入的', payload);
       state.unlicensedInfo = payload;
     },
     SET_ENDLESS_LOOP(state, payload) {
@@ -191,7 +192,7 @@ const store = new Vuex.Store({
           isLogin = false,
           accessToken = '',
           source = '',
-          appId = '',
+          appId = 'wx92c3e55fbef6b2af',
           // 无牌车逻辑
           unlicensedInfo,
           // CRM
@@ -209,6 +210,8 @@ const store = new Vuex.Store({
         // const resp = await parkingLots();
         // console.log(171171, resp);
         commit('SET_SOURCE', source);
+        commit('SET_APPID', appId);
+        
         // let { groupId, mallId } =
         if (source !== 'CRM') {
           const groupIdAndMallId = getGroupIdAndMallIdByLsbId(lbsId);
@@ -230,10 +233,13 @@ const store = new Vuex.Store({
         commit('SET_GROUP_ID', groupId);
         commit('SET_MALL_ID', mallId);
         commit('SET_BRAND_ID', brandId);
+        console.log('用户扫码进入的', unlicensedInfo, unlicensedInfo?.type);
         // 如果是无牌车
-        // console.log('218218218218', unlicensedInfo);
-        console.log('用户扫码进入的', unlicensedInfo);
-        commit('SET_UNLICENSED_INFO', unlicensedInfo)
+        if (unlicensedInfo?.type) {
+          console.log('用户扫码进入的', unlicensedInfo);
+          commit('SET_UNLICENSED_INFO', unlicensedInfo)
+          // commit('SET_ENDLESS_LOOP', true)
+        }
         /*if (/dev-|8080|qa-/.test(href)) {
          commit('SET_GROUP_ID', groupId);
          commit('SET_MALL_ID', mallId);

+ 3 - 2
src/store/order.js

@@ -148,9 +148,10 @@ const actions = {
       // const res = await checkOut('闽AAQ5519', unlicensed);
       // const res = await checkOut('粤A51113');
       // const res = await checkOut('沪DCJ986');
+      console.log('无牌车扫码出场', endlessLoop);
       // 场内缴费,调 check-out 接口,
       const method = unlicensed && endlessLoop ? unlicensedCarCheckout : checkOut
-      const res = await method(vehicleNo, unlicensed, gateId);
+      const res = await method(vehicleNo, false, gateId);
       // console.log(vehicleNo, res);
       // 所有的优惠时间长转为金额
       // console.log(112, '所有的优惠时间长转为金额');
@@ -167,7 +168,7 @@ const actions = {
   orderInitRule({ commit, dispatch, state }, checkOutResponse) {
     console.log(119, checkOutResponse);
     // 记录buildingId
-    window.localStorage.setItem('buildingId', checkOutResponse.parkingRecord.buildingId);
+    window.localStorage.setItem('buildingId', checkOutResponse.parkInfo.buildingId);
     commit('setOrderDetail', checkOutResponse);
     // 是否展示优惠
     commit('setIsShowDiscounts', checkOutResponse?.parkingRule?.enableCoupon || false);

+ 1 - 0
vue.config.js

@@ -119,6 +119,7 @@ module.exports = {
         // target: 'http://172.21.203.140:8080', //代理地址,这里设置的地址会代替axios中设置的baseURL   2023-2-9
         // target: 'http://172.21.203.20:8080', //代理地址,这里设置的地址会代替axios中设置的baseURL
         // target: 'http://172.21.200.89:8080', //代理地址,这里设置的地址会代替axios中设置的baseURL
+        // target: 'http://172.20.50.208:8080', // 代理地址,这里设置的地址会代替axios中设置的baseURL
         changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
         //ws: true, // proxy websockets
         //pathRewrite方法重写url