江西小程序管理端
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.

61 lines
1.5 KiB

1 year ago
11 months ago
1 year ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
1 year ago
11 months ago
1 year ago
  1. <template>
  2. <view class="pageBgImg">
  3. <topNavbar title="个人二维码"></topNavbar>
  4. <view class="pad">
  5. <view class="card">
  6. <view class="qcode">
  7. <canvas id="qrcode" canvas-id="qrcode" style="width: 200px;height: 200px;"></canvas>
  8. </view>
  9. </view>
  10. <view class="card">
  11. <user-info/>
  12. </view>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. import UQRCode from 'uqrcodejs';
  18. export default {
  19. onReady() {
  20. // 获取uQRCode实例
  21. var qr = new UQRCode();
  22. let {coachId, nickname, schoolId, tenantId} = this.vuex_userInfo.user
  23. // 设置二维码内容
  24. qr.data = JSON.stringify({
  25. coachId,
  26. schoolId,
  27. nickname: encodeURIComponent(nickname),
  28. schoolName: encodeURIComponent('必须与canvas设置的宽高一致/设置二维码大小')
  29. })
  30. // 设置二维码大小,必须与canvas设置的宽高一致
  31. qr.size = 200;
  32. qr.margin = 10;
  33. qr.errorCorrectLevel = UQRCode.errorCorrectLevel.L
  34. // 调用制作二维码方法
  35. qr.make()
  36. qr.foregroundImageSrc = require('./coach.png')
  37. // 获取canvas上下文
  38. var canvasContext = uni.createCanvasContext('qrcode', this); // 如果是组件,this必须传入
  39. // 设置uQRCode实例的canvas上下文
  40. qr.canvasContext = canvasContext;
  41. // 调用绘制方法将二维码图案绘制到canvas上
  42. qr.drawCanvas();
  43. }
  44. }
  45. </script>
  46. <style lang="scss" scoped>
  47. .qcode {
  48. width: 100%;
  49. height: 600rpx;
  50. display: flex;
  51. align-items: center;
  52. justify-content: center;
  53. }
  54. .card {
  55. padding: 28rpx;
  56. margin-bottom: 24rpx;
  57. }
  58. </style>