<template>
  <div v-loading="loading">
    <searchContainer
      bannerKey="首页>成果库>成果详情"
      title="成果库"
      @handleQuery="handleQuery"
    >
      <template v-slot>
        <div class="head">
          <el-breadcrumb separator="/">
            <el-breadcrumb-item>
              <span class="one">找成果</span>
            </el-breadcrumb-item>
            <el-breadcrumb-item>
              <span>成果详情</span>
            </el-breadcrumb-item>
          </el-breadcrumb>
        </div>
        <el-row type="flex" style="padding-bottom: 20px">
          <div style="flex: 1">
            <gainItem :data="state.expertDetail">
              <template v-slot:des>
                <div>{{ state.expertDetail.introduce }}</div>
              </template>
            </gainItem>
            <div class="btns">
              <div class="order">预约对接</div>
              <div class="share">一键分享</div>
            </div>

            <div class="detail">
              <div style="padding: 20px 0">
                <div class="pointTit">技术视频</div>
              </div>
              <div style="padding: 20px 0">
                <div class="pointTit">产品详情</div>
              </div>
              <div class="html" v-html="state.expertDetail.introduce"></div>
            </div>
          </div>
          <div class="r">
            <webContact />
          </div>
        </el-row>
      </template>
    </searchContainer>
  </div>
</template>

<script setup>
import webContact from "@/components/webContact/index.vue";
import gainItem from "./components/gainItem.vue";
import loadMore from "./components/loadMore.vue";
import request from "@/utils/request";
const router = useRouter();
const route = useRoute();
import { onMounted } from "vue";
import searchContainer from "./components/searchContainer.vue";
import wordcloud from "./components/wordcloud.vue";
import productItem from "./components/productItem.vue";
const loading = ref(true);
const state = reactive({
  pageNum: 1,
  pageSize: 4,
  keyword: "",
  val: 3,
  expertDetail: {},
  arr: [
    {
      name: "Cat",
      value: 26,
    },
    {
      name: "fish",
      value: 19,
    },
  ],
  activeName: "first",
});

// 建议 列表前4条
function recommend() {
  return request({
    url: "/v1/search",
    method: "post",
    data: {
      mode: 5,
      page_num: state.pageNum,
      page_size: state.pageSize,
      keyword: state.keyword,
    },
  });
}

// 成果详情
function achievementDetail(id) {
  return request({
    url: "/v1/technology/achievement/detail",
    method: "post",
    data: { id: id },
  });
}

function createdData(arr) {
  let l = [];
  let snap = JSON.parse(JSON.stringify(arr));
  snap.map((e) => {
    l.push({ name: e, value: 30 });
    return { name: e, value: 30 };
  });
  return l;
}

function handleDetail(id) {
  let routeData = router.resolve({
    path: `/searchList/0/detail/${id}`,
    query: { keyword: state.keyword },
  });
  window.open(routeData.href, "_blank");
}

function handleList(mode, keyword) {
  router.push({ path: `/searchList/${mode}`, query: { keyword } });
}

// 首次加载数据，其后跳转页面
let flag = true;

function handleQuery(keyword) {
  state.keyword = keyword;
  if (flag) {
    getDataList();
    flag = false;
  } else {
    handleList(0, keyword);
  }
}

function getDataList() {
  loading.value = true;
  let id = route.params.id;
  if (!id) return;
  achievementDetail(id)
    .then((res) => {
      if (200 == res.code) {
        console.log(res.data);
        state.expertDetail = res.data;
        loading.value = false;
      }
    })
    .catch(() => {
      loading.value = false;
    });
}
</script>

<style lang="scss" scoped>
:deep(.el-tabs) {
  .el-tabs__item {
    color: #666666;
    font-size: 14px;
  }
  .el-tabs__item:hover {
    opacity: 0.8;
  }

  .el-tabs__item.is-active {
    font-size: 16px;
    font-family: Source Han Sans CN;
    font-weight: bold;
    color: #333333;
  }
  .el-tabs__active-bar {
    background-color: #333333;
    height: 4px;
  }

  .el-tabs__nav-wrap::after {
    background-color: transparent;
  }
}
.head {
  padding: 15px 0px;
  span {
    font-size: 16px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #666666;
  }
  .one {
    color: #333333;
  }
}
.r {
  display: inline-block;
  width: 325px;
  margin-left: 14px;
  min-height: 200px;
}

.detail {
  width: 661px;
  box-sizing: border-box;
  padding: 20px;
  background: #fff;
  .describe {
    font-size: 14px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #666666;
    margin-bottom: 5px;
  }
}

.pointTit {
  position: relative;
  padding-left: 10px;
  font-size: 16px;
  font-family: Source Han Sans CN;
  font-weight: 500;
  color: #333333;
  &:before {
    content: "";
    top: 8px;
    left: 0px;
    position: absolute;
    display: block;
    width: 5px;
    height: 5px;
    background: #0054ff;
  }
}

.btns {
  overflow: hidden;
  padding: 0 20px 20px 20px;
  width: 100%;
  background-color: #fff;
  margin-top: -20px;
  div {
    margin-top: 20px;
    text-align: center;
    float: right;
    cursor: pointer;
    user-select: none;
    width: 101px;
    height: 36px;
    font-size: 14px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    line-height: 36px;
    box-sizing: border-box;
    &:hover {
      opacity: 0.7;
    }
  }
  .share {
    color: #333333;
    background: #f2f6ff;
    border: 1px solid #dcdcdc;
    margin-right: 10px;
  }
  .order {
    background: #0054ff;
    color: #ffffff;
    border: none;
  }
}

.achievementItem,
.loadMoreItem {
  padding: 20px;
  background-color: #fff;
  margin-bottom: 10px;
  .tit {
    margin-left: -8px;
    font-size: 16px;
    font-family: Source Han Sans CN;
    font-weight: bold;
    color: #333333;
  }
  .line {
    margin: 10px 0;
    font-size: 14px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #666666;
  }
}

.patentItem {
  padding: 20px;
  background-color: #fff;
  margin-bottom: 10px;
  .tit {
    font-size: 16px;
    font-family: Source Han Sans CN;
    font-weight: bold;
    color: #333333;
  }
  .line {
    padding-left: 8px;
    margin: 10px 0;
    font-size: 14px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #666666;
  }
}
</style>