You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.0 KiB

6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
  1. <template>
  2. <view class="pageBgImg">
  3. <topNavbar title="驾校二维码"></topNavbar>
  4. <view class="pad">
  5. <view class="card">
  6. <!-- <view class="refresh_row" @click="refresh">
  7. <view class="text">刷新二维码</view>
  8. <view class="icon">
  9. <image src="@/static/images/index/ic_shuaxin.png" mode=""></image>
  10. </view>
  11. </view> -->
  12. <view class="qcode">
  13. <canvas id="qrcode" canvas-id="qrcode" style="width: 200px;height: 200px;"></canvas>
  14. </view>
  15. </view>
  16. <view class="card">
  17. <user-info/>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import UQRCode from 'uqrcodejs';
  24. var qr = new UQRCode();
  25. export default {
  26. data() {
  27. return {
  28. }
  29. },
  30. onShow() {
  31. this.$nextTick(()=>{
  32. this.refresh()
  33. })
  34. },
  35. methods: {
  36. refresh() {
  37. let { schoolId, schoolName} = this.vuex_userInfo
  38. // 设置二维码内容
  39. qr.data = JSON.stringify({
  40. schoolId,
  41. schoolName: encodeURIComponent(schoolName),
  42. QrType: 1,
  43. isSchool: 1,
  44. })
  45. // 设置二维码大小,必须与canvas设置的宽高一致
  46. qr.size = 200;
  47. qr.margin = 10;
  48. qr.errorCorrectLevel = UQRCode.errorCorrectLevel.L
  49. // 调用制作二维码方法
  50. qr.make()
  51. qr.foregroundImageSrc = require('./coach.png')
  52. // 获取canvas上下文
  53. var canvasContext = uni.createCanvasContext('qrcode', this); // 如果是组件,this必须传入
  54. // 设置uQRCode实例的canvas上下文
  55. qr.canvasContext = canvasContext;
  56. // 调用绘制方法将二维码图案绘制到canvas上
  57. qr.drawCanvas();
  58. }
  59. }
  60. }
  61. </script>
  62. <style lang="scss" scoped>
  63. .qcode {
  64. width: 100%;
  65. display: flex;
  66. align-items: center;
  67. justify-content: center;
  68. padding: 50rpx 0;
  69. }
  70. .card {
  71. padding: 28rpx;
  72. margin-bottom: 24rpx;
  73. }
  74. .refresh_row {
  75. display: flex;
  76. justify-content: flex-end;
  77. align-items: center;
  78. padding: 10rpx 0;
  79. .text {
  80. color: $themC;
  81. font-size: 28rpx;
  82. }
  83. .icon {
  84. width: 24rpx;
  85. height: 24rpx;
  86. margin-left: 6rpx;
  87. }
  88. }
  89. </style>