Explorar o código

开发联调评论和点赞页面

bayi %!s(int64=2) %!d(string=hai) anos
pai
achega
ee77e84615

+ 2 - 1
api/message.js

@@ -9,5 +9,6 @@ module.exports = {
   getMessageList: (data, method = 'get') => request('/message', method, data),
   // 获取点赞列表
   getBeLikeList: data => request('/v3/message/likeInfo', 'get', data),
-
+  // 获取最新评论列表
+  getNewComment: data => request('/v3/message/postsInfo', 'get', data),
 }

+ 3 - 9
mixins/reachBottom.js

@@ -36,15 +36,9 @@ module.exports = Behavior({
         });
       })
       list = [...this.data.list, ...list]
-      if (list.length == 0) {
-        this.setData({
-          nullList: true
-        })
-      } else {
-        this.setData({
-          nullList: false
-        })
-      }
+      this.setData({
+        nullList: list.length == 0
+      })
       this.setData({
         pageNo: ++this.data.pageNo,
         list,

+ 47 - 56
pages/comment/index.js

@@ -1,66 +1,57 @@
-// pages/comment/index.js
+import {
+  getNewComment
+} from '~/api/message'
+import {
+  ReplyComment
+} from '~/api/video'
 Page({
-
-  /**
-   * 页面的初始数据
-   */
   data: {
-
+    list: []
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad(options) {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面初次渲染完成
-   */
-  onReady() {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面显示
-   */
-  onShow() {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面隐藏
-   */
-  onHide() {
-
+    this.getNewComment()
+  },
+  async getNewComment() {
+    let list = await getNewComment()
+    console.log(list);
+    this.setData({
+      list
+    })
+  },
+  setReply({
+    currentTarget
+  }) {
+    console.log(currentTarget);
+    wx.showModal({
+      title: '回复评论',
+      editable: true,
+      confirmText: '发送',
+      success: async (res) => {
+        if (res.confirm) {
+          if (!res.content) {
+            return
+          }
+          let data = {
+            postsId: currentTarget.dataset.id,
+            content: res.content,
+          }
+          await ReplyComment(data)
+          wx.showToast({
+            title: '回复成功',
+          })
+        }
+      }
+    })
+  },
+  jumpUserInfo({
+    currentTarget
+  }) {
+    wx.navigateTo({
+      url: `/pages/personal/index?uid=${currentTarget.dataset.uid}&type=user`,
+    })
   },
-
-  /**
-   * 生命周期函数--监听页面卸载
-   */
-  onUnload() {
-
-  },
-
-  /**
-   * 页面相关事件处理函数--监听用户下拉动作
-   */
-  onPullDownRefresh() {
-
-  },
-
-  /**
-   * 页面上拉触底事件的处理函数
-   */
-  onReachBottom() {
-
-  },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage() {
-
-  }
 })

+ 33 - 0
pages/comment/index.less

@@ -41,5 +41,38 @@
       border-radius: 10rpx;
       background-color: skyblue;
     }
+
+    .audioCover {
+      position: relative;
+      width: 230rpx;
+      height: 128rpx;
+      display: flex;
+      align-items: center;
+      justify-content: center;
+      border-radius: 8rpx;
+      overflow: hidden;
+      background-size: cover;
+      background-position: center;
+
+      .audioPlayBg {
+        width: 100rpx;
+        height: 100rpx;
+      }
+
+      .audioPlayZhen {
+        position: absolute;
+        right: 52rpx;
+        top: 20rpx;
+        width: 24rpx;
+        height: 30rpx;
+      }
+
+      .cover {
+        position: absolute;
+        width: 84rpx;
+        height: 84rpx;
+        border-radius: 50%;
+      }
+    }
   }
 }

+ 11 - 6
pages/comment/index.wxml

@@ -1,13 +1,18 @@
 <view class="commentPage">
-  <view class="notes" wx:for="{{3}}" wx:key="index">
-    <image src="/static/stars-1.png" class="avatar" />
+  <view class="notes" wx:for="{{list}}" wx:key="index">
+    <image src="{{item.user.avatar}}" class="avatar" data-uid='{{item.user.uid}}' bindtap="jumpUserInfo" />
     <view class="body">
-      <view class="nickName">帅气席尔瓦去</view>
+      <view class="nickName">{{item.user.nickName||item.user.eid}}</view>
       <view class="date">
-        评论了你:<text>朗读的太棒啦!朗读的太棒啦!朗读的太棒啦!3213213我去饿我去恶趣味 2023-3-14</text>
+        评论了你:<text>{{item.posts.detailDesc}} {{item.posts.day}}</text>
       </view>
-      <view class="reply">回复评论</view>
+      <view class="reply" data-id="{{item.posts.id}}" bindtap="setReply">回复评论</view>
+    </view>
+    <image src="{{item.userRead.coverImg}}" class="cover" wx:if="{{item.userRead.resourcesType==0}}" />
+    <view class="audioCover" style="background-image: url({{item.backgroundVirtualImg}});" wx:else>
+      <image src="/static/audioBg.png" class="audioPlayBg" />
+      <image src="/static/zhen.png" class="audioPlayZhen" />
+      <image src="{{item.userRead.coverImg}}" class="cover" />
     </view>
-    <image src="/static/heart_colored.png" class="cover" />
   </view>
 </view>

+ 29 - 0
pages/comment/index.wxss

@@ -35,3 +35,32 @@
   border-radius: 10rpx;
   background-color: skyblue;
 }
+.commentPage .notes .audioCover {
+  position: relative;
+  width: 230rpx;
+  height: 128rpx;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  border-radius: 8rpx;
+  overflow: hidden;
+  background-size: cover;
+  background-position: center;
+}
+.commentPage .notes .audioCover .audioPlayBg {
+  width: 100rpx;
+  height: 100rpx;
+}
+.commentPage .notes .audioCover .audioPlayZhen {
+  position: absolute;
+  right: 52rpx;
+  top: 20rpx;
+  width: 24rpx;
+  height: 30rpx;
+}
+.commentPage .notes .audioCover .cover {
+  position: absolute;
+  width: 84rpx;
+  height: 84rpx;
+  border-radius: 50%;
+}

+ 16 - 6
pages/like/index.js

@@ -1,9 +1,7 @@
 import {
   getBeLikeList
 } from '~/api/message'
-import reachBottom from '~/mixins/reachBottom'
 Page({
-  behaviors: [reachBottom],
   data: {
     list: []
   },
@@ -14,14 +12,26 @@ Page({
   onLoad(options) {
     this.getBeLikeList()
   },
-  loadMore() {
-    this.getData(getBeLikeList)
-  },
   async getBeLikeList() {
     let list = await getBeLikeList()
     console.log(list);
     this.setData({
       list
     })
-  }
+  },
+  jumpUserInfo({
+    currentTarget
+  }) {
+    wx.navigateTo({
+      url: `/pages/personal/index?uid=${currentTarget.dataset.uid}&type=user`,
+    })
+  },
+  jumpWork({
+    currentTarget
+  }) {
+    console.log(currentTarget);
+    wx.navigateTo({
+      url: `/pages/userWorks/index?id=${currentTarget.dataset.id}`,
+    })
+  },
 })

+ 2 - 2
pages/like/index.wxml

@@ -1,6 +1,6 @@
 <view class="like">
-  <view class="notes" wx:for="{{list}}" wx:key="index">
-    <image src="{{item.user.avatar}}" class="avatar" />
+  <view class="notes" wx:for="{{list}}" wx:key="index" data-id='{{item.userRead.id}}' bindtap="jumpWork">
+    <image src="{{item.user.avatar}}" class="avatar" data-uid='{{item.user.uid}}' catchtap="jumpUserInfo" />
     <view class="body">
       <view class="nickName">{{item.user.nickName||item.user.eid}}</view>
       <view class="date">

+ 31 - 3
pages/userWorks/index.js

@@ -1,18 +1,46 @@
 import {
   getSelfRead
 } from '~/api/user'
+import {
+  getreadInfo
+} from '~/api/video'
 import share from '~/mixins/share'
 import reachBottom from '~/mixins/reachBottom'
 Page({
   behaviors: [reachBottom, share],
   data: {
-
+    firstWork: ''
   },
   onLoad(options) {
-    this.loadMore()
+    console.log(options);
+    if (options.id) {
+      this.getreadInfo(options.id)
+    } else {
+      this.loadMore()
+    }
   },
   loadMore() {
-    this.getData(getSelfRead)
+    this.getData(this.getSelfRead)
+  },
+  getSelfRead(data) {
+    return new Promise(async (reslove) => {
+      let res = await getSelfRead(data)
+      if (this.data.firstWork) {
+        res.list = res.list.filter(item => {
+          return item.userRead.id != this.data.firstWork.userRead.id
+        })
+      }
+      res.list.unshift(this.data.firstWork)
+      reslove(res)
+    })
+  },
+  async getreadInfo(videoId) {
+    let firstWork = await getreadInfo(videoId)
+    console.log(firstWork);
+    this.setData({
+      firstWork
+    })
+    this.loadMore()
   },
   onReachBottom() {
     this.loadMore()