Commit 971ce0f3 by 李伟康

提交SOP埋点

1 parent 300eb55f
import api from "../request/http" import api from "../request/http"
import { import {
getScene,
sopTrackPage, sopTrackPage,
sopTrackPageType sopTrackPageType
} from '~/utils/constantData' } from '~/utils/constantData'
...@@ -15,22 +16,47 @@ const reportClick = ({ ...@@ -15,22 +16,47 @@ const reportClick = ({
...thisPage.options ...thisPage.options
} }
reportSopCustomer(thisPage, 'PAGE_CLICK') reportSopCustomer(thisPage, 'PAGE_CLICK')
//
} }
const reportStop = ({ const reportStop = ({
thisPage thisPage
}) => { }) => {
setTimeout(() => { thisPage.sopTimer = setInterval(() => {
reportSopCustomer(thisPage, 'PAGE_STOP') reportSopCustomer(thisPage, 'PAGE_STOP')
}, 3e3) }, 3e3)
} }
const reportSopCustomer = (thisPage, event_type) => { const reportHide = ({
thisPage
}) => {
if (thisPage.sopTimer) {
clearInterval(thisPage.sopTimer)
thisPage.sopTimer = null
}
}
const reportSopCustomer = async (thisPage, event_type) => {
const { const {
options, options,
route route
} = thisPage } = thisPage
if (sopTrackPage.includes(route) && (options.sopId)) { if (sopTrackPage.includes(route)) {
if (!sopTrackPage.includes(wx.p.router.getPageInstance().route)) return if (!sopTrackPage.includes(wx.p.router.getPageInstance().route)) return
if (options && options.scene) {
const data = await getScene(options.scene)
thisPage.options = data
reportSopFun({
options: data,
route
}, event_type)
} else reportSopFun({
options,
route
}, event_type)
}
}
const reportSopFun = async ({
options,
route
}, event_type) => {
if (!options.sopId) return
const userInfo = wx.p.storage.get('userInfo') || {}, const userInfo = wx.p.storage.get('userInfo') || {},
pageType = sopTrackPageType[route] || '', pageType = sopTrackPageType[route] || '',
activityId = options.id || '', activityId = options.id || '',
...@@ -45,6 +71,7 @@ const reportSopCustomer = (thisPage, event_type) => { ...@@ -45,6 +71,7 @@ const reportSopCustomer = (thisPage, event_type) => {
buryingPointList = [{ buryingPointList = [{
customer_phone: userInfo.phone || '', customer_phone: userInfo.phone || '',
add_way: 'SOP', add_way: 'SOP',
sopId: options.sopId,
// id_number: '', // id_number: '',
// org_user_id: '', // org_user_id: '',
// wechat_id: '', // wechat_id: '',
...@@ -61,10 +88,10 @@ const reportSopCustomer = (thisPage, event_type) => { ...@@ -61,10 +88,10 @@ const reportSopCustomer = (thisPage, event_type) => {
projectName: 'material', projectName: 'material',
buryingPointList buryingPointList
}, true) }, true)
}
} }
module.exports = { module.exports = {
reportSopCustomer, reportSopCustomer,
reportStop, reportStop,
reportClick reportClick,
reportHide
} }
\ No newline at end of file \ No newline at end of file
...@@ -31,6 +31,9 @@ App({ ...@@ -31,6 +31,9 @@ App({
], ],
onLoadFun: [ onLoadFun: [
api.sopApi.reportClick api.sopApi.reportClick
],
onHideFun:[
api.sopApi.reportHide
] ]
}), }),
}; };
......
// export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/store-assistant/' // export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/store-assistant/'
import getAppId from '~/utils/utils_wx' import getAppId from '~/utils/utils_wx'
import util from '~/utils/util' import util from '~/utils/util'
import api from "~/api/request/http"
export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/' export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/'
// 缓存get方法为空的默认指定值 // 缓存get方法为空的默认指定值
...@@ -57,3 +60,26 @@ export const sopTrackPage = [ ...@@ -57,3 +60,26 @@ export const sopTrackPage = [
export const sopTrackPageType = { export const sopTrackPageType = {
'packageMine/pages/questionnaire/questionnaire': 7, 'packageMine/pages/questionnaire/questionnaire': 7,
} }
/**
* 获取scene参数
*/
export const getScene = scene => {
return new Promise(async (resolve, reject) => {
const qrcodeQuery = decodeURIComponent(scene),
id = qrcodeQuery.split("=").pop(),
res = await api.post({
method: 'scrm.api.wechat.get.scene.by.id',
id
},
true)
let obj = {}
if (res.code == "0") {
let paramsArr = res?.data?.scene?.split("&");
paramsArr.forEach((item) => {
let keyValArr = item?.split('=')
obj[keyValArr[0]] = keyValArr[1]
})
resolve(obj)
} else reject(res.message)
})
};
\ No newline at end of file \ No newline at end of file
...@@ -19,7 +19,8 @@ class TRACK { ...@@ -19,7 +19,8 @@ class TRACK {
_customObject = {} _customObject = {}
constructor(options, customObject = { constructor(options, customObject = {
onLoadFun: [], onLoadFun: [],
onShowFun: [] onShowFun: [],
onHideFun: []
}) { }) {
if (options.scene == 1154 && options.mode == 'singlePage') return //朋友圈单页模式 if (options.scene == 1154 && options.mode == 'singlePage') return //朋友圈单页模式
console.log('---------------- 埋点初始化 ----------------') console.log('---------------- 埋点初始化 ----------------')
...@@ -58,6 +59,9 @@ class TRACK { ...@@ -58,6 +59,9 @@ class TRACK {
// , (_this.getPageInstance().page_show_time = Date.now()) // , (_this.getPageInstance().page_show_time = Date.now())
} }
thisPage.onHide = function () { thisPage.onHide = function () {
_this.customPageFun({
thisPage: this
}, 'onHideFun')
// let { page_show_time } = _this.getPageInstance() // let { page_show_time } = _this.getPageInstance()
onHide && onHide.apply(this, arguments) onHide && onHide.apply(this, arguments)
// ,_this.setTrack( // ,_this.setTrack(
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!