<script lang="ts">
import Vue from 'vue'
import { getMyExpoInfo } from '@/api/expo'
export default Vue.extend({
  name: "expoPopover",
  data() {
    return {
      ossUrl: process.env.VUE_APP_OSS_DOMAIN
    }
  },
  props: {
    popover_data: Object,
  },
  mounted() {
    setTimeout(()=>{
      console.log(this.popover_data)
    },2000)
  },
  methods: {
    goto(url) {
      window.open(url, '_blank')
    },
  }
})
</script>

<template>
  <div class="expo-info">
    <div class="cover loading">
      <img v-if="popover_data.images" :src="ossUrl+popover_data.images[0]">
      <div v-permission="'exhibitor.copyLink'" v-if="popover_data.form_template_id && popover_data.urla" @click="copyUrl()" class="button">复制表单地址</div>
    </div>
    <div class="info-body">
      <div class="avatar-name">
        <div class="avatar loading">
          <img v-if="popover_data.logo" :src="ossUrl+popover_data.logo">
        </div>
        <div class="name-cont">
          <div :class="['name',popover_data.expo_name!==undefined?'':'loading']">{{ popover_data.expo_name }}</div>
          <div :class="['sub-name',popover_data.organizer!==undefined?'':'loading']">{{ popover_data.organizer }}</div>
          <div class="contact">
            <div class="phone">
              <i class="icon el-icon-mobile-phone" />
              <div :class="['phone-num link',popover_data.contact_phone!==undefined?'':'loading']" @click="goto('tel:'+popover_data.contact_phone)">{{ popover_data.contact_phone }}</div>
            </div>
            <div class="email">
              <i class="icon el-icon-message" />
              <div :class="['email-addr link',popover_data.contact_email!==undefined?'':'loading']" @click="goto('mailto:'+popover_data.contact_email)">{{ popover_data.contact_email }}</div>
            </div>
            <div class="date">
              <i class="icon el-icon-date" />
              <div :class="['date-range',popover_data.start_date!==undefined?'':'loading']">{{ popover_data.start_date }} - {{ popover_data.end_date }}</div>
            </div>
          </div>
        </div>
      </div>
      <div :class="['desc',popover_data.content!==undefined?'':'loading']">
        {{ popover_data.content }}
      </div>
      <div v-if="popover_data.social_links" class="social_links">
        <div class="social-title">社交媒体</div>
        <div v-if="popover_data.social_links.facebook" class="social-item">
          <span>facebook：</span><span class="link" @click="goto(popover_data.social_links.facebook)">{{ popover_data.social_links.facebook }}</span>
        </div>
        <div v-if="popover_data.social_links.twitter" class="social-item">
          <span>twitter：</span><span class="link" @click="goto(popover_data.social_links.twitter)">{{ popover_data.social_links.twitter }}</span>
        </div>
        <div v-if="popover_data.social_links.linkedin" class="social-item">
          <span>linkedin：</span><span class="link" @click="goto(popover_data.social_links.linkedin)">{{ popover_data.social_links.linkedin }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.expo-info{
  position: relative;
  width: 100%;
  .link{
    cursor: pointer;
    text-decoration: underline;
  }
  .info-body{
    margin: auto;
    max-width: 800px;
    padding: 16px;
    .social_links{
      margin-top: 12px;
      .social-title{
        font-weight: bold;
      }
      .social-item{

      }
    }
    .desc{
      margin-top: 12px;
      &.loading{
        height: 60px;
        width: 100%;
      }
    }
    .avatar-name{
      display: flex;
      grid-gap: 8px;
      .name-cont{
        flex: 1;
        .name{
          font-size: 20px;
          font-weight: bold;
          &.loading{
            height: 26px;
            width: 120px;
          }
        }
        .sub-name{
          color: gray;
          &.loading{
            margin-top: 8px;
            margin-bottom: 8px;
            height: 20px;
            width: 160px;
          }
        }
        .contact{
          flex-wrap: wrap;
          display: flex;
          grid-gap: 0 12px;
          .phone,.email,.date{
            display: flex;
            align-items: center;
            grid-gap: 4px;
            div{
              &.loading{
                height: 16px;
                width: 120px;
              }
            }
          }
        }
      }
      .avatar{
        width: 70px;
        height: 70px;
        border-radius: 50%;
        overflow: hidden;
        img{
          display: block;
          object-fit: cover;
          width: 100%;
          height: 100%;
        }
      }
    }
  }
  .cover{
    position: relative;
    width: 100%;
    height: 300px;
    .button{
      cursor: pointer;
      background: #00000044;
      padding: 4px 12px;
      border-radius: 24px;
      border: 2px solid white;
      color: white;
      position: absolute;
      right: 16px;
      top: 16px;
    }
    img{
      display: block;
      object-fit: cover;
      width: 100%;
      height: 100%;
    }
  }
}
</style>
