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 a5bda94d
authored
Jan 18, 2024
by
李伟康
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'master' into v3.24.0
2 parents
19bc7c7d
9002e75b
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
192 additions
and
14 deletions
api/module/index.js
api/module/sopApi.js
app.js
utils/constantData.js
utils/track/Track.js
api/module/index.js
View file @
a5bda94
...
@@ -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'
import
solitaireApi
from
'./solitaire'
import
solitaireApi
from
'./solitaire'
module
.
exports
=
{
module
.
exports
=
{
...
@@ -29,5 +30,6 @@ module.exports = {
...
@@ -29,5 +30,6 @@ module.exports = {
strategyApi
,
strategyApi
,
questionnaireApi
,
questionnaireApi
,
rescueApi
,
rescueApi
,
solitaireApi
solitaireApi
,
sopApi
}
}
\ No newline at end of file
\ No newline at end of file
api/module/sopApi.js
0 → 100644
View file @
a5bda94
import
api
from
"../request/http"
import
{
getScene
,
sopTrackPage
,
sopTrackPageType
}
from
'~/utils/constantData'
/**
* sop客户埋点上报
*/
const
getDuration
=
page_show_time
=>
(
Date
.
now
()
-
page_show_time
)
/
1
e3
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
app.js
View file @
a5bda94
...
@@ -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
();
},
},
...
...
utils/constantData.js
View file @
a5bda94
// 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
utils/track/Track.js
View file @
a5bda94
...
@@ -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
*
1
e3
const
track_interval_time
=
60
*
1
e3
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
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