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({ ...@@ -171,14 +171,18 @@ Page({
}); });
}, },
onRoute(options) { onRoute(options) {
console.log("options: ", options); wx.nextTick(()=>{
let { actNum,activeNavIdx,fromLocal } = options let { actNum,activeNavIdx,fromLocal } = this.options
this.setData({ this.shareQuery = `actNum=${actNum}&activeNavIdx=${activeNavIdx}`
actNum, console.log(" this.options: ", this.options);
activeNavIdx, this.setData({
fromLocal actNum,
activeNavIdx,
fromLocal
})
this.createImg()
}) })
this.createImg()
}, },
noPageAuth : true, noPageAuth : true,
...@@ -186,7 +190,7 @@ Page({ ...@@ -186,7 +190,7 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
console.log(options,'onLoad')
}, },
/** /**
...@@ -198,6 +202,7 @@ Page({ ...@@ -198,6 +202,7 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow(options) {}, onShow(options) {},
onShareTimeline() {},
/** /**
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<product actNum="{{actNum}}" navIdx="{{activeNavIdx}}" senceData="{{senceData}}" isShare="{{true}}"/> <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}}"> <view class="img-wrap" wx:if="{{posterUrl}}">
<image class="img" style="height:{{imgH}}rpx" src="{{posterUrl}}" bindload="onloadFn" /> <image class="img" style="height:{{imgH}}rpx" src="{{posterUrl}}" bindload="onloadFn" />
<!-- <block wx:for="{{imgList}}" wx:key="*this"> <!-- <block wx:for="{{imgList}}" wx:key="*this">
......
...@@ -15,8 +15,8 @@ class Router { ...@@ -15,8 +15,8 @@ class Router {
wx.onAppRoute(e => { wx.onAppRoute(e => {
let thisPage = this.getPageInstance() let thisPage = this.getPageInstance()
if (thisPage) { if (thisPage) {
thisPage.options = this[_query]
thisPage.setData({ IMGURL: IMG_URL }) thisPage.setData({ IMGURL: IMG_URL })
if(Object.keys(this[_query]).length) thisPage.options = this[_query]
this.setNavigationBarTitleText(thisPage) this.setNavigationBarTitleText(thisPage)
let onRoute = thisPage.onRoute let onRoute = thisPage.onRoute
typeof onRoute === 'function' && onRoute(this[_query]) typeof onRoute === 'function' && onRoute(this[_query])
......
...@@ -4,8 +4,16 @@ ...@@ -4,8 +4,16 @@
* @param {*} shareImage 分享图片 不传默认当前页面截图 * @param {*} shareImage 分享图片 不传默认当前页面截图
* @param {*} shareQuery 分享页面参数 * @param {*} shareQuery 分享页面参数
* @param {*} noPageAuth 分享页面是否需要登录拦截 * @param {*} noPageAuth 分享页面是否需要登录拦截
* @param {*} shareFun 分享页面
* @param {*} shareTrackData 分享埋点数据
* @param {*} onViewTrack 开启浏览埋点
* @returns * @returns
*/ */
// import {
// reportData
// } from '~/api/index.js'
// import USERAPI from '~/api/usersApi/index'
class Share { class Share {
constructor() { constructor() {
console.log('---------------- 分享初始化 ----------------') console.log('---------------- 分享初始化 ----------------')
...@@ -23,22 +31,31 @@ class Share { ...@@ -23,22 +31,31 @@ class Share {
} }
} }
} }
/**设置全局分享 */ /**设置全局分享 */
pageLeaveProxy(page) { pageLeaveProxy(page) {
const onLoad = page.onLoad,
that = this
if (page.onShareAppMessage) { if (page.onShareAppMessage) {
const that = this
page.onShareAppMessage = function () { page.onShareAppMessage = function () {
let { let {
shareTitle, shareTitle,
sharePath, sharePath,
shareImage, shareImage,
shareQuery, shareQuery,
noPageAuth=true noPageAuth,
shareFun,
shareTrackData
} = this, } = this,
path = `/${this.route}` path = `/${this.route}`
if (sharePath) path = `/${sharePath}` if (sharePath) path = `/${sharePath}`
// path += that.setCommonShareQuery()
if (shareQuery) path += `?${shareQuery}` if (shareQuery) path += `?${shareQuery}`
console.log('::', path)
if (!noPageAuth) path = `/login/loading/loading?url=${encodeURIComponent(path)}` if (!noPageAuth) path = `/login/loading/loading?url=${encodeURIComponent(path)}`
console.log(path) if (shareFun) shareFun()
// if (shareTrackData) that.reportShareData(shareTrackData)
return { return {
path, path,
title: shareTitle, title: shareTitle,
...@@ -46,7 +63,62 @@ class Share { ...@@ -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() new Share()
\ No newline at end of file \ 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!