|
|
@@ -352,34 +352,67 @@ Page({
|
|
|
wx.navigateBack();
|
|
|
},
|
|
|
|
|
|
- // 分享功能
|
|
|
- onShare() {
|
|
|
- wx.showShareMenu({
|
|
|
- withShareTicket: true,
|
|
|
- menus: ['shareAppMessage', 'shareTimeline']
|
|
|
- });
|
|
|
+ // 分享按钮点击事件
|
|
|
+ onShareTap(e) {
|
|
|
+ // 阻止事件冒泡
|
|
|
+ e.stopPropagation();
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
// 分享给朋友
|
|
|
- onShareAppMessage() {
|
|
|
- const videoInfo = this.data.videoInfo;
|
|
|
- if (!videoInfo) return {};
|
|
|
+ onShareAppMessage(e) {
|
|
|
+ // 如果是从推荐视频分享
|
|
|
+ if (e.target && e.target.dataset.video) {
|
|
|
+ const video = e.target.dataset.video;
|
|
|
+ return {
|
|
|
+ title: video.title,
|
|
|
+ path: `/pages/video/detail?id=${video.id}&title=${encodeURIComponent(video.title)}&tag_id=${video.tag_ids[0]}`,
|
|
|
+ imageUrl: video.cover_image,
|
|
|
+ success: function(res) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '分享成功',
|
|
|
+ icon: 'success',
|
|
|
+ duration: 1500
|
|
|
+ });
|
|
|
+ },
|
|
|
+ fail: function(res) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '分享失败',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 1500
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
|
|
|
+ // 默认分享当前视频
|
|
|
+ const videoInfo = this.data.videoInfo;
|
|
|
return {
|
|
|
title: videoInfo.title,
|
|
|
- path: `/pages/video/detail?id=${videoInfo.id}`,
|
|
|
- imageUrl: videoInfo.cover
|
|
|
+ path: `/pages/video/detail?id=${videoInfo.id}&title=${encodeURIComponent(videoInfo.title)}&tag_id=${videoInfo.tag_ids[0]}`,
|
|
|
+ imageUrl: videoInfo.cover,
|
|
|
+ success: function(res) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '分享成功',
|
|
|
+ icon: 'success',
|
|
|
+ duration: 1500
|
|
|
+ });
|
|
|
+ },
|
|
|
+ fail: function(res) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '分享失败',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 1500
|
|
|
+ });
|
|
|
+ }
|
|
|
};
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
// 分享到朋友圈
|
|
|
onShareTimeline() {
|
|
|
const videoInfo = this.data.videoInfo;
|
|
|
- if (!videoInfo) return {};
|
|
|
-
|
|
|
return {
|
|
|
title: videoInfo.title,
|
|
|
- query: `id=${videoInfo.id}`,
|
|
|
+ query: `id=${videoInfo.id}&title=${encodeURIComponent(videoInfo.title)}&tag_id=${videoInfo.tag_ids[0]}`,
|
|
|
imageUrl: videoInfo.cover
|
|
|
};
|
|
|
},
|