bayi 2 years ago
parent
commit
aec6fe7012
5 changed files with 43 additions and 14 deletions
  1. 37 9
      components/comment/index.js
  2. 1 1
      mixins/video.js
  3. 3 2
      pages/like/index.js
  4. 1 1
      pages/my/index.wxml
  5. 1 1
      pages/userWorks/index.js

+ 37 - 9
components/comment/index.js

@@ -7,6 +7,7 @@ import {
   getLikeNote
 } from '~/api/video'
 import reachBottom from '~/mixins/reachBottom'
+let that = this
 Component({
   behaviors: [reachBottom],
   properties: {
@@ -22,6 +23,7 @@ Component({
     type: 'comment',
     commentId: '',
     totalSize: 0,
+    firstData: {},
     list: [],
     detailDesc: '',
     postId: '',
@@ -31,7 +33,8 @@ Component({
     animation: {}
   },
   methods: {
-    open(columnId, type = 'comment') {
+    open(columnId, type = 'comment', onceId) {
+      console.log(columnId, type, onceId);
       // 背景遮罩层
       var animation = wx.createAnimation({
         duration: 300,
@@ -45,14 +48,17 @@ Component({
         type,
         show: true,
       })
-      console.log(type);
       setTimeout(() => {
         animation.translateY(0).step()
         this.setData({
           animationData: animation.export()
         })
       }, 100)
-      this.resetData()
+      if (onceId) {
+        this.topping(onceId)
+      } else {
+        this.resetData()
+      }
     },
     changeType({
       currentTarget
@@ -82,22 +88,44 @@ Component({
       })
     },
     loadMore() {
+      console.log(this);
       if (this.data.type == 'like') {
-        this.getData(getLikeNotes, {
+        this.getData(this.getLikeNotes, {
+          userReadId: this.data.columnId,
+        })
+      } else {
+        this.getData(getComment, {
           columnId: this.data.columnId,
         })
-        return
-      }
-      let params = {
-        columnId: this.data.columnId,
       }
-      this.getData(getComment, params)
+    },
+    getLikeNotes(data) {
+      console.log(that);
+      return new Promise(async (reslove) => {
+        let res = await getLikeNotes(data)
+        if (this.data.firstData) {
+          res.list = res.list.filter(item => {
+            return item.id != this.data.firstData.id
+          })
+          res.list.unshift(this.data.firstData)
+        }
+        console.log(res);
+        reslove(res)
+      })
     },
     bindKeyInput(e) {
       this.setData({
         detailDesc: e.detail.value
       })
     },
+    async topping(id) {
+      let res = await getLikeNote(id)
+      console.log(res);
+      this.setData({
+        firstData: res
+      })
+      this.loadMore()
+    },
     async quickRemark({
       currentTarget
     }) {

+ 1 - 1
mixins/video.js

@@ -88,7 +88,7 @@ module.exports = Behavior({
       target
     }) {
       console.log(target);
-      this.selectComponent('#comment').open(target.dataset.id, target.dataset.type)
+      this.selectComponent('#comment').open(target.dataset.id, target.dataset.type, target.dataset.onceId)
     },
     // 分享
     creatShare(video) {

+ 3 - 2
pages/like/index.js

@@ -5,7 +5,8 @@ import reachBottom from '~/mixins/reachBottom'
 Page({
   behaviors: [reachBottom],
   data: {
-    list: []
+    list: [],
+    url:"https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MzIzNDY1NTgyNAMzIzNDY1NTgyNA==#wechat_redirect"
   },
   onShow(options) {
     this.resetData()
@@ -31,7 +32,7 @@ Page({
       likelog
     } = currentTarget.dataset
     wx.navigateTo({
-      url: `/pages/userWorks/index?id=${id}&likeId=${likelog}`,
+      url: `/pages/userWorks/index?id=${id}&onceId=${likelog}&type='like'`,
     })
   },
 })

+ 1 - 1
pages/my/index.wxml

@@ -147,4 +147,4 @@
   </view>
 </view>
 <!-- 广告组件 -->
-<rewardedVideo id='advert' bind:taskOver="setUserInfo" />
+<rewardedVideo id='advert' bind:taskOver="setUserInfo" />

+ 1 - 1
pages/userWorks/index.js

@@ -20,6 +20,7 @@ Page({
           target: {
             dataset: {
               type: 'like',
+              onceId: options.onceId,
               id: options.id
             }
           }
@@ -46,7 +47,6 @@ Page({
   },
   async getreadInfo(videoId) {
     let firstWork = await getreadInfo(videoId)
-    console.log(firstWork);
     this.setData({
       firstWork
     })