<template>
  <common-header />
  <div class="content">
    <div class="title">
      <div>
        {{ detailData.zz_name }} <span>智慧教研-在线学习-</span><span>{{ detailData.zz_name }}</span>
      </div>
    </div>
    <div class="header">
      <div>
        <!-- <img
          src="@/assets/img/zhjy/share.png"
          style="margin: 0 5px 0 20px"
          alt=""
        /><span>分享 </span> -->
        {{ detailData.zz_name }}
        <el-popover placement="bottom" :width="410" trigger="hover">
          <template #reference>
            <div class="share">
              <i-fluent:share-28-regular class="mr-1.5," style="color: #00a3ff; position: absolute; bottom: 0; left: -25" />分享
            </div>
          </template>

          <div class="w-full">
            <div class="w-full text-center">呼唤小伙伴们前来围观吧</div>
            <div class="flex justify-around m-10" style="position:relative">
              <div class="weibo" @click="shareToSina(shareLink)">
                <img src="@/assets/img/wb.png" />
              </div>
              <div class="qq" @click="shareToQq(shareLink)">
                <img src="@/assets/img/QQ.png" />
              </div>
              <div class="qqkj" @click="shareToQqzone(shareLink)">
                <img src="@/assets/img/QQ1.png" />
              </div>
              <qrcode-vue :value="shareLink" :size="size" level="H" />
              <div style="position:absolute;bottom:-20px;right:17px">微信扫码分享</div>
            </div>
            <el-divider></el-divider>
            <div class="text-hex-00a3ff mb-2">地址</div>
            <div class="flex">
              <div class="bg-hex-F7F7F7 p-2 flex-auto mr-4 truncate">
                {{ shareLink }}
              </div>
              <div class="
                  text-sm
                  bg-hex-0A8AFF
                  text-white
                  flex_left
                  w-100px
                  h-40px
                  rounded
                  cursor-pointer
                  copy
                " @click="copyLink">
                复制链接
              </div>
            </div>
          </div>
        </el-popover>
      </div>
    </div>

    <div class="main">
      <div class="display:flex;flex-direction:column;">
        <div class="Info">
          <div style="display: flex; justify-content: space-between">
            <div class="left">
              <img class="avatar" src="@/assets/img/zhjy/main_3.png" alt="" />

              <div class="left-top">
                <span>{{ detailData.zx_jsxx }}</span><img src="@/assets/img/zhjy/hot.png" alt="" /><span>{{
                  detailData.zx_lll
                }}</span>
              </div>
              <div class="left-bottom">
                <span>金牌讲师</span> <span>YYDS</span>
              </div>
            </div>
            <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">{{ fingerNum }}</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">{{ loveNum }}</span>
              </div>
            </div>
            <div class="right">

              <el-button type="primary" :plain="isFocus" @click="handleFocus">{{
                !isFocus ? "关注" : "已关注"
              }}</el-button>
            </div>
          </div>
        </div>

        <div class="spbf video" id="player-con">
          <video class="" src=""></video>
          <!-- <div class="spbf-left">助教:沈老师</div> -->
          <div class="spbf-right">当前观看人数：6785人</div>
        </div>
      </div>

      <div class="display:flex;flex-direction:column;">
        <!--   <div class="part">
          <ul>
            <li>相关章节</li>
            <li>02课时 行程问题</li>
            <li>03课时 过桥问题</li>
            <li>04课时 流水问题</li>
            <li>05课时 过桥问题</li>
            <li>06课时 行程问题</li>
            <li>07课时 流水问题</li>
          </ul>
        </div> -->

        <div class="rate-info">
          <el-tabs v-model="activeName" style="padding: 0 20px">
            <el-tab-pane label="评价" name="first">
              <div class="pingjia">
                <el-rate v-model="pjInfo.ke_star"></el-rate>
                <div class="rateBtn" @click="formSubmit(detailData.zz_id)">
                  评价
                </div>
                <div class="rate">
                  <div class="rate-list" v-for="(e, i) in evaluateListData" :key="i" v-show="detailData.zz_id == e.kk_id">
                    <p class="rate-list-title">
                      <span class="rate-list-name">{{
                        e.ke_user_realname
                      }}</span>
                      <span class="rate-list-time">{{
                        e.create_dateline
                      }}</span>
                    </p>
                    <div class="rate-list-star">
                      <img class="rate-list-img" src="@/assets/img/zhjyzxxx/star.png" alt="" v-for="(item, index) in Number(e.ke_star)" :key="index" />
                    </div>
                  </div>
                </div>
              </div>
            </el-tab-pane>
            <!-- <el-tab-pane label="作业" name="second">
              <ul>
                <li>2021年上学期数学期中测试卷（一）<button>下达</button></li>
              </ul>
            </el-tab-pane>
            <el-tab-pane label="资源" name="third">
              <div class="rate">
                <div class="rate-list">
                  <p class="rate-list-title">
                    <span class="">张三</span>
                    <span class="">2022</span>
                  </p>
                  <div class="">
                    <img class="" src="@/assets/kczy/word.png" alt="" />数学体系
                  </div>
                </div>
              </div>
            </el-tab-pane> -->
          </el-tabs>
        </div>
      </div>
    </div>
    <!-- <div class="footer">
      <div style="width: 1400px; height: 50px; position: relative; margin: 0 auto">
        <el-pagination background layout="total,prev, pager, next" :total="total" style="position: absolute; top: 0; right: 200px" @current-change="handleCurrentChange" :page-size="limit">
        </el-pagination>
      </div>
    </div> -->
  </div>
</template>

<script>
import {
  zxxx_detail,
  zxxx_evaluate_add,
  zxxx_evaluate_list,
  user_avatar,
  zxxx_like_add,
  zxxx_like_del,
  zxxx_fav_add,
  zxxx_fav_del,
  zxxx_attention_add,
  zxxx_attention_del
} from "./api";
import QrcodeVue from "qrcode.vue";
import { ElMessage } from "element-plus";
import CommonHeader from "@/components/CommonHeader/index.vue";
export default {
  name: "index",
  components: {
    CommonHeader,
    QrcodeVue,
  },
  data() {
    return {
      isFocus: true,
      detailData: {},
      evaluateInfo: {},
      evaluateListData: [],
      pjInfo: {
        ke_star: "",
        ke_user_realname: "",
        kk_id: "",
        kf_id: "",
      },
      limit: 10,
      total: 0,
      cur_page: 1,
      ke_id: "",
      activeName: "first",
      https: window.GLOBAL_CONFIG.api,
      shareLink: window.location.href,
      zz_id: "",
      fingerNum: 0, //点赞数
      fingerSwitch: 0, //0：关 1：开
      loveNum: 0, //收藏
      loveSwitch: 0, //0：关 1：开
    };
  },
  methods: {
    handleFocus() {
      this.isFocus = !this.isFocus;

      // /**增加关注或取消*/

      // if (this.attentionSwitch == 1) {//关注
      //   let transObj = {
      //     create_user_id: this.create_user_id,
      //   };
      //   zxxx_attention_del(transObj)
      //     .then(res => {
      //       console.log(res);
      //     })
      //     .catch(error => {
      //       console.log(error)
      //     });
      // } else {
      //   let transObj = {
      //     create_user_id: this.create_user_id,
      //   };
      //   zxxx_attention_add(transObj)
      //     .then((res) => {
      //       if (res.code == "1") {
      //         ElMessage({
      //           message: res.msg,
      //           type: "success",
      //         });
      //         this.getListData();
      //       } else {
      //         ElMessage({
      //           message: res.msg,
      //           type: "waring",
      //         });
      //       }
      //     })
      //     .catch((error) => {
      //       console.log(error);
      //     });
      // }
      // this.getDetailData();

    },
    // shareLink = window.location.href;
    async copyLink() {
      await navigator.clipboard.writeText(window.location.href);
      ElMessage.success("已复制");
    },
    //分享
    shareToQq(url) {
      // 分享到腾讯QQ
      var shareqqstring =
        "https://connect.qq.com/widget/shareqq/index.html?url=" +
        encodeURIComponent(url);
      window.open(shareqqstring);
    },
    shareToQqzone(url) {
      // 分享到QQ空间
      var shareqqzonestring =
        "http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=" +
        encodeURIComponent(url);
      window.open(shareqqzonestring);
    },
    shareToSina(url) {
      // 分享到新浪微博
      var sharesinastring =
        "http://v.t.sina.com.cn/share/share.php?url=" +
        encodeURIComponent(url) +
        "&searchPic=true#_loginLayer_1639641926022";
      window.open(sharesinastring);
    },

    //详情数据
    getDetailData() {
      let data = {
        zz_id: this.zz_id,
      };
      zxxx_detail(data)
        .then((res) => {
          this.detailData = res.data.one_info;
          this.fingerNum = res.data.one_info.zz_like_num; //点赞数
          this.fingerSwitch = res.data.one_info.is_like; //0：关 1：开
          this.loveNum = res.data.one_info.zz_fav_num; //收藏
          this.loveSwitch = res.data.one_info.is_fav; //0：关 1：开
          var player = new Aliplayer(
            {
              id: "player-con",
              source: window.GLOBAL_CONFIG.api + this.detailData.zz_video,
              width: "100%",
              height: "570px",
              autoplay: true,
              isLive: this.detailData.status == 1 ? true : false,
              rePlay: false,
              playsinline: true,
              preload: true,
              controlBarVisibility: "hover",
              useH5Prism: true,
            },
            function (player) {
              console.log("The player is created");
            }
          );
        })
        .catch((err) => {
          console.log(err);
          alert("请刷新");
        });
    },

    //评价
    evaluateData() {
      this.pjInfo = {
        ke_star: "",
        ke_user_realname: "",
        kk_id: "",
        kf_id: "",
      };
    },
    formSubmit(id) {
      let data = {
        ke_star: this.pjInfo.ke_star,
        ke_user_realname: this.pjInfo.ke_user_realname,
        kk_id: id,
        kf_id: this.pjInfo.kf_id,
      };
      zxxx_evaluate_add(data).then((res) => {
        this.evaluateInfo = res.data.one_info;
        if (res.code == 1) {
          this.getEvaluateListData();
          this.getDetailData();
        }
      });
    },
    //评价列表
    getEvaluateListData(id) {
      let data = { kk_id: id };
      zxxx_evaluate_list(data).then((res) => {
        this.evaluateListData = res.data.page_data;
        this.cur_page = Number(res.data.page_now);
        this.total = Number(res.data.total_rows);
      });
    },
    handleCurrentChange(val) {
      this.cur_page = val;
      this.getEvaluateListData();
    },
    //头像数据
    AvatarData() {
      let data = {};
      user_avatar(data).then((res) => {
        if (res.code == 1) {
          this.avatarList = res.data;
        }
      });
    },
    /**增加赞或取消*/
    finger() {
      if (this.fingerSwitch == "1") {//去掉赞
        let transObj = {
          zz_id: this.zz_id,
        };
        zxxx_like_del(transObj)
          .then(res => {
            if (res.code == "1") {
              ElMessage({
                message: res.msg,
                type: "success",
              });
              this.getDetailData();
            } else {
              ElMessage({
                message: res.msg,
                type: "waring",
              });
            }

          })
          .catch(error => { console.log(error) })
      } else {
        let transObj = {
          zz_id: this.zz_id,
        };
        zxxx_like_add(transObj)
          .then((res) => {
            if (res.code == "1") {
              ElMessage({
                message: res.msg,
                type: "success",
              });
              this.getDetailData();
            } else {
              ElMessage({
                message: res.msg,
                type: "waring",
              });
            }
          })
          .catch((error) => {
            console.log(error);
          });
      }
      this.getDetailData();
    },
    /**增加收藏或取消*/
    loveIcon() {
      if (this.loveSwitch == 1) {//去掉收藏
        let transObj = {
          zz_id: this.zz_id,
        };
        zxxx_fav_del(transObj)
          .then(res => {
            if (res.code == "1") {
              ElMessage({
                message: res.msg,
                type: "success",
              });
              this.getDetailData();
            } else {
              ElMessage({
                message: res.msg,
                type: "waring",
              });
            }

            this.getDetailData();
          })
          .catch(error => {
            console.log(error)
          });
      } else {
        let transObj = {
          zz_id: this.zz_id,

        };
        zxxx_fav_add(transObj)
          .then((res) => {
            if (res.code == "1") {
              ElMessage({
                message: res.msg,
                type: "success",
              });
              this.getDetailData();
            } else {
              ElMessage({
                message: res.msg,
                type: "waring",
              });
            }
          })
          .catch((error) => {
            console.log(error);
          });
      }
      this.getDetailData();
    },
  },
  mounted() {
    if (this.$route.params.id != "") {
      this.zz_id = this.$route.params.id;
      this.getDetailData();
      this.getEvaluateListData();
    }
  },
};
</script>

<style lang="scss" scoped>
.nicBaseInfo_action {
  //border: 1px solid red;
  width: 50%;
  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: 12%;
    top: 50%;
    transform: translate(0, -50%);
  }

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

  .posi4 {
    margin: 0 2px;
    left: 70%;
    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;
  }
}
.copy {
  text-align: center;
  line-height: 40px;
}
.content {
  width: 100%;
  min-width: 1400px;
  margin: 0 auto;
  background-image: url("@/assets/img/zhjy/xq_bg.png");
  background-repeat: no-repeat;
}
.title {
  width: 100%;
  height: 60px;
  line-height: 60px;
  font-size: 18px;
  font-family: PingFangSC, PingFangSC-Regular;
  font-weight: 400;
  color: #050026;
  background: #ffffff;
  margin-bottom: 20px;
  box-shadow: 0px 1px 10px 0px rgba(17, 46, 74, 0.1);
  div {
    width: 1400px;
    margin: 0 auto;
    span:first-of-type {
      width: 56px;
      height: 20px;
      font-size: 14px;
      font-family: PingFangSC, PingFangSC-Regular;
      font-weight: 400;
      text-align: left;
      color: #949494;
      line-height: 20px;
      margin-left: 30px;
    }
    span:last-of-type {
      width: 56px;
      height: 20px;
      font-size: 14px;
      font-family: PingFangSC, PingFangSC-Regular;
      font-weight: 400;
      text-align: left;
      color: #000000;
      line-height: 20px;
    }
  }
}
.header {
  width: 100%;
  background: transparent;
  div {
    width: 1400px;
    height: 40px;
    margin: 0 auto;
    font-size: 20px;
    font-family: PingFang, PingFang-Heavy;
    font-weight: 800;
    text-align: left;
    color: #000000;
    position: relative;
    //   img {
    //     display: inline-block;
    //   }
    //   span {
    //     width: 32px;
    //     height: 22px;
    //     font-size: 16px;
    //     font-family: PingFangSC, PingFangSC-Regular;
    //     font-weight: 400;
    //     text-align: left;
    //     color: #00a3ff;
    //     line-height: 22px;
    //     margin-left: 5px;
    //   }
    .share {
      display: inline;
      cursor: pointer;
      color: #00a3ff;
      font-weight: 400;
      margin-left: 40px;
    }
  }
}
.main {
  width: 1400px;
  margin: 0 auto;

  display: flex;
}
.Info {
  width: 850px;
  height: 100px;
  background: #ffffff;
  border-radius: 12px;
  padding: 11px 23px;
  box-shadow: 2px 10px 24px 0px rgba(161, 153, 168, 0.18);
  .left {
    width: 900px;
    height: 90px;
    position: relative;
    .avatar {
      width: 75px;
      height: 77px;
      border-radius: 50%;
      display: inline-block;
    }
    .left-top {
      display: inline-block;
      width: 150px;
      height: 22px;
      vertical-align: top;
      margin-left: 10px;
      margin-top: 10px;
      img {
        display: inline-block;
      }
      span:first-of-type {
        display: inline-block;
        width: 48px;
        height: 22px;
        font-size: 16px;
        font-family: PingFang, PingFang-Heavy;
        font-weight: 800;
        text-align: left;
        color: #000000;
        line-height: 22px;
        margin-right: 10px;
      }
      span:last-of-type {
        display: inline-block;
        width: 40px;
        height: 20px;
        font-size: 14px;
        font-family: PingFangSC, PingFangSC-Regular;
        font-weight: 400;
        text-align: left;
        color: #949494;
        line-height: 20px;
      }
    }
    .left-bottom {
      width: 150px;
      height: 22px;
      margin-left: 10px;
      position: absolute;
      bottom: 20px;
      left: 70px;
      span:first-of-type {
        display: inline-block;
        width: 63px;
        height: 23px;
        line-height: 23px;
        background: #190006;
        border: 1px solid #f1c342;
        border-radius: 12px;
        font-size: 12px;
        font-family: PingFangSC, PingFangSC-Regular;
        font-weight: 400;
        text-align: center;
        color: #ffffff;
      }
      span:last-of-type {
        display: inline-block;
        width: 63px;
        height: 24px;
        background: linear-gradient(90deg, #00a3ff 1%, #57c38f);
        border-radius: 12px;
        font-size: 14px;
        font-family: PingFangSC, PingFangSC-Regular;
        font-weight: 400;
        text-align: center;
        color: #ffffff;
        line-height: 24px;
        letter-spacing: 0.6px;
      }
    }
  }
  .right {
    height: 100px;
    line-height: 100px;
    .el-button {
      width: 100px;
      height: 40px;
      text-align: center;

      &.el-button--primary.is-plain {
        background: transparent;
        color: #409eff;
      }
    }
  }
}

.part {
  //   width: calc(30% - 20px);
  width: 400px;
  height: 459px;
  margin-left: 20px;

  margin-bottom: 30px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 2px 10px 24px 0px rgba(161, 153, 168, 0.18);
  ul {
    padding: 20px;
    li {
      width: 100%;
      height: 50px;
      line-height: 50px;
      padding-left: 20px;
      font-size: 14px;
      font-family: PingFangSC, PingFangSC-Semibold;
      font-weight: 600;
      text-align: left;
      color: #050026;
      margin: 10px 0px;
      background: rgba(#00a3ff, 0.05);
      border-radius: 16px 16px 0px 0px;
      &:nth-of-type(1) {
        width: 100%;
        display: flex;
        font-size: 16px;
        justify-content: space-between;
        margin: 0 20px;
        background-color: transparent;
      }
    }
  }
}

.spbf {
  //   width: 70%;
  width: 850px;

  //background: #cee5fb;
  background: #050026;
  border-radius: 15px;
  // border-radius: 10px;
  margin-top: 15px;
  position: relative;
  // .spbf-left {
  //   position: absolute;
  //   top: 0;
  //   left: 0;
  //   width: 176px;
  //   height: 48px;
  //   opacity: 0.5;
  //   background: #ffffff;
  //   border-radius: 0px 10px 0px 10px;
  //   font-size: 16px;
  //   font-family: PingFangSC, PingFangSC-Regular;
  //   font-weight: 400;
  //   text-align: center;
  //   color: #00a3ff;
  //   line-height: 48px;
  // }
  .spbf-right {
    width: 190px;
    height: 45px;
    color: #fff;
    line-height: 45px;
    background: rgba(#050026, 0.3);
    border-radius: 0px 10px 0px 10px;
    position: absolute;
    top: 0;
    right: 0;
    padding-left: 8px;
  }
}
.pingjia {
  width: 400px;

  // margin-left: 20px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 2px 10px 24px 0px rgba(161, 153, 168, 0.18);

  .rateBtn {
    width: 111px;
    height: 32px;
    background: linear-gradient(90deg, #00a3ff 1%, #57c38f);
    border-radius: 38px;
    font-family: PingFangSC, PingFangSC-Regular;
    font-weight: 400;
    text-align: center;
    color: #ffffff;
    line-height: 32px;
    letter-spacing: 0.6px;
    margin-top: 15px;
    cursor: pointer;
  }
  .rate {
    height: 500px;
    // border: 1px solid red;
    overflow-y: scroll;
    .rate-list {
      width: 100%;
      height: 80px;
      padding: 15px;
      border-bottom: 1px dashed rgba(#6e58c5, 0.5);
      .rate-list-title {
        .rate-list-name {
          display: inline-block;

          font-size: 14px;
          font-family: PingFangSC, PingFangSC-Semibold;
          font-weight: 600;
          text-align: left;
          color: #171721;
          line-height: 18px;
          margin-right: 8px;
        }
        .rate-list-time {
          display: inline-block;

          font-size: 12px;
          font-family: PingFangSC, PingFangSC-Regular;
          font-weight: 400;
          text-align: left;
          color: #8083a3;
          line-height: 18px;
        }
      }
      .rate-list-star {
        .rate-list-img {
          display: inline-block;
          width: 21px;
          height: 20px;
          margin-left: 14px;
        }
      }
    }
  }
  ::-webkit-scrollbar {
    width: 0;
    height: 0;
    color: transparent;
  }
  .footer {
    width: 100%;
    height: 50px;
    margin-top: 100px;

    display: inline-block;
  }
}

.el-rate {
  --el-rate-icon-size: 22px;
  margin-top: 15px;
}
</style>
