Эх сурвалжийг харах

feat(KIP-19366): 首页埋点

john 9 сар өмнө
parent
commit
0fd014c897

+ 45 - 2
src/pages/mixins/parkingFee.js

@@ -18,6 +18,7 @@ import findCarPng from '@/pages/static/images/find_car.png';
 import unlicensed1Png from '@/pages/static/images/unlicensed-1.png';
 import unlicensed0Png from '@/pages/static/images/unlicensed-0.png';
 import unlicensedScanPng from '@/pages/static/images/unlicensed-scan.png';
+import { TrackFactory } from '@/utils/trackingh5';
 
 const app = {
   globalData: {
@@ -87,7 +88,15 @@ export default {
       findCarPng,
       unlicensed1Png,
       unlicensed0Png,
-      unlicensedScanPng
+      unlicensedScanPng,
+      trackingFun: TrackFactory.getInstance(
+        'view_monthly_renewal',
+        {},
+        false,
+        true,
+        undefined,
+        false
+      ),
     };
   },
   computed: {
@@ -109,8 +118,12 @@ export default {
       endlessLoop: (state) => state.endlessLoop,
       source: (state) => state.source,
     }),
+    initTracking() {
+      return store.state.initTracking;
+    },
   },
   created() {
+    this.track
     // console.log('二次加载this.$route.query.fromPage', this.$route.query.fromPage, this.$store.state.pageHistory);
     // console.log('二次加载', this.$route.query.fromPage && !this.$store.state.pageHistory[this.$route.query.fromPage]);
     const fromPage = localStorage.getItem(`${this.$route.query.fromPage}`)
@@ -1276,6 +1289,7 @@ export default {
       let query = {}
       switch (type){
         case 'PAYMENT_RECORDS': // 缴费记录
+          this.track(101);
           query = {
             ...this.$route.query,
           }
@@ -1287,6 +1301,7 @@ export default {
           break
         case 'COUPON_EXCHANGE': // 停车券兑换
           this.$store.dispatch('clearUnlicensed');
+          this.track(102)
           uni.setStorageSync('loadData', '');
           if (isAlipay()) {
             my.navigateTo({
@@ -1308,6 +1323,7 @@ export default {
         }
           break
         case 'PARKING_INVOICE': // 停车开票
+          this.track(103);
           // const isJump = await this.jumpToPreJudgmentOfParkingInvoice();
           // if (isJump) return
           const isJump2 = await this.jumpToPreJudgmentOfParkingInvoice2();
@@ -1327,6 +1343,7 @@ export default {
           this.$router.push({path: 'parkingReceipt', query});
           break
         case 'VEHICLE_MANAGE': // 车辆管理
+          this.track(104)
           this.$store.dispatch('clearUnlicensed');
           this.$store.commit('SET_REGRESH_PAGE_KEY')
           uni.setStorageSync('loadData', '');
@@ -1340,10 +1357,12 @@ export default {
           this.$router.push({path: 'vehicleManagement', query});
           break
         case 'PARKING_BENEFITS': // 停车权益
+          this.track(106);
           console.log('停车权益', this.portalsByLbsInfo)
           this.$router.push({path: 'parkingRights', query: this.portalsByLbsInfo});
           break
           case 'FIND_CAR': // 反向寻车
+            this.track(105);
           if (this.mallId === '8a888bfd816101980181a969f513019c') {
             console.log('isAlipay:::', isAlipay())
             this.findcarFZ()
@@ -1362,6 +1381,30 @@ export default {
           }
           break
       }
-    }
+    },
+    track(action, trackParams = {}) {
+      try {
+        if (!this.initTracking) {
+          return false;
+        }
+        if (action === 1) {
+          // 页面展示的时候埋点
+          this.trackingFun.track(1, {});
+        } else {
+          // eslint-disable-next-line no-console
+          this.trackingFun.track(action, {
+            ...trackParams,
+            source_type: window.decodeURIComponent(
+              `${paramsObj.source_type || ''}`
+            ),
+            source_name: paramsObj.source_id || '',
+            source_id: paramsObj.source_id || '',
+          });
+        }
+      } catch (err) {
+        // eslint-disable-next-line no-console
+        console.log(err);
+      }
+    },
   },
 };