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
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
54 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
({
Page
({
data
:
{
data
:
{
strategyDetailObj
:
{},
strategyDetailObj
:
{},
},
},
onLoad
(
options
)
{
onLoad
(
options
)
{
this
.
data
.
enter_time
=
new
Date
().
format
(
'yyyy-MM-dd hh:mm:ss'
)
this
.
firstEnter
=
true
this
.
getStrategyDetail
(
options
.
id
);
this
.
getStrategyDetail
(
options
.
id
);
// 触发埋点
// 触发埋点
this
.
heartbeatFn
({
this
.
heartbeatFn
({
...
@@ -13,12 +16,27 @@ Page({
...
@@ -13,12 +16,27 @@ Page({
view
:
1
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
)
{
getStrategyDetail
(
id
)
{
wx
.
p
.
api
.
strategyApi
wx
.
p
.
api
.
strategyApi
.
getStrategyDetail
({
.
getStrategyDetail
({
id
,
id
,
})
})
.
then
((
res
)
=>
{
.
then
((
res
)
=>
{
Util
.
setNavigationBarTitle
(
res
.
strategyName
);
this
.
setData
({
this
.
setData
({
strategyDetailObj
:
res
,
strategyDetailObj
:
res
,
});
});
...
@@ -32,86 +50,73 @@ Page({
...
@@ -32,86 +50,73 @@ Page({
* view 动作类型 1浏览 4分享 5离开页面 6心跳
* view 动作类型 1浏览 4分享 5离开页面 6心跳
* */
* */
async
addTrack
(
query
)
{
async
addTrack
(
query
)
{
const
{
const
{
id
,
item_type
,
view
}
=
query
;
id
,
item_type
,
view
}
=
query
const
userInfo
=
wx
.
p
.
cache
.
userInfo
.
getUserInfo
()
||
{},
const
userInfo
=
wx
.
p
.
cache
.
userInfo
.
getUserInfo
()
||
{},
{
{
openId
}
=
await
USERAPI
.
getWXUserInfo
();
openId
console
.
log
(
wx
.
$merchant_id
,
"======="
);
}
=
await
USERAPI
.
getWXUserInfo
()
let
data
=
{
let
data
=
{
open_id
:
openId
||
null
,
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
,
// 进入时间
enter_time
:
this
.
data
.
enter_time
,
// 进入时间
item_type
,
item_type
,
customer_phone
:
userInfo
.
phone
||
null
,
customer_phone
:
userInfo
.
phone
||
null
,
action_type
:
view
,
action_type
:
view
,
staff_uuid
:
wx
.
p
.
storage
.
get
(
'scrm_shopmall_staff_uuid'
),
item_id
:
id
,
item_id
:
id
,
business_type
:
1
,
business_type
:
1
,
add_way
:
104
,
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,
guest_no
:
wx
.
p
.
$Track
.
getGuestNo
(),
//游客ID,
user_open_id
:
this
.
shareOpenId
||
''
user_open_id
:
this
.
shareOpenId
||
""
,
}
}
;
this
.
firstEnter
=
false
this
.
firstEnter
=
false
;
const
jsonList
=
[
JSON
.
stringify
(
data
)]
const
jsonList
=
[
JSON
.
stringify
(
data
)]
;
const
res
=
await
wx
.
p
.
api
.
shopmallApi
.
trackHttp
({
const
res
=
await
wx
.
p
.
api
.
shopmallApi
.
trackHttp
({
jsonList
jsonList
,
})
})
;
},
},
heartbeatFn
(
query
)
{
heartbeatFn
(
query
)
{
this
.
trackQuery
=
query
this
.
trackQuery
=
query
;
this
.
addTrack
(
query
)
this
.
addTrack
(
query
)
;
this
.
timer
=
setInterval
(()
=>
{
this
.
timer
=
setInterval
(()
=>
{
this
.
trackQuery
.
view
=
6
this
.
trackQuery
.
view
=
6
;
this
.
addTrack
(
this
.
trackQuery
)
this
.
addTrack
(
this
.
trackQuery
)
;
},
60
*
1
e3
)
},
60
*
1
e3
)
;
},
},
/**
/**
* 生命周期函数--监听页面卸载
* 生命周期函数--监听页面卸载
*/
*/
onUnload
:
function
()
{
onUnload
:
function
()
{
if
(
this
.
timer
)
clearInterval
(
this
.
timer
)
if
(
this
.
timer
)
clearInterval
(
this
.
timer
);
this
.
trackQuery
.
view
=
5
this
.
trackQuery
.
view
=
5
;
this
.
addTrack
(
this
.
trackQuery
)
this
.
addTrack
(
this
.
trackQuery
);
wx
.
$util
.
customerbehavior
(
2
)
wx
.
$util
.
customerbehavior
(
2
);
},
},
/**
/**
* 用户点击右上角分享
* 用户点击右上角分享
*/
*/
onShareAppMessage
:
function
()
{
onShareAppMessage
:
function
()
{
const
merchantId
=
wx
.
p
.
storage
.
get
(
'srcm_shopmall_merchant_id'
)
const
merchantId
=
wx
.
$merchant_id
;
const
userInfo
=
wx
.
p
.
cache
.
userInfo
.
getUserInfo
()
const
userInfo
=
wx
.
p
.
cache
.
userInfo
.
getUserInfo
();
let
{
let
{
strategyDetailObj
}
=
this
.
data
,
isActivity
,
open_id
=
""
;
isLive
,
console
.
log
(
strategyDetailObj
,
'9999999999'
);
goodsInfo
this
.
trackQuery
.
view
=
4
;
}
=
this
.
data
,
open_id
=
''
this
.
addTrack
(
this
.
trackQuery
);
this
.
trackQuery
.
view
=
4
if
(
userInfo
)
open_id
=
userInfo
.
openId
;
this
.
addTrack
(
this
.
trackQuery
)
let
title
=
strategyDetailObj
.
strategyName
;
if
(
userInfo
)
open_id
=
userInfo
.
openId
let
path
=
`
${
this
.
route
}
?id=
${
strategyDetailObj
.
id
}
&openId=
${
open_id
}
`
;
let
title
=
goodsInfo
.
goodsName
let
imageUrl
=
strategyDetailObj
.
strategyImg
;
let
path
=
`
${
this
.
route
}
?id=
${
goodsInfo
.
id
}
&openId=
${
open_id
}
`
if
(
merchantId
)
path
=
`
${
path
}
&merchantId=
${
merchantId
}
`
;
let
imageUrl
=
''
console
.
log
(
path
);
goodsInfo
.
goodsDetailImageList
.
map
(
e
=>
{
console
.
log
(
imageUrl
,
title
);
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
{
return
{
imageUrl
,
imageUrl
,
title
,
title
,
path
path
,
}
};
},
},
});
});
packageStrategy/pages/strategyDetail/index.json
View file @
cecf750
utils/cache/storage.js
View file @
cecf750
...
@@ -51,7 +51,6 @@ class Storage {
...
@@ -51,7 +51,6 @@ class Storage {
* @param {*} syncFlag | 同步状态,默认 false (异步),true 为同步
* @param {*} syncFlag | 同步状态,默认 false (异步),true 为同步
*/
*/
get
=
(
key
,
syncFlag
=
true
)
=>
{
get
=
(
key
,
syncFlag
=
true
)
=>
{
console
.
log
(
key
,
'===='
);
// 有值默认取key值
// 有值默认取key值
if
(
key
)
{
if
(
key
)
{
// 判断值是否是指定的对象值
// 判断值是否是指定的对象值
...
...
utils/util.js
View file @
cecf750
...
@@ -107,12 +107,39 @@ const promise = callBack => {
...
@@ -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
=
{
const
Util
=
{
onReachBottom
,
onReachBottom
,
clearObjNull
,
clearObjNull
,
throttle
,
throttle
,
isEmptyObj
,
isEmptyObj
,
parseString
,
parseString
,
promise
promise
,
setNavigationBarTitle
}
}
export
default
Util
export
default
Util
\ 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