<template>
      <div class="weixin-pay-code">
        <div class="code-box">
          <div class="qrcode" v-show="!isShowCodeMask">
            <canvas id="wxPayQrCode"></canvas>
          </div>
          <div class="code-mask" v-show="isShowCodeMask">{{$t('payment.qrCodeHasExpired')}}</div>
          <div class="text">{{$t('payment.weChatSweepPayment')}}</div>
        </div>
        <div class="wx-bg">
          <img src="~/assets/images/wxPayBg.png" alt />
        </div>
      </div>
</template>

<script>
import QRCode from 'qrcode'
export default {
  data () {
    return {
      
    }
  },
  props: {
    isShowCodeMask: {
      type: Boolean,
      default: false
    },
    weixinCodeUrl: {
      type: String
    }

  },
  mounted () {
    this.wxPayCode()
  },
  methods: {
    // 生成微信支付二维码
    wxPayCode() {
      QRCode.toCanvas(document.getElementById('wxPayQrCode'), this.weixinCodeUrl, { version: 6, errorCorrectionLevel: 'L' })
    },
  },
}
</script>

<style scoped src='~/assets/css/weixin-pay.css'>
</style>
<style scoped>
  .weixin-pay-code {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
    border-top: 0;
  }

  .text {
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    margin-top: 10px;
  }
</style>
