support.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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':(mt*2+1278)+'rpx'}">
  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. }
  20. },
  21. onLoad() {
  22. this.generateQRCode();
  23. if(uni.getStorageSync('userInfo')){
  24. this.qrVal = `https://wxapp.transcend-intl.cn?shareUserId=${JSON.parse(uni.getStorageSync('userInfo'))?.id||''}`;
  25. }
  26. },
  27. methods:{
  28. handleTurn(){
  29. uni.navigateTo({
  30. url:'/pages/webView?src=https://appyf7rnhyg7811.h5.xiaoeknow.com'
  31. })
  32. },
  33. async generateQRCode(){
  34. try {
  35. let that = this;
  36. // 确保DOM已经更新,canvas元素已准备好
  37. this.$nextTick(() => {
  38. UQrcode.make({
  39. canvasId: 'qrcode',
  40. componentInstance: this,
  41. text: that.qrVal,
  42. size: 103, // 对应 216rpx 的物理像素大小
  43. margin: 5,
  44. backgroundColor: '#ffffff',
  45. foregroundColor: '#000000',
  46. fileType: 'png',
  47. errorCorrectLevel: UQrcode.errorCorrectLevel.H,
  48. success: res => {
  49. uni.canvasToTempFilePath({
  50. canvasId: 'qrcode',
  51. fileType: 'png',
  52. quality: 1,
  53. success: (canvasRes) => {
  54. that.qrCodeDataURL = canvasRes.tempFilePath;
  55. },
  56. fail: (err) => {
  57. that.qrCodeDataURL = res;
  58. }
  59. }, this);
  60. }
  61. });
  62. });
  63. } catch { }
  64. },
  65. }
  66. }
  67. </script>
  68. <style scoped lang="scss">
  69. .default_page{
  70. position: relative;
  71. }
  72. .code{
  73. width: 216rpx;
  74. height: 216rpx;
  75. background: #FFFFFF;
  76. border-radius: 16rpx;
  77. position: absolute;
  78. left: 50%;
  79. margin-left: -108rpx;
  80. image{
  81. width: 100%;
  82. height: 100%;
  83. border-radius: 18rpx;
  84. }
  85. }
  86. </style>