Browse Source

'分享功能优化'

Rorschach 4 years ago
parent
commit
e808fd2523

+ 2 - 1
component/share/share.js

@@ -195,7 +195,7 @@ Component({
       });
     },
     share: function (data) {
-      console.log(data)
+      console.log('分享内容',data)
       if (this.data.shareType === 'works') {
 
         this.setData({
@@ -208,6 +208,7 @@ Component({
           id:data.scene,
           type:data.type,
           grade:data.grade,
+          shareImg: data.shareImg,
           // path: data.path,
           QRData: {
             page: data.path,

+ 3 - 2
component/video-swiper/index.js

@@ -397,7 +397,7 @@ Component({
         },
         openShare: function (e) {
             const obj = e.currentTarget.dataset
-            console.log('分享', obj)
+            console.log('分享的dataset', obj)
             console.log('分享', e)
             if (1) {
                 this.shareDialog = this.selectComponent("#share-dialog");
@@ -410,7 +410,8 @@ Component({
                     scene: obj.id,
                     type:obj.type,
                     grade:obj.grade,
-                    productId: 1
+                    productId: 1,
+                    shareImg:obj.shareImg
                     // tip: this.data.tip,
                 }
                 // console.log(data)

+ 1 - 1
component/video-swiper/index.wxml

@@ -180,7 +180,7 @@
               <image class="collect_btn_icon" src="{{item.isFavorite ? '../../static/index/star_colored.png' : '../../static/index/star.png'}}" />
               <text>收藏</text>
           </view>
-          <view class="video_btn share_btn" bindtap="openShare" data-author="{{item.nickName}}" data-index="{{index}}" data-id="{{item.id}}" data-avatar="{{item.avatar}}" data-uid="{{item.uid}}" data-img="{{item.img}}" data-title="{{item.title}}" data-grade="{{item.grade}}" data-type="{{item.type}}">
+          <view class="video_btn share_btn" bindtap="openShare" data-author="{{item.nickName}}"  data-index="{{index}}" data-id="{{item.id}}" data-avatar="{{item.avatar}}" data-uid="{{item.uid}}" data-img="{{item.img}}" data-title="{{item.title}}" data-shareimg="{{item.shareImg}}" data-grade="{{item.grade}}" data-type="{{item.type}}">
               <image class="share_btn_icon" src="../../static/index/share.png" />
               <text>分享</text>
           </view>

+ 21 - 16
pages/index/index.js

@@ -418,7 +418,8 @@ Page({
       temp.tagUrl = item.userRead.tag ? item.userRead.tag === 'HOT' ? '../../static/index/hot_tag.png' : '../../static/index/new_tag.png' : ''
       temp.status = item.userRead.status;
       temp.coverImg = item.userRead.coverImg;
-      temp.grade=item.userRead.grade
+      temp.shareImg = item.userRead.shareImg;
+      temp.grade = item.userRead.grade;
       temp.videoShow = false;
       this.data.videoList.push(temp);
       // tempList.push(temp);
@@ -630,7 +631,7 @@ Page({
       const myList = res.data.data;
       if (myList.length === 0) {
         this.setData({
-          videoList:[]
+          videoList: []
         })
         return
       }
@@ -661,9 +662,10 @@ Page({
         temp.status = item.userRead.status;
         temp.ifCheck = item.userRead.status === 'CHECK' ? true : false;
         temp.coverImg = item.userRead.coverImg;
-        temp.grade=item.userRead.grade
+        temp.grade = item.userRead.grade
         temp.isFans = true;
         temp.videoShow = false;
+        temp.shareImg = item.userRead.shareImg;
         myWorks.push(temp);
       });
       console.log('myWorks', myWorks)
@@ -762,7 +764,7 @@ Page({
       return {
         title: '请欣赏我的课文朗读作品,点赞+评论。',
         path: `/pages/index/index?readId=${this.data.shareId}`,
-        imageUrl: '../../static/index/share_icon.png'
+        imageUrl: this.data.shareImg
 
       }
     } else {
@@ -773,11 +775,11 @@ Page({
     }
   },
   openShare: function (e) {
-    console.log('用户点击分享按钮', e)
+    console.log('用户点击分享按钮123', e)
     this.setData({
       shareTitle: e.detail.currentTarget.dataset.title,
       shareId: e.detail.currentTarget.dataset.id,
-      shareImg: e.detail.currentTarget.dataset.img
+      shareImg: e.detail.currentTarget.dataset.shareimg
     })
   },
   // 修改年级
@@ -909,27 +911,30 @@ Page({
       }
       // console.log(data)
       this.setData({
-        noScroll: 'noScroll'
+        noScroll: 'noScroll',
+        shareTitle: obj.title,
+        shareId: obj.id,
+        shareImg: obj.shareimg
       })
       this.shareDialog.share(data);
     }
   },
-  collectTap: function(e){
-    console.log('点击收藏首页',e)
+  collectTap: function (e) {
+    console.log('点击收藏首页', e)
     const index = e.detail.index;
     let str = `videoList[${index}].isFavorite`
     this.setData({
-     [str]: e.detail.isCollect
+      [str]: e.detail.isCollect
     })
   },
-  likeTap:function(e){
-    console.log('点赞',e)
+  likeTap: function (e) {
+    console.log('点赞', e)
     const index = e.detail.index;
     let likeStr = `videoList[${index}].isLike`;
     let likeNumStr = `videoList[${index}].likes`;
-   this.setData({
-     [likeStr]: true,
-     [likeNumStr]: this.data.videoList[index].likes + 1
-   })
+    this.setData({
+      [likeStr]: true,
+      [likeNumStr]: this.data.videoList[index].likes + 1
+    })
   },
 })

+ 3 - 2
pages/mycollection/mycollection.js

@@ -66,6 +66,7 @@ Page({
       temp.isFans = true;
       temp.isFavorite = true;
       temp.coverImg = item.userRead.coverImg;
+      temp.shareImg = item.userRead.shareImg;
       temp.grade=item.userRead.grade;
       temp.videoShow = false;
       this.data.videoList.push(temp);
@@ -192,7 +193,7 @@ Page({
     this.setData({
       shareTitle: e.detail.currentTarget.dataset.title,
       shareId: e.detail.currentTarget.dataset.id,
-      shareImg: e.detail.currentTarget.dataset.img
+      shareImg: e.detail.currentTarget.dataset.shareimg
     })
   },
 
@@ -205,7 +206,7 @@ Page({
       return {
         title: '请欣赏我的课文朗读作品,点赞+评论。',
         path: `/pages/index/index?readId=${this.data.shareId}`,
-        imageUrl: '../../static/index/share_icon.png'
+        imageUrl: this.data.shareImg
 
       }
     } else {

+ 1 - 1
pages/mycollection/mycollection.wxml

@@ -11,7 +11,7 @@
       <view class='left'>{{ item.userRead.summary }}</view>
     </view> 
   </view> -->
-  <VideoSwiper wx:if="{{videoList.length > 0}}" class="video-swiper" video-list="{{videoList}}" nextMargin="{{nextMargin}}" isSwiper="{{isSwiper}}" ifHeadTap="{{true}}" bindopenComment="openComment" bindheadTap="headTapHandler" bindgoToReading="goToReading" bindcollectTap="collectTap" bindlikeTap="likeTap" binddelHideMyWork="delHideMyWork" bindchange="videoChange" />
+  <VideoSwiper wx:if="{{videoList.length > 0}}" class="video-swiper" video-list="{{videoList}}" nextMargin="{{nextMargin}}" isSwiper="{{isSwiper}}" ifHeadTap="{{true}}" bindopenComment="openComment" bindheadTap="headTapHandler" bindgoToReading="goToReading" bindcollectTap="collectTap" bindlikeTap="likeTap" bindopenShare="openShare" binddelHideMyWork="delHideMyWork" bindchange="videoChange" />
   <!-- <myPlacerholder line1="{{line1}}" line2="{{line2}}" wx:if="{{collection_data.length <= 0}}" /> -->
   <view class="comment_section" catchtouchmove="commentTouchMove" catchtap="commentTap" data-type="blank" wx:if="{{commentShow}}">
     <Comment data-type="list" commentId="{{commentId}}" commentNum="{{commentNum}}" inputValue="{{inputValue}}" bindsendReply="sendReply" />

+ 10 - 2
pages/myworks/myworks.js

@@ -136,6 +136,7 @@ Page({
         temp.isFans = true;
         temp.videoShow = false;
         temp.coverImg = item.userRead.coverImg;
+        temp.shareImg = item.userRead.shareImg;
 
         // recommendWorks.push(temp);
         this.data.videoList.push(temp);
@@ -235,7 +236,14 @@ Page({
      [likeNumStr]: this.data.videoList[index].likes + 1
    })
   },
-
+  openShare: function (e) {
+    console.log('用户点击分享按钮', e)
+    this.setData({
+      shareTitle: e.detail.currentTarget.dataset.title,
+      shareId: e.detail.currentTarget.dataset.id,
+      shareImg: e.detail.currentTarget.dataset.shareimg
+    })
+  },
   /**
    * 用户点击右上角分享
    */
@@ -248,7 +256,7 @@ Page({
       return {
         title: '请欣赏我的课文朗读作品,点赞+评论。',
         path: `/pages/index/index?readId=${this.data.shareId}`,
-        imageUrl: '../../static/index/share_icon.png'
+        imageUrl: this.data.shareImg
 
       }
     } else {

+ 1 - 1
pages/myworks/myworks.wxml

@@ -36,7 +36,7 @@
   </view>
 
 
-  <VideoSwiper wx:if="{{videoList.length > 0}}" class="video-swiper" video-list="{{videoList}}" nextMargin="{{nextMargin}}" isSwiper="{{false}}" bindopenComment="openComment" bindheadTap="headTapHandler" bindcollectTap="collectTap" bindlikeTap="likeTap" bindgoToReading="goToReading" bindplay="onPlay"></VideoSwiper>
+  <VideoSwiper wx:if="{{videoList.length > 0}}" class="video-swiper" video-list="{{videoList}}" nextMargin="{{nextMargin}}" isSwiper="{{false}}" bindopenComment="openComment" bindheadTap="headTapHandler" bindcollectTap="collectTap" bindlikeTap="likeTap" bindopenShare="openShare" bindgoToReading="goToReading" bindplay="onPlay"></VideoSwiper>
 </scroll-view>
 <view class="comment_section" catchtouchmove="touchMove"  catchtap="commentTap" data-type="blank" wx:if="{{commentShow}}">
     <Comment data-type="list" commentId="{{commentId}}" />

+ 6 - 3
pages/reading/reading.js

@@ -64,6 +64,7 @@ Page({
                 exampleId: res.data.data.userRead.exampleId,
                 summary: res.data.data.userRead.summary,
                 coverImg: res.data.data.userRead.coverImg,
+                shareImg: res.data.data.userRead.shareImg,
             })
             this.getReadInfo(id)
             httpRequestApi.userIntoPage('pages/reading/reading', '朗读页面').success((res) => {
@@ -428,7 +429,8 @@ Page({
             "productId": this.data.productId,
             "grade": this.data.grade,
             "exampleId": this.data.exampleId,
-            "coverImg": this.data.coverImg
+            "coverImg": this.data.coverImg,
+            "shareImg": this.data.shareImg,
         };
         httpRequestApi.postWork(data).success(res => {
             wx.hideLoading({
@@ -511,6 +513,7 @@ Page({
                 temp.coverImg = item.userRead.coverImg;
                 temp.videoShow = false;
                 temp.grade = item.userRead.grade;
+                temp.shareImg = item.userRead.shareImg;
                 temp.type = item.userRead.type;
 
                 // recommendWorks.push(temp);
@@ -569,7 +572,7 @@ Page({
             return {
                 title: '请欣赏我的课文朗读作品,点赞+评论。',
                 path: `/pages/index/index?readId=${this.data.shareId}`,
-                imageUrl: '../../static/index/share_icon.png'
+                imageUrl: this.data.shareImg
 
             }
         } else {
@@ -588,7 +591,7 @@ Page({
         this.setData({
             shareTitle: e.detail.currentTarget.dataset.title,
             shareId: e.detail.currentTarget.dataset.id,
-            shareImg: e.detail.currentTarget.dataset.img
+            shareImg: e.detail.currentTarget.dataset.shareimg
         })
     },
     onPlay: function (e) {

+ 1 - 1
templates/courses/courses.wxml

@@ -10,7 +10,7 @@
                         <image class="collect_icon btn_icon" src="{{item.isFavorites ?'../../static/index/star_colored.png' :'../../static/index/star.png' }}" />
                         <text class="collect_text btn_text">{{item.isFavorites? '收藏' : '收藏'}}</text>
                     </view>
-                    <view class="share course_btn" catchtap="coursesOpenShare" data-author="{{item.user.nickName}}" data-index="{{index}}" data-id="{{item.userRead.id}}" data-avatar="{{item.user.avatar}}" data-uid="{{item.user.uid}}" data-icon="{{item.userRead.iconImg}}" data-title="{{item.userRead.title}}" data-type="{{item.userRead.type}}">
+                    <view class="share course_btn" catchtap="coursesOpenShare" data-author="{{item.user.nickName}}" data-index="{{index}}" data-id="{{item.userRead.id}}" data-avatar="{{item.user.avatar}}" data-uid="{{item.user.uid}}" data-shareImg="{{item.userRead.shareImg}}" data-icon="{{item.userRead.iconImg}}" data-title="{{item.userRead.title}}" data-type="{{item.userRead.type}}">
                         <image class="share_icon btn_icon" src="../../static/index/share.png" />
                         <text class="share_text btn_text">分享</text>
                     </view>