scan.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. emplate>
  2. <div class="login-scan-container">
  3. <div ref="qrcodeRef"></div>
  4. <div class="font12 mt20 login-msg">
  5. <i class="iconfont icon-saoyisao mr5"></i>
  6. <span>{{ $t('message.scan.text') }}</span>
  7. </div>
  8. </div>
  9. </template>
  10. <script setup lang="ts" name="loginScan">
  11. import { ref, onMounted, nextTick } from 'vue';
  12. import QRCode from 'qrcodejs2-fixes';
  13. // 定义变量内容
  14. const qrcodeRef = ref<HTMLElement | null>(null);
  15. // 初始化生成二维码
  16. const initQrcode = () => {
  17. nextTick(() => {
  18. (<HTMLElement>qrcodeRef.value).innerHTML = '';
  19. new QRCode(qrcodeRef.value, {
  20. text: `https://qm.qq.com/cgi-bin/qm/qr?k=RdUY97Vx0T0vZ_1OOu-X1yFNkWgDwbjC&jump_from=webapi`,
  21. width: 260,
  22. height: 260,
  23. colorDark: '#000000',
  24. colorLight: '#ffffff',
  25. });
  26. });
  27. };
  28. // 页面加载时
  29. onMounted(() => {
  30. initQrcode();
  31. });
  32. </script>
  33. <style scoped lang="scss">
  34. .login-scan-animation {
  35. opacity: 0;
  36. animation-name: error-num;
  37. animation-duration: 0.5s;
  38. animation-fill-mode: forwards;
  39. }
  40. .login-scan-container {
  41. padding: 0 20px 20px;
  42. display: flex;
  43. flex-direction: column;
  44. text-align: center;
  45. @extend .login-scan-animation;
  46. animation-delay: 0.1s;
  47. :deep(img) {
  48. margin: auto;
  49. }
  50. .login-msg {
  51. display: flex;
  52. align-items: center;
  53. justify-content: center;
  54. color: var(--el-text-color-placeholder);
  55. @extend .login-scan-animation;
  56. animation-delay: 0.2s;
  57. }
  58. }
  59. </style>