Commit f789151d by 李伟康

设置分享

1 parent 60951ca6
......@@ -9,6 +9,8 @@ import { getUpdateManager } from "./lib/index";
import utils from "./utils/index";
// 埋点 有需要再引入
// import './utils/track/Track'
/**分享 */
import './utils/share'
App({
onLaunch(options) {
getUpdateManager();
......
......@@ -263,16 +263,11 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if (this.data.id) {
this.getGoodsDetail(this.data.id)
} else {
/**扫码、分享、直播间 */
if (options && options.id) {
this.setData(options)
this.getGoodsDetail(options.id)
if (!options.isActivity) this.getGoodscouponList(options.id)
}
}
// 推荐人+推荐人埋点
if (options.shareStaffUuid) {
let shareStaff = {
......@@ -313,6 +308,20 @@ Page({
goodsId: data.id
}
// wx.$Track.setTrack(trackobj, 6)
//设置分享
let shareQuery = `id=${data.id}`,
shareTitle = data.goodsName,
shareImage = ''
data.goodsDetailImageList.map(e => {
if (e.resType == 1) shareImage = e.content
})
if (isActivity) {
shareTitle = data.activityName
shareQuery += '&isActivity=true'
}
this.shareQuery = shareQuery
this.shareTitle = shareTitle
this.shareImage = shareImage
let activeSku = null
if (data.expressFee != null) data.expressFee = centsToyuan(data.expressFee)
if (isActivity) {
......@@ -507,37 +516,10 @@ Page({
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
const {
merchantId
} = wx.p.storage.get('merchant_info')
let {
isActivity,
isLive,
goodsInfo
} = this.data
let title = goodsInfo.goodsName
let path = `${this.route}?id=${goodsInfo.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}`
return {
imageUrl,
title,
path
}
},
onShareAppMessage: function () {},
countDown(params) {
let {
activityStatus
......
......@@ -91,7 +91,7 @@ Page({
let para = {
merchantId
}
wx.p.wxApi.equityApi.memberCard(para).then(res => {
wx.p.api.equityApi.memberCard(para).then(res => {
this.setData({
memberInfo: res
})
......
......@@ -10,7 +10,8 @@ export const STORAGE_OBJECTkEY = {
userInfo: 'userInfo',
sessionId: 'sessionId',
bindInfo:'bindInfo',
unauthorized:'unauthorized'
unauthorized:'unauthorized',
wx_user_info:'wx_user_info'
}
export default{
......
......@@ -9,12 +9,11 @@
* @param {*} onViewTrack 开启浏览埋点
* @returns
*/
import { reportData } from '~/api/index.js'
import USERAPI from '~/api/usersApi/index'
// import { reportData } from '~/api/index.js'
class Share {
constructor() {
// console.log('---------------- 分享初始化 ----------------')
console.log('---------------- 分享初始化 ----------------')
this.initPageProxy()
}
/**全局注册事件 */
......@@ -43,9 +42,14 @@ class Share {
path += that.setCommonShareQuery()
if (shareQuery) path += `&${shareQuery}`
console.log('===============', path)
if (!noPageAuth) path = `/login/loading/loading?url=${encodeURIComponent(path)}`
if (!noPageAuth) path = `/pages/loading/loading?url=${encodeURIComponent(path)}`
if (shareFun) shareFun()
if (shareTrackData) that.reportShareData(shareTrackData)
// if (shareTrackData) that.reportShareData(shareTrackData)
console.table( {
path,
title: shareTitle,
imageUrl: shareImage
})
return {
path,
title: shareTitle,
......@@ -57,7 +61,7 @@ class Share {
page.onShareTimeline = function () {
let { shareTitle, shareImage, shareQuery, shareFun, shareTrackData } = this
if (shareFun) shareFun()
if (shareTrackData) that.reportShareData(shareTrackData)
// if (shareTrackData) that.reportShareData(shareTrackData)
shareQuery = that.setCommonShareQuery(shareQuery)
console.log(shareQuery)
return {
......@@ -70,21 +74,21 @@ class Share {
page.onLoad = async function () {
onLoad && onLoad.apply(this, arguments)
if (this.onViewTrack) {
const WXUSERINFO = await USERAPI.getWXUserInfo(),
{ USERINFO } = that.getCommonData(),
shareInfo = this.options
if (shareInfo.shareOpenId)
reportData(
{
openId: WXUSERINFO.openId || '',
unionId: WXUSERINFO.unionId || '',
nickName: WXUSERINFO.nickName || '',
avatar: WXUSERINFO.avatarUrl || '',
phone: WXUSERINFO.phone || USERINFO.phone || '',
...shareInfo
},
1
)
// const WXUSERINFO = await USERAPI.getWXUserInfo(),
// { USERINFO } = that.getCommonData(),
// shareInfo = this.options
// if (shareInfo.shareOpenId)
// reportData(
// {
// openId: WXUSERINFO.openId || '',
// unionId: WXUSERINFO.unionId || '',
// nickName: WXUSERINFO.nickName || '',
// avatar: WXUSERINFO.avatarUrl || '',
// phone: WXUSERINFO.phone || USERINFO.phone || '',
// ...shareInfo
// },
// 1
// )
}
}
}
......@@ -118,4 +122,4 @@ class Share {
})
}
}
new Share()
export default new Share()
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!