Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
store-assistant
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 2bd4ceac
authored
Oct 24, 2022
by
杨北旺
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
合并代码解决冲突
2 parents
7c6a4900
aed465fb
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
323 additions
and
222 deletions
api/usersApi/UsersApi.js
pages/authentication/registerInfo/registerInfo.js
pages/checkProduct/checkProduct.js
pages/tab/discovery/components/product/product.js
pages/tab/discovery/components/product/product.scss
pages/tab/discovery/constant/data.js
pages/tab/discovery/discovery.js
pages/tab/discovery/discovery.scss
pages/tab/discovery/discovery.wxml
utils/constantData.js
utils/share.js
api/usersApi/UsersApi.js
View file @
2bd4cea
...
...
@@ -124,5 +124,32 @@ class UsersApi {
true
)
}
/**获取微信用户信息 */
async
getWXUserInfo
()
{
let
wx_user_info
=
wx
.
$storage
.
get
(
'wx_user_info'
)
if
(
!
wx_user_info
)
{
const
data
=
await
this
.
getUserProfile
()
wx
.
$storage
.
set
(
'wx_user_info'
,
data
)
return
data
}
else
return
wx_user_info
}
/** 手机号授权解析(单纯解析内容返回前端)
* 只传loginToken就返回unionId和openid
* 传加密信息就解析手机号
*/
async
getUserProfile
(
loginToken
,
detail
=
{})
{
if
(
detail
.
errMsg
&&
detail
.
errMsg
==
'getPhoneNumber:fail user deny'
)
Promise
.
reject
()
delete
detail
.
errMsg
if
(
!
loginToken
)
{
let
res
=
await
this
.
wxCodeLogin
()
loginToken
=
res
.
data
}
detail
.
loginToken
=
loginToken
return
api
.
post
({
method
:
'scrm.api.sso.wechat.applets.phone.grant.analysis'
,
...
detail
,
platformEntrance
:
'STORE_ASSISTANT'
})
}
}
export
default
UsersApi
\ No newline at end of file
pages/authentication/registerInfo/registerInfo.js
View file @
2bd4cea
...
...
@@ -31,7 +31,6 @@ Page({
},
onRoute
(
options
){
console
.
log
(
options
,
111
)
this
.
setData
({
dataFromOptions
:
options
,
staffName
:
options
.
staffName
...
...
@@ -85,7 +84,6 @@ Page({
})
},
onConfirm
(
e
){
console
.
log
(
e
)
const
{
value
}
=
e
.
detail
this
.
setData
({
department
:
value
...
...
@@ -99,7 +97,6 @@ Page({
})
},
handleRegister
({
detail
}){
console
.
log
(
detail
,
'detaildetaildetail'
)
const
{
merchantId
,
merchantFileRequest
}
=
this
.
data
.
dataFromOptions
let
params
=
{
merchantId
,
...
...
@@ -112,7 +109,6 @@ Page({
weChatNickName
:
merchantFileRequest
.
fileName
,
weChatAvatarUrl
:
merchantFileRequest
.
fileUrl
}
console
.
log
(
params
,
'ddd'
)
USERAPI
.
register
(
params
).
then
((
res
)
=>
{
if
(
res
.
code
==
'0'
){
this
.
toLogin
()
...
...
@@ -146,7 +142,6 @@ Page({
sessionId
})
{
/**多个账号 */
console
.
log
(
loginUserInfoList
,
'loginUserInfoList'
)
if
(
loginUserInfoList
.
length
>
1
)
wx
.
$router
.
go
(
'/pages/authentication/accountItems/accountItems'
,
{
sessionId
,
...
...
pages/checkProduct/checkProduct.js
View file @
2bd4cea
...
...
@@ -2,7 +2,6 @@ const navStyle = "background-color: #fff";
import
{
senceData
}
from
"~/pages/tab/discovery/constant/data"
;
import
Draw
from
"~/utils/Draw.js"
;
import
{
IMG_URL
}
from
"~/utils/constantData.js"
;
import
ActivityApi
from
'~/api/activityApi/index'
import
{
commonApi
}
from
'~/api/api.js'
...
...
@@ -89,7 +88,6 @@ Page({
path
:
'pages/checkProduct/checkProduct'
}
commonApi
.
createQrcode
(
params
).
then
(
response
=>
{
console
.
log
(
response
,
'responseresponse'
)
let
qrcode
=
response
?.
data
this
.
setData
({
imgH
:
(
imgH
/
imgW
)
*
450
...
...
@@ -114,7 +112,6 @@ Page({
drawFun
.
begin
({
imageList
:
imgList
,
}).
then
(
resp
=>
{
console
.
log
(
'posterUrl.path'
,
resp
)
this
.
setData
({
posterUrl
:
resp
.
path
,
});
...
...
@@ -148,7 +145,6 @@ Page({
wx
.
saveImageToPhotosAlbum
({
filePath
:
this
.
data
.
posterUrl
,
//仅为示例,并非真实的资源
success
(
res
)
{
console
.
log
(
'res: '
,
res
);
wx
.
$api
.
showToast
(
'下载成功!'
)
}
})
...
...
@@ -168,18 +164,31 @@ Page({
});
},
onRoute
(
options
)
{
},
noPageAuth
:
true
,
/**
* 生命周期函数--监听页面加载
*/
onLoad
(
options
)
{
console
.
log
(
options
)
wx
.
nextTick
(()
=>
{
console
.
log
(
" this.options: "
,
this
.
options
);
let
{
actNum
,
activeNavIdx
,
scene
}
=
this
.
options
this
.
shareTitle
=
senceData
[
actNum
].
productList
[
activeNavIdx
].
proName
// let name = wx.$storage.get('staff_name') || (wx.$storage.get('userInfo') ? wx.$storage.get('userInfo').name : '')
let
name
=
wx
.
$storage
.
get
(
'userInfo'
)
?
wx
.
$storage
.
get
(
'userInfo'
).
name
:
''
this
.
shareTitle
=
`
${
name
}
给你分享一个
${
senceData
[
actNum
].
productList
[
activeNavIdx
].
proName
}
~`
this
.
shareQuery
=
`actNum=
${
actNum
}
&activeNavIdx=
${
activeNavIdx
}
`
wx
.
setNavigationBarTitle
({
title
:
senceData
[
actNum
].
name
||
'特色产品'
})
if
(
scene
){
let
qrcodeQuery
=
decodeURIComponent
(
scene
)
let
id
=
qrcodeQuery
.
split
(
'='
).
pop
()
let
paramsObj
=
{}
if
(
id
){
commonApi
.
getQrcodeParams
({
id
}).
then
(
res
=>
{
console
.
log
(
res
?.
data
?.
scene
,
'responseresponse12233'
)
if
(
res
.
code
==
'0'
){
let
paramsArr
=
res
?.
data
?.
scene
?.
split
(
'&'
);
paramsArr
.
forEach
(
item
=>
{
...
...
@@ -194,15 +203,6 @@ Page({
this
.
setRouteParams
(
this
.
options
)
}
})
},
noPageAuth
:
true
,
/**
* 生命周期函数--监听页面加载
*/
onLoad
(
options
)
{
console
.
log
(
options
,
'onLoad'
)
},
/**
...
...
pages/tab/discovery/components/product/product.js
View file @
2bd4cea
...
...
@@ -86,6 +86,21 @@ Component({
curTabIdx
:
idx
})
},
download
()
{
wx
.
downloadFile
({
url
:
'https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/video/digital_card_30s.mp4'
,
success
(
res
)
{
if
(
res
.
statusCode
===
200
)
{
wx
.
saveVideoToPhotosAlbum
({
filePath
:
res
.
tempFilePath
,
success
(
res
)
{
wx
.
$api
.
showToast
(
'保存成功!'
)
}
})
}
}
})
},
getImgHeight
(){
let
query
=
wx
.
createSelectorQuery
().
in
(
this
)
let
heightArr
=
[]
...
...
@@ -96,7 +111,6 @@ Component({
heightArr
.
push
(
s
)
})
this
.
data
.
heightArr
=
heightArr
console
.
log
(
this
.
data
.
heightArr
)
}).
exec
()
},
getImgHeight
()
{
...
...
pages/tab/discovery/components/product/product.scss
View file @
2bd4cea
...
...
@@ -22,7 +22,7 @@
width
:
188rpx
;
height
:
64rpx
;
border-radius
:
12rpx
;
font-weight
:
5
00
;
font-weight
:
6
00
;
font-size
:
24rpx
;
letter-spacing
:
0
;
text-align
:
center
;
...
...
pages/tab/discovery/constant/data.js
View file @
2bd4cea
...
...
@@ -4,6 +4,8 @@ var senceData = [
img
:
'scene_talk.png'
,
active
:
'icon-car11'
,
playImg
:
'img1'
,
sceneCode
:
'SC001'
,
show
:
0
,
productList
:
[
{
img
:
'product-img1'
,
...
...
@@ -45,6 +47,8 @@ var senceData = [
img
:
'scene_delivery.png'
,
active
:
'icon-car21'
,
playImg
:
'img2'
,
sceneCode
:
'SC002'
,
show
:
0
,
productList
:
[
{
img
:
'product-img2'
,
...
...
@@ -71,27 +75,29 @@ var senceData = [
img
:
'scene_within_12mth.png'
,
active
:
'icon-car21'
,
playImg
:
'img2'
,
sceneCode
:
'SC003'
,
show
:
0
,
productList
:
[
{
img
:
'product-img3'
,
proName
:
'漆面保护膜'
,
price
:
'12000'
,
profit
:
'
21600万
'
,
profit
:
'
180000
'
,
type
:
'membrane'
,
productType
:
'protectMembrane'
,
path
:
'paintProtect'
,
sale
:
100
00
,
//销量
sale
:
100
,
//销量
varType
:
1
},
{
img
:
'product-img4'
,
proName
:
'改色膜'
,
price
:
'5000'
,
profit
:
'300000
00
'
,
profit
:
'300000'
,
type
:
'membrane'
,
productType
:
'colorMembrane'
,
path
:
'changingFilm'
,
sale
:
100
00
,
//销量
sale
:
100
,
//销量
varType
:
1
}
]
...
...
@@ -101,6 +107,8 @@ var senceData = [
img
:
'scene_more_12mth.png'
,
active
:
'icon-car31'
,
playImg
:
'img3'
,
sceneCode
:
'SC004'
,
show
:
0
,
productList
:
[
{
img
:
'product-img5'
,
...
...
pages/tab/discovery/discovery.js
View file @
2bd4cea
// pages/tab/output/output.js
const
navStyle
=
"background-color: transparent;"
;
import
{
senceData
}
from
"./constant/data"
;
import
ActivityApi
from
'~/api/activityApi/index'
Page
({
/**
...
...
@@ -9,7 +10,7 @@ Page({
data
:
{
senceData
,
headerHeight
:
0
,
actNum
:
0
,
actNum
:
3
,
navStyle
,
// 预估弹框
visible
:
false
,
...
...
@@ -24,6 +25,79 @@ Page({
},
isFirst
:
true
,
changeSale
:
0
,
sceneCodeList
:[],
currentId
:
0
,
showPage
:
false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad
(
options
)
{
const
{
merchantId
}
=
wx
.
$storage
.
get
(
'userInfo'
)
wx
.
showLoading
({
title
:
'加载中...'
,
})
ActivityApi
.
getOpenSceneList
({
merchantId
}).
then
(
res
=>
{
wx
.
hideLoading
()
if
(
res
?.
length
>
0
){
let
sceneCodeList
=
[]
let
senceData
=
[...
this
.
data
.
senceData
]
let
res
=
[
{
sceneCode
:
'SC001'
,
status
:
1
},
{
sceneCode
:
'SC002'
,
status
:
1
},
{
sceneCode
:
'SC003'
,
status
:
1
},
{
sceneCode
:
'SC004'
,
status
:
1
}
]
res
.
forEach
((
item
,
index
)
=>
{
if
(
item
.
status
==
1
)
{
let
sceneTarget
=
senceData
.
find
(
sitem
=>
sitem
.
sceneCode
==
item
.
sceneCode
)
sceneTarget
.
show
=
1
}
})
senceData
.
forEach
((
item
,
index
)
=>
{
if
(
item
.
show
==
1
)
{
sceneCodeList
.
push
(
item
.
sceneCode
)
}
})
let
idx
=
sceneCodeList
.
findIndex
(
item
=>
item
==
'SC004'
)
let
actNum
=
0
,
currentId
=
0
;
if
(
sceneCodeList
?.
length
){
if
(
idx
>-
1
){
actNum
=
3
currentId
=
idx
}
else
{
actNum
=
senceData
.
findIndex
(
item
=>
item
.
sceneCode
==
sceneCodeList
[
0
])
}
}
this
.
setData
({
sceneCodeList
,
senceData
,
actNum
,
currentId
})
}
this
.
setData
({
showPage
:
true
})
}).
catch
(
err
=>
{
this
.
setData
({
showPage
:
true
})
})
},
navbarReady
(
e
)
{
let
{
...
...
@@ -45,7 +119,7 @@ Page({
changeSwiper
(
e
){
this
.
setData
({
actNum
:
e
.
detail
.
current
,
actNum
:
e
.
detail
.
current
ItemId
,
});
},
...
...
@@ -72,7 +146,6 @@ Page({
});
},
clickDialog
(
e
)
{
console
.
log
(
e
.
changedTouches
[
0
].
clientY
);
if
(
e
.
changedTouches
[
0
].
clientY
<
352
)
{
this
.
setData
({
visible
:
false
,
...
...
@@ -90,7 +163,6 @@ Page({
});
},
clickDialog
(
e
)
{
console
.
log
(
e
.
changedTouches
[
0
].
clientY
);
if
(
e
.
changedTouches
[
0
].
clientY
<
352
)
{
this
.
setData
({
visible
:
false
,
...
...
@@ -101,11 +173,9 @@ Page({
},
// 提交测算
submit
(
e
)
{
console
.
log
(
e
);
let
sales
=
e
?
+
e
.
detail
.
value
.
sales
:
this
.
data
.
formData
.
sales
;
let
flow
=
e
?
+
e
.
detail
.
value
.
flow
:
this
.
data
.
formData
.
flow
;
const
reg
=
/^
[
1-9
]\d
*$/
;
console
.
log
(
reg
.
test
(
sales
),
flow
,
"---"
);
if
(
!
reg
.
test
(
sales
))
{
wx
.
showToast
({
title
:
"门店月平均新车销量应为正整数"
,
...
...
@@ -127,19 +197,6 @@ Page({
"lastFormData.flow"
:
flow
,
});
const
_this
=
this
;
// this.data.tabList.forEach((item, index) => {
// item.productList.forEach((i, lastIndex) => {
// if (i.profit) {
// let name = `tabList[${index}].productList[${lastIndex}].profit`;
// let profit = _this.formula(i.productType, sales, flow);
// console.log(name, profit);
// this.setData({
// [name]: profit,
// });
// }
// });
// });
this
.
data
.
senceData
.
forEach
((
item
,
index
)
=>
{
item
.
productList
.
forEach
((
i
,
lastIndex
)
=>
{
if
(
i
.
profit
)
{
...
...
@@ -148,7 +205,6 @@ Page({
let
name
=
`senceData[
${
index
}
].productList[
${
lastIndex
}
].profit`
;
// let changeSale = `senceData[${index}].productList[${lastIndex}].changeSale`;
let
profit
=
_this
.
formula
(
i
.
productType
,
sales
,
flow
);
console
.
log
(
name
,
profit
);
this
.
setData
({
[
name
]:
profit
,
[
sale
]:
sales
...
...
@@ -158,13 +214,6 @@ Page({
});
});
// 触发自定义事件 利润 数量
// this.triggerEvent('countProfit', profit, sales)
// let type = this.getProductType(sceneIndex, tabIndex);
// let profit = this.formula(type, sales, flow);
// console.log('profit: ', profit);
this
.
setData
({
visible
:
false
,
});
...
...
@@ -181,17 +230,7 @@ Page({
});
}
},
// // 获取场景下的产品类型
// getProductType(sceneIndex, tabIndex) {
// let typeArray = [
// ["benefitCard"], //数字无忧权益卡
// ["sunMembrane"], //汽车太阳膜
// ["protectMembrane", "colorMembrane"], //'漆面保护膜','改色膜'
// ["digitBeauty", "chair", "ar", "lamp", "navigation"], //'数字化美容','座椅通风','AR导航','氛围灯','360全景导航'
// ];
// return typeArray[sceneIndex][tabIndex];
// },
// 计算公式,参数:productType
formula
(
productType
,
sales
,
flow
)
{
let
profit
=
0
;
switch
(
productType
)
{
...
...
@@ -205,11 +244,11 @@ Page({
break
;
case
"protectMembrane"
:
// 漆面保护膜
profit
=
(
flow
*
0.15
*
12
000
*
12
).
toFixed
(
0
);
profit
=
(
sales
*
0.05
*
3
000
*
12
).
toFixed
(
0
);
break
;
case
"colorMembrane"
:
// 改色膜
profit
=
(
flow
*
0.05
*
5000
*
12
).
toFixed
(
0
);
profit
=
(
sales
*
0.05
*
5000
*
12
).
toFixed
(
0
);
break
;
case
"digitBeauty"
:
// 数字化美容
...
...
@@ -232,8 +271,6 @@ Page({
profit
=
(
flow
*
2880
*
0.9
*
0.015
).
toFixed
(
0
);
break
;
}
console
.
log
(
profit
.
length
);
console
.
log
(
productType
,
sales
,
flow
,
profit
);
if
(
profit
.
length
>
9
)
{
return
(
profit
/
10000
).
toFixed
(
0
)
+
"万"
;
}
else
{
...
...
@@ -255,12 +292,7 @@ Page({
});
return
false
;
},
/**
* 生命周期函数--监听页面加载
*/
onLoad
(
options
)
{
},
methods
:{
},
/**
...
...
pages/tab/discovery/discovery.scss
View file @
2bd4cea
/* pages/tab/output/output.wxss */
page
{
background-color
:
#fff
;
}
.container
{
position
:
relative
;
.scene-wrap
{
...
...
@@ -153,3 +155,14 @@
}
}
.emptyData
{
width
:
100%
;
text-align
:
center
;
.tip
{
margin-top
:
16rpx
;
font-size
:
28rpx
;
color
:
#7A8299
;
text-align
:
center
;
}
}
pages/tab/discovery/discovery.wxml
View file @
2bd4cea
<view
style="background:#fff;"
class="container">
<image style="height: {{headerHeight+45}}px;" src="{{IMGURL}}discovery_center_bg.png" class="bg-img"></image>
<view class="container">
<image
wx:if="{{sceneCodeList.length>0 && showPage}}"
style="height: {{headerHeight+45}}px;" src="{{IMGURL}}discovery_center_bg.png" class="bg-img"></image>
<navigation-bar bindnavbarReady="navbarReady" navStyle="{{navStyle}}" page-title="发现">
<text>发现</text>
</navigation-bar>
<view style="padding-top: {{headerHeight}}px;">
<view class="header">
<swiper bindchange="changeSwiper" class="scene-wrap" circular="{{true}}" previousMargin="40rpx" nextMargin="40rpx">
<block wx:for="{{senceData}}" wx:key="index">
<swiper-item>
<image class="scene-img" src="{{IMGURL}}{{item.img}}"></image>
</swiper-item>
</block>
</swiper>
<block wx:if="{{sceneCodeList.length>0 && showPage}}">
<view style="padding-top: {{headerHeight}}px;">
<view class="header">
<swiper bindchange="changeSwiper" current="{{currentId}}" class="scene-wrap" circular="{{true}}" previousMargin="40rpx" nextMargin="40rpx">
<block wx:for="{{senceData}}" wx:key="index">
<swiper-item item-id="{{index}}" wx:if="{{item.show}}">
<image class="scene-img" src="{{IMGURL}}{{item.img}}"></image>
</swiper-item>
</block>
</swiper>
</view>
<product senceData="{{senceData}}" actNum="{{actNum}}" headerHeight="{{headerHeight}}"></product>
</view>
<product senceData="{{senceData}}" actNum="{{actNum}}" headerHeight="{{headerHeight}}"></product>
</view>
</view>
<!-- 在线客服
-->
<image class="chat" src="{{IMGURL}}customer_service.png" bindtap="goConsult
" />
<!-- 申请活动
-->
<image class="applyAct" src="{{IMGURL}}application_activity.png" bindtap="applyActivity
" />
<!-- 在线客服 -->
<image class="applyAct" src="{{IMGURL}}application_activity.png" bindtap="applyActivity" />
<!-- 测算按钮 -->
<view class="calculate" bindtap="showCalculate">
<image class="icon-calculate" webp src="{{IMGURL}}calc.png"></image>
</view>
<!-- 测算弹窗 -->
<view class="dialog-wrapper" bindtap="clickDialog" hidden="{{!visible}}">
<view class="dialog-box">
<form bindsubmit="submit">
<view class="dialog-header">
<view hidden="{{isReset}}" class="header-btn btn-gray" bindtap="showCalculate">取消</view>
<view hidden="{{!isReset}}" class="header-btn btn-gray" bindtap="reset">重置</view>
<button class="header-btn btn-primary" form-type="submit">确定</button>
</view>
<view class="dialog-content">
<view class="dialog-title">输入您门店的基本情况</view>
<view class="dialog-form">
<view class="form-item">
<view class="form-label">门店月平均新车销量</view>
<input class="form-input" bindfocus="focus" maxlength="8" name="sales" value="{{formData.sales}}" type="number" />
<!-- <view class="form-unit">台</view> -->
<!-- 测算按钮 -->
<view class="calculate" bindtap="showCalculate">
<image class="icon-calculate" webp src="{{IMGURL}}calc.png"></image>
</view>
<!-- 测算弹窗 -->
<view class="dialog-wrapper" bindtap="clickDialog" hidden="{{!visible}}">
<view class="dialog-box">
<form bindsubmit="submit">
<view class="dialog-header">
<view hidden="{{isReset}}" class="header-btn btn-gray" bindtap="showCalculate">取消</view>
<view hidden="{{!isReset}}" class="header-btn btn-gray" bindtap="reset">重置</view>
<button class="header-btn btn-primary" form-type="submit">确定</button>
</view>
<view class="form-item">
<view class="form-label">3年内售后存量用户</view>
<input class="form-input" bindfocus="focus" maxlength="8" name="flow" type="number" value="{{formData.flow}}" />
<!-- <view class="form-unit">人</view> -->
<view class="dialog-content">
<view class="dialog-title">输入您门店的基本情况</view>
<view class="dialog-form">
<view class="form-item">
<view class="form-label">门店月平均新车销量</view>
<input class="form-input" bindfocus="focus" maxlength="8" name="sales" value="{{formData.sales}}" type="number" />
<!-- <view class="form-unit">台</view> -->
</view>
<view class="form-item">
<view class="form-label">3年内售后存量用户</view>
<input class="form-input" bindfocus="focus" maxlength="8" name="flow" type="number" value="{{formData.flow}}" />
<!-- <view class="form-unit">人</view> -->
</view>
<button class="dialog-btn" form-type="submit">提交测算</button>
</view>
</view>
<button class="dialog-btn" form-type="submit">提交测算</button>
</view>
</form>
</view>
</form>
</view>
</view>
\ No newline at end of file
</view>
</block>
<block wx:if="{{sceneCodeList.length<=0 && showPage}}">
<view class="emptyData" style="margin-top: {{headerHeight+32}}px;">
<image src="{{IMGURL}}toLink.png" style="height: 400rpx;width: 400rpx;"></image>
<view class="tip">
<view>您的门店尚未开通业务场景,</view>
<view>请联系在线客服进行咨询,谢谢。</view>
</view>
</view>
</block>
</view>
<!-- 在线客服 -->
<image class="chat" src="{{IMGURL}}customer_service.png" bindtap="goConsult" />
utils/constantData.js
View file @
2bd4cea
...
...
@@ -12,5 +12,6 @@ export const STORAGE_OBJECTkEY = {
app_title
:
'appTitle'
,
auto_login_object
:
'auto_login_object'
,
address_info
:
'address_info'
,
srcm_shopmall_merchant_id
:
'srcm_shopmall_merchant_id'
srcm_shopmall_merchant_id
:
'srcm_shopmall_merchant_id'
,
wx_user_info
:
'wx_user_info'
}
utils/share.js
View file @
2bd4cea
...
...
@@ -9,115 +9,113 @@
* @param {*} onViewTrack 开启浏览埋点
* @returns
*/
import
{
taskShareReport
import
{
taskShareReport
}
from
'~/api/api.js'
// import USERAPI from '~/api/usersApi/index'
class
Share
{
constructor
()
{
console
.
log
(
'---------------- 分享初始化 ----------------'
)
this
.
initPageProxy
()
}
/**全局注册事件 */
initPageProxy
()
{
let
thisPage
=
Page
let
_this
=
this
Page
=
function
(
el
)
{
try
{
el
||
(
el
=
{}),
_this
.
pageLeaveProxy
(
el
),
thisPage
.
apply
(
this
,
arguments
)
}
catch
(
el
)
{
thisPage
.
apply
(
this
,
arguments
)
}
constructor
()
{
console
.
log
(
'---------------- 分享初始化 ----------------'
)
this
.
initPageProxy
()
}
/**全局注册事件 */
initPageProxy
()
{
let
thisPage
=
Page
let
_this
=
this
Page
=
function
(
el
)
{
try
{
el
||
(
el
=
{}),
_this
.
pageLeaveProxy
(
el
),
thisPage
.
apply
(
this
,
arguments
)
}
catch
(
el
)
{
thisPage
.
apply
(
this
,
arguments
)
}
}
/**设置全局分享 */
pageLeaveProxy
(
page
)
{
const
onLoad
=
page
.
onLoad
,
that
=
this
if
(
page
.
onShareAppMessage
)
{
const
that
=
this
page
.
onShareAppMessage
=
function
()
{
let
{
shareTitle
,
sharePath
,
shareImage
,
shareQuery
,
noPageAuth
,
shareFun
,
shareTrackData
}
=
this
,
path
=
`/
${
this
.
route
}
`
if
(
sharePath
)
path
=
`/
${
sharePath
}
`
// path += that.setCommonShareQuery()
if
(
shareQuery
)
path
+=
`?
${
shareQuery
}
`
if
(
!
noPageAuth
)
path
=
`/login/loading/loading?url=
${
encodeURIComponent
(
path
)}
`
if
(
shareFun
)
shareFun
()
if
(
shareTrackData
)
that
.
reportShareData
(
shareTrackData
)
console
.
log
(
'::'
,
path
)
return
{
path
,
title
:
shareTitle
,
imageUrl
:
shareImage
}
}
}
if
(
page
.
onShareTimeline
)
{
page
.
onShareTimeline
=
function
()
{
let
{
shareTitle
,
shareImage
,
shareQuery
,
shareFun
,
shareTrackData
}
=
this
if
(
shareFun
)
shareFun
()
// if (shareTrackData) that.reportShareData(shareTrackData)
// shareQuery = that.setCommonShareQuery(shareQuery)
console
.
log
(
shareQuery
)
return
{
query
:
shareQuery
,
title
:
shareTitle
,
imageUrl
:
shareImage
}
}
/**设置全局分享 */
pageLeaveProxy
(
page
)
{
const
onLoad
=
page
.
onLoad
,
that
=
this
if
(
page
.
onShareAppMessage
)
{
const
that
=
this
page
.
onShareAppMessage
=
function
()
{
let
{
shareTitle
,
sharePath
,
shareImage
,
shareQuery
,
noPageAuth
,
shareFun
,
shareTrackData
}
=
this
,
path
=
`/
${
this
.
route
}
`
if
(
sharePath
)
path
=
`/
${
sharePath
}
`
// path += that.setCommonShareQuery()
if
(
shareQuery
)
path
+=
`?
${
shareQuery
}
`
if
(
!
noPageAuth
)
path
=
`/login/loading/loading?url=
${
encodeURIComponent
(
path
)}
`
if
(
shareFun
)
shareFun
()
if
(
shareTrackData
)
that
.
reportShareData
(
shareTrackData
)
console
.
log
(
'::'
,
path
)
return
{
path
,
title
:
shareTitle
,
imageUrl
:
shareImage
}
}
}
getCommonData
()
{
const
USERINFO
=
wx
.
$storage
.
get
(
'userInfo'
)
return
{
USERINFO
if
(
page
.
onShareTimeline
)
{
page
.
onShareTimeline
=
function
()
{
let
{
shareTitle
,
shareImage
,
shareQuery
,
shareFun
,
shareTrackData
}
=
this
if
(
shareFun
)
shareFun
()
// if (shareTrackData) that.reportShareData(shareTrackData)
// shareQuery = that.setCommonShareQuery(shareQuery)
console
.
log
(
shareQuery
)
return
{
query
:
shareQuery
,
title
:
shareTitle
,
imageUrl
:
shareImage
}
}
}
setCommonShareQuery
(
query
)
{
const
{
WXUSERINFO
,
USERINFO
}
=
this
.
getCommonData
()
query
=
`
${
query
?
`?
${
query
}
&`
:
'?'
}
merchantId=
${
USERINFO
.
merchantId
}
&shareOpenId=
${
WXUSERINFO
.
openId
}
`
if
(
USERINFO
.
phone
)
query
+=
`&sharePhone=
${
USERINFO
.
phone
}
`
return
query
}
getCommonData
()
{
const
USERINFO
=
wx
.
$storage
.
get
(
'userInfo'
)
return
{
USERINFO
}
reportShareData
(
shareTrackData
)
{
const
{
USERINFO
}
=
this
.
getCommonData
(),
thisPage
=
wx
.
$router
.
getPageInstance
()
let
data
=
{
action_type
:
4
,
// 事件类型固定为4-分享
item_type
:
3
,
// 商品类型,固定为3-众筹活动
merchant_id
:
USERINFO
.
merchantId
,
// 门店号
staff_uuid
:
USERINFO
.
uuid
,
business_type
:
1
,
// 业务类型,固定为1
add_way
:
104
,
// 来源,固定为104
create_time
:
new
Date
().
format
(
"yyyy-MM-dd hh:mm:ss"
),
// 分享时间
...
shareTrackData
}
let
jsonList
=
JSON
.
stringify
(
data
)
taskShareReport
({
jsonList
})
}
setCommonShareQuery
(
query
)
{
const
{
WXUSERINFO
,
USERINFO
}
=
this
.
getCommonData
()
query
=
`
${
query
?
`?
${
query
}
&`
:
'?'
}
merchantId=
${
USERINFO
.
merchantId
}
&shareOpenId=
${
WXUSERINFO
.
openId
}
`
if
(
USERINFO
.
phone
)
query
+=
`&sharePhone=
${
USERINFO
.
phone
}
`
return
query
}
reportShareData
(
shareTrackData
)
{
const
{
USERINFO
}
=
this
.
getCommonData
(),
thisPage
=
wx
.
$router
.
getPageInstance
()
let
data
=
{
action_type
:
4
,
// 事件类型固定为4-分享
item_type
:
3
,
// 商品类型,固定为3-众筹活动
merchant_id
:
USERINFO
.
merchantId
,
// 门店号
staff_uuid
:
USERINFO
.
uuid
,
business_type
:
1
,
// 业务类型,固定为1
add_way
:
104
,
// 来源,固定为104
create_time
:
new
Date
().
format
(
"yyyy-MM-dd hh:mm:ss"
),
// 分享时间
...
shareTrackData
}
let
jsonList
=
JSON
.
stringify
(
data
)
taskShareReport
({
jsonList
})
}
}
new
Share
()
\ 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