Bläddra i källkod

开发官方资源作品页面视频下方增加分享点赞评论收藏

bayi 1 år sedan
förälder
incheckning
be612ee2c4
2 ändrade filer med 42 tillägg och 23 borttagningar
  1. 38 15
      pages/reading/index.js
  2. 4 8
      pages/reading/index.wxml

+ 38 - 15
pages/reading/index.js

@@ -1,5 +1,7 @@
 import {
     getreadInfo,
+    likeVideo,
+    collectVideo,
     submitPlayLog
 } from '~/api/video'
 import {
@@ -789,19 +791,40 @@ Page({
             }
         })
     },
+    // 收藏课程
+    async collect() {
+        let {
+            id,
+            type,
+            uid
+        } = this.data.videoInfo.userRead
+        if (wx.getStorageSync('uid') == uid) {
+            return wx.showToast({
+                title: '不能收藏自己作品哦!',
+                icon: "none"
+            })
+        }
+        await collectVideo({
+            targetCode: id,
+            favoritesType: type
+        })
+        this.setData({
+            ['videoInfo.isFavorites']: !this.data.videoInfo.isFavorites
+        })
+    },
     // 点赞
     async likeVideo() {
-        /*   let {
-              id
-          } = this.data.videoInfoCopy.userRead
-          if (this.data.videoInfoCopy.isLike) {
-              return
-          }
-          await likeVideo(id)
-          this.setData({
-              ['videoInfoCopy.isLike']: true,
-              ['videoInfoCopy.userRead.likeAmount']: this.data.videoInfoCopy.userRead.likeAmount + 1
-          }) */
+        if (this.data.videoInfo.isLike) {
+            return
+        }
+        let {
+            id
+        } = this.data.videoInfo.userRead
+        await likeVideo(id)
+        this.setData({
+            ['videoInfo.isLike']: true,
+            ['videoInfo.userRead.likeAmount']: this.data.videoInfo.userRead.likeAmount + 1
+        })
     },
     creatShare() {
         return new Promise((resolve, reject) => {
@@ -845,13 +868,13 @@ Page({
                                     dz.src = '/static/heart.png'
                                     dz.onload = () => {
                                         ctx.drawImage(dz, 318, 222, 22, 22)
-                                        ctx.fillText(0, 254, 238)
+                                        ctx.fillText(video.userRead.likeAmount || 0, 254, 238)
                                         // 评论
                                         let pl = canvas.createImage();
                                         pl.src = '/static/comment.png'
                                         pl.onload = () => {
                                             ctx.drawImage(pl, 228, 222, 22, 22)
-                                            ctx.fillText(0, 340, 238)
+                                            ctx.fillText(video.userRead.commentAmount, 340, 238)
                                             if (video.userReadExtend.resourcesType == 1) {
                                                 let aBg = canvas.createImage();
                                                 aBg.src = '/static/shareAudioBg.png';
@@ -883,8 +906,8 @@ Page({
                                                     canvas: canvas,
                                                     success(res) {
                                                         resolve({
-                                                            title: '我的新作品发布啦,快来捧场点赞!',
-                                                            path: `/pages/pkPage/index?videoId=${wx.getStorageSync('shareVideoId')}&uid=${wx.getStorageSync('uid')}&isShare=true`,
+                                                            title: video.user.profession == '官方' ? '我正在听这篇朗读示范,这发音,播音专业水准!你也来听听!' : '我的新作品发布啦,快来捧场点赞!',
+                                                            path: video.user.profession == '官方' ? `/pages/reading/index?uid=${wx.getStorageSync('uid')}` : `/pages/pkPage/index?videoId=${wx.getStorageSync('shareVideoId')}&uid=${wx.getStorageSync('uid')}&isShare=true`,
                                                             imageUrl: res.tempFilePath
                                                         })
                                                     },

+ 4 - 8
pages/reading/index.wxml

@@ -1,3 +1,5 @@
+<wxs src="../../utils/filter.wxs" module="filters" />
+
 <view class="readingBox">
     <!-- 查看全部配音作品 -->
     <view class="moreWork" wx:if="{{readingType=='public'||readingType=='readMatch'}}">
@@ -37,18 +39,12 @@
         </view>
     </view>
     <view class="workFooter" wx:if="{{readingType=='public'}}">
-        <button class="resetBtn mangeL-box" open-type="share" data-info='{{videoInfo}}' bindtap="shareVideo"
-            wx:if="{{shareBtn}}">
+        <button class="resetBtn mangeL-box" open-type="share" data-info='{{videoInfo}}'>
             <image src="/static/share.png" mode="" class="icon" />
             <view class="icon-name">分享</view>
         </button>
-        <view class="resetBtn mangeL-box" wx:else>
-            <image src="/static/share.png" mode="" class="icon" />
-            <view class="icon-name">分享</view>
-        </view>
         <view class="mangeL-box" bindtap="collect">
-            <image src="{{videoInfo.isFavorites ? '/static/star_colored.png' : '/static/star.png'}}" mode=""
-                class="icon" />
+            <image src="{{videoInfo.isFavorites ? '/static/star_colored.png' : '/static/star.png'}}" class="icon" />
             <view class="icon-name">{{videoInfo.isFavorites?'已收藏':'收藏'}}</view>
         </view>
         <view class="mangeL-box" bindtap="openComment">