bindInfo.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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. <!-- #ifdef MP-WEIXIN -->
  8. <view class="share-item" @click="downImg()">
  9. <view class="img">
  10. <uni-icons type="redo" size="30" color="#222"></uni-icons>
  11. </view>
  12. <text class="text">分享</text>
  13. </view>
  14. <!-- #endif -->
  15. <!-- #ifdef APP-PLUS -->
  16. <view class="share-item" @click="wxShare(0)">
  17. <image src="/static/images/icon_wx.png" mode=""></image>
  18. <text class="text">微信</text>
  19. <button class='share-btn'></button>
  20. </view>
  21. <view class="share-item" @click="wxShare(1)">
  22. <image src="/static/images/icon_pyq.png" mode=""></image>
  23. <text class="text">朋友圈</text>
  24. <button class='share-btn' open-type="share">
  25. </button>
  26. </view>
  27. <!-- #endif -->
  28. <!-- <view class="share-item" @click="copyUrl()">
  29. <image src="/static/images/icon_copy_link.png" mode=""></image>
  30. <text class="text">复制链接</text>
  31. </view> -->
  32. <!-- #ifndef H5 -->
  33. <view class="share-item" @click="downImg()">
  34. <view class="img">
  35. <uni-icons type="arrow-down" size="30" color="#222"></uni-icons>
  36. </view>
  37. <text class="text">保存图片</text>
  38. </view>
  39. <!-- #endif -->
  40. </view>
  41. </view>
  42. <u-empty style="padding-top: 20vh;" mode="data" v-else="imgurl"
  43. icon="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/appimgs/cf4a86b913a04341bb44e34bb4d37aa2.png" text="暂无数据"></u-empty>
  44. </template>
  45. <script>
  46. import {
  47. getBindInfo
  48. } from "@/api/companyUser.js"
  49. export default {
  50. data() {
  51. return {
  52. imageUrl: '',
  53. urlVal: '',
  54. companyUserId: ''
  55. }
  56. },
  57. onShareAppMessage(res) {
  58. return {
  59. title: '立即绑定,享受更多权益',
  60. path: '/pages_user/bindCompanyUser?companyUserId=' + this.companyUserId,
  61. imageUrl: this.imageUrl
  62. }
  63. },
  64. //分享到朋友圈
  65. onShareTimeline(res) {
  66. return {
  67. title: '立即绑定,享受更多权益',
  68. path: '/pages_user/bindCompanyUser?companyUserId=' + this.companyUserId,
  69. imageUrl: this.imageUrl
  70. }
  71. },
  72. onLoad() {
  73. this.companyUserId = uni.getStorageSync('companyUserId') || '';
  74. this.getInfo()
  75. },
  76. methods: {
  77. getInfo() {
  78. getBindInfo().then(res => {
  79. console.log("qxj getBindInfo res",res);
  80. if (res.code == 200) {
  81. this.imageUrl = res.imageUrl
  82. this.urlVal = res.url
  83. } else {
  84. uni.showToast({
  85. title: "暂无公司码",
  86. icon: 'none'
  87. })
  88. }
  89. })
  90. },
  91. wxShare(type) {
  92. // #ifdef APP-PLUS
  93. if (!plus.runtime.isAgreePrivacy()) {
  94. uni.showToast({
  95. title: "请同意隐私政策",
  96. icon: "none",
  97. position: 'top',
  98. duration: 2000
  99. })
  100. return;
  101. }
  102. let that = this;
  103. let sceneStr = type == 0 ? "WXSceneSession" : "WXSceneTimeline";
  104. // 仅支持分享微信小程序到微信聊天界面,想进入朋友圈需改为分享图片方式,在图片中包含小程序码
  105. uni.share({
  106. provider: "weixin",
  107. scene: sceneStr,
  108. type: 2,
  109. imageUrl: this.imageUrl, //分享封面图片
  110. success: function(res) {
  111. uni.showToast({
  112. title: "分享成功",
  113. icon: 'none'
  114. });
  115. },
  116. fail: function(err) {
  117. // 此处是调起微信分享失败的回调
  118. },
  119. complete: (e) => {
  120. console.log("WXSceneTimeline", e)
  121. }
  122. });
  123. // #endif
  124. },
  125. copyUrl() {
  126. uni.setClipboardData({
  127. data: this.urlVal,
  128. success: () => {
  129. uni.showToast({
  130. title: '复制成功',
  131. icon: 'none'
  132. });
  133. },
  134. fail: () => {
  135. uni.showToast({
  136. title: '复制失败',
  137. icon: 'none'
  138. });
  139. }
  140. });
  141. },
  142. downImg() {
  143. uni.showLoading({
  144. title: "图片保存中..."
  145. })
  146. uni.downloadFile({
  147. url: this.imageUrl,
  148. fail: function(res) {
  149. uni.showModal({
  150. title: '提示',
  151. content: '保存失败',
  152. })
  153. uni.hideLoading();
  154. },
  155. success: function(res) {
  156. var tempFilePath = res.tempFilePath;
  157. uni.saveImageToPhotosAlbum({
  158. filePath: tempFilePath,
  159. success: () => {
  160. uni.showToast({
  161. title: "保存成功",
  162. duration: 2000
  163. })
  164. },
  165. fail: () => {
  166. console.log("图片失败");
  167. uni.showToast({
  168. title: "图片失败",
  169. duration: 2000,
  170. icon: "error"
  171. })
  172. uni.hideLoading();
  173. },
  174. complete: function() {
  175. uni.hideLoading();
  176. }
  177. })
  178. },
  179. })
  180. }
  181. }
  182. }
  183. </script>
  184. <style scoped lang="scss">
  185. .container {
  186. padding: 40rpx 0;
  187. padding-top: 16vh;
  188. box-sizing: border-box;
  189. display: flex;
  190. flex-direction: column;
  191. align-items: center;
  192. position: relative;
  193. }
  194. .qrcode-box {
  195. width: 480rpx;
  196. height: 480rpx;
  197. box-sizing: border-box;
  198. overflow: hidden;
  199. flex-direction: column !important;
  200. border-radius: 16rpx;
  201. background-color: #fff;
  202. font-family: PingFang SC, PingFang SC;
  203. font-weight: 400;
  204. font-size: 28rpx;
  205. color: #222;
  206. .qrcode {
  207. width: 450rpx;
  208. height: 450rpx;
  209. }
  210. .qrcode-title {
  211. font-weight: bold;
  212. font-size: 32rpx;
  213. color: #222;
  214. margin-bottom: 32rpx;
  215. }
  216. .qrcode-tip {
  217. margin: 32rpx;
  218. color: #999;
  219. text-align: center;
  220. }
  221. }
  222. .downbtn {
  223. width: 160rpx;
  224. min-height: 68rpx;
  225. border: 1px solid #2583EB !important;
  226. color: #2583EB !important;
  227. background-color: #fff !important;
  228. border-radius: 168rpx;
  229. font-family: PingFang SC, PingFang SC;
  230. font-weight: 400;
  231. font-size: 28rpx;
  232. &::after {
  233. border: none;
  234. }
  235. }
  236. .share-inner {
  237. width: 100%;
  238. box-sizing: border-box;
  239. padding: 0 10%;
  240. display: flex;
  241. flex-wrap: wrap;
  242. position: absolute;
  243. bottom: 0;
  244. left: 0;
  245. .share-item {
  246. flex: 1;
  247. display: flex;
  248. flex-direction: column;
  249. align-items: center;
  250. justify-content: center;
  251. margin-bottom: 66upx;
  252. position: relative;
  253. .img {
  254. width: 80upx;
  255. height: 80upx;
  256. margin-bottom: 20upx;
  257. background-color: #fff;
  258. display: flex;
  259. align-items: center;
  260. justify-content: center;
  261. border-radius: 50%;
  262. }
  263. image {
  264. width: 80upx;
  265. height: 80upx;
  266. margin-bottom: 20upx;
  267. }
  268. .text {
  269. font-size: 28upx;
  270. font-family: PingFang SC;
  271. font-weight: 500;
  272. color: #111111;
  273. line-height: 1;
  274. }
  275. }
  276. }
  277. .share-btn {
  278. position: absolute;
  279. left: 50%;
  280. top: 0;
  281. width: 80upx;
  282. height: 100%;
  283. transform: translateX(-50%);
  284. background-color: transparent !important;
  285. &::after {
  286. border: none;
  287. }
  288. }
  289. </style>