Browse Source

视频分享

sunxf 2 years ago
parent
commit
a5d12a92a4

+ 3 - 1
api/video.js

@@ -6,5 +6,7 @@ module.exports = {
     //设置视频状态。比如删除。禁用
     setVideoStatus: data => request('/userRead', 'put', data),
     // 作品点赞
-    likeVideo: data => request(`/userRead/like/${data}`, 'get')
+    likeVideo: data => request(`/userRead/like/${data}`, 'get'),
+    // 收藏
+    collectVideo: data => request('/favorites', 'post', data)
 }

+ 0 - 1
component/video-swiper/index.js

@@ -338,7 +338,6 @@ Component({
                         isCollect
                     })
                 });
-
             } else {
                 let str = `curQueue[${index}].isFavorite`;
                 let str2 = `curQueue[${index}].favoritesAmount`

+ 23 - 2
component/videoPreview/index.js

@@ -1,6 +1,7 @@
 import {
     setVideoStatus,
-    likeVideo
+    likeVideo,
+    collectVideo
 } from '~/api/video'
 Component({
     /**
@@ -145,6 +146,26 @@ Component({
                 }
             })
         },
-
+        // 收藏课程
+        async collect(e) {
+            let {
+                id,
+                type,
+                uid
+            } = this.properties.videoInfo.userRead
+            if (wx.getStorageSync('uid') == uid) {
+                return
+            }
+            await collectVideo({
+                targetCode: id,
+                favoritesType: type
+            })
+            let index = this.properties.index
+            let isFavorites = `list[${index}].isFavorites`;
+            let options = {
+                [isFavorites]: !this.properties.videoInfo.isFavorites
+            }
+            this.triggerEvent('changStatus', options)
+        },
     }
 })

+ 4 - 3
component/videoPreview/index.wxml

@@ -47,10 +47,11 @@
     <view class="workFooter">
         <view class="title">{{videoInfo.userRead.title}}</view>
         <view class="mange" wx:if="{{videoInfo.userRead.status!='CHECK'}}">
-            <view class="mangeL">
+            <view class="mangeL" bindtap="collect">
                 <view class="mangeL-box">
-                    <image src="/static/image/no_collect.png" mode="" class="icon" />
-                    <view class="icon-name">收藏</view>
+                    <image src="{{videoInfo.isFavorites ? '/static/index/star_colored.png' : '/static/index/star.png'}}"
+                        mode="" class="icon" />
+                    <view class="icon-name">{{item.isFavorites}}</view>
                 </view>
                 <button class="resetBtn mangeL-box" open-type="share" data-info='{{videoInfo}}'>
                     <image src="/static/index/share.png" mode="" class="icon" />

+ 0 - 3
pages/index/index.js

@@ -190,7 +190,6 @@ Page({
     },
     showPage: function () {
         let options = this.data.options;
-        console.log('this.data.workId', this.data.workId)
         if (this.data.workId) {
             // 需要在推荐第一个上插入一条分享或者刚朗读完数据
             let id = this.data.workId;
@@ -893,8 +892,6 @@ Page({
         })
     },
     onShareAppMessage: function (res) {
-        console.log('onShareAppMessage>>>>>>>>>>>>')
-        console.log('this.data', this.data)
         if (res.from === 'button') {
             return {
                 title: '请欣赏我的课文朗读作品,点赞+评论。',

+ 1 - 4
pages/index/index.wxml

@@ -20,9 +20,6 @@
 </view>
 <view class="container">
     <!-- 引入组件 -->
-    <!-- <import src="/component/group/group.wxml" /> -->
-    <!-- <import src="/component/hot/hot.wxml" /> -->
-    <!-- <import src="/component/follow/follow.wxml" /> -->
     <import src="/component/my/my.wxml" />
     <import src="/templates/courses/courses.wxml" />
     <!-- 顶部导航 -->
@@ -30,7 +27,7 @@
         <!-- <view class="tabbar {{3 == myIndex ? 'select':' '}}" bindtap="jumpMy">
             <text>我的</text>
         </view> -->
-        <view class="tabbar {{3 == myIndex ? 'select':' '}}" bindtap="switcher" data-index="3">
+        <view class="tabbar" bindtap="jumpMy">
             <text>我的</text>
         </view>
         <view class="tabbar {{0 == myIndex ? 'select':' '}}" bindtap="switcher" data-index="0">

+ 4 - 3
pages/userWorks/index.js

@@ -20,6 +20,7 @@ Page({
     //获取自己作品列表
     async getSelfRead() {
         let list = await getSelfRead()
+        console.log(list);
         this.setData({
             list
         })
@@ -79,7 +80,7 @@ Page({
                                                 success(res) {
                                                     resolve({
                                                         title: video.userRead.title,
-                                                        path: '/pages/userWorks/index',
+                                                        path: `/pages/index/index?readId=${video.userRead.id}`,
                                                         imageUrl: res.tempFilePath
                                                     })
                                                 },
@@ -136,12 +137,12 @@ Page({
                 resolve(res)
             })
         })
+        console.log(video);
         return {
             title: video.userRead.title,
-            path: '/pages/userWorks/index',
+            path: `/pages/index/index?readId=${video.userRead.id}`,
             imageUrl: video.userRead.coverImg,
             promise
         }
-
     }
 })