invite.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <template>
  2. <!-- 邀请页 -->
  3. <div class="area-process" v-show-log="state.log_invite_show">
  4. <v-head :left-data="state.detail.postUserInfo || null" :rightData="state.detail.remainAmountUsdValue"></v-head>
  5. <div class="box-process">
  6. <div class="item" v-for="item, i in state.boxs">
  7. <hover-tip :txt="item.txt" v-show="item.show || item.openStatus" :icon="item.hover_icon"></hover-tip>
  8. <img :src="item.icon" alt="" @mouseenter="mouseItem(i)" @mouseleave="mouseLeaveItem(i)" />
  9. <img :src="require('@/assets/img/icon-flash-active.png')" alt="" class="flash"
  10. v-if="item.openStatus == 0 && item.taskFinishStatus == 1" />
  11. </div>
  12. <div class="line">
  13. <div class="full" ref="line_full"></div>
  14. </div>
  15. </div>
  16. <div class="area-success-message" @mouseover="mouseOver" @mouseleave="mouseLeave">
  17. <div class="content-success-message" ref="content_success_message">
  18. <div class="success-message" v-for="item, index in state.success_message_list" :key="index"
  19. @click="clickItem(item)">
  20. <img :src="item.userInfo.avatarUrl" alt="" />
  21. <span>{{ item.userInfo.nickName }} </span> &nbsp;
  22. <span>Opened Treasure Chest</span>
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. <div class="area-nav">
  28. <div class="item" :class="{ active: state.tab_index == i }" @click="state.tab_index = i"
  29. v-for="item, i in state.tabs">
  30. <img :src="require('@/assets/svg/icon-invite.svg')" alt=""
  31. :style="{ opacity: state.tab_index == 0 ? '1' : '0.55' }" v-if="i == 0" />
  32. <img :src="require('@/assets/svg/icon-invite-list.svg')" alt=""
  33. :style="{ opacity: state.tab_index == 1 ? '1' : '0.55' }" v-if="i == 1" />
  34. {{ item.txt }}
  35. </div>
  36. </div>
  37. <div class="area-info">
  38. <invite-friends v-show="state.tab_index == 0"></invite-friends>
  39. <invite-list v-show="state.tab_index == 1"></invite-list>
  40. </div>
  41. <v-dialog v-show="state.dialog.show"></v-dialog>
  42. </template>
  43. <script setup>
  44. import { ref, onMounted, watch, inject } from 'vue'
  45. import { receiveList } from '@/http/treasure.js'
  46. import VHead from '@/view/iframe/treasure-hunt/components/head.vue'
  47. import InviteList from '@/view/iframe/treasure-hunt/components/invite-list.vue'
  48. import HoverTip from '@/view/iframe/treasure-hunt/components/hover-tip.vue'
  49. import InviteFriends from '@/view/iframe/treasure-hunt/components/invite-friends.vue'
  50. import VDialog from '@/view/iframe/treasure-hunt/components/dialog.vue'
  51. import Report from "@/log-center/log"
  52. let content_success_message = ref(null)
  53. let state = inject('state')
  54. state.log_invite_show = {
  55. businessType: Report.businessType.pageView,
  56. pageSource: Report.pageSource.inviteFriendsPage,
  57. redPacketType: Report.redPacketType.treasure,
  58. shareLinkId: state.invite_code,
  59. myShareLinkId: state.detail.inviteCopyUrl,
  60. currentInvitedNum: state.detail.inviteCount,
  61. postId: state.postId
  62. }
  63. // ---- 走马灯
  64. state.success_message_list = []
  65. // ---- box 区域
  66. let silver_close_box = require('@/assets/img/icon-silver-close-box.png')
  67. let silver_open_box = require('@/assets/img/icon-silver-open-box.png')
  68. let gold_open_box = require('@/assets/img/icon-gold-open-box.png')
  69. let gold_close_box = require('@/assets/img/icon-gold-close-box.png')
  70. // ---- tab区域 ----
  71. state.tab_index = 0
  72. state.tabs = [{
  73. txt: 'Invite Friends'
  74. }, {
  75. txt: 'Invited'
  76. }]
  77. state.boxs = []
  78. let line_full = ref(null)
  79. onMounted(() => {
  80. state.inviteInit()
  81. setInterval(() => {
  82. state.init(() => {
  83. state.inviteInit()
  84. state.inviteList()
  85. })
  86. }, 30000)
  87. })
  88. const clickItem = (item) => {
  89. window.open(`https://twitter.com/${item.userInfo.nickName}`)
  90. }
  91. state.inviteInit = () => {
  92. if (state.detail.inviteCount > 0) {
  93. state.tabs[1].txt = `invited(${state.detail.inviteCount})`
  94. }
  95. state.boxs = []
  96. state.detail.treasureRecords.forEach((item, index) => {
  97. if (item.openStatus == 0) {
  98. item.hover_icon = require('@/assets/svg/icon-user.svg')
  99. if (index > 0) {
  100. item.icon = gold_close_box
  101. } else {
  102. item.icon = silver_close_box
  103. }
  104. item.txt = item.inviteProgress
  105. } else {
  106. item.icon = silver_open_box
  107. item.hover_icon = require('@/assets/svg/icon-green-yes.svg')
  108. // 最后一条
  109. if (index > 0) {
  110. item.icon = gold_open_box
  111. } else {
  112. item.icon = silver_open_box
  113. }
  114. item.txt = '$' + item.amountValue
  115. }
  116. state.boxs.push(item)
  117. })
  118. receiveList({
  119. params: {
  120. postId: state.postId,
  121. pageNum: 1,
  122. pageSize: 100,
  123. }
  124. }).then((res) => {
  125. if (res.code == 0) {
  126. state.success_message_list = res.data
  127. state.success_message_list = state.success_message_list.concat(state.success_message_list)
  128. state.success_message_list = state.success_message_list.concat(state.success_message_list)
  129. if (content_success_message && content_success_message.value) {
  130. let dom = content_success_message.value
  131. let s = state.success_message_list.length * 4
  132. dom.style.animationDuration = s + 's'
  133. }
  134. }
  135. })
  136. btnStatus()
  137. }
  138. let line_width = 0
  139. const setLineFull = (box_num = 0, finishNeedInviteCount = 0, successInviteCount = 0) => {
  140. if (box_num == 0) {
  141. line_width = (successInviteCount / finishNeedInviteCount) * 55
  142. } else if (box_num == 1) {
  143. if (line_width == 55) {
  144. line_width = 92
  145. line_width = (successInviteCount / finishNeedInviteCount) * (155 - line_width) + line_width
  146. }
  147. } else if (box_num == 2) {
  148. if (line_width == 155) {
  149. line_width = 192
  150. line_width = (successInviteCount / finishNeedInviteCount) * (260 - line_width) + line_width
  151. }
  152. }
  153. line_full.value.style.width = line_width + 'px'
  154. }
  155. const btnStatus = () => {
  156. for (let i in state.boxs) {
  157. if (state.boxs[i].taskFinishStatus == 0) {
  158. let num = state.boxs[i].finishNeedInviteCount - state.boxs[i].successInviteCount
  159. if (num == 1) {
  160. state.open_btn.txt = 'Invite 1 Friend to Open'
  161. } else {
  162. state.open_btn.txt = `Invite ${num} Friends to Open`
  163. }
  164. state.open_btn.disabled = true
  165. break
  166. }
  167. }
  168. state.treasureId = ''
  169. let open_num = 0
  170. // 有打开的箱子 Open the chest
  171. state.boxs.forEach((item, index) => {
  172. if (item.taskFinishStatus == 1 && item.openStatus == 0) {
  173. state.open_btn.txt = 'Open the Treasure Chest'
  174. state.open_btn.disabled = false
  175. if (!state.treasureId) {
  176. state.treasureId = item.id
  177. }
  178. }
  179. setLineFull(index, item.finishNeedInviteCount, item.successInviteCount)
  180. // 三个箱子全部打开了
  181. if (item.openStatus == 1) {
  182. open_num++
  183. }
  184. if (open_num == state.boxs.length) {
  185. state.open_btn.txt = 'All Chests Have Been Opened'
  186. state.open_btn.disabled = true
  187. }
  188. })
  189. }
  190. const mouseItem = (i) => {
  191. state.boxs[i].show = true
  192. }
  193. const mouseLeaveItem = (i) => {
  194. state.boxs[i].show = false
  195. }
  196. const mouseOver = () => {
  197. if (content_success_message && content_success_message.value && content_success_message.value.style) {
  198. content_success_message.value.style.animationPlayState = 'paused'
  199. }
  200. }
  201. const mouseLeave = () => {
  202. if (content_success_message && content_success_message.value && content_success_message.value.style) {
  203. content_success_message.value.style.animationPlayState = 'running'
  204. }
  205. }
  206. </script>
  207. <style lang="scss" scoped>
  208. .area-process {
  209. width: 375px;
  210. height: 170px;
  211. background: linear-gradient(179.96deg, #735931 0.04%, #0E0803 53.64%);
  212. position: relative;
  213. .box-process {
  214. width: 350px;
  215. height: 90px;
  216. margin: 0 auto;
  217. display: flex;
  218. align-items: center;
  219. position: absolute;
  220. top: 32px;
  221. left: 13px;
  222. img {
  223. width: 60px;
  224. height: 60px;
  225. z-index: 2;
  226. }
  227. .item {
  228. z-index: 2;
  229. display: flex;
  230. justify-content: center;
  231. position: relative;
  232. .flash {
  233. position: absolute;
  234. top: 0;
  235. left: 0;
  236. z-index: 0;
  237. width: 100%;
  238. height: 100%;
  239. }
  240. }
  241. .item:nth-child(1) {
  242. margin-left: 56px;
  243. }
  244. .item:nth-child(2) {
  245. width: 60px;
  246. height: 60px;
  247. margin-left: 40px;
  248. }
  249. .item:nth-child(3) {
  250. img {
  251. width: 90px;
  252. height: 90px;
  253. }
  254. margin-left: 40px;
  255. }
  256. .line {
  257. width: 300px;
  258. height: 4px;
  259. background: rgba(255, 210, 59, 0.2);
  260. position: absolute;
  261. border-radius: 100px;
  262. overflow: hidden;
  263. left: 13px;
  264. top: 45px;
  265. .full {
  266. position: absolute;
  267. left: 0;
  268. top: 0;
  269. height: 4px;
  270. width: 0px;
  271. background: #FFD23B;
  272. }
  273. }
  274. }
  275. .area-success-message {
  276. height: 30px;
  277. width: 100%;
  278. position: absolute;
  279. bottom: 13px;
  280. overflow: hidden;
  281. .content-success-message {
  282. width: fit-content;
  283. display: flex;
  284. animation: rolling 18s linear infinite;
  285. animation-duration: 10s;
  286. animation-play-state: running;
  287. .success-message {
  288. cursor: pointer;
  289. width: fit-content;
  290. height: 30px;
  291. padding: 0 9px;
  292. border-radius: 100px;
  293. background: rgba(255, 255, 255, 0.1);
  294. display: flex;
  295. align-items: center;
  296. overflow: hidden;
  297. margin-right: 15px;
  298. img {
  299. width: 20px;
  300. height: 20px;
  301. border-radius: 100px;
  302. margin-right: 8px;
  303. }
  304. span {
  305. font-style: normal;
  306. font-weight: 500;
  307. font-size: 12px;
  308. line-height: 14px;
  309. white-space: nowrap;
  310. }
  311. span:nth-child(2) {
  312. color: #1D9BF0;
  313. }
  314. span:nth-child(3) {
  315. color: #A8A8A8;
  316. }
  317. }
  318. }
  319. }
  320. }
  321. @keyframes rolling {
  322. from {
  323. transform: translateX(0);
  324. }
  325. to {
  326. transform: translateX(-50%);
  327. }
  328. }
  329. .area-nav {
  330. width: 375px;
  331. height: 38px;
  332. display: flex;
  333. .item {
  334. display: flex;
  335. justify-content: center;
  336. align-items: center;
  337. user-select: none;
  338. color: #757575;
  339. background: #F0F0F0;
  340. text-align: center;
  341. width: 50%;
  342. font-weight: 500;
  343. font-size: 14px;
  344. line-height: 38px;
  345. cursor: pointer;
  346. img {
  347. margin-right: 8px;
  348. width: 20px;
  349. height: 20px;
  350. }
  351. }
  352. .active {
  353. background: #FFFFFF;
  354. color: #000000;
  355. }
  356. }
  357. .area-info {
  358. width: 375px;
  359. }
  360. </style>