wechatbind.vue 9.3 KB

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