<template>
  <div id="techDetail">
    <el-row>
      <el-col :span="24" class="main">
        <el-col :span="24" class="top">
          <el-col :span="8" class="left">
            <el-image v-if="detailInfo.expertimage != ''" :src="detailInfo.expertimage" style="width:100%;height:260px;"></el-image>
            <el-image v-else :src="expertimage" style="width:100%;height:260px;"></el-image>
          </el-col>
          <el-col :span="16" class="right">
            <el-col :span="24" class="name textOver">
              {{ detailInfo.name || '暂无' }}
            </el-col>
            <el-col :span="24">
              <el-col :span="3" class="otherInfo textOver">
                工作单位
              </el-col>
              <el-col :span="21" class="otherInfo textOver">
                {{ detailInfo.company || '暂无' }}
              </el-col>
            </el-col>
            <el-col :span="12">
              <el-col :span="6" class="otherInfo textOver">
                毕业院校
              </el-col>
              <el-col :span="18" class="otherInfo textOver">
                {{ detailInfo.school || '暂无' }}
              </el-col>
            </el-col>
            <el-col :span="12">
              <el-col :span="6" class="otherInfo textOver">
                最高学历
              </el-col>
              <el-col :span="18" class="otherInfo textOver">
                {{ detailInfo.education || '暂无' }}
              </el-col>
            </el-col>
            <el-col :span="12">
              <el-col :span="6" class="otherInfo textOver">
                出生日期
              </el-col>
              <el-col :span="18" class="otherInfo textOver">
                {{ detailInfo.birthDate || '暂无' }}
              </el-col>
            </el-col>
            <el-col :span="12">
              <el-col :span="6" class="otherInfo textOver">
                职务职称
              </el-col>
              <el-col :span="18" class="otherInfo textOver">
                {{ detailInfo.zwzc || '暂无' }}
              </el-col>
            </el-col>
            <el-col :span="12">
              <el-col :span="6" class="otherInfo textOver">
                QQ/微信
              </el-col>
              <el-col :span="18" class="otherInfo textOver">
                {{ detailInfo.qqwx || '暂无' }}
              </el-col>
            </el-col>
            <el-col :span="12">
              <el-col :span="6" class="otherInfo textOver">
                电子邮箱
              </el-col>
              <el-col :span="18" class="otherInfo textOver">
                {{ detailInfo.email || '暂无' }}
              </el-col>
            </el-col>
            <el-col :span="24">
              <el-col :span="3" class="otherInfo textOver">
                擅长领域
              </el-col>
              <el-col :span="21" class="otherInfo textOver">
                {{ detailInfo.expertise || '暂无' }}
              </el-col>
            </el-col>
            <!-- <el-col :span="12" class="otherInfo textOver"> 毕业院校：{{ detailInfo.school }} </el-col>
            <el-col :span="12" class="otherInfo textOver"> 最高学历：{{ detailInfo.education }} </el-col>
            <el-col :span="12" class="otherInfo textOver"> 出生日期：{{ detailInfo.birthDate }} </el-col>
            <el-col :span="12" class="otherInfo textOver"> 工作单位：{{ detailInfo.company }} </el-col>
            <el-col :span="12" class="otherInfo textOver"> QQ/微信：{{ detailInfo.qqwx }} </el-col>
            <el-col :span="12" class="otherInfo textOver"> 电子邮箱：{{ detailInfo.email }} </el-col>
            <el-col :span="12" class="otherInfo textOver"> 职务职称：{{ detailInfo.zwzc }} </el-col>
            <el-col :span="12" class="otherInfo textOver"> 擅长领域：{{ detailInfo.expertise }} </el-col> -->
          </el-col>
        </el-col>
        <el-col :span="24" class="down">
          <el-col :span="24" class="downInfo">
            <el-col :span="4" class="tit">
              <h2>工作经历</h2>
            </el-col>
            <el-col :span="20" class="info">
              {{ detailInfo.workexperience || '暂无' }}
            </el-col>
          </el-col>
          <el-col :span="24" class="downInfo">
            <el-col :span="4" class="tit">
              <h2>科研综述</h2>
            </el-col>
            <el-col :span="20" class="info">
              {{ detailInfo.scientific || '暂无' }}
            </el-col>
          </el-col>
          <el-col :span="24" class="downInfo">
            <el-col :span="4" class="tit">
              <h2>承担项目</h2>
            </el-col>
            <el-col :span="20" class="info">
              {{ detailInfo.undertakingproject || '暂无' }}
            </el-col>
          </el-col>
          <el-col :span="24" class="downInfo">
            <el-col :span="4" class="tit">
              <h2>科技奖励</h2>
            </el-col>
            <el-col :span="20" class="info">
              {{ detailInfo.scienceaward || '暂无' }}
            </el-col>
          </el-col>
          <el-col :span="24" class="downInfo">
            <el-col :span="4" class="tit">
              <h2>社会任职</h2>
            </el-col>
            <el-col :span="20" class="info">
              {{ detailInfo.social || '暂无' }}
            </el-col>
          </el-col>
        </el-col>
        <el-col :span="24" class="anniu" v-if="displayBtn">
          <el-button type="primary" size="mini" v-if="this.user.uid != detailInfo.userid" @click="btnPhone()">交流洽谈</el-button>
          <el-button type="success" size="mini" v-if="this.user.uid != detailInfo.userid" @click="onSubmit()">供求对接</el-button>
        </el-col>
      </el-col>
    </el-row>
    <el-dialog title="对接" :visible.sync="dialogTableVisible">
      <chat :room="room"></chat>
    </el-dialog>
  </div>
</template>

<script>
import _ from 'lodash';
import { mapState, createNamespacedHelpers } from 'vuex';
import chat from '@/layout/market/parts/chat.vue';
const { mapActions: personalRoom } = createNamespacedHelpers('personalroom');
const { mapActions: transaction } = createNamespacedHelpers('transaction');
export default {
  name: 'techDetail',
  props: {
    detailInfo: { type: Object },
    displayBtn: { type: Boolean },
  },
  components: { chat },
  data: function() {
    return {
      expertimage: require('@/assets/live/222.png'),
      dialogTableVisible: false,
      room: {},
    };
  },
  created() {},
  methods: {
    ...personalRoom(['create', 'countDelete']),
    ...transaction({ buyProduct: 'create' }),
    // 对接
    async btnPhone() {
      if (!this.room.id) {
        //TODO 请求房间号
        let obj = {};
        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 {
          obj.buyer_id = this.user.uid;
          obj.buyer_name = this.user.name;
        }
        if (!this.detailInfo.id) {
          this.$message.error('缺少卖家信息,请联系卖家或管理员');
          return;
        } else {
          obj.seller_id = this.detailInfo.userid;
          obj.seller_name = this.detailInfo.name;
        }
        let res = await this.create(obj);
        if (this.$checkRes(res)) {
          this.$set(this, `room`, res.data);
        }
      }
      this.dialogTableVisible = true;
    },
    // 洽谈
    onSubmit() {
      this.$emit('onSubmit', { data: this.detailInfo });
    },
  },
  computed: {
    ...mapState(['user']),
    pageTitle() {
      return `${this.$route.meta.title}`;
    },
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
};
</script>

<style lang="less" scoped>
.main {
  margin: 10px 0 0 0;
  .top {
    height: 270px;
    overflow: hidden;
    .right {
      padding: 0 0 0 10px;
      .name {
        font-size: 18px;
        font-weight: bold;
        padding: 10px;
        border: 1px solid #ccc;
      }
      .otherInfo {
        font-size: 16px;
        padding: 10px;
        border: 1px solid #ccc;
      }
    }
  }
  .down {
    margin: 0 0 15px 0;
    .downInfo {
      border: 1px solid #ccc;
      .tit {
        height: 150px;
        line-height: 150px;
        text-align: center;
        border-right: 1px solid #ccc;
      }
      .info {
        font-size: 16px;
        padding: 10px;
        height: 150px;
      }
    }
  }
  .anniu {
    text-align: center;
    /deep/.el-button {
      margin: 0 10px;
    }
  }
}
</style>
