|
@@ -3,8 +3,10 @@ import {
|
|
|
postReply,
|
|
|
ReplyComment,
|
|
|
likeReply,
|
|
|
+ delPost,
|
|
|
getLikeNotes,
|
|
|
- getLikeNote
|
|
|
+ getLikeNote,
|
|
|
+ getCommentNote
|
|
|
} from '~/api/video'
|
|
|
import {
|
|
|
setFans
|
|
@@ -24,9 +26,9 @@ Component({
|
|
|
quickShow: true,
|
|
|
type: 'comment',
|
|
|
commentId: '',
|
|
|
- totalSize: 0,
|
|
|
firstData: {},
|
|
|
list: [],
|
|
|
+ count: {},
|
|
|
detailDesc: '',
|
|
|
postId: '',
|
|
|
postIndex: '',
|
|
@@ -35,7 +37,7 @@ Component({
|
|
|
animation: {}
|
|
|
},
|
|
|
methods: {
|
|
|
- open(columnId, type = 'comment', onceId) {
|
|
|
+ async open(columnId, type = 'comment', onceId) {
|
|
|
console.log(columnId, type, onceId);
|
|
|
// 背景遮罩层
|
|
|
var animation = wx.createAnimation({
|
|
@@ -61,16 +63,30 @@ Component({
|
|
|
} else {
|
|
|
this.resetData()
|
|
|
}
|
|
|
+ let r1 = await getComment({
|
|
|
+ columnId: this.data.columnId,
|
|
|
+ pageSize: 1
|
|
|
+ })
|
|
|
+ let r2 = await getLikeNotes({
|
|
|
+ userReadId: this.data.columnId,
|
|
|
+ pageSize: 1
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ count: {
|
|
|
+ commentNum: r1.totalSize,
|
|
|
+ likeNum: r2.totalSize
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
changeType({
|
|
|
currentTarget
|
|
|
}) {
|
|
|
let type = currentTarget.dataset.type
|
|
|
this.setData({
|
|
|
- type
|
|
|
+ type,
|
|
|
+ firstData: {}
|
|
|
})
|
|
|
this.resetData()
|
|
|
- console.log(currentTarget.dataset);
|
|
|
},
|
|
|
close() {
|
|
|
this.setData({
|
|
@@ -90,26 +106,33 @@ Component({
|
|
|
})
|
|
|
},
|
|
|
loadMore() {
|
|
|
- if (this.data.type == 'like') {
|
|
|
- this.getData((data) => {
|
|
|
- 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)
|
|
|
- }
|
|
|
- reslove(res)
|
|
|
- })
|
|
|
- }, {
|
|
|
- userReadId: this.data.columnId,
|
|
|
- })
|
|
|
- } else {
|
|
|
- this.getData(getComment, {
|
|
|
- columnId: this.data.columnId,
|
|
|
+ this.getData((data) => {
|
|
|
+ return new Promise(async (reslove) => {
|
|
|
+ let res
|
|
|
+ if (this.data.type == 'comment') {
|
|
|
+ res = await getComment(data)
|
|
|
+ this.setData({
|
|
|
+ 'count.commentNum': res.totalSize
|
|
|
+ })
|
|
|
+ } else if (this.data.type == 'like') {
|
|
|
+ res = await getLikeNotes(data)
|
|
|
+ this.setData({
|
|
|
+ 'count.likeNum': res.totalSize
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (this.data.firstData.id) {
|
|
|
+ res.list = res.list.filter(item => {
|
|
|
+ return item.id != this.data.firstData.id
|
|
|
+ })
|
|
|
+ res.list.unshift(this.data.firstData)
|
|
|
+ }
|
|
|
+ reslove(res)
|
|
|
})
|
|
|
- }
|
|
|
+ }, this.data.type == 'comment' ? {
|
|
|
+ columnId: this.data.columnId
|
|
|
+ } : {
|
|
|
+ userReadId: this.data.columnId,
|
|
|
+ })
|
|
|
},
|
|
|
bindKeyInput(e) {
|
|
|
this.setData({
|
|
@@ -117,7 +140,13 @@ Component({
|
|
|
})
|
|
|
},
|
|
|
async topping(id) {
|
|
|
- let res = await getLikeNote(id)
|
|
|
+ console.log(this.data.type);
|
|
|
+ let res
|
|
|
+ if (this.data.type == 'like') {
|
|
|
+ res = await getLikeNote(id)
|
|
|
+ } else {
|
|
|
+ res = await getCommentNote(id)
|
|
|
+ }
|
|
|
console.log(res);
|
|
|
this.setData({
|
|
|
firstData: res
|
|
@@ -203,11 +232,21 @@ Component({
|
|
|
url: `/pages/personal/index?uid=${currentTarget.dataset.uid}&type=user`,
|
|
|
})
|
|
|
},
|
|
|
- onLongPress(e) {
|
|
|
+ onLongPress({
|
|
|
+ currentTarget
|
|
|
+ }) {
|
|
|
+ let {
|
|
|
+ id,
|
|
|
+ type
|
|
|
+ } = currentTarget.dataset
|
|
|
wx.showActionSheet({
|
|
|
itemList: ['删除评论'],
|
|
|
- success(res) {
|
|
|
- console.log(res.tapIndex)
|
|
|
+ success: async () => {
|
|
|
+ let res2 = await delPost({
|
|
|
+ id,
|
|
|
+ type
|
|
|
+ })
|
|
|
+ console.log(res2);
|
|
|
},
|
|
|
})
|
|
|
},
|