bobo 3 éve
szülő
commit
745241975e

+ 32 - 0
components/statistics/index.js

@@ -0,0 +1,32 @@
+import request from '../../utils/request.js'
+import { getMobileCache } from '../../utils/user'
+
+class Statistics extends request {
+    static done(params) {
+        const accountInfo = wx.getAccountInfoSync()
+        const pages = getCurrentPages()
+        const path = pages[pages.length - 1].route
+        const options =  wx.getLaunchOptionsSync()
+        const referrerInfo = options.referrerInfo || {}
+        const extraData = referrerInfo.extraData || {}
+        const department = extraData.department || '';
+
+        let postParam = {
+            source: 'WX_MINI_APP',
+            channel: params.channel || '',
+            module: params.module,
+            action: params.action,
+            appid: accountInfo.miniProgram.appId,
+            path,
+            scene: options.scene,
+            fromAppid: referrerInfo.appId || '',
+            department,
+            mobile: getMobileCache(),
+            businessId: params.businessId || '',
+        }
+
+        this.postRequest(`${this.BASE_URL}open/statistics/record-app-visit-log`, postParam, true).then(_=>{}).catch(_=>{})
+    }
+}
+
+export default Statistics

+ 13 - 0
pages/luckDraw/detail.js

@@ -1,6 +1,7 @@
 // pages/luckDraw/detail.js
 import LuckDraw from '../../api/luck-draw'
 import Common from './common'
+import Statistics from '../../components/statistics/index'
 import {getMobileCache, getPhoneNumber as getPhoneNumberSync} from '../../utils/user'
 const app = getApp();
 
@@ -68,6 +69,12 @@ Page({
         this.getDrawTimes()
         // 获取中奖名单
         this.getHitRecord()
+
+        Statistics.done({
+            module: 'luckdraw',
+            action: 'visit',
+            businessId: this.data.activityId,
+        })
     },
     loadActivity: function() {
         LuckDraw.getActivityDetail(this.data.activityId).then(resp => {
@@ -223,6 +230,12 @@ Page({
                 this.requestDrawPrize()
             }, (Math.random() + 1)*1000)
         }
+
+        Statistics.done({
+            module: 'luckdraw',
+            action: 'click',
+            businessId: this.data.activityId
+        })
     },
     
     requestDrawPrize: function() {

+ 14 - 1
pages/signIn/activity/activity.js

@@ -1,5 +1,6 @@
 // pages/signIn/index.js
 import SignIn from '../../../api/signIn'
+import Statistics from '../../../components/statistics/index'
 import { isEmpty } from '../../../utils/util'
 import { getMobileCache, getPhoneNumber as getPhoneNumberSync } from '../../../utils/user'
 const app = getApp();
@@ -28,7 +29,6 @@ Page({
      * 生命周期函数--监听页面加载
      */
     onLoad: function (options) {
-        
     },
 
         /**
@@ -49,6 +49,13 @@ Page({
                     activity: res.data
                 })
                 this.mapToView(res.data)
+
+                Statistics.done({
+                    module: 'signin',
+                    action: 'visit',
+                    businessId: res.data.id,
+                })
+
             }
         }).catch(_ => {
 
@@ -185,6 +192,12 @@ Page({
         }).finally(_ => {
             this.isLocked = false
         })
+
+        Statistics.done({
+            module: 'signin',
+            action: 'click',
+            businessId: this.data.activity.id,
+        })
     },
 
     /**