Rorschach 4 rokov pred
rodič
commit
d43af6c71e

+ 8 - 1
component/share/share.js

@@ -211,6 +211,7 @@ Component({
           grade: data.grade,
           shareImg: data.shareImg,
           shareStep: 'firend',
+          shareIndex: data.index,
           QRData: {
             page: data.path,
             scene: data.scene
@@ -288,9 +289,13 @@ Component({
             showCancel: false,
             success: (res) => {
               console.log('用户点击确定')
+              this.close();
               httpRequestApi.shareImgLog({
                 readId: this.data.id,
               }).success((oRes) => {
+                this.triggerEvent('addShareAmount', {
+                  index:this.data.shareIndex
+                })
                 setTimeout(() => {
                   if (oRes.data.count > 0) {
                     this.setData({
@@ -350,8 +355,10 @@ Component({
             this.flowerAnimationHandler();
           })
         }
+        this.triggerEvent('addShareAmount', {
+          index:this.data.shareIndex
+        })
       })
-      this.triggerEvent('customevent', {})
     },
     flowerAnimationHandler: function () {
       this.flowerBox = this.selectComponent("#flower-toast");

+ 36 - 21
component/video-swiper/index.js

@@ -306,10 +306,13 @@ Component({
                 });
 
             } else {
-                let str = `curQueue[${index}].isFavorite`
+                let str = `curQueue[${index}].isFavorite`;
+                let str2 = `curQueue[${index}].favoritesAmount`
                 httpRequestApi.collectClass(data).success((res) => {
+                    console.log('收藏数', this.data.curQueue[index].favoritesAmount)
                     this.setData({
-                        [str]: !this.data.curQueue[index].isFavorite
+                        [str]: !this.data.curQueue[index].isFavorite,
+                        [str2]: res.data.data.status === 'NORMAL' ? this.data.curQueue[index].favoritesAmount + 1 : this.data.curQueue[index].favoritesAmount - 1
                     })
                 });
             }
@@ -367,6 +370,13 @@ Component({
                 });
             }
         },
+        addShareAmount: function (e) {
+            console.log('+++++1', e.detail.index);
+            let str = `videoList[${e.detail.index}].shareAmount`;
+            this.setData({
+                [str]: this.data.videoList[e.detail.index].shareAmount + 1
+            })
+        },
         // 下载视频
         download: function (e) {
             // console.log(e.currentTarget.dataset)
@@ -374,38 +384,40 @@ Component({
                 title: '保存到本地',
                 mask: true
             })
-            const { url } = e.currentTarget.dataset;
+            const {
+                url
+            } = e.currentTarget.dataset;
             wx.downloadFile({
                 url,
-                success (res) {
+                success(res) {
                     // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
                     if (res.statusCode === 200) {
                         console.log(res.tempFilePath)
                         wx.saveVideoToPhotosAlbum({
                             filePath: res.tempFilePath,
-                            success (res) {
-                              wx.hideLoading()
-                              wx.showToast({
-                                title: '保存成功',
-                                icon: 'success',
-                                duration: 2000,
-                                mask: true
-                              })                              
+                            success(res) {
+                                wx.hideLoading()
+                                wx.showToast({
+                                    title: '保存成功',
+                                    icon: 'success',
+                                    duration: 2000,
+                                    mask: true
+                                })
                             },
-                            fail (error) {
+                            fail(error) {
                                 console.log(error)
                             }
                         })
                     }
                 },
-                fail () {
+                fail() {
                     wx.hideLoading()
                     wx.showToast({
-                      title: '网络不给力',
-                      icon: 'error',
-                      duration: 2000,
-                      mask: true
-                    })                              
+                        title: '网络不给力',
+                        icon: 'error',
+                        duration: 2000,
+                        mask: true
+                    })
                 }
             })
         },
@@ -475,7 +487,8 @@ Component({
                 type: obj.type,
                 grade: obj.grade,
                 productId: 1,
-                shareImg: obj.shareImg
+                shareImg: obj.shareImg,
+                index: obj.index
             }
             this.setData({
                 noScroll: 'noScroll'
@@ -499,8 +512,10 @@ Component({
 
             // var detail = e.detail;
             var activeId = e.target.dataset.id ? e.target.dataset.id : e.currentTarget.dataset.id;
+            var activeIndex = e.target.dataset.index ? e.target.dataset.index : e.currentTarget.dataset.index;
             this.triggerEvent(type, {
-                activeId: activeId
+                activeId: activeId,
+                activeIndex:activeIndex
             }, {
                 bubbles: false
             });

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

@@ -140,11 +140,11 @@
       <view class="foot_left">
         <view class="video_btn collect_btn" catchtap="collectTap" data-index="{{index}}" data-id="{{item.id}}" data-type="{{item.type}}">
           <image class="collect_btn_icon" src="{{item.isFavorite ? '../../static/index/star_colored.png' : '../../static/index/star.png'}}" />
-          <text>收藏</text>
+          <text>{{item.favoritesAmount === 0 ? '收藏' : item.favoritesAmount}}</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-shareimg="{{item.shareImg}}" data-grade="{{item.grade}}" data-type="{{item.type}}">
           <image class="share_btn_icon" src="../../static/index/share.png" />
-          <text>分享</text>
+          <text>{{item.shareAmount === 0 ? '分享' : item.shareAmount}}</text>
         </view>
         <!-- <button class="video_btn share_btn" open-type="share" 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"></image>
@@ -160,9 +160,9 @@
           <image class="flower_btn_icon" src="{{item.isLike ? '../../static/index/heart_colored.png' : '../../static/index/heart.png'}}" />
           <text>{{item.likes === 0 ? '点赞' : item.likes}}</text>
         </view>
-        <view class="video_btn comment_btn" catchtap="openComment" data-id="{{item.id}}">
+        <view class="video_btn comment_btn" catchtap="openComment" data-id="{{item.id}}" data-index="{{index}}">
           <image class="comment_btn_icon" src="../../static/index/comment.png" lazy-load="true" />
-          <text>{{item.commentAmount ===0 ?'评论' : '0'}}</text>
+          <text>{{item.commentAmount === 0 ?'评论' : item.commentAmount}}</text>
         </view>
       </view>
     </view>
@@ -178,4 +178,4 @@
   </view>
 </view>
 <flowerBox id="flower-toast" flowerNum="{{flowerNum}}" />
-<shareDialog id="share-dialog" shareType='works' bindShareDialogClose="shareDialogClose" shareId="{{id}}" />
+<shareDialog id="share-dialog" shareType='works' bindShareDialogClose="shareDialogClose" bindaddShareAmount="addShareAmount" shareId="{{id}}" />

+ 25 - 4
pages/index/index.js

@@ -414,6 +414,8 @@ Page({
       temp.plays = item.userRead.playAmount ? item.userRead.playAmount : 0;
       temp.likes = item.userRead.likeAmount ? item.userRead.likeAmount : 0;
       temp.commentAmount = item.userRead.commentAmount ? item.userRead.commentAmount : 0;
+      temp.shareAmount = item.userRead.shareAmount;
+      temp.favoritesAmount = item.userRead.favoritesAmount;
       temp.classId = item.userRead.exampleId ? item.userRead.exampleId : 1605097720036046;
       temp.time = formatDate(item.userRead.gmtCreated, 3);
       temp.avatar = item.user.avatar;
@@ -660,6 +662,8 @@ Page({
         temp.plays = item.userRead.playAmount ? item.userRead.playAmount : 0;
         temp.likes = item.userRead.likeAmount ? item.userRead.likeAmount : 0;
         temp.commentAmount = item.userRead.commentAmount ? item.userRead.commentAmount : 0;
+        temp.shareAmount = item.userRead.shareAmount;
+        temp.favoritesAmount = item.userRead.favoritesAmount;
         temp.classId = item.userRead.exampleId ? item.userRead.exampleId : 1605097720036046;
         temp.time = formatDate(item.userRead.gmtCreated, 3);
         temp.avatar = item.user.avatar;
@@ -696,6 +700,15 @@ Page({
   commentTap: function (e) {
     console.log('点击评论区', e)
     if (e.target.dataset.type === 'blank') {
+      if (this.data.commentShow && this.data.commentId) {
+        httpRequestApi.getClassDetail(this.data.commentId).success(res => {
+          console.log('评论回显', res.data.data.userRead.commentAmount)
+          let str = `videoList[${this.data.commentIndex}].commentAmount`;
+          this.setData({
+            [str]:res.data.data.userRead.commentAmount
+          })
+        })
+      }
       this.setData({
         commentShow: false
       })
@@ -708,9 +721,11 @@ Page({
   openComment: function (e) {
     // 
     console.log('id', e.detail.activeId)
+    console.log('id', e)
     this.setData({
       commentShow: !this.data.commentShow,
       commentId: e.detail.activeId,
+      commentIndex: e.detail.activeIndex
       // commentList: []
     });
     // this.getReply(e.detail.activeId);
@@ -790,7 +805,8 @@ Page({
     this.setData({
       shareTitle: e.detail.currentTarget.dataset.title,
       shareId: e.detail.currentTarget.dataset.id,
-      shareImg: e.detail.currentTarget.dataset.shareimg
+      shareImg: e.detail.currentTarget.dataset.shareimg,
+      goToShare: true
     })
   },
   // 修改年级
@@ -961,11 +977,13 @@ Page({
     }
   },
   collectTap: function (e) {
-    console.log('点击收藏首页', e)
     const index = e.detail.index;
-    let str = `videoList[${index}].isFavorite`
+    let str = `videoList[${index}].isFavorite`;
+    let str2 = `videoList[${index}].favoritesAmount`;
+    let favoritesAmount = e.detail.isCollect ? this.data.videoList[index].favoritesAmount + 1 : this.data.videoList[index].favoritesAmount - 1
     this.setData({
-      [str]: e.detail.isCollect
+      [str]: e.detail.isCollect,
+      [str2]: favoritesAmount
     })
   },
   likeTap: function (e) {
@@ -984,4 +1002,7 @@ Page({
     console.log('this.flower', this.flowerBox)
     this.flowerBox.comeOut();
   },
+  addShareAmount: function (e) {
+    console.log('+++++1', e)
+  }
 })

+ 1 - 1
pages/index/index.wxml

@@ -75,7 +75,7 @@
     <image class="close" bindtap="hideUpgrade" src="../../static/image/close.png"></image>
   </view> 
 </view>
-<shareDialog id="share-dialog" shareType='works' bindShareDialogClose="shareDialogClose" shareId="{{id}}" />
+<shareDialog id="share-dialog" shareType='works' bindaddShareAmount="addShareAmount" bindShareDialogClose="shareDialogClose" shareId="{{id}}" />
 <canvas canvas-id="myCanvas" style="width:300px; height: 525px; position: absolute; left: -999rpx; top: -9999rpx;"></canvas>
 <!-- <view class="index-dialog" wx:if="{{indexSignDialog}}">
   <form bindsubmit="signInBtn" report-submit="{{true}}" class="index-dialog-wrapper" >

+ 27 - 13
pages/mycollection/mycollection.js

@@ -16,7 +16,7 @@ Page({
     statusbarobj: {
       isshowbtn: false, //是否显示按钮
       title: "小学语文朗读配音", //标题
-  },
+    },
   },
 
   toClass: function (e) {
@@ -53,6 +53,8 @@ Page({
       temp.plays = item.userRead.playAmount ? item.userRead.playAmount : 0;
       temp.likes = item.userRead.likeAmount ? item.userRead.likeAmount : 0;
       temp.commentAmount = item.userRead.commentAmount ? item.userRead.commentAmount : 0;
+      temp.shareAmount = item.userRead.shareAmount;
+      temp.favoritesAmount = item.userRead.favoritesAmount;
       temp.classId = item.userRead.exampleId ? item.userRead.exampleId : 1605097720036046;
       temp.time = formatDate(item.userRead.gmtCreated, 3);
       temp.avatar = item.user.avatar;
@@ -67,7 +69,7 @@ Page({
       temp.isFavorite = true;
       temp.coverImg = item.userRead.coverImg;
       temp.shareImg = item.userRead.shareImg;
-      temp.grade=item.userRead.grade;
+      temp.grade = item.userRead.grade;
       temp.videoShow = false;
       this.data.videoList.push(temp);
     });
@@ -89,6 +91,15 @@ Page({
   commentTap: function (e) {
     console.log('点击评论区', e)
     if (e.target.dataset.type === 'blank') {
+      if (this.data.commentShow && this.data.commentId) {
+        httpRequestApi.getClassDetail(this.data.commentId).success(res => {
+          console.log('评论回显', res.data.data.userRead.commentAmount)
+          let str = `videoList[${this.data.commentIndex}].commentAmount`;
+          this.setData({
+            [str]: res.data.data.userRead.commentAmount
+          })
+        })
+      }
       this.setData({
         commentShow: false
       })
@@ -101,6 +112,7 @@ Page({
     this.setData({
       commentShow: !this.data.commentShow,
       commentId: e.detail.activeId,
+      commentIndex: e.detail.activeIndex
       // commentList: []
     });
     // this.getReply(e.detail.activeId);
@@ -170,23 +182,25 @@ Page({
   onReachBottom: function () {
 
   },
-  collectTap: function(e){
-    console.log('点击收藏',e)
+  collectTap: function (e) {
     const index = e.detail.index;
-    let str = `videoList[${index}].isFavorite`
+    let str = `videoList[${index}].isFavorite`;
+    let str2 = `videoList[${index}].favoritesAmount`;
+    let favoritesAmount = e.detail.isCollect ? this.data.videoList[index].favoritesAmount + 1 : this.data.videoList[index].favoritesAmount - 1
     this.setData({
-     [str]: e.detail.isCollect
+      [str]: e.detail.isCollect,
+      [str2]: favoritesAmount
     })
   },
-  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
+    })
   },
   openShare: function (e) {
     console.log('用户点击分享按钮', e)
@@ -201,7 +215,7 @@ Page({
    * 用户点击右上角分享
    */
   onShareAppMessage: function (res) {
-    console.log('用户点分享',res)
+    console.log('用户点分享', res)
     if (res.from === 'button') {
       return {
         title: '请欣赏我的课文朗读作品,点赞+评论。',

+ 28 - 13
pages/myworks/myworks.js

@@ -30,6 +30,7 @@ Page({
     this.setData({
       commentShow: !this.data.commentShow,
       commentId: e.detail.activeId,
+      commentIndex: e.detail.activeIndex
     });
   },
   toMyWorks: function (e) {
@@ -39,15 +40,25 @@ Page({
       url: `../../social/works/works?id=${id}&title=${title}`
     });
   },
+  // 评论区点击
   commentTap: function (e) {
     console.log('点击评论区', e)
     if (e.target.dataset.type === 'blank') {
+      if (this.data.commentShow && this.data.commentId) {
+        APIClient.getClassDetail(this.data.commentId).success(res => {
+          console.log('评论回显', res.data.data.userRead.commentAmount)
+          let str = `videoList[${this.data.commentIndex}].commentAmount`;
+          this.setData({
+            [str]: res.data.data.userRead.commentAmount
+          })
+        })
+      }
       this.setData({
         commentShow: false
       })
     }
   },
-  touchMove: function(e){
+  touchMove: function (e) {
     return
   },
   goToReading: function (e) {
@@ -121,6 +132,8 @@ Page({
         temp.plays = item.userRead.playAmount ? item.userRead.playAmount : 0;
         temp.likes = item.userRead.likeAmount ? item.userRead.likeAmount : 0;
         temp.commentAmount = item.userRead.commentAmount ? item.userRead.commentAmount : 0;
+        temp.shareAmount = item.userRead.shareAmount;
+        temp.favoritesAmount = item.userRead.favoritesAmount;
         temp.classId = item.userRead.exampleId ? item.userRead.exampleId : 1605097720036046;
         temp.time = formatDate(item.userRead.gmtCreated, 3);
         temp.avatar = item.user.avatar;
@@ -175,7 +188,7 @@ Page({
    * 生命周期函数--监听页面初次渲染完成
    */
   onReady: function () {
-    
+
   },
 
   /**
@@ -212,29 +225,31 @@ Page({
   onReachBottom: function () {
     this.setData({
       pageNo: this.data.pageNo + 1
-    },()=>{
+    }, () => {
       if (this.data.pageNo <= this.data.totalNo) {
         this.getUserWorks();
       }
     })
   },
-  collectTap: function(e){
-    console.log('点击收藏',e)
+  collectTap: function (e) {
     const index = e.detail.index;
-    let str = `videoList[${index}].isFavorite`
+    let str = `videoList[${index}].isFavorite`;
+    let str2 = `videoList[${index}].favoritesAmount`;
+    let favoritesAmount = e.detail.isCollect ? this.data.videoList[index].favoritesAmount + 1 : this.data.videoList[index].favoritesAmount - 1
     this.setData({
-     [str]: e.detail.isCollect
+      [str]: e.detail.isCollect,
+      [str2]: favoritesAmount
     })
   },
-  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
+    })
   },
   openShare: function (e) {
     console.log('用户点击分享按钮', e)

+ 23 - 7
pages/reading/reading.js

@@ -643,6 +643,10 @@ Page({
                 temp.img = item.userRead.iconImg;
                 temp.plays = item.userRead.playAmount ? item.userRead.playAmount : 0;
                 temp.likes = item.userRead.likeAmount ? item.userRead.likeAmount : 0;
+                temp.shareAmount = item.userRead.shareAmount;
+                temp.favoritesAmount = item.userRead.favoritesAmount;
+                temp.commentAmount = item.userRead.commentAmount ? item.userRead.commentAmount : 0;
+
                 temp.classId = item.userRead.exampleId;
                 temp.time = formatDate(item.userRead.gmtCreated, 3);
                 temp.avatar = item.user ? item.user.avatar : '';
@@ -675,11 +679,20 @@ Page({
     commentTap: function (e) {
         console.log('点击评论区', e)
         if (e.target.dataset.type === 'blank') {
-            this.setData({
-                commentShow: false
+          if (this.data.commentShow && this.data.commentId) {
+            httpRequestApi.getClassDetail(this.data.commentId).success(res => {
+              console.log('评论回显', res.data.data.userRead.commentAmount)
+              let str = `videoList[${this.data.commentIndex}].commentAmount`;
+              this.setData({
+                [str]:res.data.data.userRead.commentAmount
+              })
             })
+          }
+          this.setData({
+            commentShow: false
+          })
         }
-    },
+      },
     scrollToLower: function (e) {
         console.log('滑动到底部', e)
         this.setData({
@@ -706,6 +719,7 @@ Page({
         this.setData({
             commentShow: !this.data.commentShow,
             commentId: e.detail.activeId,
+            commentIndex: e.detail.activeIndex
         });
     },
     goToReading: function (e) {
@@ -758,13 +772,15 @@ Page({
         }
     },
     collectTap: function (e) {
-        console.log('点击收藏', e)
         const index = e.detail.index;
-        let str = `videoList[${index}].isFavorite`
+        let str = `videoList[${index}].isFavorite`;
+        let str2 = `videoList[${index}].favoritesAmount`;
+        let favoritesAmount = e.detail.isCollect ? this.data.videoList[index].favoritesAmount + 1 : this.data.videoList[index].favoritesAmount - 1
         this.setData({
-            [str]: e.detail.isCollect
+          [str]: e.detail.isCollect,
+          [str2]: favoritesAmount
         })
-    },
+      },
     likeTap: function (e) {
         console.log('点赞', e)
         const index = e.detail.index;