Commit a5bda94d by 李伟康

Merge branch 'master' into v3.24.0

2 parents 19bc7c7d 9002e75b
......@@ -12,6 +12,7 @@ import entmicroApi from './entmicro'
import strategyApi from './strategy'
import questionnaireApi from './questionnaire'
import rescueApi from './rescueApi'
import sopApi from './sopApi'
import solitaireApi from './solitaire'
module.exports = {
......@@ -29,5 +30,6 @@ module.exports = {
strategyApi,
questionnaireApi,
rescueApi,
solitaireApi
solitaireApi,
sopApi
}
\ No newline at end of file
import api from "../request/http"
import {
getScene,
sopTrackPage,
sopTrackPageType
} from '~/utils/constantData'
/**
* sop客户埋点上报
*/
const getDuration = page_show_time => (Date.now() - page_show_time) / 1e3
const reportClick = ({
thisPage,
options
}) => {
thisPage.options = {
...options,
...thisPage.options
}
reportSopCustomer(thisPage, 'PAGE_CLICK')
}
const reportHide = ({
thisPage
}) => {
reportSopCustomer(thisPage, 'PAGE_STOP')
}
const reportSopCustomer = async (thisPage, event_type) => {
const {
options,
route
} = thisPage
if (sopTrackPage.includes(route)) {
if (!sopTrackPage.includes(wx.p.router.getPageInstance().route)) return
if (options && options.scene) {
const data = await getScene(options.scene)
thisPage.options = data
reportSopFun(thisPage, event_type)
} else reportSopFun(thisPage, event_type)
}
}
const reportSopFun = async (thisPage, event_type) => {
const {
options,
route
} = thisPage
if (!options.sopId) return
const userInfo = wx.p.storage.get('userInfo') || {},
pageType = sopTrackPageType[route] || '',
activityId = options.id || '',
merchantId = options.merchantId || '',
unionId = userInfo.unionId || '',
sopId = options.sopId || '',
extra = {
pageType,
activityId,
unionId,
merchantId,
sopId,
}
if (event_type == 'PAGE_STOP') extra.time = getDuration(thisPage.page_show_time)
const buryingPointList = [{
customer_phone: userInfo.phone || '',
add_way: 'SOP',
sopId,
// id_number: '',
// org_user_id: '',
// wechat_id: '',
wechat_union_id: unionId,
org_id: merchantId,
system_source: 'scrm',
platform: 'MimiProgram',
event_type,
event_time: new Date().format('yyyy-MM-dd hh:mm:ss'),
extra: JSON.stringify(extra)
}]
api.post({
method: 'marketing.api.sop.buryingPoint',
projectName: 'material',
buryingPointList
}, true)
}
module.exports = {
reportSopCustomer,
reportClick,
reportHide
}
\ No newline at end of file
......@@ -3,9 +3,13 @@
import sentryInit from "~/utils/sentryConfig/sentryInit";
sentryInit();
import api from "./api/index";
import { router } from "./router/index";
import {
router
} from "./router/index";
// 判断小程序是否需要更新
import { getUpdateManager } from "./lib/index";
import {
getUpdateManager
} from "./lib/index";
import utils from "./utils/index";
// 埋点 有需要再引入
import TRACK from './utils/track/Track'
......@@ -21,9 +25,15 @@ App({
api,
router,
storage: new utils.cache.Storage(),
$Track: new TRACK(options),
$Track: new TRACK(options, {
onLoadFun: [
api.sopApi.reportClick
],
onHideFun:[
api.sopApi.reportHide
]
}),
};
console.log(wx.p);
// 存储设备信息
utils.cache.storageApi.setSystem_info();
},
......@@ -35,11 +45,11 @@ App({
globalData: {
ROUTE_QUERY: {},
goodsPageParam: {
appearance: 1,
pageSize: 0,
pageCount: 3
appearance: 1,
pageSize: 0,
pageCount: 3
},
goodsLoaded: false,
goodsCommodityList: []
},
});
});
\ No newline at end of file
// export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/store-assistant/'
import getAppId from '~/utils/utils_wx'
import util from '~/utils/util'
import api from "~/api/request/http"
export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/'
// 缓存get方法为空的默认指定值
......@@ -49,4 +52,34 @@ export const STORAGE_OBJECTkEY = {
export const IMG_VERSION = async () => {
const accountInfo = await util.getMockData()
return accountInfo?.version || Date.now()
}
\ No newline at end of file
}
export const sopTrackPage = [
'packageMine/pages/questionnaire/questionnaire'
]
export const sopTrackPageType = {
'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
......@@ -3,7 +3,9 @@
*/
import mapApi from '../mapapi/mapapi'
import api from '~/api/request/http'
import { getUserInfo } from '~/utils/cache/userInfo'
import {
getUserInfo
} from '~/utils/cache/userInfo'
// 实例化对象存储
// import { Storage } from '~/utils/cache/storage'
import Storage from '~/utils/cache/storage'
......@@ -14,12 +16,19 @@ let TRACK_TIME = null,
const track_interval_time = 60 * 1e3
class TRACK {
constructor() {
_customObject = {}
constructor(options, customObject = {
onLoadFun: [],
onShowFun: [],
onHideFun: []
}) {
if (options.scene == 1154 && options.mode == 'singlePage') return //朋友圈单页模式
console.log('---------------- 埋点初始化 ----------------')
this.initPageProxy()
// this.sendTrack()
//this.getAddressInfo().then(res => (ADDRESS_INFO = res))
// this.appHide()
this._customObject = customObject
}
/**监听页面 */
pageLeaveProxy(thisPage) {
......@@ -34,16 +43,25 @@ class TRACK {
// , _this.setTrack({}, 1)
}
thisPage.onLoad = function () {
_this.customPageFun({
thisPage: this
}, 'onLoadFun')
onLoad && onLoad.apply(this, arguments)
//, _this.setTrack({
// enterTime: new Date().format('yyyy-MM-dd hh:mm:ss')
// })
}
thisPage.onShow = function () {
_this.customPageFun({
thisPage: this
}, 'onShowFun')
onShow && onShow.apply(this, arguments)
// , (_this.getPageInstance().page_show_time = Date.now())
, (_this.getPageInstance().page_show_time = Date.now())
}
thisPage.onHide = function () {
_this.customPageFun({
thisPage: this
}, 'onHideFun')
// let { page_show_time } = _this.getPageInstance()
onHide && onHide.apply(this, arguments)
// ,_this.setTrack(
......@@ -54,6 +72,9 @@ class TRACK {
// )
}
thisPage.onUnload = function () {
_this.customPageFun({
thisPage: this
}, 'onHideFun')
// let { page_show_time } = _this.getPageInstance()
onUnload && onUnload.apply(this, arguments)
// ,_this.setTrack(
......@@ -113,7 +134,11 @@ class TRACK {
jsonList: prepare_data
}
if (prepare_data && prepare_data.length)
api.post(data, true).then(({ code, data, message }) => {
api.post(data, true).then(({
code,
data,
message
}) => {
if (code == 0 && data) {
$Storage.set('prepare_data', [])
console.log('---------------- 埋点定时推送成功 ----------------', new Date().format('yyyy-MM-dd hh:mm:ss'), ':', prepare_data)
......@@ -128,11 +153,16 @@ class TRACK {
}
/**获取页面标题 */
getPageTitle() {
let { route, navigationBarTitleText } = this.getPageInstance()
let {
route,
navigationBarTitleText
} = this.getPageInstance()
if ('\u672a\u53d6\u5230' === route || !route) return ''
let title = ''
if (__wxConfig) {
let { window } = __wxConfig.page[`${route}.html`]
let {
window
} = __wxConfig.page[`${route}.html`]
title = window.navigationStyle == 'custom' ? navigationBarTitleText : window.navigationBarTitleText
}
if (!title) title = '中海物业'
......@@ -140,7 +170,13 @@ class TRACK {
}
/**获取设备信息 */
getSystemInfo() {
let { SDKVersion, brand, model, system, version } = $Storage.get('system_info')
let {
SDKVersion,
brand,
model,
system,
version
} = $Storage.get('system_info')
return {
SDK_version: SDKVersion,
brand,
......@@ -151,7 +187,9 @@ class TRACK {
}
/**获取门店信息 */
getMerchantInfo() {
let { merchantId } = $Storage.get('merchant_info')
let {
merchantId
} = $Storage.get('merchant_info')
return {
merchant_id: merchantId
}
......@@ -164,7 +202,10 @@ class TRACK {
else
wx.getLocation({
type: 'gcj02'
}).then(({ latitude, longitude }) => {
}).then(({
latitude,
longitude
}) => {
if (!addressInfo) this.setTrack({}, 5)
console.log('---------------- 更新地理位置 ----------------')
mapApi.detailedAdrress([latitude, longitude]).then(detail => {
......@@ -187,6 +228,13 @@ class TRACK {
}
return `GH_${name}_${Date.now()}`
}
/**在全局埋点onShow增加自定义埋点事件 */
customPageFun(options, name) {
this._customObject[name]?.map(e => {
e && e(options)
})
}
}
export default TRACK
export default TRACK
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!