forward.vue 3.9 KB

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