share.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <view class="card-box">
  3. <lPainter ref="painter" css="position:relative;">
  4. <lPainterView :css="'background:#ffffff;border-radius:'+tovw(8)+';width:'+tovw(280)+';height:'+tovw(463)">
  5. <lPainterImage :src="imageUrl" :css="'width:'+tovw(280)+';height:'+tovw(200)+';border-radius:'+tovw(8)" object-fit="fill" />
  6. <lPainterView :css="'display: flex;flex-direction: column;margin:auto;align-items: center;position: absolute;bottom: '+tovw(25)+';width:'+tovw(140)">
  7. <lPainterView :css="'width:'+tovw(56)+';height:'+tovw(56)+';border-radius:50%;background:#ffffff'">
  8. <lPainterImage :src="userInfo.headpic || 'https://yossys06593.obs.cn-east-3.myhuaweicloud.com:443/202406011717209838416B6150695f.webp'" :css="'width:'+tovw(56)+';height:'+tovw(56)+';border-radius:50%;border: 2px solid #FFFFFF'" object-fit="fill" />
  9. </lPainterView>
  10. <lPainterView :css="'display: flex;align-items: center;align-content: center;font-family: Source Han Sans SC, Source Han Sans SC;padding-top:'+tovw(10)">
  11. <lPainterText :text="userInfo.name||'暂无'" :css="'font-weight: 500;font-size: '+tovw(18)+';color: #333333;'"></lPainterText>
  12. <lPainterView :css="'border: 1px solid #C30D23;padding-top:'+tovw(5)+';padding-bottom:'+tovw(5)+';padding-left:'+tovw(5)+';padding-right:'+tovw(5)+';margin-top:'+tovw(15)+';margin-bottom:'+tovw(15)+';margin-left:'+tovw(12)+';margin-right:'+tovw(12)+';color: #C30D23;border-radius:'+tovw(10)"><lPainterText :text="userInfo.rolenames||'暂无'" :css="'font-size:'+tovw(10)"></lPainterText></lPainterView>
  13. </lPainterView>
  14. <lPainterView :css="'margin-bottom: '+tovw(10)+';display: flex;align-items: center;align-content: center;align-self: self-start'">
  15. <lPainterImage src="/static/workbench/手机.svg" :css="'width:'+tovw(14)+';height:'+tovw(14)"></lPainterImage>
  16. <lPainterText :css="'margin-left: '+tovw(10)+';font-weight: 400;font-size: '+tovw(12)+';color: #666666;'" :text="userInfo.phonebumber||'暂无'"></lPainterText>
  17. </lPainterView>
  18. <lPainterView :css="'margin-bottom: '+tovw(21)+';display: flex;align-items: center;align-content: center;align-self: self-start'">
  19. <lPainterImage src="/static/workbench/邮箱.svg" :css="'width:'+tovw(14)+';height:'+tovw(14)"></lPainterImage>
  20. <lPainterText :css="'margin-left: '+tovw(10)+';font-weight: 400;font-size: '+tovw(12)+';color: #666666;'" :text="userInfo.email||'暂无'"></lPainterText>
  21. </lPainterView>
  22. <lPainterView :css="'display: flex;flex-direction: column;align-content: center;align-items: center;font-weight: 400;font-size: '+tovw(10)+';color: #999999'">
  23. <lPainterQrcode :text="qrCode + 'callingCard?userid=' + userid" :css="'width: '+tovw(70)+'; height: '+tovw(70)+';color:#000;'" />
  24. <lPainterText :css="'font-weight: 400;font-size: '+tovw(12)+';color: #666666;margin-top:'+tovw(5)" :text="'请长按扫码'"></lPainterText>
  25. </lPainterView>
  26. </lPainterView>
  27. </lPainterView>
  28. </lPainter>
  29. <view class="bottom">
  30. <view class="but" @click="loading?'':saveTheImage()" hover-class="navigator-hover">
  31. <u-loading-icon v-if="loading" color="#fff" />
  32. <text v-else>保存名片海报</text>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import lPainter from "../../uni_modules/lime-painter/components/l-painter/l-painter.vue"
  39. import lPainterView from "../../uni_modules/lime-painter/components/l-painter-view/l-painter-view.vue"
  40. import lPainterText from "../../uni_modules/lime-painter/components/l-painter-text/l-painter-text.vue"
  41. import lPainterImage from "../../uni_modules/lime-painter/components/l-painter-image/l-painter-image.vue"
  42. import lPainterQrcode from "../../uni_modules/lime-painter/components/l-painter-qrcode/l-painter-qrcode.vue"
  43. export default {
  44. components: { lPainter, lPainterView, lPainterText, lPainterImage, lPainterQrcode },
  45. data () {
  46. return {
  47. userInfo:{},
  48. userid:'',
  49. imageUrl:'',
  50. qrCode: this.qrCodePrefix,
  51. loading:false
  52. }
  53. },
  54. methods: {
  55. saveTheImage () {
  56. let that = this
  57. this.loading = true;
  58. this.$refs.painter.canvasToTempFilePathSync({
  59. fileType: "jpg",
  60. // 如果返回的是base64是无法使用 saveImageToPhotosAlbum,需要设置 pathType为url
  61. pathType: 'url',
  62. quality: 1,
  63. success: (res) => {
  64. // 非H5 保存到相册
  65. // H5 提示用户长按图另存
  66. uni.saveImageToPhotosAlbum({
  67. filePath: res.tempFilePath,
  68. success: function (e) {
  69. uni.showModal({
  70. title: '提示',
  71. content: '图片已保存到系统相册',
  72. showCancel: false
  73. })
  74. that.loading = false;
  75. },
  76. fail: ({ errMsg }) => {
  77. if (errMsg == 'saveImageToPhotosAlbum:fail auth deny') {
  78. uni.showModal({
  79. title: '提示',
  80. content: '请授权添加到相册权限后再试!',
  81. showCancel: false,
  82. complete: (complete) => {
  83. uni.openSetting({
  84. success: res => {
  85. that.loading = false;
  86. if (res.authSetting['scope.writePhotosAlbum']) {
  87. this.saveTheImage()
  88. } else {
  89. uni.showModal({
  90. title: '提示',
  91. content: '未获取授权!已取消保存',
  92. showCancel: false,
  93. })
  94. }
  95. }
  96. })
  97. },
  98. })
  99. } else {
  100. that.loading = false;
  101. uni.showModal({
  102. title: '提示',
  103. content: '已取消保存',
  104. showCancel: false,
  105. })
  106. }
  107. },
  108. });
  109. },
  110. });
  111. },
  112. async getuserInfo (id) {
  113. let res = await this.$Http.basic({
  114. "id": 20240514161502,
  115. "content": {
  116. userid:this.userid
  117. },
  118. })
  119. if (this.cutoff(res.msg)) return;
  120. this.userInfo = res.data
  121. this.userInfo.headpic = this.userInfo.attinfos.find(v => v.usetype == "headportrait") && this.userInfo.attinfos.find(v => v.usetype == "headportrait").url || '';
  122. console.log(this.userInfo,'用户信息');
  123. },
  124. async getImages () {
  125. let res = await this.$Http.basic({
  126. id:20240426154302,
  127. content: {
  128. systemclient:'wechatsaletool',
  129. locations:['business_card']
  130. }
  131. })
  132. if (res.data.business_card.length) {
  133. this.imageUrl = res.data.business_card[0].attinfos.length && res.data.business_card[0].attinfos[0].url
  134. }
  135. console.log(this.imageUrl,'海报广告图');
  136. }
  137. },
  138. onLoad (option) {
  139. this.userid = option.id
  140. this.getImages()
  141. this.getuserInfo()
  142. },
  143. onShareAppMessage(res) {
  144. return {
  145. title:this.userInfo.name+'的名片',
  146. path:'/cloud/businessCard/share?id='+this.userInfo.userid
  147. }
  148. }
  149. }
  150. </script>
  151. <style lang="scss">
  152. .card-box {
  153. width:280px;
  154. height: 463px;
  155. margin: 20px auto 0 auto;
  156. box-sizing: border-box;
  157. .bottom {
  158. display: flex;
  159. position: fixed;
  160. bottom: 0;
  161. left: 0;
  162. width: 375px;
  163. height: 64px;
  164. background: #FFFFFF;
  165. box-shadow: 0px -2px 6px 1px rgba(0, 0, 0, 0.16);
  166. box-sizing: border-box;
  167. z-index: 9999999;
  168. padding: 10px;
  169. .but {
  170. width: 355px;
  171. height: 45px;
  172. font-family: PingFang SC, PingFang SC;
  173. font-weight: 500;
  174. font-size: 14px;
  175. color: #FFFFFF;
  176. background: #C30D23;
  177. border-radius: 5px 5px 5px 5px;
  178. border: 1px solid #FFFFFF;
  179. display: flex;
  180. align-items: center;
  181. align-content: center;
  182. justify-content: space-evenly;
  183. }
  184. }
  185. }
  186. </style>