<template>
  <div class="codeLayout">
    <div id="QRcode"></div>
  </div>
</template>

<script>
import QRCode from 'qrcodejs2'
export default {
  name: 'qrCodeCard',
  props: {
    msg: {
      type: String,
      default: ''
    }
  },
  data () {
    return {
      lessonType: {
        800: '1012-',
        801: '1012-',
        802: '1011-',
        803: '1010-',
        804: '1013-'
      }
    }
  },
  methods: {
    InitCodeRules (info) {
      let codeText = info
      const ele = document.querySelector('#QRcode')
      this.qrCode = new QRCode(ele, {
        text: codeText,
        width: '100',
        height: '100',
        colorDark: '#000000',
        colorLight: '#ffffff',
        correctLevel: QRCode.CorrectLevel.H
      })
    }
  },
  components: {
    QRCode
  },
  mounted () {
    this.InitCodeRules(this.msg)
  }
}
</script>

<style lang="scss" scoped>
.codeLayout{
  display: flex;
  flex-flow: column nowrap;
  justify-content: center;
  align-items: center;
  padding-bottom: .1rem;
}
</style>
