<template>
  <div class="commentDetail">
    <div class="avatar-info">
      <div class="avatar-img">
        <img :src="data.villagerCircleInfo.avatarUrl" alt="" v-if="data.villagerCircleInfo && data.villagerCircleInfo.avatarUrl" >
        <img src="img/tx@2x.png" alt="" v-else>
      </div>
      <div class="avatar-title">
        <div class="name" v-if="data.villagerCircleInfo && data.villagerCircleInfo.createUserName">
          {{ data.villagerCircleInfo.createUserName }}
        </div>
        <div class="time">
          <span v-if="data.villagerCircleInfo && data.villagerCircleInfo.topic">{{ $dict.getLabel('villagerCircleTopic',data.villagerCircleInfo.topic) }}</span>
          <span>|</span>
          <span v-if="data.villagerCircleInfo && data.villagerCircleInfo.createTime">{{ data.villagerCircleInfo.createTime }}</span>
        </div>
      </div>
    </div>
    <div class="textarea" v-if="data.villagerCircleInfo && data.villagerCircleInfo.content">{{ data.villagerCircleInfo.content }}</div>
    <div style="background: #FFFFFF; padding:0 30px; box-sizing: border-box;padding-bottom: 20px;" v-if="data.villagerCircleInfo && data.villagerCircleInfo.pictures">
      <img :src="item.url" alt="" v-for="(item, i) in data.villagerCircleInfo.pictures" :key="i"  @click="previewImage(data.villagerCircleInfo.pictures, item.url)" class="upLoadPic" />
    </div>
    <div class="address" v-if="data.villagerCircleInfo && data.villagerCircleInfo.gpsDesc">
      <span class="addr-bg">
        <img src="img/address.png" alt="">
        <span v-if="data.villagerCircleInfo && data.villagerCircleInfo.gpsDesc">{{ data.villagerCircleInfo.gpsDesc }}</span>
      </span>
    </div>
    <div class="comment" v-if="data.content">
      <div class="comment-list">
        <div class="title">评论:</div>
        <div class="item">
          <span class="avatar">{{ data.replyUserName }}</span><span>:</span><span>{{ data.content }}</span>
        </div>
      </div>
    </div>

    <!-- 通过 -->
    <div class="readOnly" v-if="data.status ==1 ">
      <div class="item">
        <div>审核结果</div>
        <div>通过</div>
      </div>
      <div class="item">
        <div>审核人</div>
        <div>{{ data.auditUserName }}</div>
      </div>
      <div class="item last">
        <div>审核时间</div>
        <div>{{ data.auditTime }}</div>
      </div>
    </div>

    <!-- 不通过 -->
    <div class="readOnly" v-if="data.status ==2">
      <div class="item">
        <div>审核结果</div>
        <div>不通过</div>
      </div>
      <div class="item nopass">
        <div>不通过理由</div>
        <div class="textarea">{{ data.auditOpinion }}</div>
      </div>
      <div class="item">
        <div>审核人</div>
        <div>{{ data.auditUserName }}</div>
      </div>
      <div class="item last">
        <div>审核时间</div>
        <div>{{ data.auditTime }}</div>
      </div>
    </div>

    <div style="height: 56px;"></div>

    <div class="btn" v-if="data.status == 0">
      <div class="reject" @click="toReject">驳回发布</div>
      <div class="agree" @click="agree">同意发布</div>
    </div>

  </div>
</template>

<script>
export default {
  name: 'commentDetail',
  data() {
    return {
      files: [],
      status: 0,
      id: '',
      data: {},
      flag: 1
    }
  },
  onLoad(o) {
    this.$dict.load('villagerCircleTopic').then(()=>{
      this.id = o.id
      this.getDetail()
    })
  },
  methods: {
     previewImage(images, img) {
      uni.previewImage({
        urls: images.map(v => v.url),
        current: img
      })
    },
    getDetail() {
      this.$http.post(`/app/appvillagercirclecomment/queryDetailById?id=${this.id}`).then(res => {
        if(res?.data){
          this.data = res.data
          this.$forceUpdate()
        }
      })
    },
    toReject() {
      uni.navigateTo({url: `./Reject?id=${this.data.id}&pass=0&flag=1`})
    },
    agree() {
      this.$http.post('/app/appvillagercirclecomment/examine',null, {
        params: {
          id: this.id,
          pass: 1,
        }
      }).then(() => {
        // this.$u.toast('发布成功')
        uni.$emit('update')
        setTimeout(()=>{
          uni.navigateBack()
        },600)
      })
    }
  },
  onShow() {
    document.title = "评论审核"
  },
}
</script>

<style lang="scss" scoped>
.commentDetail {
  .avatar-info {
    display: flex;
    padding: 0 32px;
    box-sizing: border-box;
    background: #FFFFFF;
    .avatar-img {
      margin-right: 20px;
      img {
        margin-top: 30px;
        width: 88px;
        height: 88px;
        border-radius: 50%;
      }
    }
    .avatar-title {
      padding: 30px 32px;
      box-sizing: border-box;
      .name {
        font-size: 32px;
        color: #333333;
        font-weight: 600;
        margin-bottom: 12px;
      }
      .time {
        font-size: 26px;
        color: #999999;
        span {
          padding: 0 6px;
        }
      }
    }
  }
  .textarea {
    padding: 0 32px;
    box-sizing: border-box;
    font-size: 32px;
    background: #FFFFFF;
    padding-bottom: 40px;
    color: #333333;
  }
  .address {
    background: #FFFFFF;
    padding: 20px 32px;
    box-sizing: border-box;

    .addr-bg {
      display: inline-block;
      border-radius: 28px;
      padding: 6px 20px;
      background: #EFF1F3;

      img {
        padding-top: 5px;
        width: 32px;
        height: 32px;
      }

      span {
        vertical-align: top;
      }
    }
  }
  .comment {
    padding: 0 32px 30px 32px;
    box-sizing: border-box;
    background: #FFFFFF;

    .comment-list {
      padding: 20px 30px;
      background: #F7F8F9;
      border-radius: 16px;
      .title {
        color: #333333;
        font-weight: 600;
      }
      .item {
        font-size: 28px;
        padding: 10px 0;
        .avatar {
          color: #576a91;
        }
      }
    }
  }
  .readOnly {
    font-size: 32px;
    .item {
      display: flex;
      justify-content: space-between;
      background: #FFFFFF;
      border-bottom: 1px solid #D8DDE6;
      padding: 30px 30px;
      box-sizing: border-box;

      .textarea {
        width: 100%;
        padding: 30px 0 0 0 ;
        color: #333333;
        margin-bottom: 20px;
      }
    }
    .nopass {
      flex-direction: column;
      border-bottom: 1px solid #D8DDE6;
    }
    .last {
      border-bottom: none;
    }
  }
  .upLoadPic {
    width: 204px;
    height:204px;
    margin-right: 8px;
  }
  .upLoadPic:nth-child(3n) {
    margin-right: 0;
  }
  .btn {
    display: flex;
    position: fixed;
    bottom: 0;
    width: 100%;
    height: 112px;
    line-height: 112px;
    .reject {
      width: 50%;
      color: #FF4466;
      background: #FFFFFF;
      text-align: center;
    }
    .agree {
      width: 50%;
      color: #FFFFFF;
      background: #3975C6;
      text-align: center;
    }
  }
}
</style>
