invite.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. <v-carousel></v-carousel>
  6. <v-boxs></v-boxs>
  7. </div>
  8. <div class="area-nav">
  9. <div class="item" :class="{ active: state.tab_index == i }" @click="state.tab_index = i"
  10. v-for="item, i in state.tabs">
  11. <img :src="require('@/assets/svg/icon-invite.svg')" alt=""
  12. :style="{ opacity: state.tab_index == 0 ? '1' : '0.55' }" v-if="i == 0" />
  13. <img :src="require('@/assets/svg/icon-invite-list.svg')" alt=""
  14. :style="{ opacity: state.tab_index == 1 ? '1' : '0.55' }" v-if="i == 1" />
  15. {{ item.txt }}
  16. </div>
  17. </div>
  18. <div class="area-info">
  19. <invite-friends v-show="state.tab_index == 0"></invite-friends>
  20. <invite-list v-show="state.tab_index == 1"></invite-list>
  21. </div>
  22. <v-dialog v-show="state.dialog.show"></v-dialog>
  23. </template>
  24. <script setup>
  25. import { ref, onMounted, watch, inject } from 'vue'
  26. import VHead from '@/view/iframe/treasure-hunt/components/head.vue'
  27. import InviteList from '@/view/iframe/treasure-hunt/components/invite-list.vue'
  28. import HoverTip from '@/view/iframe/treasure-hunt/components/hover-tip.vue'
  29. import InviteFriends from '@/view/iframe/treasure-hunt/components/invite-friends.vue'
  30. import VDialog from '@/view/iframe/treasure-hunt/components/dialog.vue'
  31. import VBoxs from '@/view/iframe/treasure-hunt/components/boxs.vue'
  32. import VCarousel from '@/view/iframe/treasure-hunt/components/carousel.vue'
  33. import Report from "@/log-center/log"
  34. let state = inject('state')
  35. state.log_invite_show = {
  36. businessType: Report.businessType.pageView,
  37. pageSource: Report.pageSource.inviteFriendsPage,
  38. redPacketType: Report.redPacketType.treasure,
  39. shareLinkId: state.invite_code,
  40. myShareLinkId: state.detail.inviteCopyUrl,
  41. currentInvitedNum: state.inviteCount,
  42. postId: state.postId
  43. }
  44. // ---- tab区域 ----
  45. state.tab_index = 0
  46. state.tabs = [{
  47. txt: 'Invite Friends'
  48. }, {
  49. txt: 'Invited'
  50. }]
  51. let line_full = ref(null)
  52. onMounted(() => {
  53. state.inviteInit()
  54. setInterval(() => {
  55. state.init(() => {
  56. state.inviteInit()
  57. state.inviteListRefresh()
  58. })
  59. }, 30000)
  60. })
  61. const clickItem = (item) => {
  62. window.open(`https://twitter.com/${item.userInfo.nickName}`)
  63. }
  64. state.inviteInit = () => {
  65. // state.boxs = []
  66. btnStatus()
  67. }
  68. const btnStatus = () => {
  69. for (let i in state.boxs) {
  70. if (state.boxs[i].taskFinishStatus == 0) {
  71. let num = state.boxs[i].finishNeedInviteCount - state.boxs[i].successInviteCount
  72. if (num == 1) {
  73. state.open_btn.txt = 'Invite 1 Friend to Open'
  74. } else {
  75. state.open_btn.txt = `Invite ${num} Friends to Open`
  76. }
  77. state.open_btn.disabled = true
  78. break
  79. }
  80. }
  81. state.treasureId = ''
  82. let open_num = 0
  83. // 有打开的箱子 Open the chest
  84. state.boxs.forEach((item, index) => {
  85. if (item.taskFinishStatus == 1 && item.openStatus == 0) {
  86. state.open_btn.txt = 'Open the Treasure Chest'
  87. state.open_btn.disabled = false
  88. if (!state.treasureId) {
  89. state.treasureId = item.id
  90. }
  91. }
  92. // setLineFull(index, item.finishNeedInviteCount, item.successInviteCount)
  93. // 三个箱子全部打开了
  94. if (item.openStatus == 1) {
  95. open_num++
  96. }
  97. if (open_num == state.boxs.length) {
  98. state.open_btn.txt = 'All Chests Have Been Opened'
  99. state.open_btn.disabled = true
  100. }
  101. })
  102. }
  103. </script>
  104. <style lang="scss" scoped>
  105. .area-process {
  106. width: 375px;
  107. height: 170px;
  108. background: linear-gradient(179.96deg, #735931 0.04%, #0E0803 53.64%);
  109. position: relative;
  110. }
  111. .area-nav {
  112. width: 375px;
  113. height: 38px;
  114. display: flex;
  115. .item {
  116. display: flex;
  117. justify-content: center;
  118. align-items: center;
  119. user-select: none;
  120. color: #757575;
  121. background: #F0F0F0;
  122. text-align: center;
  123. width: 50%;
  124. font-weight: 500;
  125. font-size: 14px;
  126. line-height: 38px;
  127. cursor: pointer;
  128. img {
  129. margin-right: 8px;
  130. width: 20px;
  131. height: 20px;
  132. }
  133. }
  134. .active {
  135. background: #FFFFFF;
  136. color: #000000;
  137. }
  138. }
  139. .area-info {
  140. width: 375px;
  141. }
  142. </style>