Commit a8e9746d by 李伟康

修改浏览埋点

1 parent 2e627bbc
...@@ -7,9 +7,6 @@ const navStyle = "background-color: #fff"; ...@@ -7,9 +7,6 @@ const navStyle = "background-color: #fff";
import { import {
senceData senceData
} from "~/pages/tab/index/constant/data"; } from "~/pages/tab/index/constant/data";
import {
reportData
} from '~/api/index.js'
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
...@@ -59,33 +56,15 @@ Page({ ...@@ -59,33 +56,15 @@ Page({
actNum, actNum,
activeNavIdx activeNavIdx
}) })
if (this.options?.shareOpenId) {
const WXUSERINFO = wx.$storage.get('wx_user_info'),
USERINFO = wx.$storage.get('userInfo'),
shareInfo = this.options
reportData({
openId: WXUSERINFO.openId || '',
unionId: WXUSERINFO.unionId || '',
nickName: WXUSERINFO.nickName || '',
avatar: WXUSERINFO.avatarUrl || '',
phone: USERINFO.phone || '',
merchantId: shareInfo.merchantId || '',
shareOpenId: shareInfo.shareOpenId || '',
sharePhone: shareInfo.sharePhone || '',
productCode: shareInfo.productCode || '',
productDesc: shareInfo.productDesc || ''
}, 1)
// 禁用分享功能
wx.hideShareMenu()
}
}, },
onViewTrack: true, //是否浏览埋点
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
// actNum,activeNavIdx isShare // actNum,activeNavIdx isShare
// 禁用分享功能
wx.hideShareMenu()
}, },
/** /**
......
...@@ -5,7 +5,6 @@ import { IMG_URL } from '~/utils/constantData' ...@@ -5,7 +5,6 @@ import { IMG_URL } from '~/utils/constantData'
import { generateRoutList } from './wxOnAppRoute.js' import { generateRoutList } from './wxOnAppRoute.js'
import { getNavigationBarTitleText } from '~/utils/cache/storageApi' import { getNavigationBarTitleText } from '~/utils/cache/storageApi'
import { getUserInfo } from '~/utils/cache/userInfo' import { getUserInfo } from '~/utils/cache/userInfo'
import USERAPI from '~/api/usersApi/index'
class Router { class Router {
[_query] = {}; [_query] = {};
[_routeHooks] = []; [_routeHooks] = [];
...@@ -13,10 +12,9 @@ class Router { ...@@ -13,10 +12,9 @@ class Router {
constructor(router) { constructor(router) {
this[_routerList] = generateRoutList(router) this[_routerList] = generateRoutList(router)
wx.onAppRoute && wx.onAppRoute &&
wx.onAppRoute(async e => { wx.onAppRoute(e => {
let thisPage = this.getPageInstance() let thisPage = this.getPageInstance()
if (thisPage) { if (thisPage) {
if(!thisPage.route.includes('login')) await USERAPI.getWXUserInfo()
thisPage.setData({ IMG_URL }) thisPage.setData({ IMG_URL })
if(Object.keys(this[_query]).length) thisPage.options = this[_query] if(Object.keys(this[_query]).length) thisPage.options = this[_query]
this.setNavigationBarTitleText(thisPage) this.setNavigationBarTitleText(thisPage)
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
import { import {
reportData reportData
} from '~/api/index.js' } from '~/api/index.js'
import USERAPI from '~/api/usersApi/index'
class Share { class Share {
constructor() { constructor() {
console.log('---------------- 分享初始化 ----------------') console.log('---------------- 分享初始化 ----------------')
...@@ -31,6 +33,8 @@ class Share { ...@@ -31,6 +33,8 @@ class Share {
/**设置全局分享 */ /**设置全局分享 */
pageLeaveProxy(page) { pageLeaveProxy(page) {
const onLoad = page.onLoad,
that = this
if (page.onShareAppMessage) { if (page.onShareAppMessage) {
const that = this const that = this
page.onShareAppMessage = function () { page.onShareAppMessage = function () {
...@@ -78,6 +82,28 @@ class Share { ...@@ -78,6 +82,28 @@ class Share {
} }
} }
} }
page.onLoad = async function () {
onLoad && onLoad.apply(this, arguments)
if (this.onViewTrack) {
const WXUSERINFO = await USERAPI.getWXUserInfo(),
{
USERINFO
} = that.getCommonData(),
shareInfo = this.options
reportData({
openId: WXUSERINFO.openId || '',
unionId: WXUSERINFO.unionId || '',
nickName: WXUSERINFO.nickName || '',
avatar: WXUSERINFO.avatarUrl || '',
phone: USERINFO.phone || '',
merchantId: shareInfo.merchantId || '',
shareOpenId: shareInfo.shareOpenId || '',
sharePhone: shareInfo.sharePhone || '',
productCode: shareInfo.productCode || '',
productDesc: shareInfo.productDesc || ''
}, 1)
}
}
} }
getCommonData() { getCommonData() {
const WXUSERINFO = wx.$storage.get('wx_user_info'), const WXUSERINFO = wx.$storage.get('wx_user_info'),
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!