forward.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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-title">PERILL团队发展动态评估</div>
  7. <div class="box-code adffcac">
  8. <div class="box-code-ewm">
  9. <canvas canvas-id="qrcode" style="width:274rpx;height:274rpx; position: fixed;left: -9999px;top: -9999px;"></canvas>
  10. <image v-if="qrCodeDataURL" :src="qrCodeDataURL" mode="scaleToFill" show-menu-by-longpress></image>
  11. </div>
  12. <div class="box-code-tip">长按保存小程序二维码</div>
  13. </div>
  14. </div>
  15. <button class="share-btn" open-type="share">立即分享</button>
  16. </div>
  17. </view>
  18. </template>
  19. <script>
  20. import { BaseApi } from '@/http/baseApi.js'
  21. import UQrcode from '@/uqrcode.js'
  22. export default {
  23. data(){
  24. return {
  25. imgBase:this.$imgBase,
  26. qrCodeDataURL:'',
  27. qrVal:'https://wxapp.transcend-intl.cn',
  28. }
  29. },
  30. onLoad() {
  31. this.generateQRCode();
  32. if(uni.getStorageSync('userInfo')){
  33. this.qrVal = `https://wxapp.transcend-intl.cn?shareUserId=${JSON.parse(uni.getStorageSync('userInfo'))?.id||''}`;
  34. }
  35. },
  36. methods:{
  37. onShareAppMessage(res) {
  38. const sharerId = JSON.parse(uni.getStorageSync('userInfo'))?.id||'';
  39. return {
  40. title: '创衡汇教练AI智能体',
  41. path: `/pages/home?shareUserId=${sharerId}&shareType=Forward`,
  42. };
  43. },
  44. async generateQRCode(){
  45. try {
  46. let that = this;
  47. // 确保DOM已经更新,canvas元素已准备好
  48. this.$nextTick(() => {
  49. UQrcode.make({
  50. canvasId: 'qrcode',
  51. componentInstance: this,
  52. text: that.qrVal,
  53. size: 137, // 对应 274rpx 的物理像素大小
  54. margin: 5,
  55. backgroundColor: '#ffffff',
  56. foregroundColor: '#000000',
  57. fileType: 'png',
  58. errorCorrectLevel: UQrcode.errorCorrectLevel.H,
  59. success: res => {
  60. uni.canvasToTempFilePath({
  61. canvasId: 'qrcode',
  62. fileType: 'png',
  63. quality: 1,
  64. success: (canvasRes) => {
  65. that.qrCodeDataURL = canvasRes.tempFilePath;
  66. },
  67. fail: (err) => {
  68. that.qrCodeDataURL = res;
  69. }
  70. }, this);
  71. }
  72. });
  73. });
  74. } catch { }
  75. },
  76. }
  77. }
  78. </script>
  79. <style scoped lang="scss">
  80. .share-btn {
  81. width: 100%;
  82. height: 88rpx;
  83. background: linear-gradient( 90deg, #33A7A7 0%, #4DB2B2 100%);
  84. border-radius: 44rpx;
  85. border: none;
  86. padding: 0;
  87. margin: 0;
  88. font-family: PingFang-SC, PingFang-SC;
  89. font-weight: bold;
  90. font-size: 32rpx;
  91. color: #FFFFFF;
  92. line-height: 88rpx;
  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 74rpx;
  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: 48rpx 50rpx;
  115. box-sizing: border-box;
  116. &-title{
  117. font-family: PingFang-SC, PingFang-SC;
  118. font-weight: bold;
  119. font-size: 32rpx;
  120. color: #FFFFFF;
  121. line-height: 36rpx;
  122. text-align: center;
  123. }
  124. &-code{
  125. background: #FFFFFF;
  126. border-radius: 8rpx;
  127. padding: 24rpx 45rpx;
  128. margin-top: 24rpx;
  129. &-ewm{
  130. width: 274rpx;
  131. height: 274rpx;
  132. image{
  133. width: 100%;
  134. height: 100%;
  135. }
  136. }
  137. &-tip{
  138. font-family: PingFangSC, PingFang SC;
  139. font-weight: 400;
  140. font-size: 24rpx;
  141. color: #002846;
  142. line-height: 24rpx;
  143. margin-top: 24rpx;
  144. }
  145. }
  146. }
  147. }
  148. </style>