<template>
  <common-header />
  <div class="ysgc_detail">
    <div class="top">
      <div class="top_nav">
        <div class="title">详情</div>
        <div class="sub_title">
          艺术广场 - 学生优秀作业 - <span class="t_detail">详情</span>
        </div>
      </div>
    </div>
    <div class="content">
      <div class="title">
        <h3 class="con_title">美术 +</h3>
        <div class="nicBaseInfo_action">
          <div class="coverC" @click="finger">
            <img class="posiA posi1" v-if="fingerSwitch == '0'" src="@/assets/kczy/zanIcon.png" />
            <img class="posiA posi1" v-else src="@/assets/kczy/zanIcon_full.png" />
            <span class="posiA posi2">{{ detailData.yz_like_num }}1111</span>
          </div>
          <div class="coverC" @click="loveIcon">
            <img class="posiA posi3" v-if="loveSwitch == '0'" src="@/assets/kczy/collectIcon.png" />
            <img class="posiA posi3" v-else src="@/assets/kczy/collectIcon_full.png" />
            <span class="posiA posi4">{{ detailData.yz_fav_num }}11111</span>
          </div>
        </div>
      </div>

      <div class="art" :style=" {'background':'url('+ https+ detailData.yz_img+')','background-repeat':'no-repeat','background-size':'100%'}">
        <div class="author">
          <img src="@/assets/img/zhjy/main_3.png" alt="" class="avt" />
          <span class="name">{{detailData.yz_author_name}}</span>
        </div>
        <div class="evaluate">
          <div class="pj-list">
            <ul class="eva" v-for="(e, i) in evaluateListData" :key="i" v-show="detailData.yz_id === e.yz_id">
              <li class="each_eva">
                <div class="eva_person">
                  <span class="eva_name"> {{ e.yze_user_realname }} </span>
                  <span class="eva_time"> {{ e.create_time }} </span>
                </div>
                <div class="rate-list-star">
                  <img class="rate-list-img" src="@/assets/img/zhjyzxxx/star.png" alt="" v-for="(item, index) in Number(e.yze_star)" :key="index" />
                </div>
              </li>
            </ul>
          </div>
          <div class="addComment">
            <el-rate v-model="pjInfo.yze_star"></el-rate>
            <!-- <input type="text" v-model="pjInfo.yze_star" /> -->
            <button class="add" @click="formSubmit(detailData.yz_id)">评价</button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { ysgc_detail, ysgc_evaluate, ysgc_addEvaluate } from './api';
import CommonHeader from "@/components/CommonHeader/index.vue";
export default {
  components: {
    CommonHeader,

  },

  data() {
    return {
      yz_id: "",
      evaluateInfo: {},
      detailData: {},
      evaluateListData: [],
      pjInfo: {

        yze_user_realname: "",
        yz_id: "",
        yze_type: "1",
        yze_id: "",
        yze_star: ""
      },
      https: window.GLOBAL_CONFIG.api,
    }
  },
  methods: {
    //学生作品详情列表
    getDetailData() {
      let data = {
        yz_id: this.yz_id,
      };
      ysgc_detail(data).then((res) => {
        this.detailData = res.data.one_info;
        console.log(this.detailData, 111);
      });
    },
    //评价
    evaluateData() {
      this.pjInfo = {
        yze_star: "",
        yze_user_realname: "",
        yz_id: "",
        yze_type: "1",
        yze_id: "",
      };
    },
    formSubmit(id) {
      let data = {
        yze_user_realname: this.pjInfo.yze_user_realname,
        yze_star: this.pjInfo.yze_star,
        yz_id: id,
        yze_id: this.pjInfo.yze_id,
      };
      ysgc_addEvaluate(data).then((res) => {
        this.evaluateInfo = res.data.one_info;
        if (res.code == 1) {
          this.getDetailData();
          this.getEvaluateListData();
          this.pjInfo.yze_star = ""
          this.$forceUpdate();//强制刷新
        }
      });
    },
    //评价列表
    getEvaluateListData(id) {
      let data = { yz_id: id };
      ysgc_evaluate(data).then((res) => {
        this.evaluateListData = res.data.page_data;
        console.log(this.evaluateListData, 2222);
      });
    },
  },

  mounted() {
    if (this.$route.params.id != "") {
      this.yz_id = this.$route.params.id;
      this.getDetailData();
      this.getEvaluateListData();
    }
  }
}
</script>

<style lang="scss" scoped>
.rate-list-star {
  width: 200px;
  height: 25px;
  .rate-list-img {
    display: inline-block;
    width: 21px;
    height: 20px;
    margin-left: 14px;
  }
}
.ysgc_detail {
  width: 100%;
  margin: 0 auto;
  background-color: #fcfeff;
  background-image: url("../../../assets/ysgc/back.png");
  background-size: 100%;
  background-repeat: no-repeat;
  .top {
    width: 100%;
    height: 60px;
    line-height: 60px;
    background: #ffffff;
    box-shadow: 0px 1px 10px 0px rgba(17, 46, 74, 0.1);
    .top_nav {
      width: 1650px;
      min-width: 1280px;
      margin: 0 auto;
      display: flex;
      padding: 0 10px;
      box-sizing: border-box;
      .title {
        font-size: 18px;
        font-family: PingFangSC, PingFangSC-Regular;
        font-weight: 400;
        color: #050026;
        margin-right: 45px;
      }
      .sub_title {
        font-size: 14px;
        color: #949494;
        .t_detail {
          color: #000;
        }
      }
    }
  }
  .content {
    width: 1650px;
    min-width: 1280px;
    margin: 0 auto;
    .con_title {
      height: 40px;
      line-height: 40px;
      font-size: 18px;
      font-family: PingFangSC, PingFangSC-Medium;
      font-weight: 500;
      color: #050026;
      margin: 10px 0;
      display: inline-block;
    }
    .art {
      width: 100%;
      height: 838px;
      margin-bottom: 10px;

      background-size: 100%;
      position: relative;
      .author {
        position: absolute;
        top: 30px;
        right: 30px;
        display: flex;
        .avt {
          width: 59px;
          height: 59px;
          border-radius: 50%;
        }
        .name {
          height: 59px;
          line-height: 59px;
          font-size: 16px;
          color: #fff;
          font-weight: 500;
          margin-left: 10px;
        }
      }
      .evaluate {
        width: 400px;
        height: 400px;
        position: absolute;
        bottom: 24px;
        left: 7.5px;
        color: #fff;
        .pj-list {
          height: 300px;

          overflow-y: scroll;
        }
        ::-webkit-scrollbar {
          width: 0;
          height: 0;
          color: transparent;
        }
        .eva {
          width: 100%;
          .each_eva {
            width: 394px;
            height: 84px;
            opacity: 0.6;
            background: #050026;
            border-radius: 10px;
            color: #fff;
            padding: 20px;
            box-sizing: border-box;
            margin-bottom: 10px;
            .eva_person {
              .eva_name {
                font-size: 14px;
                font-weight: 600;
                margin-right: 8px;
              }
              .eva_time {
                font-size: 12px;
              }
            }
            .eva_nav {
              font-size: 14px;
              margin: 10px 5px;
            }
          }
        }
        .addComment {
          //  width: 100%;
          margin: 20px 0;
          width: 398px;
          height: 71px;
          line-height: 71px;
          opacity: 0.91;
          background: #ffffff;
          border-radius: 0px 10px 0px 10px;
          padding: 0px 20px;
          .add {
            width: 111px;
            height: 32px;
            line-height: 32px;
            margin-left: 50px;
            background: linear-gradient(
              90deg,
              rgba(0, 163, 255, 0.7) 20%,
              #57c38f
            );
            border-radius: 38px;
          }
        }
      }
    }
  }
}
.el-rate {
  --el-rate-icon-size: 26px;
  margin-top: 15px;
}
.title {
  display: flex;
  justify-content: space-between;

  .nicBaseInfo_action {
    //border: 1px solid red;
    display: inline-block;
    width: 250px;
    height: 30px;
    margin-top: 25px;
    font-size: 16px;
    font-weight: 400;
    text-align: left;
    color: #00a3ff;
    position: relative;
    .coverC {
      cursor: pointer;
    }
    .posiA {
      position: absolute;
      z-index: 12;
    }
    .posi1 {
      left: 0px;
      top: 50%;
      transform: translate(0, -50%);
    }

    .posi2 {
      margin: 0 2px;
      left: 10%;
      top: 50%;
      transform: translate(0, -50%);
    }

    .posi3 {
      left: 50%;
      top: 50%;
      transform: translate(0, -50%);
    }

    .posi4 {
      margin: 0 2px;
      left: 60%;
      top: 50%;
      transform: translate(0, -50%);
      // border: 1px solid red;
    }

    .zan {
      background: url("../assets/kczy/zanIcon.png") no-repeat left center;
      background-size: 21px 20px;
      box-sizing: border-box;
      padding: 3px 0 3px 25px;
      cursor: pointer;
    }

    .collect {
      background: url("../assets/kczy/collectIcon.png") no-repeat left center;
      background-size: 21px 20px;
      box-sizing: border-box;
      padding: 3px 0 3px 25px;
      margin-left: 30px;
      cursor: pointer;
    }
  }
}
</style>
