Rorschach преди 6 години
родител
ревизия
fc0db30b57

+ 12 - 5
pages/main/class/class.js

@@ -9,7 +9,10 @@ Page({
     title: '',
     poster: '',
     works: [],
-    total: ''
+    total: '',
+    title: '',
+    id: '',
+    iconImg: ''
   },
   onLoad: function (option) {
     console.log(option);
@@ -20,13 +23,15 @@ Page({
       title: option.title,
       id: option.id
     })
+
     let uid = wx.getStorageSync('uid');;
 
     httpRequestApi.getClassDetail(uid, option.id).success(res => {
       console.log(res);
       this.setData({
         title: res.data.data.title,
-        videoUrl: res.data.data.playUrl
+        videoUrl: res.data.data.playUrl,
+        iconImg: res.data.data.iconImg
       })
       this.getReadInfo(1,10);
     })
@@ -52,16 +57,18 @@ Page({
   collect: function (e) {
     let uid =  wx.getStorageSync('uid');
     let data = {
-      
+      targetCode: this.data.id,
+      title: this.data.title,
+      iconImg: this.data.iconImg
     }
-    httpRequestApi.collectBook(uid, data).success(res => {
+    httpRequestApi.collectClass(uid, data).success(res => {
       console.log(res);
     })
   },
   getReadInfo: function(pageNo,pageSize){
     const uid =  wx.getStorageSync('uid');
     const data = {
-      lessonId: 1 ,
+      lessonId: 1,
       pageNo: pageNo,
       pageSize: pageSize
     };

+ 1 - 1
pages/main/class/class.wxml

@@ -19,7 +19,7 @@
     </scroll-view>
     <view class="footSection">
         <image class="blackbord" src="../../../static/image/blackbord.png" />
-        <view class="collectBtn footerBtn">
+        <view class="collectBtn footerBtn" bindtap="collect">
             <image src="../../../static/image/collected.png" />
             <text>收藏</text>
         </view>

+ 16 - 1
pages/social/replyDetail/replyDetail.js

@@ -39,6 +39,7 @@ Page({
                 temp.text = item.content;
                 temp.time = formatDate(item.gmtCreated,3);
                 temp.likes = 0;
+                temp.id = item.postId;
                 temp.avatar = item.user.avatar;
                 replyTemp.push(temp);
                 console.log(replyTemp);
@@ -47,5 +48,19 @@ Page({
                 comment: replyTemp
             })
         });
-    }
+    },
+      // 点赞评论
+      likeCommend: function (e) {
+        console.log(e);
+        let uid = wx.getStorageSync('uid');
+        let followUid = e.currentTarget.dataset.id;
+        let index = e.currentTarget.dataset.index;
+        httpRequestApi.likeCommend(uid, followUid).success(res => {
+            console.log(res);
+            const str = `comment[${index}].likes`;
+            this.setData({
+                [str]: res.data.data.favors
+            })
+        });
+    },
 })

+ 2 - 2
pages/social/replyDetail/replyDetail.wxml

@@ -9,8 +9,8 @@
             <view class="btnWrapper">
                 <image class="commentBtn" src="../../../static/image/comment.png" wx:if="{{index===0}}" />
                 <text class="commentText" wx:if="{{index===0}}">评论</text>
-                <image class="likeBtn" src="../../../static/image/like.png" />
-                <text class="likeText">{{item.likes}}</text>
+                <!-- <image class="likeBtn" data-index="{{index}}" data-likes="{{item.likes}}" data-id="{{item.id}}" src="../../../static/image/like.png" bindtap="likeCommend" /> -->
+                <!-- <text class="likeText" >{{item.likes}}</text> -->
             </view>
         </view>
     </view>

+ 44 - 14
pages/social/works/works.js

@@ -16,18 +16,20 @@ Page({
         replyList: [],
         howMuch: '2000',
         moneySelect: 'moneySelect',
-        moneyNormal: 'moneyNormal'
+        moneyNormal: 'moneyNormal',
+        ifReward: false
     },
     onLoad: function (option) {
-        if (option.title) {
-            wx.setNavigationBarTitle({
-                title: option.title //页面标题为路由参数
-            })
-            this.setData({
-                title: option.title,
-                id: option.id
-            })
-        }
+        console.log(option)
+
+        wx.setNavigationBarTitle({
+            title: option.title //页面标题为路由参数
+        })
+
+        this.setData({
+            title: option.title,
+            id: option.id
+        })
         let uid = wx.getStorageSync('uid');
         this.getWorks(uid, option.id);
     },
@@ -93,6 +95,20 @@ Page({
             console.log(res)
         });
     },
+    // 点赞评论
+    likeCommend: function (e) {
+        console.log(e);
+        let uid = wx.getStorageSync('uid');
+        let followUid = e.currentTarget.dataset.id;
+        let index = e.currentTarget.dataset.index;
+        httpRequestApi.likeCommend(uid, followUid).success(res => {
+            console.log(res);
+            const str = `replyList[${index}].likes`;
+            this.setData({
+                [str]: res.data.data.favors
+            })
+        });
+    },
     // 去其他用户的作品页
     goToOthers: function (e) {
         wx.navigateTo({
@@ -103,6 +119,7 @@ Page({
     getReply: function () {
         let uid = wx.getStorageSync('uid');
         let columnId = this.data.id;
+        console.log(columnId)
         let pageNo = 1;
         let pageSize = 10;
         httpRequestApi.getReply(uid, columnId, pageNo, pageSize).success((res) => {
@@ -117,6 +134,7 @@ Page({
                 temp.id = item.id;
                 temp.replyCount = item.replyCount;
                 temp.time = formatDate(item.gmtCreated, 3);
+                temp.likes = item.postsAttributeInfo.favors || 0;
                 console.log(temp.time)
                 replyTemp.push(temp);
             });
@@ -157,17 +175,22 @@ Page({
         }
     },
     // 选择金额
-    setMoney: function(e){
+    setMoney: function (e) {
         this.setData({
             howMuch: e.currentTarget.dataset.money
         })
     },
+    reward: function () {
+        this.setData({
+            ifReward: true
+        })
+    },
     // 奖励
     rewardMoney: function () {
         console.log(this.data.authorUid);
         const data = {
             targetUid: this.data.authorUid,
-            amount: "50"
+            amount: this.data.howMuch
         }
         let uid = wx.getStorageSync('uid');
         httpRequestApi.rewardMoney(uid, data).success(res => {
@@ -192,15 +215,22 @@ Page({
                     content: '支付成功',
                     success(res) {
                         if (res.confirm) {
-                            console.log('点击确定')
+                            this.setData({
+                                ifReward: false
+                            })
                         } else if (res.cancel) {
-                            console.log('取消')
+                            this.setData({
+                                ifReward: false
+                            })
                         }
                     }
                 })
 
             },
             'fail': function (res) {
+                this.setData({
+                    ifReward: false
+                })
                 console.log('支付失败', res)
             }
         })

+ 3 - 3
pages/social/works/works.wxml

@@ -42,8 +42,8 @@
             <view class="btnWrapper">
                 <image class="commentBtn" src="../../../static/image/comment.png" />
                 <text class="commentText">评论</text>
-                <image class="likeBtn" src="../../../static/image/like.png" />
-                <text class="likeText">165</text>
+                <image class="likeBtn" src="../../../static/image/like.png" data-index="{{index}}" data-likes="{{item.likes}}" data-id="{{item.id}}" bindtap="likeCommend" />
+                <text class="likeText">{{item.likes}}</text>
             </view>
         </view>
     </view>
@@ -65,7 +65,7 @@
         </view>
     </view>
     <!-- 奖励弹窗 -->
-    <cover-view class="modalWrapper">
+    <cover-view class="modalWrapper" wx:if="{{ifReward}}">
         <cover-view class="rewardContent">
             <cover-image class="rewardWrapper" src="../../../static/image/reward_wrapper.png" />
             <cover-image class="rewardAvatar" src="{{authorAvatar}}" />

+ 9 - 2
utils/APIClient.js

@@ -141,6 +141,13 @@ module.exports = {
 			uid
 		}).url(url).data(data).method('POST').send();
 	},
+	// 点赞评论
+	likeCommend(uid,likeUid){
+		let url = getBaseUrl(`wx/posts/attribute/${likeUid}`);
+		return request.getInstance().header({
+			uid
+		}).url(url).method('GET').send();
+	},
 	// 发布讨论
 	postReply(uid, data){
 		let url = getBaseUrl(`wx/posts`);
@@ -179,8 +186,8 @@ module.exports = {
 		}).method('POST').send();
 	},
 	// 收藏课程
-	collectBook(uid, data){
-		let url = getBaseUrl(`wx/favorites`);
+	collectClass(uid, data){
+		let url = getProductUrl(`wx/favorites`);
 		return request.getInstance().header({
 			uid
 		}).url(url).data(data).method('POST').send();