123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- import httpRequestApi from '../../../utils/APIClient';
- import {
- formatDate
- } from '../../../utils/util';
- Page({
- data: {
- class1: 'commentItem commentItemFirst',
- classNormal: 'commentItem',
- postId: '',
- comment: [],
- replyInfo: '',
- count: ''
- },
- onLoad: function (option) {
- console.log(option)
- this.setData({
- postId: option.id,
- productId: option.productId
- // count: option.count === 'undefined' ? 0 : option.count
- })
- wx.setNavigationBarTitle({
- // title: option.count + '条回复' //页面标题为路由参数
- title: '回复详情' //页面标题为路由参数
- })
- this.uid = wx.getStorageSync('uid');
- this.getReplyDetail();
- },
- // 保存 回复的内容
- saveValue: function (e) {
- this.setData({
- replyInfo: e.detail.value
- });
- },
- replyDone: function () {
- console.log(this.data.productId)
- const data = {
- postsId: this.data.postId,
- productId: this.data.productId,
- content: encodeURI(this.data.replyInfo)
- }
- if (this.data.replyInfo) {
- httpRequestApi.postReplyComment(this.uid, data).success(res => {
- this.setData({
- replyModal: false,
- replyInfo: '',
- flowerNum: res.data.count
- }, () => {
- if (res.data.count > 0) {
- console.log(123123)
- this.flowerBox = this.selectComponent("#flower-box");
- this.flowerBox.comeOut();
- }
- this.getReplyDetail();
- });
- });
- }
- },
- // 查询回复详情
- getReplyDetail: function () {
- // let uid = wx.getStorageSync('uid');
- httpRequestApi.getReplyComment(this.uid, this.data.postId).success((res) => {
- console.log(res);
- const replyList = res.data.data.replyVOList;
- const replied = res.data.data;
- const replyTemp = [];
- const authorDetail = {};
- authorDetail.name = replied.user.wechatName;
- authorDetail.text = decodeURI(replied.detailDesc);
- authorDetail.time = formatDate(replied.gmtCreated, 3);
- authorDetail.likes = replied.postsAttributeInfo.favors;
- authorDetail.avatar = replied.user.avatar;
- replyTemp.push(authorDetail);
- replyList.forEach(item => {
- const temp = {};
- temp.name = item.user.wechatName;
- temp.text = decodeURI(item.content);
- temp.time = formatDate(item.gmtCreated, 3);
- temp.likes = 0;
- temp.id = item.postId;
- temp.avatar = item.user.avatar;
- if (item.isRisky === 'NORMAL') {
- replyTemp.push(temp);
- }
- console.log(replyTemp);
- });
- const count = replyTemp.length - 1;
- this.setData({
- comment: replyTemp,
- count
- })
- });
- },
- // 点赞评论
- 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(this.uid, followUid).success(res => {
- console.log(res);
- const str = `comment[${index}].likes`;
- this.setData({
- [str]: res.data.data.favors
- })
- });
- },
- // 设置点击时的id
- setSBId: function (e) {
- console.log(e)
- this.setData({
- // replySBId: e.currentTarget.dataset.id,
- replyModal: true
- })
- },
- // 回复某个评论
- replySB: function () {
- const data = {
- postsId: this.data.postId,
- content: this.data.inputSBValue
- }
- httpRequestApi.postReplyComment(this.uid, data).success(res => {
- console.log(res.data.count)
- this.setData({
- replyModal: false,
- })
- });
- },
- // 获取回复楼中楼的内容
- inputSBValue: function (e) {
- this.setData({
- inputSBValue: e.detail.value
- });
- },
- })
|