
<template>
  <div>
    <div class="short-content">
      <img
        class="tit-img"
        src="../../../assets/pass/shortIerm-tit.png"
        alt=""
      >
      <div style="display: flex;justify-content: space-between">
        <div class="short-content-left">
          <img
            class="short"
            src="../../../assets/pass/shortIerm-short.png"
            alt=""
          >
          <img class="user-img" :src="itemData.avatar" alt="">
          <!-- <img
            class="build-icon"
            src="../../../assets/pass/build-icon.png"
            alt=""
          /> -->
          <div ref="smallCode" class="qrcode" alt="" @click="BlowUp" />
        </div>
        <div class="short-content-right">
          <div class="tit">临时通行证</div>
          <div class="user-msg">
            <div class="user-msg-item">
              <span>人员姓名：</span>
              {{ itemData.name }}
            </div>
            <div class="user-msg-item">
              <span>证件编号：</span>
              {{ itemData.passSn }}
            </div>
            <div class="user-msg-item">
              <span>单位名称：</span>
              {{ itemData.username }}
            </div>
            <!-- <div>施工单位：贵州华欣源科技有限公司</div> -->
            <div class="user-msg-item" style="height:80px;display: flex;flex-direction: column">
              <span>引领人：</span>
              <span
                v-for="(item, index) in itemData.leaderList"
                :key="index"
                style="line-height: 16px"
              >{{ item.name||'' }}-{{ item.passSn||'' }}-{{ item.unitConciseName||'' }}</span>
            </div>
            <div class="user-msg-item">
              <span>通行区域：</span>
              <div style="width: calc(24px * 5 + 5px)">
                <span
                  v-for="(item, index) in itemData.areaList"
                  :key="index"
                  :class="['area', item.choose ? 'choose-area' : '']"
                >
                  {{ item.name }}
                </span>
              </div>
            </div>
          </div>
          <img
            class="type"
            src="../../../assets/pass/shortIerm-type.png"
            alt=""
          >
          <div class="time-text">启用时间-到期时间</div>
          <div class="time">{{ itemData.startTime }}</div>
          <div class="time">{{ itemData.endTime }}</div>
        </div>
      </div>
    </div>
    <!-- 点击放大二维码 -->
    <div :class="[showBigCord ? 'big-box' : 'hidden']">
      <div class="BigCode">
        <div style="position: relative">
          <i class="el-icon-error" @click="minification" />
          <div ref="BigCode" class="big" alt="" @click="BlowUp" />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import QRCode from 'qrcodejs2'
export default {
  components: {},
  filters: {},
  props: {
    areaList: {
      type: Array,
      default() {
        return []
      }
    },
    itemData: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      showBigCord: false
    }
  },
  computed: {},
  watch: {},
  created() {
    if (this.itemData.passSn) {
      this.getQRCode()
    }
  },
  methods: {
    getQRCode() {
      setTimeout(() => {
        new QRCode(this.$refs.smallCode, {
          text: 'https://ldb-airport.hz-hanghui.com:9100/ldb-pass-management?passSn=' + this.itemData.passSn + '&idNumber=' + this.itemData.idNumber, // 二维码的内容
          width: 50,
          height: 50,
          colorDark: '#fff',
          colorLight: '#000',
          correctLevel: QRCode.CorrectLevel.H
        })
      }, 0)
      setTimeout(() => {
        new QRCode(this.$refs.BigCode, {
          text:
            'https://ldb-airport.hz-hanghui.com:9100/ldb-pass-management?passSn=' +
            this.itemData.passSn +
            '&idNumber=' +
            this.itemData.idNumber, // 二维码的内容
          width: 400,
          height: 400,
          colorDark: '#fff',
          colorLight: '#000',
          correctLevel: QRCode.CorrectLevel.H
        })
      }, 0)
    },
    BlowUp() {
      this.showBigCord = true
    },
    minification() {
      this.showBigCord = false
    }
  }
}
</script>
<style scoped lang="scss">
.short-content {
  width: calc(100% - 12px);
  height: 380px;
  background-color: #babdaf;
  padding: 10px 4px 10px 10px;
  margin: 5px 6px;
  .tit-img {
    width: 126px;
    height: 25px;
    margin: 0 auto;
    display: block;
  }
  &-left {
    width: 50px;
    position: relative;
    .short {
      height: 23px;
      margin-top: 6px;
      margin-bottom: 5px;
    }
    .user-img {
      height: 75px;
      width: 49px;
    }
    .build-icon {
      width: 49px;
      height: 47px;
    }
    .qrcode {
      width: 49px;
      height: 49px;
      //margin-top: 110px;
      position: absolute;
      bottom: 2px;
    }
  }
  &-right {
    width: calc(100% - 50px);
    padding-left: 5px;
    box-sizing: border-box;
    .tit {
      font-size: 24px;
      font-weight: 500;
      letter-spacing: 0.84px;
      height: 36px;
      line-height: 36px;
    }
    .user-msg {
      width: 100%;
      &-item {
        width: 100%;
        font-size: 12px;
        line-height: 16px;
      }
      .area {
        width: 24px;
        height: 22px;
        line-height: 22px;
        display: inline-block;
        border-radius: 2px;
        background: #8c9271;
        color: rgba(162, 168, 129, 0.5);
        text-align: center;
        font-size: 13px;
        font-weight: 900;
        margin-right: 1px;
        margin-bottom: 1px;
      }
      .choose-area {
        color: #494d2f;
      }
    }

    .type {
      width: 124px;
      height: 34px;
      margin-top: 2px;
    }
    .time-text {
      font-size: 10px;
      font-weight: 700;
      line-height: 16px;
    }
    .time {
      font-size: 14px;
      font-weight: 700;
      line-height: 18px;
    }
  }
}
.big-box {
  z-index: 2002;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}
.BigCode {
  width: 100%;
  height: 100%;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
}
.el-icon-error {
  font-size: 50px;
  position: absolute;
  top: -36px;
  right: -39px;
  z-index: 3000;
}
.hidden {
  opacity: 0;
  visibility: hidden;
  position: fixed;
}
</style>
