123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- import {
- getComment,
- postReply,
- ReplyComment,
- likeReply
- } from '~/api/video'
- Component({
- /**
- * 组件的属性列表
- */
- properties: {
- // 是否在tabbar页面使用,是的话就给个padding
- tabBarPadding: {
- type: Boolean,
- value: false
- }
- },
- /**
- * 组件的初始数据
- */
- data: {
- show: false,
- commentId: '',
- totalSize: 0,
- list: [],
- detailDesc: '',
- postId: '',
- postIndex: '',
- ifGetFocus: false,
- replyType: 'works', // 回复类型,works是回复作品,comment是回复评论
- animation: {}
- },
- methods: {
- open(columnId) {
- // 背景遮罩层
- var animation = wx.createAnimation({
- duration: 300,
- timingFunction: "linear",
- delay: 0
- })
- animation.translateY(1000).step()
- this.setData({
- animationData: animation.export(),
- columnId,
- show: true,
- })
- setTimeout(() => {
- animation.translateY(0).step()
- this.setData({
- animationData: animation.export()
- })
- }, 100)
- this.getComment()
- },
- close() {
- this.setData({
- show: false,
- commentId: '',
- totalSize: 0,
- list: [],
- detailDesc: '',
- replyType: 'works',
- postId: null,
- postIndex: null,
- ifGetFocus: false,
- })
- },
- async getComment() {
- let params = {
- columnId: this.data.columnId,
- pageNo: 1,
- pageSize: 10000
- }
- let {
- totalSize,
- list
- } = await getComment(params)
- this.setData({
- totalSize,
- list
- })
- },
- bindKeyInput(e) {
- this.setData({
- detailDesc: e.detail.value
- })
- },
- // 评论作品
- async sendReply() {
- if (!this.data.detailDesc) {
- return
- }
- if (this.data.replyType == 'works') {
- let data = {
- columnId: this.data.columnId,
- detailDesc: this.data.detailDesc,
- }
- await postReply(data)
- } else {
- let data = {
- postsId: this.data.postId,
- content: this.data.detailDesc,
- }
- await ReplyComment(data)
- }
- this.setData({
- detailDesc: '',
- replyType: 'works'
- })
- this.getComment()
- },
- async ReplyComment({
- currentTarget
- }) {
- let postId = currentTarget.dataset.id
- let index = currentTarget.dataset.index
- this.setData({
- postId: postId,
- replyType: 'comment',
- ifGetFocus: true,
- postIndex: index
- })
- },
- cancelId() {
- this.setData({
- replyType: 'works',
- postId: null,
- postIndex: null,
- ifGetFocus: false,
- })
- },
- // 评论点赞
- async setLike({
- currentTarget
- }) {
- let postId = currentTarget.dataset.id
- let index = currentTarget.dataset.index
- let res = await likeReply(postId)
- const str = `list[${index}].likeCount`;
- const strImg = `list[${index}].isLike`;
- this.setData({
- [str]: res,
- [strImg]: true
- })
- }
- }
- })
|