<template>
  <div class="codeLayout">
    <div id="QRcode"></div>
    <div class='text'>{{num}}</div>
  </div>
</template>

<script>
import QRCode from 'qrcodejs2'
export default {
  name: 'qrCodeCard',
  props: {
    msg: {
      type: Object,
      default: () => { }
    }
  },
  data () {
    return {
      num: ''
    }
  },
  methods: {
    InitCodeRules (info) {
      let codeText = `${this.msg.record_id}`
      this.num = codeText
      const ele = document.querySelector('#QRcode')
      this.qrCode = new QRCode(ele, {
        text: codeText,
        width: '150',
        height: '150',
        colorDark: '#000000',
        colorLight: '#ffffff',
        correctLevel: QRCode.CorrectLevel.H
      })
    }
  },
  components: {
    QRCode
  },
  mounted () {
    this.InitCodeRules()
  }
}
</script>

<style lang="scss" scoped>
.codeLayout {
  display: flex;
  flex-flow: column nowrap;
  justify-content: center;
  align-items: center;
  padding-bottom: 0.1rem;
}
.text {
  text-align: center;
  margin-top: 0.2rem;
  font-size: 0.14rem;
}
</style>
