
<template>
  <div>
    <div class="left">
      <img
        class="tit-img"
        src="../../../assets/pass/shortIerm-tit.png"
        alt=""
      />
      <div class="flex">
        <div class="left2">
          <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="right2">
          <div class="tit">临时通行证</div>
          <div class="user-msg">
            <div>人员姓名：{{ itemData.name }}</div>
            <div>证件编号：{{ itemData.passSn }}</div>
            <div>单位名称：{{ itemData.username }}</div>
            <!-- <div>施工单位：贵州华欣源科技有限公司</div> -->
            <div>
              引领人：<span
                v-for="(item, index) in itemData.leaderList"
                :key="index"
                >{{ item.name }}；</span
              >
            </div>
            <div>通行区域：</div>
          </div>
          <div>
            <span
              :class="['area', item.choose ? 'choose-area' : '']"
              v-for="(item, index) in itemData.areaList"
              :key="index"
            >
              {{ item.name }}
            </span>
          </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"></i>
          <div ref="BigCode" class="big" alt="" @click="BlowUp" />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import QRCode from "qrcodejs2";
export default {
  props: {
    areaList: {
      type: Array,
      default() {
        return [];
      },
    },
    itemData: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  components: {},
  filters: {},
  computed: {},
  data() {
    return {
      showBigCord: false,
    };
  },
  created() {
    if (this.itemData.passSn) {
      this.getQRCode();
    }
  },
  watch: {},
  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">
.left {
  width: 222px;
  height: 345px;
  background-color: #babdaf;
  padding: 10px 16px 9px 14px;
  margin: 4px 6px;
  .tit-img {
    width: 126px;
    height: 25px;
    margin: 0 auto;
    display: block;
    margin-bottom: 8px;
  }
  .left2 {
    width: 49px;
    margin-right: 7px;
    .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;
    }
  }
  .right2 {
    width: 136px;
    .tit {
      font-size: 26px;
      font-weight: 600;
      letter-spacing: 0.84px;
      height: 36px;
      line-height: 36px;
    }
    .user-msg > div {
      width: 200px;
      font-size: 16px;
      -o-transform: scale(1);
      -webkit-transform-origin-x: 0;
      -webkit-transform: scale(0.75);
      transform: scale(0.75);
      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: 20px;
    }
    .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>
