<template>
  <div id="index">
    <el-col :span="24" class="main">
      <el-col :span="24" class="marketTop">
        <!-- <el-col :span="12" class="left">
          <el-col :span="1" class="leftTitle">
            <p>科<br />技<br />产<br />品</p>
            <p></p>
          </el-col>
          <el-col :span="23" class="infoLeft">
            <el-col :span="12" class="productList" v-for="(item, index) in productList" :key="index" @click.native="productDetail(item.id)">
              <el-image :src="item.image[0].url"></el-image>
              <p class="textOver">{{ item.name }}</p>
            </el-col>
          </el-col>
          <el-col :span="24" class="leftListDown"><span></span><span @click="toProductList">MORE</span></el-col>
        </el-col> -->
        <!-- <el-col :span="12" class="right">
          <el-col :span="24" class="rightListTop"><span @click="toTecList">MORE</span><span></span></el-col>
          <el-col :span="23" class="infoRight">
            <el-col :span="24" class="tecList" v-for="(item, index) in tecList" :key="index">
              <span></span>
              <span class="textOver" @click="tecDetail(item.id)">{{ item.name }}</span>
              <span>对接</span>
              <span>{{ item.meta | getDate }}</span>
            </el-col>
          </el-col>
          <el-col :span="1" class="rightTitle">
            <p></p>
            <p>技<br />术<br />供<br />求</p>
          </el-col>
        </el-col> -->
        <el-col :span="12" class="left">
          <el-col :span="24" class="downLeftTop">
            <el-image :src="downLeftTopImage"></el-image>
            <span class="topText">
              <span>产品供求</span>
              <span
                ><p>P</p>
                <p>roduct</p></span
              >
              <span @click="toProductList">更多</span>
            </span>
          </el-col>
          <el-col :span="12" class="productList" v-for="(item, index) in productList" :key="index" @click.native="productDetail(item.id)">
            <!-- <el-image :src="item.image[0].url"></el-image> -->
            <template v-if="item.image.length">
              <el-image :src="item.image[0].url"></el-image>
            </template>
            <template v-else>暂无图片</template>
            <p class="textOver">{{ item.name || '暂无' }}</p>
          </el-col>
        </el-col>
        <el-col :span="12" class="right">
          <el-col :span="24" class="downLeftTop">
            <el-image :src="downLeftTopImage"></el-image>
            <span class="topText">
              <span>技术供求</span>
              <span
                ><p>T</p>
                <p>echnology</p></span
              >
              <span @click="toTecList">更多</span>
            </span>
          </el-col>
          <el-col :span="24" class="tecList" v-for="(item, index) in tecList" :key="index">
            <p>
              <el-col :span="24">
                <span></span>
                <span @click="tecDetail(item.id)">{{ item.name || '暂无' }}</span>
                <span>{{ item.meta | getDate }}</span>
              </el-col>
              <!-- <span @click="toChat(item)" style="display:none">对接</span> -->
              <el-col :span="24">
                <el-col :span="18" class="coopermode">
                  合作方式：
                  {{
                    item.coopermode == '0'
                      ? '技术转让'
                      : item.coopermode == '1'
                      ? '技术服务'
                      : item.coopermode == '2'
                      ? '技术许可'
                      : item.coopermode == '3'
                      ? '技术融资'
                      : item.coopermode == '4'
                      ? '其他'
                      : '暂无'
                  }}</el-col
                >
                <el-col :span="6" class="price" v-if="item.price"
                  >价格：{{ item.price }}/{{
                    item.priceunit === '0' ? '公斤' : item.priceunit === '1' ? '套' : item.priceunit === '2' ? '件' : '' || '暂无'
                  }}</el-col
                >
                <el-col :span="6" class="price" v-else>价格：{{ '面议' }}</el-col>
              </el-col>
            </p>
          </el-col>
        </el-col>
        <el-col :span="24">
          <el-image :src="gongqiuImage" class="gongqiuImage"></el-image>
        </el-col>
      </el-col>
      <el-col :span="24" class="marketDown">
        <el-col :span="24" class="downMain">
          <el-col :span="12" class="left">
            <el-col :span="24" class="downLeftTop">
              <el-image :src="downLeftTopImage"></el-image>
              <span class="topText">
                <span>服务供求</span>
                <span
                  ><p>S</p>
                  <p>ervice</p></span
                >
                <span @click="toServiceList">更多</span>
              </span>
            </el-col>
            <el-col :span="24" class="downLeftInfo">
              <el-col :span="24" class="bankingList" v-for="(item, index) in serviceList" :key="index" @click.native="serviceDetail(item.id)">
                <el-col :span="10">
                  <template v-if="item.image.length">
                    <el-image :src="item.image[0].url"></el-image>
                  </template>
                  <template v-else>暂无图片</template>
                </el-col>
                <el-col :span="14">
                  <span class="textOver">{{ item.name || '暂无' }}</span>
                  <span>{{ item.introduction || '暂无' }}</span>
                </el-col>
              </el-col>
            </el-col>
          </el-col>
          <el-col :span="12" class="right">
            <el-col :span="24" class="downLeftTop">
              <el-image :src="downLeftTopImage"></el-image>
              <span class="topText">
                <span>专家供求</span>
                <span
                  ><p>E</p>
                  <p>xpert</p></span
                >
                <span @click="zhuanjia">更多</span>
              </span>
            </el-col>
            <el-col :span="24">
              <el-col :span="24" class="downRightList" v-for="(item, index) in expertsList" :key="index" @click.native="zhuanjiaDetail(item.id)">
                <el-col :span="6">
                  <el-image :src="item.img_path"></el-image>
                </el-col>
                <el-col :span="18" class="infos">
                  <p>{{ item.name || '暂无' }}</p>
                  <p>
                    <span class="textOver">院校:{{ item.school }} </span>
                    <span class="textOver">学位:{{ item.xw || '暂无' }}</span>
                  </p>
                  <p>
                    <span class="textOver">学历:{{ item.xl || '暂无' }}</span>
                    <span class="textOver">专业:{{ item.major || '暂无' }}</span>
                  </p>
                </el-col>
              </el-col>
            </el-col>
          </el-col>
        </el-col>
      </el-col>
      <el-col :span="24" class="marketPublish" @click.native="fabu()"> <span @click="fabu()">我要发布</span></el-col>
    </el-col>
  </div>
</template>

<script>
import _ from 'lodash';
import { mapActions, mapState, createNamespacedHelpers } from 'vuex';
const { mapActions: product } = createNamespacedHelpers('marketproduct');
const { mapActions: expertsuser } = createNamespacedHelpers('expertsuser');
var moment = require('moment');
export default {
  name: 'index',
  props: {},
  components: {},
  data: () => ({
    gongqiuImage: require('@/assets/live/main2.png'),
    downLeftTopImage: require('@/assets/live/square_big.png'),
    productList: [],
    tecList: [],
    expertsList: [],
    serviceList: [],
    newList: [],
  }),
  created() {
    this.search();
  },
  filters: {
    getDate(meta) {
      let createdAt = _.get(meta, `createdAt`);
      let date = new Date(createdAt)
        .toLocaleDateString()
        .replace('/', '-')
        .replace('/', '-');
      return date;
    },
  },
  computed: {
    ...mapState(['user']),
    pageTitle() {
      return `${this.$route.meta.title}`;
    },
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },

  methods: {
    ...product(['newquery']),
    ...expertsuser({ expertQuery: 'query' }),
    async search() {
      let res = await this.newquery({ skip: 0, limit: 5, totaltype: '0', status: '1' });
      if (this.$checkRes(res)) this.$set(this, `tecList`, res.data);
      res = await this.newquery({ skip: 0, limit: 4, totaltype: '1', status: '1' });
      if (this.$checkRes(res)) this.$set(this, `productList`, res.data);
      if (this.$checkRes(res)) this.$set(this, `newList`, res.data);
      res = await this.newquery({ skip: 0, limit: 4, totaltype: '2', status: '1' });
      if (this.$checkRes(res)) this.$set(this, `serviceList`, res.data);
      res = await this.expertQuery({ skip: 0, limit: 6 });
      if (this.$checkRes(res)) this.$set(this, `expertsList`, res.data);
    },
    toProductList() {
      this.$router.push({ path: '/market/marketlists', query: { totaltype: 1, column_name: '产品供求', display: 1 } });
    },
    productDetail(id) {
      this.$router.push({ path: '/market/marketlists', query: { totaltype: 1, id: id, display: 2, column_name: '科技产品' } });
    },
    toTecList() {
      this.$router.push({ path: '/market/marketlists', query: { totaltype: 0, column_name: '技术供求', display: 1 } });
    },
    tecDetail(id) {
      this.$router.push({ path: '/market/marketlists', query: { totaltype: 0, id: id, display: 2, column_name: '技术供求' } });
    },
    toServiceList() {
      this.$router.push({ path: '/market/marketlists', query: { totaltype: 2, column_name: '服务供求', display: 1 } });
    },
    serviceDetail(id) {
      this.$router.push({ path: '/market/marketlists', query: { totaltype: 2, id: id, display: 2, column_name: '服务供求' } });
    },
    zhuanjia() {
      this.$router.push({ path: '/market/marketlists', query: { column_name: '专家供求', display: 1 } });
    },
    zhuanjiaDetail(id) {
      this.$router.push({ path: '/market/marketlists', query: { id: id, display: 3, column_name: '专家供求' } });
    },
    fabu() {
      if (this.user.role == '2' || this.user.role == '3') {
        this.$router.push({ path: '/market/marketfabu' });
      } else if (this.user.uid == undefined) {
        this.$router.push({ path: '/login' });
      } else {
      }
    },
    // toChat(data) {
    //   this.$router.push({ path: '/market/contact', query: { id: data.id } });
    // },
  },
};
</script>

<style lang="less" scoped>
.gongqiuImage {
  width: 100%;
  height: 100%;
}
.main {
  width: 100%;
  margin: 20px auto;
  float: none;
}
.marketTop {
  width: 80%;
  margin: 20px auto;
  float: none;
}
.left {
  float: left;
  height: 500px;
  margin: 10px 0 20px 0;
  overflow: hidden;
  // box-shadow: 2px 2px 2px #888888;
  border-right: 1px dashed #044b79;
  width: 49.5%;
}
.leftTitle {
  text-align: center;
  position: relative;
}
.leftTitle p:first-child {
  font-size: 18px;
  color: #044b79;
  font-weight: bold;
}
.leftTitle p:last-child {
  float: left;
  width: 2px;
  height: 402px;
  background-color: #044b79;
  margin: 0 5px;
  position: absolute;
  left: 9px;
}
.infoLeft {
  height: 480px;
  padding: 0 10px;
}
.productList {
  position: relative;
  margin: 0 10px 10px 0;
  width: 48%;
  height: 220px;
  cursor: pointer;
}
.productList:nth-child(2n) {
  margin: 0 0 10px 0;
}
.productList .el-image {
  width: 100%;
  height: 220px;
}
.productList p {
  position: absolute;
  text-align: center;
  bottom: 0;
  height: 50px;
  line-height: 50px;
  text-indent: 5px;
  // padding: 0 10px;
  background: #044b799f;
  color: #fff;
  width: 100%;
  font-size: 18px;
}
.leftListDown {
  position: relative;
}
.leftListDown span:first-child {
  display: inline-block;
  width: 80%;
  height: 3px;
  background: rgba(4, 75, 121, 0.37);
  margin: 0 10px 0 0;
  position: absolute;
  left: -10px;
  top: 10px;
}
.leftListDown span:last-child {
  font-size: 16px;
  float: right;
  padding: 0 15px 0 0;
  color: #044b79;
  font-weight: 700;
  cursor: pointer;
}
.right {
  float: right;
  height: 500px;
  overflow: hidden;
  margin: 10px 0 20px 0;
  width: 49.5%;
}
.rightListTop {
  position: relative;
}
.rightListTop span:first-child {
  font-size: 16px;
  float: left;
  padding: 0 0 0 15px;
  color: #044b79;
  font-weight: 700;
  cursor: pointer;
}
.rightListTop span:last-child {
  display: inline-block;
  width: 80%;
  height: 3px;
  background: rgba(4, 75, 121, 0.37);
  margin: 0 10px 0 0;
  position: absolute;
  right: -10px;
  top: 10px;
}
.infoRight {
  height: 480px;
  padding: 0 10px;
}
.tecList {
  padding: 0 15px;
  margin: 15px 0;
}
.tecList p span:first-child {
  display: inline-block;
  width: 10px;
  height: 10px;
  background: #2188c6;
  border-radius: 90px;
  overflow: hidden;
}

.tecList p .coopermode {
  display: inline-block;
  width: 65%;
  font-size: 16px;
  padding: 5px 24px;

  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  -o-text-overflow: ellipsis;
  white-space: nowrap;
}
.tecList p .price {
  display: inline-block;
  width: 27%;
  text-align: center;
  overflow: hidden;
  // height: 20px;
  // background-color: #044b79;
  font-size: 16px;
  padding: 5px 0 5px 83px;
  cursor: pointer;
}

.tecList p span:nth-child(2n) {
  display: inline-block;
  width: 65%;
  font-size: 18px;
  // height: 20px;
  padding: 0 15px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  -o-text-overflow: ellipsis;
  white-space: nowrap;
}
.tecList p span:nth-child(3n) {
  display: inline-block;
  width: 27%;
  text-align: center;
  overflow: hidden;
  // height: 20px;
  // background-color: #044b79;
  font-size: 16px;
  padding: 3px 0px;
  cursor: pointer;
}
.tecList span:last-child {
  display: block;
  width: 120px;
  text-align: left;
  padding: 5px 0 5px 25px;
  font-size: 14px;
}
.rightTitle {
  text-align: center;
}
.rightTitle p:first-child {
  width: 2px;
  height: 370px;
  background: #044b79;
  position: relative;
  left: 10px;
  top: -20px;
}
.rightTitle p:last-child {
  font-size: 18px;
  font-weight: bold;
  color: #044b79;
}
.marketDown {
  height: 550px;
  overflow: hidden;
  margin: 20px 0 20px 0;
  background: #e9edf6;
  padding-top: 30px;
}
.downMain {
  width: 80%;
  float: none;
  height: 550px;
  margin: 0 auto;
}
.downLeftTop .el-image {
  width: 40px;
}

.topTexts {
  width: 100%;
  border-bottom: 2.5px solid #044b79;
  display: inline-block;
  position: relative;
  top: -10px;
  margin: 0 0 0 5px;
}
.topTexts span:first-child {
  font-size: 24px;
  font-weight: 700;
  color: #000000;
  padding: 0 10px;
  top: 4px;
}
.topTexts span p:first-child {
  font-weight: 800;
  font-size: 34px;

  color: #92959a;

  top: 11px;
  display: inline-block;
}
.topTexts span p:last-child {
  display: inline-block;
  font-weight: 700;
  font-size: 18px;
  color: #92959a;
}
.topTexts span:last-child {
  float: right;
  font-size: 16px;
  font-weight: 700;
  color: #044b79;
  position: relative;
  top: 20px;
  cursor: pointer;
}

.topText {
  width: 89%;
  border-bottom: 2.5px solid #044b79;
  display: inline-block;
  position: relative;
  top: -10px;
  margin: 0 0 0 5px;
}
.topText span:first-child {
  font-size: 24px;
  font-weight: 700;
  color: #000000;
  padding: 0 10px;
  top: 4px;
  padding: 0 10px 0 0;
}
.topText span p:first-child {
  font-weight: 800;
  font-size: 34px;

  color: #92959a;

  top: 11px;
  display: inline-block;
}
.topText span p:last-child {
  display: inline-block;
  font-weight: 700;
  font-size: 18px;
  color: #92959a;
}
.topText span:last-child {
  float: right;
  font-size: 16px;
  font-weight: 700;
  color: #044b79;
  position: relative;
  top: 20px;
  cursor: pointer;
}
.bankingLists {
  height: 152px;
  cursor: pointer;
}
.bankingLists .el-image {
  width: 100%;
  height: 130px;
  display: inline-block;
}
.bankingLists span {
  margin: 0 5px 0 5px;
  display: inline-block;
  width: 80%;
  font-size: 18px;
  padding: 0 0 0 10px;
  color: #044b79;
  font-weight: 700;
}
.bankingLists span:last-child {
  margin: 10px 0 0 5px;
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: 4;
  word-break: break-all;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  padding: 0 0 0 10px;
  color: #666;
  line-height: 25px;
  font-weight: 400;
}

.bankingList {
  height: 152px;
  cursor: pointer;
}
.bankingList .el-image {
  width: 100%;
  height: 130px;
  display: inline-block;
}
.bankingList span {
  margin: 0 5px 0 5px;
  display: inline-block;
  width: 80%;
  font-size: 18px;
  padding: 0 0 0 10px;
  color: #044b79;
  font-weight: 700;
}
.bankingList span:last-child {
  margin: 10px 0 0 5px;
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: 4;
  word-break: break-all;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  padding: 0 0 0 10px;
  color: #666;
  line-height: 25px;
  font-weight: 400;
}
.downRightList {
  width: 50%;
  cursor: pointer;
  border-bottom: 1px dashed #044b79;
  padding: 15px 0;
  height: 140px;
  margin: 0 0 12px 0;
}
.downRightList .el-image {
  height: 95px;
  border-radius: 100%;
}
.downRightList .infos {
  padding: 0 10px;
}
.downRightList .infos p {
  float: left;
  width: 100%;
  // font-size: 16px;
  padding: 0 0 10px 0;
}
.downRightList .infos p:first-child {
  font-size: 18px;
  font-weight: bold;
}
.downRightList .infos p span {
  display: inline-block;
  width: 50%;
  font-size: 14px !important;
}
.marketNew {
  float: none;
  width: 80%;
  margin: 30px auto;
  height: 400px;
}
.downLeftInfos {
  height: 330px;
}
.marketPublish {
  position: fixed;
  background: #0279d5;
  width: 100px;
  height: 100px;
  z-index: 999;
  left: 2%;
  top: 80%;
  border-radius: 20px;
  box-shadow: 2px 2px 2px #055c9f;
  text-align: center;
  line-height: 100px;
  font-size: 20px;
  color: #fff;
  font-weight: bold;
}
.marketPublish:hover {
  background: #f60;
  cursor: pointer;
}
</style>
