Commit 39d4ccbc by 前端

Merge branch 'zq_dev_3.0' into 'v3.0'

Zq dev 3.0

See merge request !45
2 parents 839bbbb9 f20e3e17
......@@ -171,14 +171,18 @@ Page({
});
},
onRoute(options) {
console.log("options: ", options);
let { actNum,activeNavIdx,fromLocal } = options
this.setData({
actNum,
activeNavIdx,
fromLocal
wx.nextTick(()=>{
let { actNum,activeNavIdx,fromLocal } = this.options
this.shareQuery = `actNum=${actNum}&activeNavIdx=${activeNavIdx}`
console.log(" this.options: ", this.options);
this.setData({
actNum,
activeNavIdx,
fromLocal
})
this.createImg()
})
this.createImg()
},
noPageAuth : true,
......@@ -186,7 +190,7 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log(options,'onLoad')
},
/**
......@@ -198,6 +202,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow(options) {},
onShareTimeline() {},
/**
* 生命周期函数--监听页面隐藏
......
......@@ -6,7 +6,7 @@
<product actNum="{{actNum}}" navIdx="{{activeNavIdx}}" senceData="{{senceData}}" isShare="{{true}}"/>
<!-- 分享弹框 -->
<view class="share-wrap" wx:if="{{isShow}}">
<view class="share-wrap" wx:if="{{isShow && fromLocal==1}}">
<view class="img-wrap" wx:if="{{posterUrl}}">
<image class="img" style="height:{{imgH}}rpx" src="{{posterUrl}}" bindload="onloadFn" />
<!-- <block wx:for="{{imgList}}" wx:key="*this">
......
......@@ -15,8 +15,8 @@ class Router {
wx.onAppRoute(e => {
let thisPage = this.getPageInstance()
if (thisPage) {
thisPage.options = this[_query]
thisPage.setData({ IMGURL: IMG_URL })
if(Object.keys(this[_query]).length) thisPage.options = this[_query]
this.setNavigationBarTitleText(thisPage)
let onRoute = thisPage.onRoute
typeof onRoute === 'function' && onRoute(this[_query])
......
......@@ -4,8 +4,16 @@
* @param {*} shareImage 分享图片 不传默认当前页面截图
* @param {*} shareQuery 分享页面参数
* @param {*} noPageAuth 分享页面是否需要登录拦截
* @param {*} shareFun 分享页面
* @param {*} shareTrackData 分享埋点数据
* @param {*} onViewTrack 开启浏览埋点
* @returns
*/
// import {
// reportData
// } from '~/api/index.js'
// import USERAPI from '~/api/usersApi/index'
class Share {
constructor() {
console.log('---------------- 分享初始化 ----------------')
......@@ -23,22 +31,31 @@ class Share {
}
}
}
/**设置全局分享 */
pageLeaveProxy(page) {
const onLoad = page.onLoad,
that = this
if (page.onShareAppMessage) {
const that = this
page.onShareAppMessage = function () {
let {
shareTitle,
sharePath,
shareImage,
shareQuery,
noPageAuth=true
noPageAuth,
shareFun,
shareTrackData
} = this,
path = `/${this.route}`
if (sharePath) path = `/${sharePath}`
// path += that.setCommonShareQuery()
if (shareQuery) path += `?${shareQuery}`
console.log('::', path)
if (!noPageAuth) path = `/login/loading/loading?url=${encodeURIComponent(path)}`
console.log(path)
if (shareFun) shareFun()
// if (shareTrackData) that.reportShareData(shareTrackData)
return {
path,
title: shareTitle,
......@@ -46,7 +63,62 @@ class Share {
}
}
}
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
}
}
}
}
getCommonData() {
const WXUSERINFO = wx.$storage.get('wx_user_info'),
USERINFO = wx.$storage.get('userInfo')
return {
WXUSERINFO,
USERINFO
}
}
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 {
WXUSERINFO,
USERINFO
} = this.getCommonData(),
thisPage = wx.$router.getPageInstance()
reportData({
openId: WXUSERINFO.openId || '',
unionId: WXUSERINFO.unionId || '',
nickName: WXUSERINFO.nickName || '',
avatar: WXUSERINFO.avatarUrl || '',
phone: USERINFO.phone || '',
merchantId: thisPage.merchantId || USERINFO.merchantId || '',
shareOpenId: thisPage.shareOpenId || WXUSERINFO.openId || '',
sharePhone: thisPage.sharePhone || USERINFO.phone || '',
...shareTrackData
})
}
}
new Share()
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!