// mycomponent/yz_comment_popup/commentCell/commentCell.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    avatar: {
      type: String,
      value: ""
    },
    nickname: {
      type: String,
      value: ""
    },
    time: {
      type: String,
      value: ""
    },
    content: {
      type: String,
      value: ""
    },
    index: {
      type: Number,
      value: 0
    },
    page: {
      type: Number, //一页几条数据
      value: 5
    },
    replynum: {
      type: Number,
      value: 0
    },
  },
  options: {
    multipleSlots: true // 在组件定义时的选项中启用多slot支持
  },

  /**
   * 组件的初始数据
   */
  data: {
    slotChildren: 0, //计算回复数
    reduceRely: false //是否 显示“收起”评论样式
  },

  /**
   * 组件的方法列表
   */
  methods: {
    replyComment() {
      console.log(" =========== 点击一级评论 =============");
      let commentInputOptiones = {
        replyName: this.data.nickname,
        type: "reply",
        placeholder: "请输入你的回复吧",
        index: this.data.index,
        childIndex: 0,
        content: this.data.content.slice(0, 10) + "..."
      };
      this.triggerEvent('showCOMInput', commentInputOptiones);
    },
    getRely() {
      if (this.data.reduceRely) {
        //已加载过评论，此时只展开
        this.setData({
          reduceRely: false
        });
        return;
      }

      this.setData({
        slotChildren: this.data.slotChildren + this.data.page //默认一页5条数据
      });
      this.triggerEvent('getRely', {
        index: this.data.index
      });
    },
    packUPRely() {
      this.setData({
        reduceRely: true
      });
    }
  },

});