You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

281 lines
6.6 KiB

  1. <template>
  2. <view class="all">
  3. <!-- 背景图部分 -->
  4. <image class="img-share" src="/static/my/shareBackground.png"/>
  5. <image class="img-greenBack" src="/static/my/greenBackground.png"/>
  6. <!-- todo 这里给我个码-->
  7. <image class="img-QRcode" src="/static/my/QRcode.png"/>
  8. <image class="img-award" src="/static/my/award.png"/>
  9. <image class="img-myFriends" src="/static/my/myFriends.png"/>
  10. <image class="img-friends" src="/static/my/shareFriends.png"/>
  11. <!-- dccode -->
  12. <text class="jwcode">{{ dccode }}</text>
  13. <!-- 邀请按钮 -->
  14. <button class="invite" @click="openShare">立即邀请</button>
  15. <!-- 分享弹窗 -->
  16. <uni-popup ref="shareRef" type="share" safeArea>
  17. <SharePopup @select="onShareSelect" @close="closeShare" title=" "/>
  18. </uni-popup>
  19. <!-- 二次弹窗 -->
  20. <uni-popup ref="secondPopup" type="share">
  21. <view class="second-popup">
  22. <view style=" display: flex;justify-content: center;align-items: center; font-size: 17px">
  23. <image style="width: 16px; height: 16px; margin-right: 8rpx" src="/static/my/share/success.png"/>
  24. <text>已复制</text>
  25. </view>
  26. <view class="popup-msg-box">
  27. <text>{{ popupMsg }}</text>
  28. </view>
  29. <view style="justify-content: center; align-items: center;">
  30. <!-- 二次弹窗中的按钮图标 -->
  31. <button
  32. style="border-radius: 40rpx; background-color: black; color: white; display: flex; align-items: center; justify-content: center; padding: 12rpx 24rpx;"
  33. @click="closeSecondPopup">
  34. <image style="width: 25px; height: 25px; margin-right: 8rpx;"
  35. :src="platformIconMap[selectedPlatform]"/>
  36. 去粘贴给好友
  37. </button>
  38. </view>
  39. </view>
  40. </uni-popup>
  41. </view>
  42. </template>
  43. <script setup>
  44. import {ref} from 'vue'
  45. import SharePopup from '@/components/SharePopup.vue'
  46. import {getUserInfo} from "@/api/member";
  47. /* =============== 数据与引用 =============== */
  48. const shareRef = ref(null)
  49. const secondPopup = ref(null)
  50. const popupMsg = ref('')
  51. // const jwcode = ref('90047681')
  52. // 选中的平台
  53. const selectedPlatform = ref('')
  54. // dccode
  55. const dccode = ref('')
  56. // token
  57. const token = ref('1ab8f83f391ca866191385d0e5048938')
  58. // 设备码
  59. const deviceId = ref(100)
  60. // 版本
  61. const version = ref(100)
  62. // 获取设备类型
  63. const client = ref('android')
  64. // 平台图标
  65. const platformIconMap = ref({
  66. 'WeChat': '/static/my/share/WeChat.png',
  67. 'WhatsApp': '/static/my/share/WhatsApp.png',
  68. 'Line': '/static/my/share/Line.png',
  69. 'KakaoTalk': '/static/my/share/KakaoTalk.png',
  70. '复制链接': '/static/my/share/share.png'
  71. })
  72. /* =============== 方法 =============== */
  73. const userInfoRes = ref()
  74. userInfoRes.value = getUserInfo()
  75. userInfoRes.value.then(res => {
  76. dccode.value = res.data.dccode
  77. console.log('用户信息', res.data)
  78. })
  79. // 打开分享弹窗
  80. function openShare() {
  81. shareRef.value.open()
  82. }
  83. // 关闭分享弹窗
  84. function closeShare() {
  85. shareRef.value.close()
  86. }
  87. //
  88. // 点击分享选项
  89. function onShareSelect({item}) {
  90. console.log('选择了:', item.name)
  91. selectedPlatform.value = item.name // 记录选中的平台
  92. // 生成动态助力链接 todo 这里只能传代参的,header传不了
  93. const baseUrl = '下载链接'
  94. // const shareLink = `${baseUrl}?token=${encodeURIComponent(token.value)}&deviceId=${encodeURIComponent(deviceId.value)}&version=${encodeURIComponent(version.value)}&client=${encodeURIComponent(client.value)}`
  95. const shareLink = `${baseUrl}`
  96. // 关闭第一个弹窗
  97. shareRef.value.close()
  98. popupMsg.value = `【DeepChart】邀请你加入,点击链接帮我助力: ${shareLink}`
  99. uni.setClipboardData({
  100. data: popupMsg.value,
  101. showToast: false
  102. });
  103. /* // 根据分享选项显示不同提示
  104. if (item.name === '复制链接') {
  105. popupMsg.value = '链接已复制,快去分享给好友吧~'
  106. } else if (item.name === 'WeChat') {
  107. popupMsg.value = '请在微信中分享~'
  108. } else {
  109. popupMsg.value = `你选择了 ${item.name}`
  110. }*/
  111. // 打开第二个弹窗
  112. secondPopup.value.open()
  113. }
  114. // 关闭第二个弹窗
  115. function closeSecondPopup() {
  116. if (selectedPlatform.value === 'WeChat') {
  117. uni.share({
  118. provider: "weixin",
  119. scene: "WXSceneSession",
  120. type: 1,
  121. summary: popupMsg.value,
  122. success: function (res) {
  123. console.log("success:" + JSON.stringify(res));
  124. },
  125. fail: function (err) {
  126. console.log("fail:" + JSON.stringify(err));
  127. }
  128. });
  129. secondPopup.value.close()
  130. }
  131. // 其他的几种情况 需要适配
  132. else if (selectedPlatform.value === 'WhatsApp' || selectedPlatform.value === 'Line' || selectedPlatform.value === 'KakaoTalk') {
  133. secondPopup.value.close()
  134. uni.showToast({title: '开发中……', icon: 'none'})
  135. } else if (selectedPlatform.value === '复制链接') {
  136. uni.showToast({title: '已复制', icon: 'success'})
  137. secondPopup.value.close()
  138. }
  139. }
  140. </script>
  141. <style scoped>
  142. .all {
  143. position: relative;
  144. width: 750rpx;
  145. height: auto;
  146. }
  147. /* 背景图片部分 */
  148. .img-share {
  149. width: 750rpx;
  150. height: 2118rpx;
  151. position: absolute;
  152. top: 0;
  153. left: 0;
  154. z-index: 1;
  155. }
  156. .img-greenBack {
  157. width: 670rpx;
  158. height: 1740rpx;
  159. position: absolute;
  160. top: 16vh;
  161. left: 40rpx;
  162. z-index: 2;
  163. }
  164. .img-QRcode {
  165. width: 320rpx;
  166. height: 320rpx;
  167. position: absolute;
  168. top: 26vh;
  169. left: 215rpx;
  170. z-index: 3;
  171. }
  172. .img-award {
  173. width: 300rpx;
  174. height: 120rpx;
  175. position: absolute;
  176. top: 61vh;
  177. left: 75rpx;
  178. z-index: 3;
  179. }
  180. .img-myFriends {
  181. width: 300rpx;
  182. height: 88rpx;
  183. position: absolute;
  184. top: 61vh;
  185. right: 75rpx;
  186. z-index: 3;
  187. }
  188. .img-friends {
  189. width: 602rpx;
  190. height: 840rpx;
  191. position: absolute;
  192. top: 68vh;
  193. left: 74rpx;
  194. z-index: 3;
  195. }
  196. /* 邀请码与按钮 */
  197. .jwcode {
  198. width: 320rpx;
  199. height: 38rpx;
  200. display: flex;
  201. justify-content: center;
  202. align-items: center;
  203. position: absolute;
  204. top: 19vh;
  205. left: 212rpx;
  206. z-index: 999;
  207. }
  208. .invite {
  209. width: 320rpx;
  210. height: 80rpx;
  211. border-radius: 40rpx;
  212. background-color: black;
  213. color: white;
  214. display: flex;
  215. justify-content: center;
  216. align-items: center;
  217. position: absolute;
  218. top: 50.7vh;
  219. left: 212rpx;
  220. z-index: 999;
  221. }
  222. /* 第二个弹窗样式 */
  223. .second-popup {
  224. background-color: #fff;
  225. border-radius: 12px;
  226. padding: 30rpx;
  227. text-align: center;
  228. }
  229. .popup-msg-box {
  230. background-color: #F3F3F3;
  231. border-radius: 8px;
  232. padding: 12px 16px;
  233. margin: 10px;
  234. align-items: center;
  235. justify-content: center;
  236. overflow: hidden; /* 隐藏溢出内容 */
  237. text-overflow: ellipsis; /* 溢出部分显示... */
  238. }
  239. </style>