Commit 9a5770b3 by 赵雅纹

分享

parent f52d1736
...@@ -72,6 +72,8 @@ App({ ...@@ -72,6 +72,8 @@ App({
// } // }
// }) // })
}, },
onHide: function () { onHide: function () {
this.globalData.loginFirst = false this.globalData.loginFirst = false
......
...@@ -41,7 +41,10 @@ Component({ ...@@ -41,7 +41,10 @@ Component({
console.log(e) console.log(e)
let params = { let params = {
url: e.currentTarget.dataset.url, url: e.currentTarget.dataset.url,
title: e.currentTarget.dataset.title title: e.currentTarget.dataset.title,
headline: e.currentTarget.dataset.headline,
describe: e.currentTarget.dataset.describe,
id: e.currentTarget.dataset.id
} }
wxService.nextTick(() => { wxService.nextTick(() => {
this.triggerEvent('_onTapShare',params) this.triggerEvent('_onTapShare',params)
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<view class="share-oprate" catchtap="onTapLike" data-id="{{id}}" data-type="{{type}}"> <view class="share-oprate" catchtap="onTapLike" data-id="{{id}}" data-type="{{type}}">
<image class="share-img" src="{{type ? '/assets/imgs/heart-primary.png' : '/assets/imgs/heart-default.png'}}"></image> <image class="share-img" src="{{type ? '/assets/imgs/heart-primary.png' : '/assets/imgs/heart-default.png'}}"></image>
<text class="share-number">{{enjoySum || 0}}</text> <text class="share-number">{{enjoySum || 0}}</text>
</view> <view class="share-oprate" catchtap="onTapShare" data-title="{{headline}}" data-url="{{url}}"> </view> <view class="share-oprate" catchtap="onTapShare" data-title="{{headline}}" data-url="{{url}}" data-headline="{{headline}}" data-describe="{{describe}}" data-id="{{id}}">
<image class="share-img" src="/assets/imgs/share.png"></image> <image class="share-img" src="/assets/imgs/share.png"></image>
<text class="share-number">{{transmitSum || 0}}</text> <text class="share-number">{{transmitSum || 0}}</text>
</view> </view>
......
...@@ -20,12 +20,8 @@ wxService.page({ ...@@ -20,12 +20,8 @@ wxService.page({
showCardModal:false, showCardModal:false,
cardTitle:'', cardTitle:'',
cardUrl:'', cardUrl:'',
contentList:[ contentList:[],
{ currentShareContent: null
url:'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=222247294,2919493301&fm=26&gp=0.jpg',
headline:'好好爱好好好爱护哦啊哈哦啊'
}
]
}, },
// 点击切换 // 点击切换
...@@ -51,7 +47,7 @@ wxService.page({ ...@@ -51,7 +47,7 @@ wxService.page({
*/ */
onShow() { onShow() {
this.getCategoryList() this.getCategoryList()
console.log('--------',Integer.digit('611935532804608000',10,64) ) this.data.currentShareContent = null;
}, },
// 获取分类 // 获取分类
...@@ -139,11 +135,26 @@ wxService.page({ ...@@ -139,11 +135,26 @@ wxService.page({
// 分享 // 分享
_onTapShare(e){ _onTapShare(e){
console.log(e)
this.setData({ let tentacleInfo = {
showCardModal: true, content: JSON.stringify(e.detail),
cardTitle: e.detail.title, contentId: e.detail.id,
cardUrl: e.detail.url, contentType: 2, //内容类型 1.文章 2.商品 3.页面
title: e.detail.title, //标题
type: 3// 1:门店,2:员工(暂时不做),3:会员,4:第三方外部渠道,5:智能营销
}
this.data.currentShareContent = e.detail;
wxService.getTentacleContent(tentacleInfo).then(res =>{
if (res && res.tentacleId){
this.data.currentShareContent.tentacleId = res.tentacleId;
this.setData({
showCardModal: true,
cardTitle: e.detail.title,
cardUrl: e.detail.url
});
}
}) })
}, },
...@@ -168,5 +179,42 @@ wxService.page({ ...@@ -168,5 +179,42 @@ wxService.page({
}) })
this.getContentList(this.data.currentTab) this.getContentList(this.data.currentTab)
} }
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function (res) {
if (res.from != 'menu'){
let id = Integer.digit(this.data.currentShareContent.id, 10, 64);
let tentacleId = Integer.digit(this.data.currentShareContent.tentacleId,10,64);
var path = 'subPackage/page/pages/myReleaseDetail/myReleaseDetail?i=' + id + '&t=' + tentacleId;
console.log(path)
return {
path: path
}
}
let tentacleInfo = {
content: this.route,
title: this.route,
contentType : 3,
type: 3// 1:门店,2:员工(暂时不做),3:会员,4:第三方外部渠道,5:智能营销
};
wxService.getTentacleContent(tentacleInfo).then(res => {
if (res && res.tentacleId) {
this.data.currentShareContent.tentacleId = res.tentacleId;
this.setData({
showCardModal: true,
cardTitle: e.detail.title,
cardUrl: e.detail.url
});
let tentacleId = Integer.digit(res.tentacleId, 10, 64);
var path = `pages/myShare/myShare?t=${tentacleId}`;
return {
path : path
}
}
});
} }
}) })
\ No newline at end of file
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
"list": [] "list": []
}, },
"miniprogram": { "miniprogram": {
"current": 23, "current": 14,
"list": [ "list": [
{ {
"id": -1, "id": -1,
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
"id": 14, "id": 14,
"name": "种草详情", "name": "种草详情",
"pathName": "pages/wantToBuyDetail/wantToBuyDetail", "pathName": "pages/wantToBuyDetail/wantToBuyDetail",
"query": "", "query": "i= 3QCBjb83JC&t=1001",
"scene": null "scene": null
}, },
{ {
......
...@@ -19,9 +19,12 @@ wxService.page({ ...@@ -19,9 +19,12 @@ wxService.page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
console.log(options)
if (options && options.id) { if (options && options.id) {
this.setData({ this.setData({
id: options.id id: options.id
},() => {
this.getContentDetail()
}) })
} }
}, },
...@@ -39,6 +42,8 @@ wxService.page({ ...@@ -39,6 +42,8 @@ wxService.page({
}).then(res => { }).then(res => {
if (!res) return false if (!res) return false
const { result, data } = res.data const { result, data } = res.data
console.log('content info ----------------------------------')
console.log(data)
if (result == 0) { if (result == 0) {
this.setData({ this.setData({
contentInfo: data contentInfo: data
......
...@@ -84,9 +84,8 @@ class Http { ...@@ -84,9 +84,8 @@ class Http {
url, url,
method: 'GET', method: 'GET',
header: { header: {
'buyer-token': this.getToken() 'buyer-token': this.getToken(),
// 'buyer-token': '3e15b819c551713ae210adc525da028b' 'TENTACLE_CONTENT': this.getTentacle()
// 'seller-token': 'f80d09122733517ea4a0c2628c4eb0e9'
}, },
data: parmas data: parmas
}) })
...@@ -97,9 +96,8 @@ class Http { ...@@ -97,9 +96,8 @@ class Http {
url, url,
method: 'POST', method: 'POST',
header: { header: {
'buyer-token': this.getToken() 'buyer-token': this.getToken(),
// 'buyer-token':'3e15b819c551713ae210adc525da028b' 'TENTACLE_CONTENT': this.getTentacle()
// 'seller-token': 'f80d09122733517ea4a0c2628c4eb0e9'
}, },
data: parmas, data: parmas,
channel: channel channel: channel
...@@ -175,6 +173,19 @@ class Http { ...@@ -175,6 +173,19 @@ class Http {
// } // }
return wx.getStorageSync('token') return wx.getStorageSync('token')
} }
getTentacle(){
let time = Date.parse(new Date())
let TIME_EXPIRATION = wx.getStorageSync('TIME_EXPIRATION')
let TENTACLE_CONTENT = JSON.stringify(wx.getStorageSync('TENTACLE_CONTENT'))
if (TENTACLE_CONTENT && TIME_EXPIRATION > time){
wx.setStorageSync('TIME_EXPIRATION', time)
return TENTACLE_CONTENT
}else{
wx.removeStorageSync('TENTACLE_CONTENT')
wx.removeStorageSync('TIME_EXPIRATION')
}
}
} }
export default Http export default Http
...@@ -17,6 +17,8 @@ const Promise = require('../lib/bluebird') ...@@ -17,6 +17,8 @@ const Promise = require('../lib/bluebird')
const config = require('../config/index').envInfo const config = require('../config/index').envInfo
import utils from './util' import utils from './util'
const citysData = require('./city.js') const citysData = require('./city.js')
import { Integer } from './integerDigitalConvertion'
let openCardLister = null let openCardLister = null
/** /**
* 单例 * 单例
...@@ -242,6 +244,40 @@ class WXService extends Http { ...@@ -242,6 +244,40 @@ class WXService extends Http {
}) })
} }
//生成触点对象Id
getTentacleContent(tentacleInfo){
return this.post('/marketing/tentacleContent/getTentacleContent', tentacleInfo).then((res) => {
let data = res.data.data
return Promise.resolve(data);
}).finally(() => {
})
}
//根据触点对象id获取触点对象信息
getTentacleContentByTentacleId(tentacleId){
this.post('/marketing/tentacleContent/getTentacleContent', { tentacleId: tentacleId}).then((res) => {
let data = res.data.data
let TENTACLE_CONTENT = {
id: data.id,
tentacleType: data.type,
tentacleId: data.tentacleId,
contentType: data.contentType,
contentId: data.contentId
}
if (data.status == 1) {
var timestamp = Date.parse(new Date())
var expiration = timestamp + 1800000
wx.setStorageSync('TENTACLE_CONTENT', TENTACLE_CONTENT)
wx.setStorageSync('TIME_EXPIRATION', expiration)
}
}).finally(() => {
})
}
getManageDate() { getManageDate() {
return manageDate return manageDate
} }
...@@ -387,12 +423,31 @@ class WXService extends Http { ...@@ -387,12 +423,31 @@ class WXService extends Http {
onLoad: function(...args) { onLoad: function(...args) {
const page = this const page = this
_self.initAppGlobalDataSync() _self.initAppGlobalDataSync()
config.onLoad && config.onLoad.apply(page, args) //修改参数
let pageIsFromShare = false, tentacleId = null;
args.forEach(item => {
if(item['t']){
pageIsFromShare = true;
tentacleId = Integer.digit(item['t'],64,10);
if (item['i']){
item['id'] = Integer.digit(item['i'], 64, 10);
}
}
});
//如果打开的是分享界面则进行触点对象信息请求并存储到本地 放到后续的header中
if (pageIsFromShare){
//调用接口
_self.getTentacleContentByTentacleId(tentacleId);
}
config.onLoad && config.onLoad.apply(page, args);
}, },
onShow: function(...args) { onShow: function(...args) {
const page = this const page = this
_self.currentPage = page _self.currentPage = page
config.onShow && config.onShow.apply(page, args) config.onShow && config.onShow.apply(page, args)
}, },
onReady: function(...args) { onReady: function(...args) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment