invite.vue 10 KB

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