share.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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.headpoc || 'https://yossys06593.obs.cn-east-3.myhuaweicloud.com:443/202404231713854678447B26b4363.svg'" :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. console.log(this.userInfo,'用户信息');
  122. },
  123. async getImages () {
  124. let res = await this.$Http.basic({
  125. id:20240426154302,
  126. content: {
  127. systemclient:'wechatsaletool',
  128. locations:['business_card']
  129. }
  130. })
  131. if (res.data.business_card.length) {
  132. this.imageUrl = res.data.business_card[0].attinfos.length && res.data.business_card[0].attinfos[0].url
  133. }
  134. console.log(this.imageUrl,'海报广告图');
  135. }
  136. },
  137. onLoad (option) {
  138. this.userid = option.id
  139. this.getImages()
  140. this.getuserInfo()
  141. },
  142. onShareAppMessage(res) {
  143. return {
  144. title:this.userInfo.name+'的名片',
  145. path:'/cloud/businessCard/share?id='+this.userInfo.userid
  146. }
  147. }
  148. }
  149. </script>
  150. <style lang="scss">
  151. .card-box {
  152. width:280px;
  153. height: 463px;
  154. margin: 20px auto 0 auto;
  155. box-sizing: border-box;
  156. .bottom {
  157. display: flex;
  158. position: fixed;
  159. bottom: 0;
  160. left: 0;
  161. width: 375px;
  162. height: 64px;
  163. background: #FFFFFF;
  164. box-shadow: 0px -2px 6px 1px rgba(0, 0, 0, 0.16);
  165. box-sizing: border-box;
  166. z-index: 9999999;
  167. padding: 10px;
  168. .but {
  169. width: 355px;
  170. height: 45px;
  171. font-family: PingFang SC, PingFang SC;
  172. font-weight: 500;
  173. font-size: 14px;
  174. color: #FFFFFF;
  175. background: #C30D23;
  176. border-radius: 5px 5px 5px 5px;
  177. border: 1px solid #FFFFFF;
  178. display: flex;
  179. align-items: center;
  180. align-content: center;
  181. justify-content: space-evenly;
  182. }
  183. }
  184. }
  185. </style>