<template>
  <div id="xmdj">
    <el-row>
      <el-col :span="24" class="main">
        <el-col :span="24" class="one">
          <div class="w_1200">
            <el-col :span="20" class="left">
              <el-col :span="24" class="leftone">
                <span>科技成果展洽会</span>
                <span>欢迎您</span>
              </el-col>
              <el-col :span="24" class="lefttwo">
                SCIENTIFIC AND TECHNOLOGICAL ACHIEVEEMENTS EXHIBITION
              </el-col>
            </el-col>
            <el-col :span="4" class="right">
              <el-link :underline="false">帮助中心</el-link>
            </el-col>
          </div>
        </el-col>
        <el-col :span="24" class="two">
          <div class="w_1200">
            <el-col :span="24" class="twotop">
              <el-col :span="18" class="left">
                <p>{{ dockInfo.title }}</p>
                <el-image :src="two1"></el-image>
              </el-col>
              <el-col :span="6" class="right">
                <el-image :src="two2"></el-image>
                <p>{{ dockInfo.start_time }}</p>
                <p>距离展会结束还有</p>
                <p>倒计时</p>
              </el-col>
            </el-col>
            <el-col :span="24" class="twocen">
              <el-col :span="15" class="left"> <span>主办单位：</span>{{ dockInfo.sponsor }} </el-col>
              <el-col :span="8" class="right">
                <el-button class="btn1" @click="$router.push({ path: '/halltwo/directTwo', query: { id: dockInfo.id } })">返回展会进行页</el-button>
                <el-button class="btn2" @click="$router.push({ path: '/halltwo/detail', query: { id: dockInfo.id } })">进入展会总结页</el-button>
              </el-col>
            </el-col>
          </div>
        </el-col>
        <el-col :span="24" class="three">
          <div class="w_1200">
            <el-col :span="24" class="threeinfo">
              <span v-if="this.type == '0'">
                <techDetail :detailInfo="detailInfo" @onSubmit="onSubmit" :displayBtn="displayBtn"></techDetail>
              </span>
              <span v-else-if="this.type == '1'">
                <achiDetail :detailInfo="detailInfo" @onSubmit="onSubmit" :displayBtn="displayBtn"></achiDetail>
              </span>
              <span v-else-if="this.type == '2'">
                <busiDetail :detailInfo="detailInfo" @onSubmit="onSubmit" :displayBtn="displayBtn"></busiDetail>
              </span>
              <span v-else>
                <expeDetail :detailInfo="detailInfo" @onSubmit="onSubmit" :displayBtn="displayBtn"></expeDetail>
              </span>
            </el-col>
          </div>
        </el-col>
        <el-col :span="24" class="four">
          <div class="w_1200">
            <el-col :span="24" class="info">
              <el-col :span="8" class="left">
                <h1>专家咨询：</h1>
                <p>工作日：08:30~17:00</p>
                <p>咨询电话：</p>
                <p>0431-81666508</p>
              </el-col>
              <el-col :span="8" class="left">
                <h1>业务联系：</h1>
                <p>长春中科北斗工程技术有限公司</p>
                <p>联系人：刘经理</p>
                <p>电话：18604328977</p>
                <p>邮箱：18889898@qq.com</p>
              </el-col>
              <el-col :span="8" class="left right">
                <h1>活动帮微信：</h1>
                <el-image :src="erweima" style="width:132px;height:132px;"></el-image>
              </el-col>
            </el-col>
          </div>
        </el-col>
      </el-col>
      <div class="pz_down">
        <live-foot></live-foot>
      </div>
    </el-row>
  </div>
</template>

<script>
import liveFoot from '@/layout/live/foot.vue';
import techDetail from '@/views/market/detail/techDetail.vue';
import achiDetail from '@/views/market/detail/achiDetail.vue';
import busiDetail from '@/views/market/detail/busiDetail.vue';
import expeDetail from '@/views/market/detail/expeDetail.vue';
import { mapState, createNamespacedHelpers } from 'vuex';
const { mapActions: dock } = createNamespacedHelpers('dock');
const { mapActions: transaction } = createNamespacedHelpers('transaction');
const { mapActions: expertsuser } = createNamespacedHelpers('expertsuser');
export default {
  metaInfo() {
    return { title: this.$route.meta.title };
  },
  name: 'xmdj',
  props: {},
  components: {
    liveFoot,
    techDetail,
    achiDetail,
    busiDetail,
    expeDetail,
  },
  data: function() {
    return {
      two1: require('@a/sy_04.png'),
      two2: require('@a/dock2.png'),
      // 展會詳情
      dockInfo: {},
      // 指导单位
      erweima: require('@a/二维码.jpg'),
      // 产品列表
      productList: [],
      // 产品详情
      detailInfo: {},
      // 显示按钮
      displayBtn: true,
    };
  },
  async created() {
    await this.searchInfo();
  },
  methods: {
    ...dock({ dockQuery: 'query', dockFetch: 'fetch', goodsquery: 'goodsquery' }),
    ...transaction({ buyProduct: 'create' }),
    ...expertsuser(['fetch']),
    async searchInfo() {
      // 查询展会详情
      if (this.dock_id) {
        let res = await this.dockFetch(this.dock_id);
        if (this.$checkRes(res)) {
          this.$set(this, `dockInfo`, res.data);
          if (this.type == '3') {
            this.searchExpert();
          } else {
            // 查询产品
            let czxm = res.data.apply.map(item => item.goodsList);
            czxm = _.flattenDeep(czxm);
            let czxmNew = czxm.filter(item => item.dockStatus == '1');
            this.$set(this, `productList`, czxmNew);
            this.searchProduct();
          }
        }
      }
    },
    // 查找产品详情
    searchProduct() {
      let productInfo = this.productList.find(i => i._id == this.id);
      if (productInfo) {
        this.$set(this, `detailInfo`, productInfo);
      }
    },
    // 查找专家详情
    async searchExpert() {
      let res = await this.fetch(this.id);
      if (res.errcode === 0) {
        this.$set(this, `detailInfo`, res.data);
      }
    },
    // 洽谈
    async onSubmit() {
      let data = this.detailInfo;
      let form = {};
      if (this.type == '3') {
        form = {
          userid: this.user.uid,
          username: this.user.name,
          product_id: data.id,
          product_name: data.name,
          market_userid: data.id,
          market_username: data.name,
          status: '0',
          type: '1',
        };
      } else {
        form = {
          userid: this.user.uid,
          username: this.user.name,
          product_id: data._id,
          product_name: data.name,
          market_userid: data.userid,
          market_username: data.contacts,
          status: '0',
          type: '1',
        };
      }
      if (!this.user.uid) {
        // this.$message.error('游客身份无法与卖家对话,请先注册');
        this.$message({
          dangerouslyUseHTMLString: true,
          message: '<strong><a href="http://free.liaoningdoupo.com/platlive/webLogin" style="color:red;">游客身份无法与卖家对话,请先注册</a></strong>',
          type: 'error',
        });
        return;
      } else {
        let res = await this.buyProduct(form);
        this.$checkRes(res, '购买申请成功', res.errmsg || '购买申请失败');
      }
    },
  },
  computed: {
    ...mapState(['user']),
    dock_id() {
      return this.$route.query.dock_id;
    },
    id() {
      return this.$route.query.id;
    },
    type() {
      return this.$route.query.type;
    },
  },
  watch: {},
};
</script>

<style lang="less" scoped>
.main {
  .one {
    height: 100px;
    .left {
      height: 100px;
      .leftone {
        margin: 15px 0 0 0;
        span:nth-child(1) {
          font-size: 35px;
          color: #535353;
          font-weight: bold;
          font-family: cursive;
        }
        span:nth-child(2) {
          font-size: 15px;
          padding: 0 10px;
          color: #535353;
        }
      }
      .lefttwo {
        font-size: 12px;
        color: #535353;
      }
    }
    .right {
      height: 100px;
      line-height: 100px;
      text-align: right;
    }
  }
  .two {
    height: 610px;
    background: url('~@/assets/bj1.jpg');
    padding: 20px 0;
    .twotop {
      margin: 0 0 10px 0;
      .left {
        height: 357px;
        margin: 0 10px 0 0;
        background: url('~@/assets/dock1.png');
        p {
          float: left;
          width: 79%;
          font-size: 43px;
          color: #fff;
          font-weight: bold;
          padding: 13% 0 0 20px;
        }
        .el-image {
          float: left;
          width: 153px;
          height: 94px;
          margin: 4% 0 0 0;
        }
      }
      .right {
        background-color: #ffffff;
        width: 24%;
        height: 357px;
        text-align: center;
        padding: 0 10px;
        .el-image {
          width: 120px;
          height: 48px;
          margin: 50px 0 0px 0;
        }
        p:nth-child(2) {
          font-size: 18px;
          margin: 30px 0 5px 0;
        }
        p:nth-child(3) {
          font-size: 22px;
          font-weight: bold;
          margin-bottom: 30px;
        }
        p:nth-child(4) {
          background: #f5f5f5;
          padding: 20px 0px;
          border-radius: 5px;
          height: 50px;
        }
      }
      .right:hover {
        cursor: pointer;
        p:nth-child(3) {
          color: #535353;
        }
      }
    }
    .twocen {
      height: 130px;
      overflow: hidden;
      line-height: 130px;
      background-color: #fff;
      margin: 0 0 35px 0;
      .left {
        font-size: 18px;
        margin: 0 0 0 30px;
        span {
          font-size: 22px;
          font-weight: bold;
        }
      }
      .right {
        .btn1 {
          font-size: 16px;
          color: #fff;
          background: red;
          border: none;
          font-weight: bold;
        }
        .btn2 {
          font-size: 16px;
          color: #ff0000;
          border: 1px solid #ff0000;
          font-weight: bold;
        }
      }
    }
  }
  .three {
    min-height: 700px;
    overflow: hidden;
    position: relative;
    top: -50px;
    z-index: 999;
    .threeinfo {
      min-height: 700px;
      overflow: hidden;
      background-color: #fff;
      padding: 15px;
      box-shadow: 0 5px 15px rgba(33, 82, 203, 0.35);
    }
  }
  .four {
    border-top: 2px solid #305798;
    height: 250px;
    .info {
      .left {
        h1 {
          padding: 15px 0;
          font-weight: bold;
          color: #4d4d4d;
        }
        p {
          font-size: 16px;
          color: #4d4d4d;
          padding: 5px 0;
        }
      }
      .right {
        text-align: center;
      }
    }
  }
}
</style>
