Invite-staff.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <ax-body blank="0" title="">
  3. <view class="invite-staff-bg">
  4. <image :src="bg_img" mode="widthFix"></image>
  5. </view>
  6. <view class="invite-staff-box">
  7. <view class="attend-card-box" @longpress="longpressTap">
  8. <view class="userinfo-box">
  9. <image class="user-avatar" :src="avatar_img" mode=""></image>
  10. <view class="user-nikename">{{userinfo.nickName?userinfo.nickName:'匿名'}}</view>
  11. </view>
  12. <view class="card-img-box">
  13. <image :src="card_img" mode="widthFix"></image>
  14. </view>
  15. <view class="card-qrcode-box">
  16. <!-- <image class="card-qrcode" src="@/static/img/1111.png"></image> -->
  17. </view>
  18. <view class="tips-text">长按识别二维码</view>
  19. </view>
  20. <view class="bottom-tips-text">
  21. <image src="@/static/img/tips-icon.svg" mode=""></image>
  22. <text>长按上方海报发送给好友</text>
  23. </view>
  24. </view>
  25. <r-canvas ref="rCanvas"></r-canvas>
  26. </ax-body>
  27. </template>
  28. <script>
  29. import rCanvas from "@/components/r-canvas/r-canvas.vue"
  30. export default {
  31. components: {
  32. rCanvas
  33. },
  34. data() {
  35. return {
  36. bg_img: 'https://hyxhsh.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/yzBqSYi5PEsId74406272837cf072c83825d28c270d3.png/1.png',
  37. card_img: '/static/img/enterprise_playbil.jpg',
  38. // avatar_img:'https://hyxhsh.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/IBN033tZBgCeb082e48d7fc55ab5c8e84b890c41f169.png/1.png',
  39. isImageLoaded: false,
  40. userinfo:{}
  41. }
  42. },
  43. onLoad() {
  44. this.userinfo=this.$app.storage.get('USER_INFO')
  45. },
  46. onReady() {},
  47. methods: {
  48. longpressTap() {
  49. this.get_downloadImg()
  50. },
  51. async get_downloadImg() {
  52. this.$nextTick(async () => {
  53. await this.$refs.rCanvas.init({
  54. canvas_id: "rCanvas"
  55. })
  56. await this.$refs.rCanvas.setCanvasWidth(319)
  57. await this.$refs.rCanvas.setCanvasHeight(414)
  58. // 背景卡片
  59. await this.$refs.rCanvas.drawImage({
  60. url: this.card_img,
  61. x: -10,
  62. y: 30,
  63. w: 338,
  64. h: 395
  65. }).catch(err_msg => {
  66. uni.showToast({
  67. title: err_msg,
  68. icon: "none"
  69. })
  70. })
  71. // 头像
  72. await this.$refs.rCanvas.drawImage({
  73. url:this.avatar_img,
  74. x:134,
  75. y:0,
  76. w: 50,
  77. h: 50
  78. }).catch(err_msg => {
  79. uni.showToast({
  80. title: err_msg,
  81. icon: "none"
  82. })
  83. })
  84. // 二维码
  85. // await this.$refs.rCanvas.drawImage({
  86. // url:'/static/img/1111.png',
  87. // x:134,
  88. // y:0,
  89. // w: 50,
  90. // h: 50
  91. // }).catch(err_msg => {
  92. // uni.showToast({
  93. // title: err_msg,
  94. // icon: "none"
  95. // })
  96. // })
  97. //文字
  98. await this.$refs.rCanvas.drawText({
  99. text:this.userinfo.nickName?userinfo.nickName:'匿名用户',
  100. max_width: 0,
  101. x:132,
  102. y:70,
  103. font_color: "#181818",
  104. font_size: 14
  105. }).catch(err_msg => {
  106. uni.showToast({
  107. title: err_msg,
  108. icon: "none"
  109. })
  110. })
  111. await this.$refs.rCanvas.drawText({
  112. text: "长按识别二维码",
  113. max_width: 0,
  114. x:108,
  115. y:386,
  116. font_color: "#181818",
  117. font_size: 14
  118. }).catch(err_msg => {
  119. uni.showToast({
  120. title: err_msg,
  121. icon: "none"
  122. })
  123. })
  124. // 生成海报
  125. await this.$refs.rCanvas.draw((res) => {
  126. //res.tempFilePath:生成成功,返回base64图片
  127. uni.showShareImageMenu({
  128. path: res.tempFilePath,
  129. success: (res) => console.log('分享成功', res),
  130. fail: (err) => console.error('分享失败', err),
  131. });
  132. // this.$refs.rCanvas.saveImage(res.tempFilePath)
  133. })
  134. })
  135. }
  136. }
  137. }
  138. </script>
  139. <style scoped>
  140. @import url("Invite-staff.css");
  141. </style>