support.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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:108px;height:108px;border-radius: 8px; 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. // 确保DOM已经更新,canvas元素已准备好
  39. this.$nextTick(() => {
  40. UQrcode.make({
  41. canvasId: 'qrcode',
  42. componentInstance: this,
  43. text: that.qrVal,
  44. size: 108, // 对应 216rpx 的物理像素大小
  45. margin: 5,
  46. backgroundColor: '#ffffff',
  47. foregroundColor: '#000000',
  48. fileType: 'png',
  49. errorCorrectLevel: UQrcode.errorCorrectLevel.H,
  50. success: res => {
  51. uni.canvasToTempFilePath({
  52. canvasId: 'qrcode',
  53. fileType: 'png',
  54. quality: 1,
  55. success: (canvasRes) => {
  56. that.qrCodeDataURL = canvasRes.tempFilePath;
  57. },
  58. fail: (err) => {
  59. that.qrCodeDataURL = res;
  60. }
  61. }, this);
  62. }
  63. });
  64. });
  65. } catch { }
  66. },
  67. }
  68. }
  69. </script>
  70. <style scoped lang="scss">
  71. .default_page{
  72. position: relative;
  73. }
  74. .code{
  75. width: 108px;
  76. height: 108px;
  77. background: #FFFFFF;
  78. border-radius: 8px;
  79. position: absolute;
  80. left: 50%;
  81. margin-left: -54px;
  82. image{
  83. width: 100%;
  84. height: 100%;
  85. border-radius: 8px;
  86. }
  87. }
  88. </style>