wechatbind.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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/202404231713854678447B26b4363.svg'"
  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. this.userMsg = res.data;
  70. this.name = res.data.enterprise_hr.name ? res.data.enterprise_hr.name + ',邀请您加入' : '邀请您加入'
  71. })
  72. },
  73. saveTheImage() {
  74. let that = this;
  75. this.loading = true;
  76. this.$refs.painter.canvasToTempFilePathSync({
  77. fileType: "jpg",
  78. // 如果返回的是base64是无法使用 saveImageToPhotosAlbum,需要设置 pathType为url
  79. pathType: 'url',
  80. quality: 1,
  81. success: (res) => {
  82. // 非H5 保存到相册
  83. // H5 提示用户长按图另存
  84. uni.saveImageToPhotosAlbum({
  85. filePath: res.tempFilePath,
  86. success: function (e) {
  87. uni.showModal({
  88. title: '提示',
  89. content: '图片已保存到系统相册',
  90. showCancel: false
  91. })
  92. that.loading = false;
  93. this.$Http.basic({
  94. "id": 20240319142702,
  95. "content": {
  96. sat_sharematerialid: that.detail.sat_sharematerialid, type: 1
  97. }
  98. }).then(res => {
  99. console.log(type, '记录', res)
  100. })
  101. },
  102. fail: ({ errMsg }) => {
  103. if (errMsg == 'saveImageToPhotosAlbum:fail auth deny') {
  104. uni.showModal({
  105. title: '提示',
  106. content: '请授权添加到相册权限后再试!',
  107. showCancel: false,
  108. complete: (complete) => {
  109. uni.openSetting({
  110. success: res => {
  111. that.loading = false;
  112. if (res.authSetting['scope.writePhotosAlbum']) {
  113. this.saveTheImage()
  114. } else {
  115. uni.showModal({
  116. title: '提示',
  117. content: '未获取授权!已取消保存',
  118. showCancel: false,
  119. })
  120. }
  121. }
  122. })
  123. },
  124. })
  125. } else {
  126. that.loading = false;
  127. uni.showModal({
  128. title: '提示',
  129. content: '已取消保存',
  130. showCancel: false,
  131. })
  132. }
  133. },
  134. });
  135. },
  136. });
  137. },
  138. onBack() {
  139. uni.navigateBack();
  140. },
  141. getSheraDate() {
  142. return {
  143. title: this.name, // 标题
  144. path: "/pages/index/index?wechatBindUserid=" + this.userid + '&userName=' + this.userName, // 分享路径
  145. imageUrl: ""// 分享图
  146. };
  147. }
  148. },
  149. onShareAppMessage(res) {
  150. return this.getSheraDate()
  151. }
  152. }
  153. </script>
  154. <style lang="scss" scoped>
  155. .head {
  156. position: relative;
  157. width: 100vw;
  158. .custom {
  159. position: absolute;
  160. width: 100vw;
  161. display: flex;
  162. justify-content: center;
  163. align-items: center;
  164. font-family: PingFang SC, PingFang SC;
  165. font-weight: 500;
  166. font-size: 17px;
  167. color: #FFFFFF;
  168. .back {
  169. position: absolute;
  170. padding: 0 10px;
  171. left: 0;
  172. color: #fff;
  173. font-size: 12px;
  174. transform: rotateY(180deg);
  175. }
  176. }
  177. }
  178. .painter-box {
  179. display: flex;
  180. justify-content: center;
  181. margin-top: 25px;
  182. }
  183. .share {
  184. display: flex;
  185. justify-content: space-around;
  186. width: 275px;
  187. margin: 30px auto 0;
  188. .item {
  189. display: flex;
  190. align-items: center;
  191. justify-content: center;
  192. width: 48px;
  193. height: 48px;
  194. border-radius: 50%;
  195. background: rgba(255, 255, 255, 0.3);
  196. overflow: hidden;
  197. .iconfont {
  198. font-size: 28px;
  199. color: #fff;
  200. }
  201. }
  202. }
  203. .footer {
  204. position: fixed;
  205. bottom: 0;
  206. display: flex;
  207. justify-content: space-between;
  208. width: 100vw;
  209. height: 65px;
  210. background: #FFFFFF;
  211. box-shadow: 0px -2px 6px 1px rgba(0, 0, 0, 0.16);
  212. padding: 5px 10px;
  213. box-sizing: border-box;
  214. .insert {
  215. display: flex;
  216. align-items: center;
  217. justify-content: center;
  218. width: 168px;
  219. height: 45px;
  220. background: #FFFFFF;
  221. border-radius: 5px;
  222. border: 1px solid #999999;
  223. font-family: PingFang SC, PingFang SC;
  224. font-size: 16px;
  225. color: #666666;
  226. box-sizing: border-box;
  227. margin-right: 10px;
  228. }
  229. .invite {
  230. display: flex;
  231. align-items: center;
  232. justify-content: center;
  233. width: 177px;
  234. height: 45px;
  235. background: #C30D23;
  236. border-radius: 5px;
  237. font-family: PingFang SC, PingFang SC;
  238. font-weight: 500;
  239. font-size: 16px;
  240. color: #FFFFFF;
  241. }
  242. }
  243. </style>