bindInfo.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <view class="container" v-if="imageUrl || urlVal">
  3. <view class="qrcode-box x-c">
  4. <image class="qrcode" :src="imageUrl" mode="aspectFill" show-menu-by-longpress="true"></image>
  5. </view>
  6. <view class="share-inner">
  7. <view class="share-item">
  8. <view class="img">
  9. <u-icon name="share-square" size="30" color="#222"></u-icon>
  10. </view>
  11. <text class="text">分享</text>
  12. <button class='share-btn' open-type="share"></button>
  13. </view>
  14. <!-- <view class="share-item" @click="copyUrl()">
  15. <image src="https://cqtyt-2025.oss-cn-beijing.aliyuncs.com/huyi/images/icon_copy_link.png" mode=""></image>
  16. <text class="text">复制链接</text>
  17. </view> -->
  18. <!-- #ifndef H5 -->
  19. <view class="share-item" @click="downImg()">
  20. <view class="img">
  21. <u-icon name="download" size="30" color="#222"></u-icon>
  22. </view>
  23. <text class="text">保存图片</text>
  24. </view>
  25. <!-- #endif -->
  26. </view>
  27. </view>
  28. <u-empty style="padding-top: 20vh;" mode="data" v-else="imgurl"
  29. icon="https://cqtyt-2025.oss-cn-beijing.aliyuncs.com/huyi/imagesNew/cf4a86b913a04341bb44e34bb4d37aa2.png" text="暂无数据"></u-empty>
  30. </template>
  31. <script>
  32. import {
  33. getBindInfo
  34. } from "@/api/companyUser.js"
  35. export default {
  36. data() {
  37. return {
  38. imageUrl: '',
  39. urlVal: '',
  40. companyUserId: ''
  41. }
  42. },
  43. //发送给朋友
  44. onShareAppMessage(res) {
  45. console.log("fe===",this.imageUrl)
  46. return {
  47. title: '立即绑定,享受更多权益',
  48. path: '/pages_user/bindCompanyUser?companyUserId=' + this.companyUserId,
  49. imageUrl: this.imageUrl,
  50. }
  51. },
  52. //分享到朋友圈
  53. onShareTimeline(res) {
  54. return {
  55. title: '立即绑定,享受更多权益',
  56. query:'companyUserId='+this.companyUserId,//页面参数
  57. imageUrl: this.imageUrl
  58. }
  59. },
  60. onLoad() {
  61. this.companyUserId = uni.getStorageSync('companyUserId') || '';
  62. this.getInfo()
  63. },
  64. methods: {
  65. getInfo() {
  66. getBindInfo().then(res => {
  67. if (res.code == 200) {
  68. this.imageUrl = res.imageUrl
  69. this.urlVal = res.url
  70. } else {
  71. uni.showToast({
  72. title: res.msg,
  73. icon: 'none'
  74. })
  75. }
  76. })
  77. },
  78. copyUrl() {
  79. uni.setClipboardData({
  80. data: this.urlVal,
  81. success: () => {
  82. uni.showToast({
  83. title: '复制成功',
  84. icon: 'none'
  85. });
  86. },
  87. fail: () => {
  88. uni.showToast({
  89. title: '复制失败',
  90. icon: 'none'
  91. });
  92. }
  93. });
  94. },
  95. downImg() {
  96. uni.showLoading({
  97. title: "图片保存中..."
  98. })
  99. uni.downloadFile({
  100. url: this.imageUrl,
  101. fail: function(res) {
  102. uni.showModal({
  103. title: '提示',
  104. content: '保存失败',
  105. })
  106. uni.hideLoading();
  107. },
  108. success: function(res) {
  109. var tempFilePath = res.tempFilePath;
  110. uni.saveImageToPhotosAlbum({
  111. filePath: tempFilePath,
  112. success: () => {
  113. uni.showToast({
  114. title: "保存成功",
  115. duration: 2000
  116. })
  117. },
  118. fail: () => {
  119. console.log("图片失败");
  120. uni.showToast({
  121. title: "图片失败",
  122. duration: 2000,
  123. icon: "error"
  124. })
  125. uni.hideLoading();
  126. },
  127. complete: function() {
  128. uni.hideLoading();
  129. }
  130. })
  131. },
  132. })
  133. }
  134. }
  135. }
  136. </script>
  137. <style scoped lang="scss">
  138. .container {
  139. padding: 40rpx 0;
  140. padding-top: 16vh;
  141. box-sizing: border-box;
  142. display: flex;
  143. flex-direction: column;
  144. align-items: center;
  145. position: relative;
  146. }
  147. .qrcode-box {
  148. width: 480rpx;
  149. height: 480rpx;
  150. box-sizing: border-box;
  151. overflow: hidden;
  152. flex-direction: column !important;
  153. border-radius: 16rpx;
  154. background-color: #fff;
  155. font-family: PingFang SC, PingFang SC;
  156. font-weight: 400;
  157. font-size: 28rpx;
  158. color: #222;
  159. .qrcode {
  160. width: 450rpx;
  161. height: 450rpx;
  162. }
  163. .qrcode-title {
  164. font-weight: bold;
  165. font-size: 32rpx;
  166. color: #222;
  167. margin-bottom: 32rpx;
  168. }
  169. .qrcode-tip {
  170. margin: 32rpx;
  171. color: #999;
  172. text-align: center;
  173. }
  174. }
  175. .downbtn {
  176. width: 160rpx;
  177. min-height: 68rpx;
  178. border: 1px solid #FF5C03 !important;
  179. color: #FF5C03 !important;
  180. background-color: #fff !important;
  181. border-radius: 168rpx;
  182. font-family: PingFang SC, PingFang SC;
  183. font-weight: 400;
  184. font-size: 28rpx;
  185. &::after {
  186. border: none;
  187. }
  188. }
  189. .share-inner {
  190. width: 100%;
  191. box-sizing: border-box;
  192. padding: 0 10%;
  193. display: flex;
  194. flex-wrap: wrap;
  195. position: absolute;
  196. bottom: 0;
  197. left: 0;
  198. .share-item {
  199. flex: 1;
  200. display: flex;
  201. flex-direction: column;
  202. align-items: center;
  203. justify-content: center;
  204. margin-bottom: 66upx;
  205. position: relative;
  206. .img {
  207. width: 80upx;
  208. height: 80upx;
  209. margin-bottom: 20upx;
  210. background-color: #fff;
  211. display: flex;
  212. align-items: center;
  213. justify-content: center;
  214. border-radius: 50%;
  215. }
  216. image {
  217. width: 80upx;
  218. height: 80upx;
  219. margin-bottom: 20upx;
  220. }
  221. .text {
  222. font-size: 28upx;
  223. font-family: PingFang SC;
  224. font-weight: 500;
  225. color: #111111;
  226. line-height: 1;
  227. }
  228. }
  229. }
  230. .share-btn {
  231. position: absolute;
  232. left: 50%;
  233. top: 0;
  234. width: 80upx;
  235. height: 100%;
  236. transform: translateX(-50%);
  237. background-color: transparent !important;
  238. &::after {
  239. border: none;
  240. }
  241. }
  242. </style>