invite.vue 12 KB

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