red-packet.vue 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213
  1. <template>
  2. <div class="content">
  3. <!-- open -->
  4. <div v-if="data.status == 'opened'" class="opened">
  5. <div class="header" :style="{ 'backgroundImage': `url(${require('../assets/svg/back-head-top.svg')})` }">
  6. <div class="seat"></div>
  7. <div class="title">Awesome! You Will Get</div>
  8. <div class="money">
  9. <img :src="require('../assets/svg/icon-dollar.svg')" alt />
  10. <span class="big">{{ data.money / 100 }}</span>
  11. <span class="small">{{ data.detail.amountCurrencyCode || '' }}</span>
  12. </div>
  13. </div>
  14. <div class="list">
  15. <div class="item" v-for="item, i in data.detail.taskCondition" v-bind:key="i">
  16. <template v-if="item.type == 1 && item.relatedUsers && item.relatedUsers.length > 0">
  17. <div class="item-content">
  18. <div class="item-follow-title">
  19. <img :src="require('../assets/svg/icon-follow.svg')" alt />
  20. <div class="item-title">Follow</div>
  21. <img v-if="data.done.follow" :src="require('../assets/svg/icon-true.svg')" alt />
  22. <div v-else class="btn" @click="clickFollowAll(item.relatedUsers)">Follow All</div>
  23. </div>
  24. <div class="item-follow-area">
  25. <div class="item-follow" v-for="item2, i in item.relatedUsers" v-bind:key="i">
  26. <span :class="{ finished: item2.finished }">@{{ item2.name }}</span>
  27. <img v-if="item2.finished" :src="require('../assets/svg/icon-true-ed.svg')" alt />
  28. <img v-else :src="require('../assets/svg/icon-add.svg')" alt />
  29. </div>
  30. </div>
  31. </div>
  32. </template>
  33. <template v-if="item.type == 2">
  34. <img :src="require('../assets/svg/icon-like.svg')" alt />
  35. <div class="item-content">
  36. <div class="item-title">Like</div>
  37. </div>
  38. <img v-if="data.done.like" :src="require('../assets/svg/icon-true.svg')" alt />
  39. <div v-else class="btn" @click="clickLickBtn">Like</div>
  40. </template>
  41. <template v-if="item.type == 3">
  42. <img :src="require('../assets/svg/icon-retweet.svg')" alt />
  43. <div class="item-content">
  44. <div class="item-title">Retweet</div>
  45. </div>
  46. <img v-if="data.done.retweet" :src="require('../assets/svg/icon-true.svg')" alt />
  47. <div v-else class="btn" @click="clickRetweetBtn">Retweet</div>
  48. </template>
  49. </div>
  50. </div>
  51. <div class="people" @click="clickRoad">
  52. <div class="txt">Total ${{ data.detail.amountValue }} USD,{{ data.detail.receiveCount || 0 }}/{{
  53. data.detail.totalCount || 0
  54. }} People Got</div>
  55. <div class="right">
  56. <template v-for="item, i in data.detail.allReceived.slice(0, 3)" v-bind:key="i">
  57. <img :src="item.simpleUserInfoVO.avatarUrl" alt :style="{ right: `${i * 16 + 14}px` }"
  58. v-if="item.simpleUserInfoVO.avatarUrl" />
  59. <img v-else :src="require('../assets/svg/icon-twitter.svg')" alt :style="{ right: `${i * 16 + 14}px` }" />
  60. </template>
  61. <img :src="require('../assets/svg/icon-right.svg')" alt class="road" />
  62. </div>
  63. </div>
  64. <div class="footer">
  65. <div class="first">
  66. <div class="validity">Validity</div>
  67. <div class="time">{{ data.detail.validity || '' }}</div>
  68. </div>
  69. <div class="btn" @click="clickGetGiveaways">Get Giveaways</div>
  70. </div>
  71. </div>
  72. <!-- success -->
  73. <div v-else-if="data.status == 'success'" class="success">
  74. <div class="header" :style="{ 'backgroundImage': `url(${require('../assets/svg/back-head-top.svg')})` }">
  75. <div class="seat"></div>
  76. <div class="money">
  77. <img :src="require('../assets/svg/icon-dollar.svg')" alt />
  78. <span class="big">{{ data.money / 100 }}</span>
  79. <span class="small">USD</span>
  80. </div>
  81. <div class="done" @click="clickDone">
  82. <img :src="require('../assets/svg/icon-done.svg')" alt class="icon-done" />
  83. <span>Giveaways transferred to Wallet</span>
  84. <img :src="require('../assets/svg/icon-right.svg')" alt class="icon-right" />
  85. </div>
  86. </div>
  87. <div class="luck-list-title">
  88. <div>{{ data.detail.receiveCount || 0 }}/{{ data.detail.totalCount || 0 }} People Got</div>
  89. <div>Total ${{ data.detail.amountValue || '' }} {{ data.detail.amountCurrencyCode || '' }}</div>
  90. </div>
  91. <div class="luck-list" @scroll="handleScroll($event)">
  92. <div class="luck-item" v-for="item, i in data.detail.allReceived" v-bind:key="i">
  93. <img v-if="item.simpleUserInfoVO.avatarUrl" :src="item.simpleUserInfoVO.avatarUrl" alt />
  94. <img v-else :src="require('../assets/svg/icon-twitter.svg')" alt />
  95. <div class="luck-content">
  96. <div class="luck-title" v-if="item.simpleUserInfoVO.nickName">{{ item.simpleUserInfoVO.nickName }}</div>
  97. <div class="luck-title" v-else>Twitter User</div>
  98. <div class="luck-time">{{ moment(item.receiveTimestamp).format('MM-DD hh:mm:ss') }}</div>
  99. </div>
  100. <div class="luck-money">
  101. <img :src="require('../assets/svg/icon-dollar.svg')" alt />
  102. <div class="luck-money-txt">{{ showLastTwoPlace(item.amountValue) || 0 }}</div>
  103. </div>
  104. <div class="luck-king" v-if="item.maxAmount">
  105. <img :src="require('../assets/svg/icon-king-hat.svg')" alt />
  106. <span>Luckiest Draw</span>
  107. </div>
  108. </div>
  109. </div>
  110. </div>
  111. <!-- no-open -->
  112. <div v-else-if="data.status == 'not-open'" class="not-open">
  113. <img :src="require('../assets/img/up.png')" alt class="up" />
  114. <img :src="require('../assets/img/down.png')" alt class="down" />
  115. <div class="open" @click="clickOpenRedPacket">OPEN</div>
  116. </div>
  117. <!-- 领取列表 -->
  118. <div v-else-if="data.status == 'luck-peopel-list'" class="luck-peopel-list">
  119. <div class="head">
  120. <img :src="require('../assets/svg/icon-back.svg')" alt @click="clickBack" />
  121. </div>
  122. <div class="luck-list-title">
  123. <div>{{ data.detail.receiveCount || 0 }}/{{ data.detail.totalCount || 0 }} People Got</div>
  124. <div>Total ${{ data.detail.amountValue || 0 }} {{ data.detail.amountCurrencyCode || '' }}</div>
  125. </div>
  126. <div class="luck-list" @scroll="handleScroll">
  127. <div class="luck-item" v-for="item, i in data.detail.allReceived" v-bind:key="i">
  128. <img v-if="item.simpleUserInfoVO.avatarUrl" :src="item.simpleUserInfoVO.avatarUrl" alt />
  129. <img v-else :src="require('../assets/svg/icon-twitter.svg')" alt />
  130. <div class="luck-content">
  131. <div class="luck-title" v-if="item.simpleUserInfoVO.nickName">{{ item.simpleUserInfoVO.nickName }}</div>
  132. <div class="luck-title" v-else>Twitter User</div>
  133. <div class="luck-time">{{ moment(item.receiveTimestamp).format('MM-DD hh:mm:ss') }}</div>
  134. </div>
  135. <div class="luck-money">
  136. <img :src="require('../assets/svg/icon-dollar.svg')" alt />
  137. <div class="luck-money-txt">{{ showLastTwoPlace(item.amountValue) }}</div>
  138. </div>
  139. <div class="luck-king" v-if="item.maxAmount">
  140. <img :src="require('../assets/svg/icon-king-hat.svg')" alt />
  141. <span>Luckiest Draw</span>
  142. </div>
  143. </div>
  144. </div>
  145. </div>
  146. <!-- 红包被领完了 -->
  147. <div v-else-if="data.status == 'close'" class="close">
  148. <div class="header" :style="{ 'backgroundImage': `url(${require('../assets/svg/back-head-top.svg')})` }">
  149. <div class="seat"></div>
  150. <div class="close-title">{{ data.close_title }}</div>
  151. <div class="close-title" v-if="data.close_text">{{ data.close_text }}</div>
  152. </div>
  153. <div class="luck-list-title">
  154. <div>{{ data.detail.receiveCount || 0 }}/{{ data.detail.totalCount || 0 }} People Got</div>
  155. <div>Total ${{ data.detail.amountValue || 0 }} {{ data.detail.amountCurrencyCode || '' }}</div>
  156. </div>
  157. <div class="luck-list" @scroll="handleScroll">
  158. <div class="luck-item" v-for="item, i in data.detail.allReceived" v-bind:key="i">
  159. <img v-if="item.simpleUserInfoVO.avatarUrl" :src="item.simpleUserInfoVO.avatarUrl" alt />
  160. <img v-else :src="require('../assets/svg/icon-twitter.svg')" alt />
  161. <div class="luck-content">
  162. <div class="luck-title" v-if="item.simpleUserInfoVO.nickName">{{ item.simpleUserInfoVO.nickName }}</div>
  163. <div class="luck-title" v-else>Twitter User</div>
  164. <div class="luck-time">{{ moment(item.receiveTimestamp).format('MM-DD hh:mm:ss') }}</div>
  165. </div>
  166. <div class="luck-money">
  167. <img :src="require('../assets/svg/icon-dollar.svg')" alt />
  168. <div class="luck-money-txt">{{ showLastTwoPlace(item.amountValue) || 0 }}</div>
  169. </div>
  170. <div class="luck-king" v-if="item.maxAmount">
  171. <img :src="require('../assets/svg/icon-king-hat.svg')" alt />
  172. <span>Luckiest Draw</span>
  173. </div>
  174. </div>
  175. </div>
  176. </div>
  177. <!-- error -->
  178. <div v-else-if="data.status == 'error'" class="error">
  179. <img :src="require('../assets/svg/icon-error.svg')" alt />
  180. <div class="txt">
  181. {{ data.error_txt }}
  182. </div>
  183. </div>
  184. <!-- loading -->
  185. <div v-show="data.loading_show" class="loading">
  186. <img :src="require('../assets/svg/icon-loading.svg')" alt />
  187. </div>
  188. </div>
  189. </template>
  190. <script>
  191. export default {
  192. name: 'redPacket',
  193. }
  194. </script>
  195. <script setup>
  196. import { onMounted, reactive } from "vue";
  197. import { getPostDetail, getRedPacket, finishRedPacket, oneKeyLike, oneKeyReTweet, oneKeyFollow, getTaskDetail, getReceivedList } from '../http/redPacket.js'
  198. import { getQueryString } from '../uilts/help.js'
  199. import { getChromeStorage } from '../uilts/chromeExtension.js'
  200. var moment = require('moment');
  201. let data = reactive({
  202. status: '',
  203. loading_show: false,
  204. detail: {},
  205. luck_list_end: false,
  206. page_index: 1,
  207. page_size: 20,
  208. srcContentId: '',
  209. close_title: 'Better luck next time!',
  210. error_txt: `oops, new accounts cannot participate in this event,`,
  211. receiveAmount: 0,
  212. money: 0,
  213. // 状态
  214. done: {
  215. follow: false,
  216. like: false,
  217. retweet: false
  218. }
  219. })
  220. async function clickLickBtn() {
  221. let _userInfo = await checkIsLogin()
  222. if (!_userInfo) {
  223. return
  224. }
  225. data.loading_show = true
  226. oneKeyLike({
  227. params: {
  228. tweetId: data.srcContentId
  229. }
  230. }).then((res) => {
  231. data.loading_show = false
  232. if (res.code == 0) {
  233. if (res.data.result) {
  234. data.done.like = true
  235. } else {
  236. data.done.like = false
  237. }
  238. } else {
  239. data.done.like = false
  240. console.log(res)
  241. }
  242. })
  243. }
  244. function clickDone() {
  245. window.open(`${chrome.runtime.getURL('/iframe/home.html')}`)
  246. }
  247. function handleScroll(e) {
  248. if (data.luck_list_end) {
  249. return
  250. }
  251. e = e.target
  252. if ((e.clientHeight + e.scrollTop) / e.scrollHeight > .8) {
  253. data.luck_list_end = true
  254. data.page_index++
  255. getReceivedList({
  256. params: {
  257. pageNum: data.page_index,
  258. pageSize: data.page_size,
  259. postId: data.postId
  260. }
  261. }).then((res) => {
  262. if (res.code == 0) {
  263. if (res.data.length > 0) {
  264. data.detail.allReceived = data.detail.allReceived.concat(res.data)
  265. data.luck_list_end = false
  266. } else {
  267. data.luck_list_end = true
  268. }
  269. } else {
  270. console.log('getReceivedList', res)
  271. }
  272. })
  273. }
  274. }
  275. async function clickRetweetBtn() {
  276. let _userInfo = await checkIsLogin()
  277. if (!_userInfo) {
  278. return
  279. }
  280. data.loading_show = true
  281. oneKeyReTweet({
  282. params: {
  283. tweetId: data.srcContentId
  284. }
  285. }).then((res) => {
  286. data.loading_show = false
  287. if (res.code == 0) {
  288. if (res.data.result) {
  289. data.done.retweet = true
  290. } else {
  291. data.done.retweet = false
  292. }
  293. } else {
  294. data.done.retweet = false
  295. console.log(res)
  296. }
  297. })
  298. }
  299. function getValidity() {
  300. let _d1, _d2, _d3, _h, _m, _s
  301. if (!data.detail.myReceived.taskEndTimestamp) {
  302. return
  303. }
  304. let timer = setInterval(() => {
  305. let _time = new Date().getTime()
  306. _d3 = data.detail.myReceived.taskEndTimestamp - _time
  307. if (_d3 > 0) {
  308. _d1 = moment(data.detail.myReceived.taskEndTimestamp)
  309. _d2 = moment(_time)
  310. _h = moment.duration(_d1.diff(_d2)).hours()
  311. _m = moment.duration(_d1.diff(_d2)).minutes()
  312. _s = moment.duration(_d1.diff(_d2)).seconds()
  313. data.detail.validity = `${_h}:${_m}:${_s}`
  314. } else {
  315. clearInterval(timer)
  316. }
  317. }, 1000)
  318. }
  319. async function clickFollowAll(item) {
  320. let _userInfo = await checkIsLogin()
  321. if (!_userInfo) {
  322. return
  323. }
  324. data.loading_show = true
  325. let arr_name = []
  326. for (let i in item) {
  327. arr_name.push(item[i].name)
  328. }
  329. oneKeyFollow({
  330. params: {
  331. names: arr_name
  332. }
  333. }).then((res) => {
  334. data.loading_show = false
  335. if (res.code == 0) {
  336. res.data.forEach((item1) => {
  337. data.detail.taskCondition[0].relatedUsers.forEach(item2 => {
  338. if (item1.name == item2.name) {
  339. item2.finished = true
  340. }
  341. });
  342. })
  343. let _len = data.detail.taskCondition[0].relatedUsers.filter((item) => { return item.finished == false }).length
  344. if (_len > 0) {
  345. data.done.follow = false
  346. } else {
  347. data.done.follow = true
  348. }
  349. } else {
  350. data.detail.taskCondition[0].relatedUsers.forEach(item => {
  351. item.finished = false
  352. });
  353. }
  354. })
  355. }
  356. // 我领取了的状态
  357. function myReceivedState() {
  358. data.status = 'opened'
  359. data.money = data.detail.myReceived.amountValue
  360. // 我的红包已经过期了 and 大红包可以领取
  361. if (data.detail.myReceived.taskFinishStatus == 2 && !data.detail.receiveTimeExpired) {
  362. data.status = 'not-open'
  363. // 任务已经被领完了
  364. if (data.detail.totalCount == data.detail.receiveCount) {
  365. data.status = 'close'
  366. data.close_title = 'Better luck next time!'
  367. }
  368. }
  369. // 我领取未完成 and 大红包可以领取
  370. if (data.detail.myReceived.taskFinishStatus == 0 && !data.detail.receiveTimeExpired) {
  371. initTaskDetail()
  372. getValidity()
  373. data.detail.taskCondition = JSON.parse(data.detail.taskCondition)
  374. data.detail.amountValue = showLastTwoPlace(data.detail.amountValue)
  375. data.detail.receiveAmountValue = showLastTwoPlace(data.detail.receiveAmountValue)
  376. }
  377. // 大红包不能领取了
  378. if (data.detail.receiveTimeExpired) {
  379. data.status = 'close'
  380. data.close_title = `This Giveaways`
  381. data.close_text = `expired on ${moment(data.detail.endTimestamp).format('MM-DD')}`
  382. }
  383. // 我领取成功了
  384. if (data.detail.myReceived.taskFinishStatus == 1) {
  385. data.status = 'success'
  386. }
  387. }
  388. function showLastTwoPlace(n) {
  389. return n / 100
  390. }
  391. function init() {
  392. getPostDetail({
  393. params: {
  394. postId: data.postId
  395. }
  396. }).then((res) => {
  397. switch (res.code.toString()) {
  398. case "0":
  399. data.srcContentId = res.data.srcContentId
  400. // if (data.tweetId != data.srcContentId) {
  401. // data.error_txt = 'Giveaways link Error'
  402. // data.status = 'error'
  403. // return
  404. // }
  405. data.detail = JSON.parse(res.data.postBizData)
  406. console.log(data.detail)
  407. // 红包未开始
  408. if (data.detail.status == 0) {
  409. data.status = 'not-open'
  410. // 任务进行中
  411. } else if (data.detail.status == 1) {
  412. data.status = 'not-open'
  413. // 我领取过的状态
  414. if (data.detail.myReceived) {
  415. myReceivedState()
  416. } else {
  417. // 大红包不可以领取了
  418. if (data.detail.receiveTimeExpired) {
  419. data.status = 'close'
  420. data.close_title = `This Giveaways`
  421. data.close_text = `expired on ${moment(data.detail.endTimestamp).format('MM-DD')}`
  422. }
  423. // 任务已经被领完了
  424. if (data.detail.totalCount == data.detail.receiveCount) {
  425. data.status = 'close'
  426. data.close_title = 'Better luck next time!'
  427. }
  428. }
  429. // 任务已经结束了
  430. } else if (data.detail.status == 2) {
  431. // 我领取过的状态
  432. if (data.detail.myReceived) {
  433. myReceivedState()
  434. } else {
  435. data.status = 'close'
  436. data.close_title = `This Giveaways`
  437. data.close_text = `expired on ${moment(data.detail.endTimestamp).format('MM-DD')}`
  438. }
  439. }
  440. break
  441. }
  442. })
  443. }
  444. function initTaskDetail() {
  445. // 任务详情
  446. getTaskDetail({
  447. params: {
  448. postId: data.postId
  449. }
  450. }).then((res) => {
  451. if (res.code == 0) {
  452. for (let i in res.data) {
  453. switch (res.data[i].type) {
  454. case 1:
  455. data.done.follow = res.data[i].finished
  456. data.detail.taskCondition[0].relatedUsers = res.data[i].detail
  457. break
  458. case 2:
  459. data.done.like = res.data[i].finished
  460. break
  461. case 3:
  462. data.done.retweet = res.data[i].finished
  463. break
  464. }
  465. }
  466. } else {
  467. console.log(res.msg)
  468. }
  469. })
  470. }
  471. onMounted(() => {
  472. data.postId = getQueryString('postId')
  473. data.tweetId = getQueryString('tweetId')
  474. init()
  475. // data.loading_show = true
  476. })
  477. // 点击领取
  478. function clickOpenRedPacket() {
  479. handleRedPacket()
  480. }
  481. function handleRedPacket() {
  482. getRedPacket({
  483. params: {
  484. postId: data.postId
  485. }
  486. }).then((res) => {
  487. switch (res.code.toString()) {
  488. case "0":
  489. data.status = 'opened'
  490. data.money = res.data.receiveAmount
  491. init()
  492. break
  493. case "2008":
  494. data.status = 'close'
  495. data.close_title = 'Better luck next time!'
  496. break
  497. }
  498. })
  499. }
  500. chrome.storage.onChanged.addListener(changes => {
  501. if (changes.userInfo) {
  502. // let item = JSON.parse(changes.userInfo.newValue)
  503. data.loading_show = false
  504. init()
  505. }
  506. })
  507. // 校验是否封路
  508. function checkIsLogin() {
  509. return new Promise((resolve) => {
  510. getChromeStorage('userInfo', (_userInfo) => {
  511. if (!_userInfo) {
  512. data.loading_show = true
  513. chrome.runtime.sendMessage(
  514. { method: "POPUP_LOGIN", data: "" },
  515. (response) => {
  516. console.log("res", response);
  517. }
  518. )
  519. resolve(_userInfo)
  520. } else {
  521. resolve(_userInfo)
  522. }
  523. })
  524. })
  525. }
  526. async function clickGetGiveaways() {
  527. let _userInfo = await checkIsLogin()
  528. if (_userInfo) {
  529. handleFinishRedPacket()
  530. }
  531. }
  532. function handleFinishRedPacket() {
  533. data.loading_show = true
  534. finishRedPacket({
  535. params: {
  536. postId: data.postId
  537. }
  538. }).then((res) => {
  539. data.loading_show = false
  540. switch (res.code.toString()) {
  541. case '0':
  542. if (res.data.finished) {
  543. data.status = 'success'
  544. data.receiveAmount = res.data.receiveAmount
  545. init()
  546. } else {
  547. let _data = res.data.conditionResult
  548. for (let i in _data) {
  549. switch (_data[i].type.toString()) {
  550. case '1':
  551. data.detail.taskCondition[0].relatedUsers = _data[i].detail
  552. if (_data[i].finished) {
  553. data.done.follow = true
  554. } else {
  555. alert('Please complete the task: follow')
  556. }
  557. break
  558. case '2':
  559. if (_data[i].finished) {
  560. data.done.like = true
  561. } else {
  562. alert('Please complete the task: like tweet')
  563. }
  564. break
  565. case '3':
  566. if (_data[i].finished) {
  567. data.done.retweet = true
  568. } else {
  569. alert('Please complete the task: Retweet')
  570. }
  571. break
  572. }
  573. }
  574. }
  575. break
  576. case "2009":
  577. data.error_txt = `oops, new accounts cannot participate in this event,`
  578. data.status = 'error'
  579. break
  580. case "-106":
  581. alert('Clicking too often, wait a moment and click again')
  582. break
  583. default:
  584. console(res)
  585. }
  586. })
  587. }
  588. function clickBack() {
  589. data.status = 'opened'
  590. }
  591. function clickRoad() {
  592. data.status = 'luck-peopel-list'
  593. }
  594. </script>
  595. <style lang="scss">
  596. html,
  597. body {
  598. margin: 0;
  599. padding: 0;
  600. }
  601. .content {
  602. width: 375px;
  603. height: 500px;
  604. background: #fafafa;
  605. border-radius: 11px;
  606. font-family: "SF Pro Display";
  607. font-style: normal;
  608. .loading {
  609. background: #FFFFFF;
  610. opacity: 0.8;
  611. z-index: 222;
  612. text-align: center;
  613. width: 375px;
  614. height: 500px;
  615. position: fixed;
  616. top: 0;
  617. left: 0;
  618. img {
  619. margin-top: 216px;
  620. width: 70px;
  621. height: 70px;
  622. }
  623. }
  624. .error {
  625. text-align: center;
  626. img {
  627. width: 160px;
  628. height: 160px;
  629. margin-top: 80px;
  630. }
  631. .txt {
  632. font-weight: 500;
  633. font-size: 22px;
  634. line-height: 26px;
  635. text-align: center;
  636. letter-spacing: 0.3px;
  637. color: #a8a8a8;
  638. margin: 34px 44px 0 44px;
  639. }
  640. }
  641. .success,
  642. .close,
  643. .luck-peopel-list {
  644. filter: drop-shadow(0px 4px 94px rgba(0, 0, 0, 0.3));
  645. width: 100%;
  646. height: 100%;
  647. border-radius: 11px;
  648. background: #fff;
  649. overflow: hidden;
  650. display: flex;
  651. flex-direction: column;
  652. .close-title {
  653. font-weight: 600;
  654. font-size: 27px;
  655. line-height: 32px;
  656. text-align: center;
  657. letter-spacing: 0.3px;
  658. color: #ffffff;
  659. }
  660. .head {
  661. padding: 14px 16px;
  662. img {
  663. cursor: pointer;
  664. width: 24px;
  665. height: 24px;
  666. }
  667. }
  668. .header {
  669. text-align: center;
  670. height: 150px;
  671. width: 100%;
  672. background: #fff;
  673. // padding-top: 30px;
  674. background-size: 100% 100%;
  675. position: relative;
  676. .seat {
  677. width: 100%;
  678. height: 30px;
  679. }
  680. .done {
  681. cursor: pointer;
  682. position: absolute;
  683. top: 107px;
  684. left: 50%;
  685. margin-left: -150px;
  686. width: 300px;
  687. height: 60px;
  688. display: flex;
  689. align-items: center;
  690. border-radius: 100px;
  691. background: #ffffff;
  692. box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.1);
  693. span {
  694. color: #000000;
  695. font-size: 14px;
  696. }
  697. .icon-done {
  698. width: 24px;
  699. height: 24px;
  700. margin-left: 28px;
  701. margin-right: 10px;
  702. }
  703. .icon-right {
  704. margin-left: 5px;
  705. width: 7px;
  706. height: 14px;
  707. }
  708. }
  709. .title {
  710. margin-top: 30px;
  711. color: #fff7e4;
  712. opacity: 0.6;
  713. font-weight: 700;
  714. font-size: 18px;
  715. line-height: 21px;
  716. letter-spacing: -0.3px;
  717. }
  718. .money {
  719. margin-top: 16px;
  720. img {
  721. width: 40px;
  722. height: 40px;
  723. margin-right: 9px;
  724. }
  725. .big {
  726. font-weight: 700;
  727. font-size: 46px;
  728. line-height: 55px;
  729. /* identical to box height */
  730. letter-spacing: 0.3px;
  731. color: #fff8e6;
  732. }
  733. .small {
  734. margin-left: 4px;
  735. font-weight: 700;
  736. font-size: 13px;
  737. line-height: 16px;
  738. /* identical to box height */
  739. letter-spacing: 0.5px;
  740. color: #fff8e6;
  741. }
  742. }
  743. }
  744. .luck-list-title {
  745. /* margin-top: 47px;*/
  746. padding: 0 16px;
  747. background: #fff;
  748. color: #9b9b9b;
  749. display: flex;
  750. justify-content: space-between;
  751. }
  752. .luck-list {
  753. background: #fff;
  754. overflow: auto;
  755. .luck-item {
  756. display: flex;
  757. padding: 12px 16px;
  758. border-top: 1px solid #d1d1d1;
  759. justify-content: space-between;
  760. position: relative;
  761. img:first-child {
  762. border-radius: 50%;
  763. }
  764. .luck-king {
  765. position: absolute;
  766. top: 36px;
  767. right: 16px;
  768. display: flex;
  769. align-items: center;
  770. img {
  771. width: 22px;
  772. height: 19px;
  773. margin: 0;
  774. }
  775. span {
  776. font-weight: 500;
  777. font-size: 12px;
  778. line-height: 14px;
  779. letter-spacing: 0.3px;
  780. color: #f5b945;
  781. }
  782. }
  783. img {
  784. width: 42px;
  785. height: 42px;
  786. margin-right: 12px;
  787. }
  788. .luck-content {
  789. flex: auto;
  790. .luck-title {
  791. font-weight: 500;
  792. font-size: 16px;
  793. letter-spacing: 0.3px;
  794. color: #444444;
  795. }
  796. .luck-time {
  797. font-weight: 400;
  798. font-size: 12px;
  799. line-height: 14px;
  800. color: #9b9b9b;
  801. }
  802. }
  803. .luck-money {
  804. display: flex;
  805. height: 17px;
  806. align-items: center;
  807. img {
  808. width: 14px;
  809. height: 14px;
  810. margin-right: 6px;
  811. }
  812. .luck-money-txt {
  813. font-weight: 500;
  814. font-size: 14px;
  815. /* identical to box height */
  816. text-align: right;
  817. letter-spacing: 0.3px;
  818. color: #444444;
  819. }
  820. }
  821. }
  822. }
  823. }
  824. .success {
  825. .luck-list-title {
  826. margin-top: 47px;
  827. }
  828. }
  829. .opened {
  830. filter: drop-shadow(0px 4px 94px rgba(0, 0, 0, 0.3));
  831. width: 100%;
  832. height: 100%;
  833. display: flex;
  834. flex-direction: column;
  835. justify-content: space-between;
  836. .header {
  837. text-align: center;
  838. height: 150px;
  839. width: 100%;
  840. background: #fff;
  841. // padding-top: 30px;
  842. background-size: 100% 100%;
  843. .seat {
  844. width: 100%;
  845. height: 30px;
  846. }
  847. .title {
  848. color: #fff7e4;
  849. opacity: 0.6;
  850. font-weight: 700;
  851. font-size: 18px;
  852. line-height: 21px;
  853. letter-spacing: -0.3px;
  854. }
  855. .money {
  856. margin-top: 16px;
  857. img {
  858. margin-right: 9px;
  859. width: 40px;
  860. height: 40px;
  861. }
  862. .big {
  863. font-weight: 700;
  864. font-size: 46px;
  865. line-height: 55px;
  866. /* identical to box height */
  867. letter-spacing: 0.3px;
  868. color: #fff8e6;
  869. }
  870. .small {
  871. margin-left: 4px;
  872. font-weight: 700;
  873. font-size: 13px;
  874. line-height: 16px;
  875. /* identical to box height */
  876. letter-spacing: 0.5px;
  877. color: #fff8e6;
  878. }
  879. }
  880. }
  881. .list {
  882. padding: 0 16px 0 16px;
  883. background: #ffffff;
  884. flex: 1;
  885. .item {
  886. display: flex;
  887. align-items: center;
  888. min-height: 50px;
  889. border-bottom: 1px solid #f0f0f0;
  890. img {
  891. width: 24px;
  892. height: 24px;
  893. }
  894. .item-content {
  895. width: 100%;
  896. flex: 1;
  897. .item-follow-title {
  898. display: flex;
  899. align-items: center;
  900. margin-top: 20px;
  901. margin-bottom: 11px;
  902. position: relative;
  903. .btn {
  904. position: absolute;
  905. right: 0;
  906. }
  907. }
  908. .item-title {
  909. flex: 1;
  910. margin-left: 10px;
  911. font-weight: 500;
  912. font-size: 16px;
  913. letter-spacing: 0.3px;
  914. color: #000000;
  915. }
  916. .item-follow-area {
  917. display: flex;
  918. margin-bottom: 4px;
  919. // flex-wrap: wrap;
  920. .item-follow {
  921. cursor: pointer;
  922. border: 1px solid #ebebeb;
  923. border-radius: 1000px;
  924. height: 26px;
  925. margin-right: 5px;
  926. margin-bottom: 5px;
  927. display: flex;
  928. align-items: center;
  929. .finished {
  930. text-decoration: line-through;
  931. color: #949494;
  932. }
  933. span {
  934. margin-left: 8px;
  935. margin-right: 2px;
  936. color: #389aff;
  937. opacity: 1;
  938. }
  939. img {
  940. width: 16px;
  941. height: 16px;
  942. margin-right: 7px;
  943. }
  944. }
  945. }
  946. span {
  947. font-weight: 400;
  948. font-size: 11px;
  949. line-height: 13px;
  950. letter-spacing: 0.3px;
  951. color: #000000;
  952. opacity: 0.4;
  953. }
  954. }
  955. .btn {
  956. width: 72px;
  957. height: 29px;
  958. line-height: 29px;
  959. background: rgba(56, 154, 255, 0.1);
  960. border-radius: 500px;
  961. text-align: center;
  962. letter-spacing: 0.3px;
  963. color: #389aff;
  964. cursor: pointer;
  965. }
  966. }
  967. }
  968. .people {
  969. cursor: pointer;
  970. padding-left: 16px;
  971. height: 38px;
  972. line-height: 38px;
  973. background: #fff;
  974. border-bottom: 1px solid #f0f0f0;
  975. box-shadow: 0px 1px 0px #f2f2f2;
  976. display: flex;
  977. align-items: center;
  978. justify-content: space-between;
  979. .txt {
  980. font-weight: 400;
  981. font-size: 12px;
  982. line-height: 14px;
  983. letter-spacing: 0.3px;
  984. color: #000000;
  985. opacity: 0.4;
  986. }
  987. .right {
  988. flex: 1;
  989. cursor: pointer;
  990. margin-right: 22px;
  991. display: flex;
  992. align-items: center;
  993. position: relative;
  994. img {
  995. position: absolute;
  996. width: 22px;
  997. height: 22px;
  998. border: 2px solid #fff;
  999. border-radius: 50%;
  1000. }
  1001. .road {
  1002. right: 0;
  1003. width: 7px;
  1004. height: 14px;
  1005. }
  1006. }
  1007. }
  1008. .footer {
  1009. background: #ffffff;
  1010. display: flex;
  1011. padding: 19px 22px 19px 17px;
  1012. .first {
  1013. flex: 1;
  1014. .validity {
  1015. font-weight: 400;
  1016. font-size: 12px;
  1017. line-height: 14px;
  1018. letter-spacing: 0.3px;
  1019. color: #000000;
  1020. opacity: 0.4;
  1021. margin: 2px 0 8px 0;
  1022. }
  1023. .time {
  1024. font-weight: 500;
  1025. font-size: 13px;
  1026. line-height: 16px;
  1027. /* identical to box height */
  1028. color: #000000;
  1029. }
  1030. }
  1031. .btn {
  1032. background: #ef4545;
  1033. border-radius: 100px;
  1034. color: #fff;
  1035. width: 258px;
  1036. height: 52px;
  1037. font-weight: 600;
  1038. font-size: 18px;
  1039. line-height: 52px;
  1040. text-align: center;
  1041. cursor: pointer;
  1042. }
  1043. }
  1044. }
  1045. .not-open {
  1046. filter: drop-shadow(0px 4px 94px rgba(0, 0, 0, 0.3));
  1047. position: relative;
  1048. img {
  1049. width: 100%;
  1050. }
  1051. .up {
  1052. position: absolute;
  1053. top: 0;
  1054. box-shadow: 0px 4px 44px rgba(0, 0, 0, 0.1);
  1055. z-index: 1;
  1056. }
  1057. .down {
  1058. position: absolute;
  1059. top: 253px;
  1060. }
  1061. .open {
  1062. width: 110px;
  1063. height: 110px;
  1064. text-align: center;
  1065. font-size: 26px;
  1066. font-weight: 600;
  1067. background: #ffe9b5;
  1068. color: #ef4545;
  1069. cursor: pointer;
  1070. border-radius: 50%;
  1071. line-height: 110px;
  1072. position: absolute;
  1073. top: 235px;
  1074. left: 50%;
  1075. margin-left: -55px;
  1076. z-index: 2;
  1077. }
  1078. }
  1079. }
  1080. </style>