<template>
  <div class="box">
    <div class="content">
      <div class="title">
        <img src="../../assets/56.jpg" alt="" />
        <p>厄斐琉斯</p>
      </div>
      <div class="item">
        <div class="item_title">{{ this.list.cultureTitle }}</div>
        <div class="item_content" v-html="this.list.cultureContent"></div>
        <div class="imgs">
          <img  :src="this.list.cultureImage" />
        </div>
      </div>
    </div>

    <div class="search">
      <input type="text" placeholder="说点什么吧！！！~~~~" v-model="commentContent" />
      <div class="btns">
        <p @click="answer">发送评论</p>
      </div>
    </div>

    <div class="answerList">
      <div class="item_answer" v-for="(item, index) in answerList" :key="index">
        <div class="title">
          <img src="../../assets/56.jpg" alt="" />
          <div>
            <p>{{ item.name }}</p>
            <p style="margin-top: 10px">{{ item.likeNum }}</p>
          </div>
        </div>
        <div class="item">
          <div class="item_content">{{ item.commentContent }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { apiServe } from '@/api/api';
export default {
  name: "WenhuaWebuiZhiShiDesc",

  data() {
    return {
      id:null,
      uid:null,
      list:[],
      answerList:[],
    };
  },

  created() {
    // 从路由的 query 中获取参数
    this.id = this.$route.query.id;
    this.uid = localStorage.getItem('userid')
  },
  mounted() {
    this.searchUser()
    this.pinglist()
  },

  methods: {
    searchUser() {
      
      apiServe.Clwh(this.id).then((res) => {
        console.log(res);
        this.list = res.data.data
      });
    },
    pinglist() {
      apiServe.pinglun(this.id).then((res) => {
        console.log(res);
        this.answerList = res.data.data
      });
    },
    answer() {
      let cdata = {
        commentContent:this.commentContent,
        id:this.uid,
        cid: this.id

      }
      apiServe.addpinglun(cdata).then((res) => {
        console.log(res);
          this.$message({
          message: "评论成功！",
          type: "success",
        });
        setTimeout(() => {
                     
                      location.reload();
                    }, 1000);
      });
      

    },
  },
};
</script>

<style scoped lang="less">
.box::v-deep {
  width: 100%;
  //   height: 100vh;
  //   background-color: #ccc;
  padding: 60px 60px 30px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  .content {
    width: 1200px;
    border: 1px solid #ccc;
    background-color: #fff;
    padding: 30px;
    box-sizing: border-box;
    border-radius: 5px;
    // margin-left: 30px;

    .title {
      display: flex;
      // justify-content: ;
      align-items: center;

      img {
        width: 60px;
        height: 60px;
        border-radius: 50%;
      }

      p {
        margin-left: 10px;
      }
    }

    .item {
      width: 100%;

      .item_title {
        font-weight: bold;
        font-size: 24px;
        margin-top: 20px;
        margin-bottom: 10px;
      }

      .item_content {
        margin-bottom: 10px;
      }
    }

    .imgs {
      display: flex;
      // justify-content: space-around;
      align-items: center;

      img {
        width: 150px;
        height: 120px;
        border-radius: 5px;
        margin-right: 15px;
      }
    }

    .role {
      text-align: right;
      display: flex;
      justify-content: space-between;
      align-items: center;

      .total {
        display: flex;
        align-items: center;

        .role_item {
          display: flex;
          align-items: center;
          margin-right: 15px;

          img {
            width: 30px;
            height: 30px;
            margin-right: 5px;
          }
        }
      }
    }
  }

  .search {
    width: 1200px;
    display: flex;
    align-items: center;
    margin-top: 40px;
    // margin-left: 30px;

    input {
      width: 500px;
      height: 30px;
      background-color: #ffffff;
      border-radius: 5px;
      border: 1px solid #ccc !important;
      padding-left: 15px;
      box-sizing: border-box;
    }

    .btns {
      // width: 100px;
      // background-color: rgba(0, 0, 0, alpha);
      //   padding: 15px 30px;
      box-sizing: border-box;
      margin-left: 10px;
      //   position: absolute;
      //   right: 0;

      p {
        width: 100px;
        height: 30px;
        text-align: center;
        line-height: 30px;
        background-color: rgba(22, 155, 213, 1);
        font-size: 10px;
        border-radius: 7px;
        color: #ffffff;
      }
    }
  }

  .answerList {
    width: 1200px;
    border: 1px solid #ccc;
    background-color: #fff;
    padding: 20px 30px;
    box-sizing: border-box;
    border-radius: 5px;
    margin-top: 20px;
    // margin-left: 50px;

    .item_answer {
        margin-bottom: 10px;
        border-bottom: 1px solid #EBEBEB;
        padding: 10px 0;
    }

    .title {
      display: flex;
      // justify-content: ;
      align-items: center;

      img {
        width: 60px;
        height: 60px;
        border-radius: 50%;
      }

      p {
        margin-left: 10px;
      }
    }

    .item {
      width: 100%;

      .item_title {
        font-weight: bold;
        font-size: 24px;
        margin-top: 20px;
        margin-bottom: 10px;
      }

      .item_content {
        margin-bottom: 10px;
        margin-top: 15px;
        margin-left: 10px;
      }
    }

    .imgs {
      display: flex;
      // justify-content: space-around;
      align-items: center;

      img {
        width: 150px;
        height: 120px;
        border-radius: 5px;
        margin-right: 15px;
      }
    }

    .role {
      text-align: right;
      display: flex;
      justify-content: space-between;
      align-items: center;

      .total {
        display: flex;
        align-items: center;

        .role_item {
          display: flex;
          align-items: center;
          margin-right: 15px;

          img {
            width: 30px;
            height: 30px;
            margin-right: 5px;
          }
        }
      }
    }
  }
}
</style>