forward.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <view class="default_page adffc" :style="{'height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='转发推荐'></cus-header>
  4. <div class="all adffc">
  5. <div class="box adffcac">
  6. <div class="box-code adffcac">
  7. <div class="box-code-ewm">
  8. <canvas canvas-id="qrcode" style="width:274rpx;height:274rpx; position: fixed;left: -9999px;top: -9999px;"></canvas>
  9. <image v-if="qrCodeDataURL" :src="qrCodeDataURL" mode="scaleToFill" show-menu-by-longpress></image>
  10. </div>
  11. </div>
  12. <div class="box-code-tip">扫码立即体验</div>
  13. <button class="share-btn" open-type="share">点击分享</button>
  14. </div>
  15. </div>
  16. </view>
  17. </template>
  18. <script>
  19. import { BaseApi } from '@/http/baseApi.js'
  20. import UQrcode from '@/uqrcode.js'
  21. export default {
  22. data(){
  23. return {
  24. imgBase:this.$imgBase,
  25. qrCodeDataURL:'',
  26. qrVal:'https://wxapp.transcend-intl.cn',
  27. }
  28. },
  29. onLoad() {
  30. this.generateQRCode();
  31. if(uni.getStorageSync('userInfo')){
  32. this.qrVal = `https://wxapp.transcend-intl.cn?shareUserId=${JSON.parse(uni.getStorageSync('userInfo'))?.id||''}`;
  33. }
  34. },
  35. methods:{
  36. onShareAppMessage(res) {
  37. const sharerId = JSON.parse(uni.getStorageSync('userInfo'))?.id||'';
  38. return {
  39. title: '致力于帮助企业打造高价值创造团队',
  40. path: `/pages/home?shareUserId=${sharerId}&shareType=Forward`,
  41. };
  42. },
  43. async generateQRCode(){
  44. try {
  45. let that = this;
  46. // 确保DOM已经更新,canvas元素已准备好
  47. this.$nextTick(() => {
  48. UQrcode.make({
  49. canvasId: 'qrcode',
  50. componentInstance: this,
  51. text: that.qrVal,
  52. size: 137, // 对应 274rpx 的物理像素大小
  53. margin: 5,
  54. backgroundColor: '#ffffff',
  55. foregroundColor: '#000000',
  56. fileType: 'png',
  57. errorCorrectLevel: UQrcode.errorCorrectLevel.H,
  58. success: res => {
  59. uni.canvasToTempFilePath({
  60. canvasId: 'qrcode',
  61. fileType: 'png',
  62. quality: 1,
  63. success: (canvasRes) => {
  64. that.qrCodeDataURL = canvasRes.tempFilePath;
  65. },
  66. fail: (err) => {
  67. that.qrCodeDataURL = res;
  68. }
  69. }, this);
  70. }
  71. });
  72. });
  73. } catch { }
  74. },
  75. }
  76. }
  77. </script>
  78. <style scoped lang="scss">
  79. .share-btn {
  80. width: 100%;
  81. height: 88rpx;
  82. background: linear-gradient( 180deg, #CFD9A4 0%, #029292 100%);
  83. border-radius: 44rpx;
  84. border: none;
  85. padding: 0;
  86. margin: 0;
  87. font-family: SourceHanSansCN, SourceHanSansCN;
  88. font-weight: bold;
  89. font-size: 32rpx;
  90. color: #002846;
  91. line-height: 88rpx;
  92. letter-spacing: 2px;
  93. text-align: center;
  94. margin-top: 46rpx;
  95. &::after {
  96. border: none;
  97. }
  98. }
  99. .default_page{
  100. box-sizing: border-box;
  101. .all{
  102. width: 100%;
  103. flex: 1;
  104. padding: 0 30rpx 62rpx;
  105. box-sizing: border-box;
  106. justify-content: flex-end;
  107. background: url('https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/forward_bg.png') no-repeat;
  108. background-size: 100% 100%;
  109. }
  110. .box{
  111. width: 100%;
  112. background: rgba(255,255,255,0.14);
  113. border-radius: 16rpx;
  114. padding: 36rpx 172rpx;
  115. box-sizing: border-box;
  116. &-code{
  117. background: #FFFFFF;
  118. border-radius: 16rpx;
  119. padding: 24rpx 45rpx;
  120. &-ewm{
  121. width: 274rpx;
  122. height: 274rpx;
  123. image{
  124. width: 100%;
  125. height: 100%;
  126. }
  127. }
  128. &-tip{
  129. font-family: PingFangSC, PingFang SC;
  130. font-weight: 600;
  131. font-size: 50rpx;
  132. color: #FFFFFF;
  133. line-height: 50rpx;
  134. letter-spacing: 2px;
  135. margin-top: 24rpx;
  136. }
  137. }
  138. }
  139. }
  140. </style>