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 cecf7503
authored
Sep 26, 2023
by
匡雅琴
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
分享事件
1 parent
f146ae1b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
101 additions
and
70 deletions
packageStrategy/pages/strategyDetail/index.js
packageStrategy/pages/strategyDetail/index.json
utils/cache/storage.js
utils/util.js
packageStrategy/pages/strategyDetail/index.js
View file @
cecf750
import
USERAPI
from
'~/api/usersApi/index'
import
USERAPI
from
"~/api/usersApi/index"
;
import
Util
from
"~/utils/util"
;
Page
({
data
:
{
strategyDetailObj
:
{},
},
onLoad
(
options
)
{
this
.
data
.
enter_time
=
new
Date
().
format
(
'yyyy-MM-dd hh:mm:ss'
)
this
.
firstEnter
=
true
this
.
getStrategyDetail
(
options
.
id
);
// 触发埋点
this
.
heartbeatFn
({
...
...
@@ -13,105 +16,107 @@ Page({
view
:
1
})
},
onRoute
:
function
(
options
)
{
console
.
log
(
options
,
"000000"
);
this
.
data
.
enter_time
=
new
Date
().
format
(
'yyyy-MM-dd hh:mm:ss'
)
this
.
firstEnter
=
true
this
.
getStrategyDetail
(
options
.
id
);
// 触发埋点
this
.
heartbeatFn
({
id
:
options
.
id
,
item_type
:
6
,
view
:
1
,
});
},
getStrategyDetail
(
id
)
{
wx
.
p
.
api
.
strategyApi
.
getStrategyDetail
({
id
,
})
.
then
((
res
)
=>
{
Util
.
setNavigationBarTitle
(
res
.
strategyName
);
this
.
setData
({
strategyDetailObj
:
res
,
});
});
},
/**添加埋点开始 */
/**添加埋点开始 */
/**
* 商品-活动id,
* 商品-活动id,
* 物品类型item_type 1 商品 3活动,
* view 动作类型 1浏览 4分享 5离开页面 6心跳
* */
async
addTrack
(
query
)
{
const
{
id
,
item_type
,
view
}
=
query
async
addTrack
(
query
)
{
const
{
id
,
item_type
,
view
}
=
query
;
const
userInfo
=
wx
.
p
.
cache
.
userInfo
.
getUserInfo
()
||
{},
{
openId
}
=
await
USERAPI
.
getWXUserInfo
()
{
openId
}
=
await
USERAPI
.
getWXUserInfo
();
console
.
log
(
wx
.
$merchant_id
,
"======="
);
let
data
=
{
open_id
:
openId
||
null
,
create_time
:
this
.
firstEnter
?
this
.
data
.
enter_time
:
new
Date
().
format
(
'yyyy-MM-dd hh:mm:ss'
),
// 离开时间
create_time
:
this
.
firstEnter
?
this
.
data
.
enter_time
:
new
Date
().
format
(
"yyyy-MM-dd hh:mm:ss"
),
// 离开时间
enter_time
:
this
.
data
.
enter_time
,
// 进入时间
item_type
,
customer_phone
:
userInfo
.
phone
||
null
,
action_type
:
view
,
staff_uuid
:
wx
.
p
.
storage
.
get
(
'scrm_shopmall_staff_uuid'
),
item_id
:
id
,
business_type
:
1
,
add_way
:
104
,
merchant_id
:
wx
.
p
.
storage
.
get
(
'srcm_shopmall_merchant_id'
)
,
merchant_id
:
wx
.
$merchant_id
,
guest_no
:
wx
.
p
.
$Track
.
getGuestNo
(),
//游客ID,
user_open_id
:
this
.
shareOpenId
||
''
}
this
.
firstEnter
=
false
const
jsonList
=
[
JSON
.
stringify
(
data
)]
user_open_id
:
this
.
shareOpenId
||
""
,
}
;
this
.
firstEnter
=
false
;
const
jsonList
=
[
JSON
.
stringify
(
data
)]
;
const
res
=
await
wx
.
p
.
api
.
shopmallApi
.
trackHttp
({
jsonList
})
jsonList
,
})
;
},
heartbeatFn
(
query
)
{
this
.
trackQuery
=
query
this
.
addTrack
(
query
)
this
.
trackQuery
=
query
;
this
.
addTrack
(
query
)
;
this
.
timer
=
setInterval
(()
=>
{
this
.
trackQuery
.
view
=
6
this
.
addTrack
(
this
.
trackQuery
)
},
60
*
1
e3
)
this
.
trackQuery
.
view
=
6
;
this
.
addTrack
(
this
.
trackQuery
)
;
},
60
*
1
e3
)
;
},
/**
/**
* 生命周期函数--监听页面卸载
*/
onUnload
:
function
()
{
if
(
this
.
timer
)
clearInterval
(
this
.
timer
)
this
.
trackQuery
.
view
=
5
this
.
addTrack
(
this
.
trackQuery
)
wx
.
$util
.
customerbehavior
(
2
)
},
onUnload
:
function
()
{
if
(
this
.
timer
)
clearInterval
(
this
.
timer
);
this
.
trackQuery
.
view
=
5
;
this
.
addTrack
(
this
.
trackQuery
);
wx
.
$util
.
customerbehavior
(
2
);
},
/**
/**
* 用户点击右上角分享
*/
onShareAppMessage
:
function
()
{
const
merchantId
=
wx
.
p
.
storage
.
get
(
'srcm_shopmall_merchant_id'
)
const
userInfo
=
wx
.
p
.
cache
.
userInfo
.
getUserInfo
()
let
{
isActivity
,
isLive
,
goodsInfo
}
=
this
.
data
,
open_id
=
''
this
.
trackQuery
.
view
=
4
this
.
addTrack
(
this
.
trackQuery
)
if
(
userInfo
)
open_id
=
userInfo
.
openId
let
title
=
goodsInfo
.
goodsName
let
path
=
`
${
this
.
route
}
?id=
${
goodsInfo
.
id
}
&openId=
${
open_id
}
`
let
imageUrl
=
''
goodsInfo
.
goodsDetailImageList
.
map
(
e
=>
{
if
(
e
.
resType
==
1
&&
!
imageUrl
)
imageUrl
=
e
.
content
})
if
(
isActivity
)
{
title
=
goodsInfo
.
activityName
path
=
`
${
path
}
&isActivity=true`
}
if
(
isLive
)
path
=
`
${
path
}
&isLive=true`
if
(
merchantId
)
path
=
`
${
path
}
&merchantId=
${
merchantId
}
&isUpgrade=
${
this
.
isUpgrade
||
false
}
&isCarOwner=
${
this
.
isCarOwner
||
false
}
`
return
{
imageUrl
,
title
,
path
}
},
onShareAppMessage
:
function
()
{
const
merchantId
=
wx
.
$merchant_id
;
const
userInfo
=
wx
.
p
.
cache
.
userInfo
.
getUserInfo
();
let
{
strategyDetailObj
}
=
this
.
data
,
open_id
=
""
;
console
.
log
(
strategyDetailObj
,
'9999999999'
);
this
.
trackQuery
.
view
=
4
;
this
.
addTrack
(
this
.
trackQuery
);
if
(
userInfo
)
open_id
=
userInfo
.
openId
;
let
title
=
strategyDetailObj
.
strategyName
;
let
path
=
`
${
this
.
route
}
?id=
${
strategyDetailObj
.
id
}
&openId=
${
open_id
}
`
;
let
imageUrl
=
strategyDetailObj
.
strategyImg
;
if
(
merchantId
)
path
=
`
${
path
}
&merchantId=
${
merchantId
}
`
;
console
.
log
(
path
);
console
.
log
(
imageUrl
,
title
);
return
{
imageUrl
,
title
,
path
,
};
},
});
packageStrategy/pages/strategyDetail/index.json
View file @
cecf750
{
"usingComponents"
:
{
"mp-html"
:
"../../../components/mp-html/index"
}
}
\ No newline at end of file
"usingComponents"
:
{
"mp-html"
:
"../../../components/mp-html/index"
}
}
utils/cache/storage.js
View file @
cecf750
...
...
@@ -51,7 +51,6 @@ class Storage {
* @param {*} syncFlag | 同步状态,默认 false (异步),true 为同步
*/
get
=
(
key
,
syncFlag
=
true
)
=>
{
console
.
log
(
key
,
'===='
);
// 有值默认取key值
if
(
key
)
{
// 判断值是否是指定的对象值
...
...
utils/util.js
View file @
cecf750
...
...
@@ -107,12 +107,39 @@ const promise = callBack => {
})
}
//设置标题
const
setNavigationBarTitle
=
(
title
)
=>
{
wx
.
getSystemInfo
({
success
:
(
res
)
=>
{
let
width
=
res
.
safeArea
.
width
/
res
.
fontSizeSetting
;
let
space
=
''
;
width
=
width
-
(
title
.
length
)
/
2
for
(
let
i
=
0
;
i
<
width
;
i
++
)
{
space
=
space
+
' '
;
}
if
(
res
.
system
.
includes
(
'iOS'
)
===
false
)
{
wx
.
setNavigationBarTitle
({
title
:
space
+
title
});
}
else
{
wx
.
setNavigationBarTitle
({
title
:
title
});
}
}
});
}
const
Util
=
{
onReachBottom
,
clearObjNull
,
throttle
,
isEmptyObj
,
parseString
,
promise
promise
,
setNavigationBarTitle
}
export
default
Util
\ 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