Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas
/
mini-program
/
zhwy
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 971ce0f3
authored
Jan 09, 2024
by
李伟康
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
提交SOP埋点
1 parent
300eb55f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
97 additions
and
37 deletions
api/module/sopApi.js
app.js
utils/constantData.js
utils/track/Track.js
api/module/sopApi.js
View file @
971ce0f
import
api
from
"../request/http"
import
api
from
"../request/http"
import
{
import
{
getScene
,
sopTrackPage
,
sopTrackPage
,
sopTrackPageType
sopTrackPageType
}
from
'~/utils/constantData'
}
from
'~/utils/constantData'
...
@@ -15,56 +16,82 @@ const reportClick = ({
...
@@ -15,56 +16,82 @@ 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'
)
},
3
e3
)
},
3
e3
)
}
}
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
const
userInfo
=
wx
.
p
.
storage
.
get
(
'userInfo'
)
||
{},
if
(
options
&&
options
.
scene
)
{
pageType
=
sopTrackPageType
[
route
]
||
''
,
const
data
=
await
getScene
(
options
.
scene
)
activityId
=
options
.
id
||
''
,
thisPage
.
options
=
data
merchantId
=
options
.
merchantId
||
''
,
reportSopFun
({
unionId
=
userInfo
.
unionId
||
''
,
options
:
data
,
extra
=
JSON
.
stringify
({
route
pageType
,
},
event_type
)
activityId
,
}
else
reportSopFun
({
unionId
,
options
,
merchantId
,
route
}),
},
event_type
)
buryingPointList
=
[{
customer_phone
:
userInfo
.
phone
||
''
,
add_way
:
'SOP'
,
// 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
}]
api
.
post
({
method
:
'marketing.api.sop.buryingPoint'
,
projectName
:
'material'
,
buryingPointList
},
true
)
}
}
}
}
const
reportSopFun
=
async
({
options
,
route
},
event_type
)
=>
{
if
(
!
options
.
sopId
)
return
const
userInfo
=
wx
.
p
.
storage
.
get
(
'userInfo'
)
||
{},
pageType
=
sopTrackPageType
[
route
]
||
''
,
activityId
=
options
.
id
||
''
,
merchantId
=
options
.
merchantId
||
''
,
unionId
=
userInfo
.
unionId
||
''
,
extra
=
JSON
.
stringify
({
pageType
,
activityId
,
unionId
,
merchantId
,
}),
buryingPointList
=
[{
customer_phone
:
userInfo
.
phone
||
''
,
add_way
:
'SOP'
,
sopId
:
options
.
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
}]
api
.
post
({
method
:
'marketing.api.sop.buryingPoint'
,
projectName
:
'material'
,
buryingPointList
},
true
)
}
module
.
exports
=
{
module
.
exports
=
{
reportSopCustomer
,
reportSopCustomer
,
reportStop
,
reportStop
,
reportClick
reportClick
,
reportHide
}
}
\ No newline at end of file
\ No newline at end of file
app.js
View file @
971ce0f
...
@@ -31,6 +31,9 @@ App({
...
@@ -31,6 +31,9 @@ App({
],
],
onLoadFun
:
[
onLoadFun
:
[
api
.
sopApi
.
reportClick
api
.
sopApi
.
reportClick
],
onHideFun
:[
api
.
sopApi
.
reportHide
]
]
}),
}),
};
};
...
...
utils/constantData.js
View file @
971ce0f
// 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方法为空的默认指定值
...
@@ -56,4 +59,27 @@ export const sopTrackPage = [
...
@@ -56,4 +59,27 @@ export const sopTrackPage = [
]
]
export
const
sopTrackPageType
=
{
export
const
sopTrackPageType
=
{
'packageMine/pages/questionnaire/questionnaire'
:
7
,
'packageMine/pages/questionnaire/questionnaire'
:
7
,
}
\ No newline at end of file
\ No newline at end of file
}
/**
* 获取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
utils/track/Track.js
View file @
971ce0f
...
@@ -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(
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment