support.vue 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <view class="default_page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='专业支持'></cus-header>
  4. <image style="width: 100%;" :src="imgBase+'support.png'" mode="widthFix" @click="handleTurn"></image>
  5. <div class="code" :style="{'top':codetop+'px'}">
  6. <canvas canvas-id="qrcode" style="width:216rpx;height:216rpx;border-radius: 16rpx; position: fixed;left: -9999px;top: -9999px;"></canvas>
  7. <image v-if="qrCodeDataURL" :src="qrCodeDataURL" mode="scaleToFill" show-menu-by-longpress></image>
  8. </div>
  9. </view>
  10. </template>
  11. <script>
  12. import UQrcode from '@/uqrcode.js'
  13. export default {
  14. data(){
  15. return {
  16. imgBase:this.$imgBase,
  17. qrCodeDataURL:'',
  18. qrVal:'https://wxapp.transcend-intl.cn',
  19. codetop:0,
  20. }
  21. },
  22. onLoad() {
  23. this.codetop = uni.upx2px(this.mt*2+1278);
  24. this.generateQRCode();
  25. if(uni.getStorageSync('userInfo')){
  26. this.qrVal = `https://wxapp.transcend-intl.cn?shareUserId=${JSON.parse(uni.getStorageSync('userInfo'))?.id||''}`;
  27. }
  28. },
  29. methods:{
  30. handleTurn(){
  31. uni.navigateTo({
  32. url:'/pages/webView?src=https://appyf7rnhyg7811.h5.xiaoeknow.com'
  33. })
  34. },
  35. async generateQRCode(){
  36. try {
  37. let that = this;
  38. const canvasSizePx = uni.upx2px(216);
  39. // 确保DOM已经更新,canvas元素已准备好
  40. this.$nextTick(() => {
  41. UQrcode.make({
  42. canvasId: 'qrcode',
  43. componentInstance: this,
  44. text: that.qrVal,
  45. size: canvasSizePx, // 对应 216rpx 的物理像素大小
  46. margin: 5,
  47. backgroundColor: '#ffffff',
  48. foregroundColor: '#000000',
  49. fileType: 'png',
  50. errorCorrectLevel: UQrcode.errorCorrectLevel.H,
  51. success: res => {
  52. uni.canvasToTempFilePath({
  53. canvasId: 'qrcode',
  54. fileType: 'png',
  55. quality: 1,
  56. success: (canvasRes) => {
  57. that.qrCodeDataURL = canvasRes.tempFilePath;
  58. },
  59. fail: (err) => {
  60. that.qrCodeDataURL = res;
  61. }
  62. }, this);
  63. }
  64. });
  65. });
  66. } catch { }
  67. },
  68. }
  69. }
  70. </script>
  71. <style scoped lang="scss">
  72. .default_page{
  73. position: relative;
  74. }
  75. .code{
  76. width: 216rpx;
  77. height: 216rpx;
  78. background: #FFFFFF;
  79. border-radius: 16rpx;
  80. position: absolute;
  81. left: 50%;
  82. margin-left: -108rpx;
  83. image{
  84. width: 100%;
  85. height: 100%;
  86. border-radius: 18rpx;
  87. }
  88. }
  89. </style>