bindInfo.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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="/static/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://cos.his.cdwjyyh.com/fs/20240423/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. // imageUrl: 'https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20230106/6b459adfb1004c1a96219bcdf07e337c.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  51. }
  52. },
  53. //分享到朋友圈
  54. onShareTimeline(res) {
  55. return {
  56. title: '立即绑定,享受更多权益',
  57. query:'companyUserId='+this.companyUserId,//页面参数
  58. imageUrl: this.imageUrl
  59. }
  60. },
  61. onLoad() {
  62. this.companyUserId = uni.getStorageSync('companyUserId') || '';
  63. this.getInfo()
  64. },
  65. methods: {
  66. getInfo() {
  67. getBindInfo().then(res => {
  68. if (res.code == 200) {
  69. this.imageUrl = res.imageUrl
  70. this.urlVal = res.url
  71. } else {
  72. uni.showToast({
  73. title: res.msg,
  74. icon: 'none'
  75. })
  76. }
  77. })
  78. },
  79. copyUrl() {
  80. uni.setClipboardData({
  81. data: this.urlVal,
  82. success: () => {
  83. uni.showToast({
  84. title: '复制成功',
  85. icon: 'none'
  86. });
  87. },
  88. fail: () => {
  89. uni.showToast({
  90. title: '复制失败',
  91. icon: 'none'
  92. });
  93. }
  94. });
  95. },
  96. downImg() {
  97. uni.showLoading({
  98. title: "图片保存中..."
  99. })
  100. uni.downloadFile({
  101. url: this.imageUrl,
  102. fail: function(res) {
  103. uni.showModal({
  104. title: '提示',
  105. content: '保存失败',
  106. })
  107. uni.hideLoading();
  108. },
  109. success: function(res) {
  110. var tempFilePath = res.tempFilePath;
  111. uni.saveImageToPhotosAlbum({
  112. filePath: tempFilePath,
  113. success: () => {
  114. uni.showToast({
  115. title: "保存成功",
  116. duration: 2000
  117. })
  118. },
  119. fail: () => {
  120. console.log("图片失败");
  121. uni.showToast({
  122. title: "图片失败",
  123. duration: 2000,
  124. icon: "error"
  125. })
  126. uni.hideLoading();
  127. },
  128. complete: function() {
  129. uni.hideLoading();
  130. }
  131. })
  132. },
  133. })
  134. }
  135. }
  136. }
  137. </script>
  138. <style scoped lang="scss">
  139. .container {
  140. padding: 40rpx 0;
  141. padding-top: 16vh;
  142. box-sizing: border-box;
  143. display: flex;
  144. flex-direction: column;
  145. align-items: center;
  146. position: relative;
  147. }
  148. .qrcode-box {
  149. width: 480rpx;
  150. height: 480rpx;
  151. box-sizing: border-box;
  152. overflow: hidden;
  153. flex-direction: column !important;
  154. border-radius: 16rpx;
  155. background-color: #fff;
  156. font-family: PingFang SC, PingFang SC;
  157. font-weight: 400;
  158. font-size: 28rpx;
  159. color: #222;
  160. .qrcode {
  161. width: 450rpx;
  162. height: 450rpx;
  163. }
  164. .qrcode-title {
  165. font-weight: bold;
  166. font-size: 32rpx;
  167. color: #222;
  168. margin-bottom: 32rpx;
  169. }
  170. .qrcode-tip {
  171. margin: 32rpx;
  172. color: #999;
  173. text-align: center;
  174. }
  175. }
  176. .downbtn {
  177. width: 160rpx;
  178. min-height: 68rpx;
  179. border: 1px solid #FF5C03 !important;
  180. color: #FF5C03 !important;
  181. background-color: #fff !important;
  182. border-radius: 168rpx;
  183. font-family: PingFang SC, PingFang SC;
  184. font-weight: 400;
  185. font-size: 28rpx;
  186. &::after {
  187. border: none;
  188. }
  189. }
  190. .share-inner {
  191. width: 100%;
  192. box-sizing: border-box;
  193. padding: 0 10%;
  194. display: flex;
  195. flex-wrap: wrap;
  196. position: absolute;
  197. bottom: 0;
  198. left: 0;
  199. .share-item {
  200. flex: 1;
  201. display: flex;
  202. flex-direction: column;
  203. align-items: center;
  204. justify-content: center;
  205. margin-bottom: 66upx;
  206. position: relative;
  207. .img {
  208. width: 80upx;
  209. height: 80upx;
  210. margin-bottom: 20upx;
  211. background-color: #fff;
  212. display: flex;
  213. align-items: center;
  214. justify-content: center;
  215. border-radius: 50%;
  216. }
  217. image {
  218. width: 80upx;
  219. height: 80upx;
  220. margin-bottom: 20upx;
  221. }
  222. .text {
  223. font-size: 28upx;
  224. font-family: PingFang SC;
  225. font-weight: 500;
  226. color: #111111;
  227. line-height: 1;
  228. }
  229. }
  230. }
  231. .share-btn {
  232. position: absolute;
  233. left: 50%;
  234. top: 0;
  235. width: 80upx;
  236. height: 100%;
  237. transform: translateX(-50%);
  238. background-color: transparent !important;
  239. &::after {
  240. border: none;
  241. }
  242. }
  243. </style>