Commit 9002e75b by 前端

Merge branch 'v3.23.1' into 'master'

合并SOP版本

See merge request !12
2 parents 3860d1f0 dc777a16
project.private.config.json project.private.config.json
project.config.json
miniprogram_npm miniprogram_npm
node_modules node_modules
import { preReleaseAppId } from '~/config' import { preReleaseAppId } from '~/config'
const target = ['ip', 'dev', 'uat', 'prod', 'preRelease'] const target = ['ip', 'dev', 'uat', 'prod', 'preRelease']
let index = 3 let index = 2
/** /**
* *
......
...@@ -12,6 +12,7 @@ import entmicroApi from './entmicro' ...@@ -12,6 +12,7 @@ import entmicroApi from './entmicro'
import strategyApi from './strategy' import strategyApi from './strategy'
import questionnaireApi from './questionnaire' import questionnaireApi from './questionnaire'
import rescueApi from './rescueApi' import rescueApi from './rescueApi'
import sopApi from './sopApi'
module.exports = { module.exports = {
wechatApi, wechatApi,
...@@ -27,5 +28,6 @@ module.exports = { ...@@ -27,5 +28,6 @@ module.exports = {
entmicroApi, entmicroApi,
strategyApi, strategyApi,
questionnaireApi, questionnaireApi,
rescueApi rescueApi,
sopApi
} }
\ No newline at end of file \ 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 \ No newline at end of file
...@@ -3,9 +3,13 @@ ...@@ -3,9 +3,13 @@
import sentryInit from "~/utils/sentryConfig/sentryInit"; import sentryInit from "~/utils/sentryConfig/sentryInit";
sentryInit(); sentryInit();
import api from "./api/index"; 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 utils from "./utils/index";
// 埋点 有需要再引入 // 埋点 有需要再引入
import TRACK from './utils/track/Track' import TRACK from './utils/track/Track'
...@@ -21,9 +25,15 @@ App({ ...@@ -21,9 +25,15 @@ App({
api, api,
router, router,
storage: new utils.cache.Storage(), 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(); utils.cache.storageApi.setSystem_info();
}, },
......
...@@ -164,6 +164,14 @@ ...@@ -164,6 +164,14 @@
"pages/success/success", "pages/success/success",
"pages/packageDetail/packageDetail" "pages/packageDetail/packageDetail"
] ]
},
{
"root": "packageActivity",
"pages": [
"pages/solitaire/index/index",
"pages/redEnvelope/index/index",
"pages/redEnvelope/record/record"
]
} }
], ],
"usingComponents": { "usingComponents": {
......
// packageActivity/pages/redEnvelope/index/index.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file \ No newline at end of file
<!--packageActivity/pages/redEnvelope/index/index.wxml-->
<text>packageActivity/pages/redEnvelope/index/index.wxml</text>
\ No newline at end of file \ No newline at end of file
// packageActivity/pages/redEnvelope/record/record.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file \ No newline at end of file
<!--packageActivity/pages/redEnvelope/record/record.wxml-->
<text>packageActivity/pages/redEnvelope/record/record.wxml</text>
\ No newline at end of file \ No newline at end of file
// packageActivity/pages/solitaire/index/index.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file \ No newline at end of file
<!--packageActivity/pages/solitaire/index/index.wxml-->
<text>packageActivity/pages/solitaire/index/index.wxml</text>
\ No newline at end of file \ No newline at end of file
{
"appid": "wxb818f6bc908c52fc",
"compileType": "miniprogram",
"packOptions": {
"ignore": [],
"include": []
},
"setting": {
"coverView": true,
"es6": true,
"postcss": true,
"minified": true,
"enhance": true,
"showShadowRootInWxmlPanel": true,
"packNpmRelationList": [],
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"useCompilerPlugins": [
"sass"
]
},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 2
}
}
\ No newline at end of file \ No newline at end of file
...@@ -88,8 +88,9 @@ class Router { ...@@ -88,8 +88,9 @@ class Router {
* @param {*} callBack true未登录 false已登录 * @param {*} callBack true未登录 false已登录
*/ */
async intercept(auto = true) { async intercept(auto = true) {
const authStatus = wx.$LoginStatus const authStatus = wx.$LoginStatus,
if (authStatus) { userInfo = wx.p.cache.userInfo.getUserInfo() || {}
if (!userInfo.phone || authStatus) {
if (auto) wx.navigateTo({ if (auto) wx.navigateTo({
url: '/pages/Login/Login', url: '/pages/Login/Login',
}) })
......
// 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方法为空的默认指定值
...@@ -50,3 +53,33 @@ export const IMG_VERSION = async () => { ...@@ -50,3 +53,33 @@ export const IMG_VERSION = async () => {
const accountInfo = await util.getMockData() const accountInfo = await util.getMockData()
return accountInfo?.version || Date.now() return accountInfo?.version || Date.now()
} }
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 \ No newline at end of file
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
*/ */
import mapApi from '../mapapi/mapapi' import mapApi from '../mapapi/mapapi'
import api from '~/api/request/http' 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'
import Storage from '~/utils/cache/storage' import Storage from '~/utils/cache/storage'
...@@ -14,12 +16,19 @@ let TRACK_TIME = null, ...@@ -14,12 +16,19 @@ let TRACK_TIME = null,
const track_interval_time = 60 * 1e3 const track_interval_time = 60 * 1e3
class TRACK { class TRACK {
constructor() { _customObject = {}
constructor(options, customObject = {
onLoadFun: [],
onShowFun: [],
onHideFun: []
}) {
if (options.scene == 1154 && options.mode == 'singlePage') return //朋友圈单页模式
console.log('---------------- 埋点初始化 ----------------') console.log('---------------- 埋点初始化 ----------------')
this.initPageProxy() this.initPageProxy()
// this.sendTrack() // this.sendTrack()
//this.getAddressInfo().then(res => (ADDRESS_INFO = res)) //this.getAddressInfo().then(res => (ADDRESS_INFO = res))
// this.appHide() // this.appHide()
this._customObject = customObject
} }
/**监听页面 */ /**监听页面 */
pageLeaveProxy(thisPage) { pageLeaveProxy(thisPage) {
...@@ -34,16 +43,25 @@ class TRACK { ...@@ -34,16 +43,25 @@ class TRACK {
// , _this.setTrack({}, 1) // , _this.setTrack({}, 1)
} }
thisPage.onLoad = function () { thisPage.onLoad = function () {
_this.customPageFun({
thisPage: this
}, 'onLoadFun')
onLoad && onLoad.apply(this, arguments) onLoad && onLoad.apply(this, arguments)
//, _this.setTrack({ //, _this.setTrack({
// enterTime: new Date().format('yyyy-MM-dd hh:mm:ss') // enterTime: new Date().format('yyyy-MM-dd hh:mm:ss')
// }) // })
} }
thisPage.onShow = function () { thisPage.onShow = function () {
_this.customPageFun({
thisPage: this
}, 'onShowFun')
onShow && onShow.apply(this, arguments) onShow && onShow.apply(this, arguments)
// , (_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(
...@@ -54,6 +72,9 @@ class TRACK { ...@@ -54,6 +72,9 @@ class TRACK {
// ) // )
} }
thisPage.onUnload = function () { thisPage.onUnload = function () {
_this.customPageFun({
thisPage: this
}, 'onHideFun')
// let { page_show_time } = _this.getPageInstance() // let { page_show_time } = _this.getPageInstance()
onUnload && onUnload.apply(this, arguments) onUnload && onUnload.apply(this, arguments)
// ,_this.setTrack( // ,_this.setTrack(
...@@ -113,7 +134,11 @@ class TRACK { ...@@ -113,7 +134,11 @@ class TRACK {
jsonList: prepare_data jsonList: prepare_data
} }
if (prepare_data && prepare_data.length) 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) { if (code == 0 && data) {
$Storage.set('prepare_data', []) $Storage.set('prepare_data', [])
console.log('---------------- 埋点定时推送成功 ----------------', new Date().format('yyyy-MM-dd hh:mm:ss'), ':', prepare_data) console.log('---------------- 埋点定时推送成功 ----------------', new Date().format('yyyy-MM-dd hh:mm:ss'), ':', prepare_data)
...@@ -128,11 +153,16 @@ class TRACK { ...@@ -128,11 +153,16 @@ class TRACK {
} }
/**获取页面标题 */ /**获取页面标题 */
getPageTitle() { getPageTitle() {
let { route, navigationBarTitleText } = this.getPageInstance() let {
route,
navigationBarTitleText
} = this.getPageInstance()
if ('\u672a\u53d6\u5230' === route || !route) return '' if ('\u672a\u53d6\u5230' === route || !route) return ''
let title = '' let title = ''
if (__wxConfig) { if (__wxConfig) {
let { window } = __wxConfig.page[`${route}.html`] let {
window
} = __wxConfig.page[`${route}.html`]
title = window.navigationStyle == 'custom' ? navigationBarTitleText : window.navigationBarTitleText title = window.navigationStyle == 'custom' ? navigationBarTitleText : window.navigationBarTitleText
} }
if (!title) title = '中海物业' if (!title) title = '中海物业'
...@@ -140,7 +170,13 @@ class TRACK { ...@@ -140,7 +170,13 @@ class TRACK {
} }
/**获取设备信息 */ /**获取设备信息 */
getSystemInfo() { getSystemInfo() {
let { SDKVersion, brand, model, system, version } = $Storage.get('system_info') let {
SDKVersion,
brand,
model,
system,
version
} = $Storage.get('system_info')
return { return {
SDK_version: SDKVersion, SDK_version: SDKVersion,
brand, brand,
...@@ -151,7 +187,9 @@ class TRACK { ...@@ -151,7 +187,9 @@ class TRACK {
} }
/**获取门店信息 */ /**获取门店信息 */
getMerchantInfo() { getMerchantInfo() {
let { merchantId } = $Storage.get('merchant_info') let {
merchantId
} = $Storage.get('merchant_info')
return { return {
merchant_id: merchantId merchant_id: merchantId
} }
...@@ -164,7 +202,10 @@ class TRACK { ...@@ -164,7 +202,10 @@ class TRACK {
else else
wx.getLocation({ wx.getLocation({
type: 'gcj02' type: 'gcj02'
}).then(({ latitude, longitude }) => { }).then(({
latitude,
longitude
}) => {
if (!addressInfo) this.setTrack({}, 5) if (!addressInfo) this.setTrack({}, 5)
console.log('---------------- 更新地理位置 ----------------') console.log('---------------- 更新地理位置 ----------------')
mapApi.detailedAdrress([latitude, longitude]).then(detail => { mapApi.detailedAdrress([latitude, longitude]).then(detail => {
...@@ -187,6 +228,13 @@ class TRACK { ...@@ -187,6 +228,13 @@ class TRACK {
} }
return `GH_${name}_${Date.now()}` 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 \ 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!