<style>
  .activityMain {
    background: #fff;
    width: 740px;
    min-height: 500px;
  }

  .activityTitle {
    font-size: 16px;
    font-weight: 400;
    color: #000;
  }

  .activityContent {
    font-size: 14px;
    line-height: 24px;
    color: #333;
    margin: 20px 0;
  }

  .activeImgContent {
    width: 100%;
  }

  .activeImgContent img {
    max-width: 100%;
  }

  .activityFlex {
    display: flex;
    padding: 20px;
    border-bottom: 1px solid #E1E4E6;
  }

  .aImg {
    width: 88px;
    height: 88px;
    position: relative;
  }

  .aUserName {
    margin: 5px 0;
    color: #2d64b3;
    text-align: center;
  }

  .active_NameLeft {
    flex-shrink: 0;
    margin-right: 20px;
  }

  .activeComment {
    width: 100%;
    background-color: #f7f8fa;
    margin-top: 10px;
    padding: 15px;
  }

  .activeComList {
    display: flex;
    padding-bottom: 10px;
    border-bottom: 1px #d7d7d7 dotted;
    display: flex;
    margin-bottom: 10px;
    position: relative;
  }

  .compentImg {
    width: 32px;
    height: 32px;
    padding: 1px;
    border: 1px solid #ccc;
    flex-shrink: 0;
  }

  .compentRight {
    color: #333;
    font-size: 14px;
    line-height: 20px;
    margin-left: 10px;
    width: 100%;
  }

  .compentName {
    color: #2d64b3;
  }

  .commonDate {
    font-size: 12px;
    color: #999;
  }

  .activeDel {
    width: 25px;
    position: absolute;
    right: -8px;
    top: -8px;
    display: none;
    cursor: pointer;
  }

  .activeDel img {
    width: 100%;
  }

  .activeComList:hover .activeDel {
    display: block;
  }

  .activeLouzhu {
    position: absolute;
    right: 0;
    top: 0;
  }

</style>
<template>
  <div class="activityInfo">
    <div class="activityMain">
      <div class="activityFlex">
        <div class="active_NameLeft">
          <div class="aImg">
            <img style="width:100%;height:100%;" :src="dataList.Photo" />
            <img src="../../assets/img/userman/louzhu.png" class="activeLouzhu" alt="" />
          </div>
          <div class="aUserName">{{dataList.UserName}}</div>
        </div>
        <div>
          <div class="activityTitle">{{dataList.ActivityTitle}}</div>
          <div class="activityContent">
            {{dataList.Content}}
          </div>
          <div class="activeImgContent" v-for="(item,index) in dataList.ImageList" :key="index">
            <img :src="item" alt="" />
          </div>
        </div>
      </div>
      <div>
        <div class="activityFlex" v-for="(subItem,cindex) in compentList" :key="cindex">
          <div class="active_NameLeft">
            <div class="aImg">
              <img style="width:100%;height:100%;" :src="subItem.Photo" />
              <img src="../../assets/img/userman/louzhu.png" v-if="subItem.UserId==dataList.UserId" class="activeLouzhu" alt="" />
            </div>
            <div class="aUserName">{{subItem.UserName}}</div>
          </div>
          <div style="width:100%;">
            <div class="activityContent" style="margin-top:0;">
              {{subItem.Content}}
            </div>
            <div class="activeImgContent" v-for="(item,index) in subItem.ImageList" :key="index">
              <img :src="item" alt="" />
            </div>
            <div class="activeComment" v-if="subItem.ReplyNum>0">
              <div class="activeComList" v-for="(cItem,cindex) in subItem.ReplyList" :key="cindex">
                <div class="compentImg">
                  <img style="width:100%;height:100%;" :src="cItem.Photo" alt="" />
                </div>
                <div class="compentRight">
                  <div>
                    <span class="compentName">{{cItem.UserName}}：</span>{{cItem.Content}}
                  </div>
                  <div style="text-align:right;">
                    <span class="commonDate">{{cItem.CreateDate}}</span>
                  </div>
                </div>
              </div>
              <div>
                
              </div>
            </div>
          </div>
        </div>
        <!-- <div class="activeComment">
          <div class="activeComList" v-for="(item,cindex) in compentList" :key="cindex">
            <div class="compentImg">
              <img style="width:100%;height:100%;" :src="item.Photo" alt="" />
            </div>
            <div class="compentRight">
              <div>
                <span class="compentName">{{item.UserName}}：</span>{{item.Content}}
              </div>
              <div style="text-align:right;">
                <span class="commonDate">{{item.CreateDate}}</span>
              </div>
            </div>
            <div class="activeDel" @click="delCompent(item)">
              <img src="../../assets/img/userman/del.png" alt="" />
            </div>
          </div>
          <div class="activeComList" v-for="(subItem,subIndex) in replayList" :key="subIndex+100">
            <div class="compentImg">
              <img style="width:100%;height:100%;" :src="subItem.Photo" alt="" />
            </div>
            <div class="compentRight">
              <div>
                <span class="compentName">{{subItem.UserName}}：</span><span>回复</span><span
                  style="margin-left:5px;color:#2d64b3">{{subItem.ReplyUserName}}</span>：{{subItem.Content}}
              </div>
              <div style="text-align:right;">
                <span class="commonDate">{{subItem.CreateDate}}</span>
              </div>
            </div>
            <div class="activeDel" @click="delCompent(subItem)">
              <img src="../../assets/img/userman/del.png" alt="" />
            </div>
          </div>
          <el-pagination style="text-align:right" background v-if="pageCount>0" @current-change="handleCurrentChange"
            :page-size="comMsg.pageSize" layout="prev, pager, next" :current-page.sync="comMsg.pageIndex"
            :total="pageCount">
          </el-pagination>
        </div> -->
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        msg: {
          ActivityId: 0
        },
        comMsg: {
          pageIndex: 1,
          pageSize: 20,
          ActivityId: 0
        },
        replayMsg: {
          pageIndex: 1,
          pageSize: 20,
          ParentId: 0
        },
        dataList: {},
        compentList: [],
        pageCount: 0,
        replayList: []
      }
    },
    created() {},
    mounted() {
      if (this.$route.query.Id) {
        this.msg.ActivityId = this.$route.query.Id;
        this.comMsg.ActivityId = this.$route.query.Id;
        this.replayMsg.ParentId = this.$route.query.Id;
      }
      this.getList();
      this.getCommentList();
      this.getSecondReply();
    },
    methods: {
      //获取帖子头部数据
      getList() {
        this.apipost("/api/Miai/GetActivityInfo", this.msg, res => {
          if (res.data.resultCode == 1) {
            console.log(res, '数据');
            this.dataList = res.data.data;
          } else {
            this.Error(res.data.message);
          }
        })
      },
      //获取评论
      getCommentList() {
        this.apipost("/api/Miai/GetActivityDiscussPageList", this.comMsg, res => {
          if (res.data.resultCode == 1) {
            console.log(res, '评论数据');
            this.pageCount = res.data.data.pageCount;
            this.compentList = res.data.data.pageData;
          } else {
            this.Error(res.data.message);
          }
        })
      },
      //评论翻页
      handleCurrentChange(val) {
        this.comMsg.pageIndex = val;
        this.getCommentList();

        this.replayMsg.pageIndex = val;
        this.getSecondReply();
      },
      //获取二级回复
      getSecondReply() {
        this.apipost("/api/Miai/GetActivityReplyPageList", this.replayMsg, res => {
          if (res.data.resultCode == 1) {
            console.log(res, '回复数据');
            // this.pageCount = res.data.data.pageCount;
            // this.compentList = res.data.data.pageData;
            this.replayList = res.data.data.pageData;
          } else {
            this.Error(res.data.message);
          }
        })
      },
      //删除评论
      delCompent(item) {
        let that = this;
        that.$confirm('是否删除?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          let msg = {
            DiscussId: item.Id
          }
          this.apipost("/api/Miai/DelActivityDiscussInfo", msg, res => {
            if (res.data.resultCode == 1) {
              this.getCommentList();
              this.getSecondReply();
            } else {
              this.Error(res.data.message);
            }
          })
        }).catch(() => {

        });
      }
    }
  }

</script>
