wechatbind.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <view>
  3. <view class="painter-box" v-if="userMsg.userid" style="">
  4. <view>
  5. <l-painter ref="painter" css="position: relative;width: 280px; height: 426px">
  6. <l-painter-image
  7. src="https://yossys06593.obs.cn-east-3.myhuaweicloud.com:443/202405151715764356769B1a729abd.webp"
  8. css="width: 280px; height: 426px;position: absolute;" />
  9. <l-painter-image
  10. :src="userMsg.headpic || 'https://yossys06593.obs.cn-east-3.myhuaweicloud.com:443/202406011717209838416B6150695f.webp'"
  11. css="width: 56px; height:56px;border-radius: 50%;position: absolute;top:20px;left:20px;z-index:2;"
  12. object-fit="fill" />
  13. <l-painter-text :text="name"
  14. css="width:180px;line-height:24px;height:24px;position: absolute;left:86px;top:21px;z-index:2;font-family: Source Han Sans SC, Source Han Sans SC;font-weight: 500;font-size: 16px;color: #333333; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;" />
  15. <l-painter-text :text="userMsg.areaname"
  16. css="width:180px;line-height:20px;height:20px;position: absolute;left:86px;top:55px;z-index:2;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;font-family: Source Han Sans SC, Source Han Sans SC;font-size: 14px;color: #666666;" />
  17. <l-painter-text text="扫码绑定微信"
  18. css="width:72px;line-height:17px;position: absolute;left:50%;bottom:269px;z-index:2;margin-left:-36px;font-size: 12px;color: #666666;font-family: PingFang SC, PingFang SC;" />
  19. <l-painter-qrcode :text="qrCode + 'wechatBind?wechatBindUserid=' + userid + '&userName=' + userName"
  20. css="width: 200px; height: 200px;position: absolute;left:50%;bottom:55px;z-index:2;margin-left:-100px;" />
  21. </l-painter>
  22. </view>
  23. </view>
  24. <view style="height: 70px;" />
  25. <view class="footer">
  26. <view class="invite" style="flex: 1;" hover-class="navigator-hover" @click="saveTheImage">
  27. 保存图片
  28. </view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import lPainter from "../../uni_modules/lime-painter/components/l-painter/l-painter.vue"
  34. import lPainterView from "../../uni_modules/lime-painter/components/l-painter-view/l-painter-view.vue"
  35. import lPainterText from "../../uni_modules/lime-painter/components/l-painter-text/l-painter-text.vue"
  36. import lPainterImage from "../../uni_modules/lime-painter/components/l-painter-image/l-painter-image.vue"
  37. import lPainterQrcode from "../../uni_modules/lime-painter/components/l-painter-qrcode/l-painter-qrcode.vue"
  38. import contact from "../../components/contact"
  39. export default {
  40. components: { lPainter, lPainterView, lPainterText, lPainterImage, lPainterQrcode, contact },
  41. data() {
  42. return {
  43. userMsg: {
  44. userid: 0
  45. },
  46. qrCode: this.qrCodePrefix,
  47. name: "",
  48. userid: 0,
  49. userName: ""
  50. }
  51. },
  52. onLoad(options) {
  53. console.log(options)
  54. this.userid = options.id;
  55. this.userName = options.name;
  56. uni.setNavigationBarTitle({
  57. title: '绑定微信'
  58. });
  59. this.getUserMsg()
  60. },
  61. methods: {
  62. getUserMsg() {
  63. this.$Http.basic({
  64. "id": 20240510104102,
  65. "content": {},
  66. }).then(res => {
  67. console.log("获取个人信息", res)
  68. if (this.cutoff(res.msg)) return;
  69. res.data.headpic = res.data.attinfos.find(v => v.usetype == "headportrait") && res.data.attinfos.find(v => v.usetype == "headportrait").url || '';
  70. this.userMsg = res.data;
  71. this.name = res.data.enterprise_hr.name ? res.data.enterprise_hr.name + ',邀请您加入' : '邀请您加入'
  72. })
  73. },
  74. saveTheImage() {
  75. let that = this;
  76. this.loading = true;
  77. this.$refs.painter.canvasToTempFilePathSync({
  78. fileType: "jpg",
  79. // 如果返回的是base64是无法使用 saveImageToPhotosAlbum,需要设置 pathType为url
  80. pathType: 'url',
  81. quality: 1,
  82. success: (res) => {
  83. // 非H5 保存到相册
  84. // H5 提示用户长按图另存
  85. uni.saveImageToPhotosAlbum({
  86. filePath: res.tempFilePath,
  87. success: function (e) {
  88. uni.showModal({
  89. title: '提示',
  90. content: '图片已保存到系统相册',
  91. showCancel: false
  92. })
  93. that.loading = false;
  94. that.$Http.basic({
  95. "id": 20240319142702,
  96. "content": {
  97. sat_sharematerialid: that.detail.sat_sharematerialid, type: 1
  98. }
  99. }).then(res => {
  100. console.log(type, '记录', res)
  101. })
  102. },
  103. fail: ({ errMsg }) => {
  104. if (errMsg == 'saveImageToPhotosAlbum:fail auth deny') {
  105. uni.showModal({
  106. title: '提示',
  107. content: '请授权添加到相册权限后再试!',
  108. showCancel: false,
  109. complete: (complete) => {
  110. uni.openSetting({
  111. success: res => {
  112. that.loading = false;
  113. if (res.authSetting['scope.writePhotosAlbum']) {
  114. this.saveTheImage()
  115. } else {
  116. uni.showModal({
  117. title: '提示',
  118. content: '未获取授权!已取消保存',
  119. showCancel: false,
  120. })
  121. }
  122. }
  123. })
  124. },
  125. })
  126. } else {
  127. that.loading = false;
  128. uni.showModal({
  129. title: '提示',
  130. content: '已取消保存',
  131. showCancel: false,
  132. })
  133. }
  134. },
  135. });
  136. },
  137. });
  138. },
  139. onBack() {
  140. uni.navigateBack();
  141. },
  142. getSheraDate() {
  143. return {
  144. title: this.name, // 标题
  145. path: "/pages/index/index?wechatBindUserid=" + this.userid + '&userName=' + this.userName, // 分享路径
  146. imageUrl: ""// 分享图
  147. };
  148. }
  149. },
  150. onShareAppMessage(res) {
  151. return this.getSheraDate()
  152. }
  153. }
  154. </script>
  155. <style lang="scss" scoped>
  156. .head {
  157. position: relative;
  158. width: 100vw;
  159. .custom {
  160. position: absolute;
  161. width: 100vw;
  162. display: flex;
  163. justify-content: center;
  164. align-items: center;
  165. font-family: PingFang SC, PingFang SC;
  166. font-weight: 500;
  167. font-size: 17px;
  168. color: #FFFFFF;
  169. .back {
  170. position: absolute;
  171. padding: 0 10px;
  172. left: 0;
  173. color: #fff;
  174. font-size: 12px;
  175. transform: rotateY(180deg);
  176. }
  177. }
  178. }
  179. .painter-box {
  180. display: flex;
  181. justify-content: center;
  182. margin-top: 25px;
  183. }
  184. .share {
  185. display: flex;
  186. justify-content: space-around;
  187. width: 275px;
  188. margin: 30px auto 0;
  189. .item {
  190. display: flex;
  191. align-items: center;
  192. justify-content: center;
  193. width: 48px;
  194. height: 48px;
  195. border-radius: 50%;
  196. background: rgba(255, 255, 255, 0.3);
  197. overflow: hidden;
  198. .iconfont {
  199. font-size: 28px;
  200. color: #fff;
  201. }
  202. }
  203. }
  204. .footer {
  205. position: fixed;
  206. bottom: 0;
  207. display: flex;
  208. justify-content: space-between;
  209. width: 100vw;
  210. height: 65px;
  211. background: #FFFFFF;
  212. box-shadow: 0px -2px 6px 1px rgba(0, 0, 0, 0.16);
  213. padding: 5px 10px;
  214. box-sizing: border-box;
  215. .insert {
  216. display: flex;
  217. align-items: center;
  218. justify-content: center;
  219. width: 168px;
  220. height: 45px;
  221. background: #FFFFFF;
  222. border-radius: 5px;
  223. border: 1px solid #999999;
  224. font-family: PingFang SC, PingFang SC;
  225. font-size: 16px;
  226. color: #666666;
  227. box-sizing: border-box;
  228. margin-right: 10px;
  229. }
  230. .invite {
  231. display: flex;
  232. align-items: center;
  233. justify-content: center;
  234. width: 177px;
  235. height: 45px;
  236. background: #C30D23;
  237. border-radius: 5px;
  238. font-family: PingFang SC, PingFang SC;
  239. font-weight: 500;
  240. font-size: 16px;
  241. color: #FFFFFF;
  242. }
  243. }
  244. </style>