index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771
  1. <template>
  2. <div class="content" :style="{ 'backgroundImage': `url(${this.back_img})` }" v-show="home_show">
  3. <div class="logo">
  4. <img src="/svg/icon-logo.svg" alt />
  5. </div>
  6. <!-- 红包 -->
  7. <div class="redPacket" :class="{ redPacket2: status != 'open', key_packet: status == 'open' }">
  8. <div
  9. class="area"
  10. :class="{ key_area: status == 'open' }"
  11. v-if="status == 'open' || status == 'no-chrome'"
  12. >
  13. <div class="title">
  14. <img :src="detail.postBizData.postUserInfo.avatarUrl" alt />
  15. <span>Giveaways from: {{ detail.postBizData.postUserInfo.nickName }}</span>
  16. </div>
  17. <div class="txt">Good Luck!</div>
  18. </div>
  19. <img
  20. src="/svg/back-top.svg"
  21. alt
  22. class="top"
  23. v-if="status == 'open' || status == 'no-chrome'"
  24. :class="{ key_top: status == 'open' }"
  25. />
  26. <img
  27. src="/svg/back-down.svg"
  28. alt
  29. class="down"
  30. v-if="status == 'open' || status == 'no-chrome'"
  31. :class="{ key_down: status == 'open' }"
  32. />
  33. <img src="/svg/icon-usd.svg" alt class="start" v-if="status == 'no-chrome'" />
  34. <img src="/git/icon-start.gif" alt class="start" v-if="status == 'open'" />
  35. <!-- 内容 -->
  36. <div class="head">
  37. <div class="head-title">
  38. <img :src="detail.postBizData.postUserInfo.avatarUrl" alt />
  39. <span>Giveaways from: {{ detail.postBizData.postUserInfo.nickName }}</span>
  40. </div>
  41. <div class="head-txt" v-if="status == 'open' || status == 'opened'">Awesome! You Will Get</div>
  42. <!-- <div class="head-area" v-else-if="status == 'opened'">opened!</div> -->
  43. <div class="head-area" v-else-if="status == 'nothing'">Better luck next time!</div>
  44. <div class="head-area" v-else-if="status == 'expire'">
  45. <div>This Giveways</div>
  46. <div>expired on 03-14</div>
  47. </div>
  48. <div class="head-money" v-if="status == 'open' || status == 'opened'">
  49. <img src="/svg/icon-usd.svg" alt />
  50. <span class="money-txt">{{receiveAmount/100}}</span>
  51. <div>
  52. <span>USD</span>
  53. </div>
  54. </div>
  55. </div>
  56. <div class="luck-list-title">
  57. <div>{{ detail.postBizData.receiveCount || 0 }}/{{ detail.postBizData.totalCount || 0 }} People Got</div>
  58. <div>Total ${{ detail.postBizData.amountValue / 100 || '' }} {{ detail.postBizData.amountCurrencyCode || '' }}</div>
  59. </div>
  60. <div class="luck-list" @scroll="handleScroll" ref="list">
  61. <div class="luck-item" v-for="item, i in luck_list" v-bind:key="i">
  62. <img v-if="item.simpleUserInfoVO.avatarUrl" :src="item.simpleUserInfoVO.avatarUrl" alt />
  63. <img v-else src="/svg/icon-twitter.svg" alt />
  64. <div class="luck-content">
  65. <div class="luck-title">{{ item.simpleUserInfoVO.nickName || 'Twitter User' }}</div>
  66. <div class="luck-time" v-if="item.receiveTimestamp == -1">刚刚</div>
  67. <div class="luck-time">{{ formatTime(item.receiveTimestamp) }}</div>
  68. </div>
  69. <div class="luck-money">
  70. <img src="/svg/icon-usd.svg" alt />
  71. <div class="luck-money-txt">{{ item.amountValue / 100 }}</div>
  72. </div>
  73. <div class="luck-king" v-if="item.maxAmount">
  74. <img src="/svg/icon-king-hat.svg" alt />
  75. <span>Luckiest Draw</span>
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. <!-- 安装 -->
  81. <div
  82. class="install"
  83. v-if="status == 'open' || status == 'opened'"
  84. :class="{ key_install: status == 'open' }"
  85. >
  86. <div class="title">Withdraw to Wallet</div>
  87. <div class="validity">
  88. <template v-if="validity_state">
  89. <span>Validity</span>
  90. <span style="color: red;">{{ validity }}</span>
  91. </template>
  92. <template v-else>
  93. <span style="color: red;">Giveaways Validity</span>
  94. </template>
  95. </div>
  96. <div class="flow">
  97. <div class="line"></div>
  98. <div class="area_num">
  99. <div class="num">1</div>
  100. <span>Install DeNet</span>
  101. </div>
  102. <div class="tip">Used for Task Verification and Giveaways Withdrawal</div>
  103. <div class="install_btn">Install</div>
  104. <div class="area_num">
  105. <div class="num" style="background: #E0E0E0;">2</div>
  106. <span>Complete Tasks by {{ detail.postBizData.postUserInfo.nickName }}</span>
  107. </div>
  108. <div class="tip">Follow、Like tweet、Retweet (Just 1-3 minutes)</div>
  109. </div>
  110. </div>
  111. <div class="install install-error" v-if="status == 'nothing' || status == 'expire'">
  112. <div class="title">Install DeNet</div>
  113. <div class="title">Don't miss the next Giveaway</div>
  114. <div class="tip">Used for Task Verification and Giveaways Withdrawal</div>
  115. <div class="install_btn">Install</div>
  116. </div>
  117. <div class="install install-error" v-if="status == 'no-chrome'">
  118. <div class="title">Open Giveaways</div>
  119. <div class="title">with chrome</div>
  120. <div class="tip">Only supports getting Giveaways through chrome</div>
  121. <div class="install_chrome">
  122. <img src="/svg/icon-chrome.svg" alt />
  123. Install Chrome
  124. </div>
  125. </div>
  126. </div>
  127. </template>
  128. <script>
  129. import axios from 'axios';
  130. import Cookies from 'js-cookie'
  131. import { kill } from 'process';
  132. import { isBrowser } from '../utils/help.js'
  133. var moment = require('moment');
  134. export default {
  135. name: "index",
  136. data() {
  137. return {
  138. back_img: '/svg/back-denet.svg',
  139. area_show: true,
  140. home_show: false,
  141. validity: '',
  142. receiveAmount:0,
  143. validity_state: true,
  144. detail: {
  145. postId: '',
  146. postBizData: {
  147. imagePath: ''
  148. }
  149. },
  150. title: '',
  151. twitterTitle: 'deNet',
  152. jumpUrl: 'https://de-net-test.piaoquantv.com/',
  153. status: '',
  154. page_index: 1,
  155. page_size: 20,
  156. luck_list: [],
  157. luck_list_end: false,
  158. received_log: [],
  159. }
  160. },
  161. head() {
  162. return {
  163. type: '',
  164. title: this.title,
  165. meta: [
  166. {
  167. name: 'twitter:card',
  168. content: 'summary_large_image'
  169. },
  170. {
  171. name: 'twitter:url',
  172. content: this.jumpUrl + this.detail.postId
  173. },
  174. {
  175. name: 'twitter:title',
  176. content: this.twitterTitle
  177. },
  178. {
  179. name: 'twitter:image',
  180. content: this.detail.postBizData.imagePath || ''
  181. },
  182. {
  183. name: 'twitter:image:width',
  184. content: '1280'
  185. },
  186. {
  187. name: 'twitter:image:height',
  188. content: '720'
  189. },
  190. ]
  191. }
  192. },
  193. methods: {
  194. formatTime(time) {
  195. return moment(time).format('MM-DD hh:mm:ss')
  196. },
  197. handleScroll(e) {
  198. if (this.luck_list_end) {
  199. return
  200. }
  201. if ((this.$refs.list.clientHeight + this.$refs.list.scrollTop) / this.$refs.list.scrollHeight > .8) {
  202. this.luck_list_end = false
  203. this.page_index++
  204. this.getReceivedList()
  205. }
  206. },
  207. async getRedPacket() {
  208. this.received_log = Cookies.get('received_log') || []
  209. // 判断领取过
  210. if (this.received_log.length > 0) {
  211. this.received_log = JSON.parse(this.received_log)
  212. let _item = this.received_log.filter((item) => { return item.postId == this.detail.postId })
  213. if (_item.length>0) {
  214. // 领取过了
  215. this.status = 'opened'
  216. this.receiveAmount = _item[0].receiveAmount
  217. // 领取列表分页
  218. this.getReceivedList()
  219. return
  220. }
  221. }
  222. // return
  223. let { data } = await axios.post('https://denettestapi.piaoquantv.com/denet/post/luckdrop/receiveLuckdrop', {
  224. baseInfo: {
  225. },
  226. params: {
  227. postId: this.detail.postId || ''
  228. }
  229. })
  230. switch (data.code.toString()) {
  231. case '0':
  232. this.status = 'open'
  233. let _obj = {
  234. postId: this.detail.postId,
  235. receivedId: data.data.receivedId,
  236. receiveAmount:data.data.receiveAmount
  237. }
  238. this.receiveAmount = data.data.receiveAmount
  239. this.received_log.push(_obj)
  240. Cookies.set('received_log', JSON.stringify(this.received_log), { expires: 100 });
  241. break;
  242. // 红包被领完了
  243. case '2008':
  244. this.status = 'nothing'
  245. break
  246. case '2029':
  247. // 推文未发布
  248. break
  249. default:
  250. console.log('getRedPacket', data)
  251. break;
  252. }
  253. // 领取列表分页
  254. this.getReceivedList()
  255. },
  256. async getReceivedList() {
  257. let { data } = await axios.post('https://denettestapi.piaoquantv.com/denet/post/luckdrop/getReceivedList', {
  258. params: {
  259. pageNum: this.page_index,
  260. pageSize: this.page_size,
  261. postId: this.detail.postId || ''
  262. }
  263. })
  264. if (data.code == 0) {
  265. if (data.data.length > 0) {
  266. this.luck_list = this.luck_list.concat(data.data)
  267. this.luck_list_end = false
  268. } else {
  269. this.luck_list_end = true
  270. }
  271. } else {
  272. console.log('getReceivedList', data)
  273. }
  274. },
  275. getValidity() {
  276. let timer = setInterval(() => {
  277. let _time = new Date().getTime()
  278. if (this.detail.postBizData.endTimestamp - _time > 0) {
  279. this.validity = moment(this.detail.postBizData.endTimestamp - _time).format('HH:mm:ss')
  280. } else {
  281. this.validity_state = false
  282. clearInterval(timer)
  283. }
  284. }, 1000)
  285. }
  286. },
  287. async asyncData(params) {
  288. let { route } = params;
  289. let { data } = await axios.post('https://denettestapi.piaoquantv.com/denet/post/getDetail', {
  290. baseInfo: {
  291. token: ''
  292. },
  293. params: {
  294. postId: route.params.id || ''
  295. }
  296. })
  297. if (data.code == 0) {
  298. if (data.data && data.data.postBizData && typeof data.data.postBizData == 'string') {
  299. data.data.postBizData = JSON.parse(data.data.postBizData)
  300. }
  301. return {
  302. detail: data.data,
  303. }
  304. }
  305. },
  306. mounted() {
  307. //改变font-size
  308. (function (doc, win) {
  309. var docEI = doc.documentElement,
  310. resizeEvt = 'orientationchange' in window ? 'orientataionchange' : 'resize',
  311. recalc = function () {
  312. var clientWidth = docEI.clientWidth;
  313. if (!clientWidth) return;
  314. //100是字体大小,1510是开发时浏览器窗口的宽度,等比计算
  315. docEI.style.fontSize = 10 * (clientWidth / 1510) + 'px';
  316. }
  317. if (!doc.addEventListener) return;
  318. win.addEventListener(resizeEvt, recalc, false);
  319. doc.addEventListener('DOMContentLoaded', recalc, false);
  320. })(document, window);
  321. this.home_show = true
  322. if (isBrowser() == 'chrome') {
  323. // 领取任务红包
  324. this.getRedPacket()
  325. this.getValidity()
  326. } else {
  327. this.status = 'no-chrome'
  328. }
  329. }
  330. }
  331. </script>
  332. <style lang="scss" >
  333. html,
  334. body,
  335. #__nuxt,
  336. #__layout {
  337. width: 100%;
  338. height: 100%;
  339. padding: 0;
  340. margin: 0;
  341. }
  342. .content {
  343. width: 100%;
  344. height: 100%;
  345. background-size: 100%;
  346. background-repeat: no-repeat;
  347. position: relative;
  348. font-family: "SF Pro Display";
  349. font-style: normal;
  350. font-weight: 600;
  351. .logo {
  352. position: absolute;
  353. left: 4rem;
  354. top: 1.5rem;
  355. img {
  356. width: 107px;
  357. height: 40px;
  358. }
  359. }
  360. .key_packet {
  361. animation: key_packet 3s;
  362. animation-delay: 6s;
  363. animation-fill-mode: forwards;
  364. }
  365. .redPacket {
  366. display: flex;
  367. justify-content: flex-start;
  368. flex-direction: column;
  369. position: absolute;
  370. top: 9rem;
  371. left: 50%;
  372. width: 37.5rem;
  373. margin-left: -18rem;
  374. height: 65rem;
  375. border-radius: 2rem;
  376. // background: red;
  377. overflow: hidden;
  378. box-shadow: 0 0 5px #888888;
  379. .start {
  380. position: absolute;
  381. width: 10rem;
  382. height: 10rem;
  383. bottom: 24rem;
  384. left: 50%;
  385. margin-left: -5rem;
  386. z-index: 13;
  387. }
  388. .key_top {
  389. animation: key_top 4s;
  390. animation-delay: 2s;
  391. animation-fill-mode: forwards;
  392. }
  393. .top {
  394. top: 0;
  395. position: absolute;
  396. width: 100%;
  397. z-index: 12;
  398. }
  399. .down {
  400. bottom: 0;
  401. position: absolute;
  402. height: 32.3rem;
  403. z-index: 11;
  404. }
  405. .key_down {
  406. animation: key_down 4s;
  407. animation-delay: 2s;
  408. animation-fill-mode: forwards;
  409. }
  410. .head {
  411. .head-title {
  412. height: 9.7rem;
  413. line-height: 9.7rem;
  414. background: #ef4545;
  415. text-align: center;
  416. border-radius: 0 586px 586px/0 0 104px 104px;
  417. overflow: hidden;
  418. box-shadow: 0 0 5px #888888;
  419. img {
  420. width: 3rem;
  421. height: 3rem;
  422. border-radius: 50%;
  423. border: 2px solid #fff4db;
  424. }
  425. span {
  426. font-size: 1.4rem;
  427. color: #fff2d3;
  428. }
  429. }
  430. .head-txt {
  431. margin-top: 4.7rem;
  432. font-size: 2rem;
  433. text-align: center;
  434. color: #ef4545;
  435. }
  436. .head-area {
  437. height: 10rem;
  438. line-height: 10rem;
  439. text-align: center;
  440. letter-spacing: 0.3px;
  441. font-size: 2rem;
  442. text-align: center;
  443. color: #ef4545;
  444. }
  445. .head-money {
  446. display: flex;
  447. align-items: center;
  448. justify-content: center;
  449. margin-bottom: 3.2rem;
  450. img {
  451. width: 4rem;
  452. height: 4rem;
  453. }
  454. span {
  455. font-size: 1.3rem;
  456. }
  457. .money-txt {
  458. font-weight: 700;
  459. font-size: 4.8rem;
  460. color: #000000;
  461. letter-spacing: 0.3px;
  462. }
  463. }
  464. }
  465. .luck-list-title {
  466. padding: 0 16px;
  467. background: #fff;
  468. color: #9b9b9b;
  469. display: flex;
  470. justify-content: space-between;
  471. }
  472. .luck-list {
  473. background: #fff;
  474. flex: 1;
  475. overflow: scroll;
  476. .luck-item {
  477. display: flex;
  478. padding: 12px 16px;
  479. border-top: 1px solid #d1d1d1;
  480. justify-content: space-between;
  481. position: relative;
  482. img:first-child {
  483. border-radius: 50%;
  484. }
  485. .luck-king {
  486. position: absolute;
  487. top: 36px;
  488. right: 16px;
  489. display: flex;
  490. align-items: center;
  491. img {
  492. width: 22px;
  493. height: 19px;
  494. margin: 0;
  495. }
  496. span {
  497. font-weight: 500;
  498. font-size: 12px;
  499. line-height: 14px;
  500. letter-spacing: 0.3px;
  501. color: #f5b945;
  502. }
  503. }
  504. img {
  505. width: 42px;
  506. height: 42px;
  507. margin-right: 12px;
  508. }
  509. .luck-content {
  510. flex: auto;
  511. .luck-title {
  512. font-weight: 500;
  513. font-size: 16px;
  514. letter-spacing: 0.3px;
  515. color: #444444;
  516. }
  517. .luck-time {
  518. font-weight: 400;
  519. font-size: 12px;
  520. line-height: 14px;
  521. color: #9b9b9b;
  522. }
  523. }
  524. .luck-money {
  525. display: flex;
  526. height: 17px;
  527. align-items: center;
  528. img {
  529. width: 14px;
  530. height: 14px;
  531. margin-right: 6px;
  532. }
  533. .luck-money-txt {
  534. font-weight: 500;
  535. font-size: 14px;
  536. /* identical to box height */
  537. text-align: right;
  538. letter-spacing: 0.3px;
  539. color: #444444;
  540. }
  541. }
  542. }
  543. }
  544. .area {
  545. position: absolute;
  546. z-index: 112;
  547. width: 100%;
  548. .title {
  549. z-index: 11;
  550. margin-top: 8.5rem;
  551. text-align: center;
  552. img {
  553. width: 3.6rem;
  554. height: 3.6rem;
  555. border: 2px solid #fff4db;
  556. border-radius: 50%;
  557. }
  558. span {
  559. letter-spacing: 0.3px;
  560. font-size: 1.6rem;
  561. color: #fff2d3;
  562. }
  563. }
  564. .txt {
  565. font-size: 4rem;
  566. text-align: center;
  567. letter-spacing: 0.03rem;
  568. color: #fff2d3;
  569. }
  570. }
  571. .key_area {
  572. animation: key_area 1s;
  573. animation-delay: 1s;
  574. animation-fill-mode: forwards;
  575. }
  576. }
  577. .redPacket2 {
  578. left: 30.6rem;
  579. margin-left: -18rem;
  580. }
  581. .key_install {
  582. opacity: 0;
  583. animation: key_install 2s;
  584. animation-delay: 6s;
  585. animation-fill-mode: forwards;
  586. }
  587. .install {
  588. position: absolute;
  589. top: 20rem;
  590. left: 78.5rem;
  591. .title {
  592. font-size: 4.8rem;
  593. color: #000000;
  594. letter-spacing: 0.3px;
  595. }
  596. .validity {
  597. padding-left: 1.5rem;
  598. margin-top: 2rem;
  599. background: rgba(166, 166, 166, 0.1);
  600. width: 40rem;
  601. height: 3.3rem;
  602. line-height: 3.3rem;
  603. span {
  604. color: #000000;
  605. font-size: 1.4rem;
  606. }
  607. }
  608. .flow {
  609. position: absolute;
  610. margin-top: 4.6rem;
  611. .line {
  612. position: absolute;
  613. height: 16rem;
  614. border: 1px solid #e0e0e0;
  615. top: 3rem;
  616. left: 1.2rem;
  617. }
  618. .area_num {
  619. display: flex;
  620. align-items: center;
  621. .num {
  622. width: 2.4rem;
  623. height: 2.4rem;
  624. background-color: rgba(56, 154, 255, 1);
  625. border-radius: 50%;
  626. color: #fff;
  627. text-align: center;
  628. line-height: 2.4rem;
  629. font-size: 1.4rem;
  630. }
  631. span {
  632. margin-left: 1.5rem;
  633. color: #000000;
  634. font-size: 1.8rem;
  635. }
  636. }
  637. .tip {
  638. margin-left: 4rem;
  639. margin-top: 0.7rem;
  640. font-size: 1.4rem;
  641. color: #a4a4a4;
  642. }
  643. .install_btn {
  644. margin-left: 4rem;
  645. margin-top: 2rem;
  646. margin-bottom: 6.7rem;
  647. width: 23rem;
  648. height: 5.8rem;
  649. background: #389aff;
  650. border-radius: 10rem;
  651. color: #fff;
  652. line-height: 5.8rem;
  653. text-align: center;
  654. font-size: 2rem;
  655. }
  656. }
  657. .tip {
  658. margin-top: 0.7rem;
  659. font-size: 1.4rem;
  660. color: #a4a4a4;
  661. }
  662. .install_btn {
  663. margin-top: 2rem;
  664. margin-bottom: 6.7rem;
  665. width: 23rem;
  666. height: 5.8rem;
  667. background: #389aff;
  668. border-radius: 10rem;
  669. color: #fff;
  670. line-height: 5.8rem;
  671. text-align: center;
  672. font-size: 2rem;
  673. }
  674. }
  675. .install-error {
  676. left: 78.5rem;
  677. .install_chrome {
  678. cursor: pointer;
  679. width: 24.3rem;
  680. height: 5.8rem;
  681. font-size: 2rem;
  682. font-weight: 500;
  683. letter-spacing: 0.3px;
  684. display: flex;
  685. align-items: center;
  686. border: 1px solid #e8e8e8;
  687. border-radius: 10rem;
  688. margin-top: 3.3rem;
  689. img {
  690. width: 3.2rem;
  691. height: 3.2rem;
  692. margin-left: 3.3rem;
  693. }
  694. span {
  695. margin-left: 1.2rem;
  696. }
  697. }
  698. }
  699. }
  700. @keyframes key_area {
  701. 0% {
  702. opacity: 1;
  703. }
  704. 100% {
  705. opacity: 0;
  706. }
  707. }
  708. @keyframes key_install {
  709. 0% {
  710. opacity: 0;
  711. }
  712. 100% {
  713. opacity: 1;
  714. }
  715. }
  716. @keyframes key_packet {
  717. 0% {
  718. }
  719. 100% {
  720. left: 30.6rem;
  721. margin-left: -18rem;
  722. }
  723. }
  724. @keyframes key_top {
  725. 0% {
  726. top: 0;
  727. }
  728. 50% {
  729. top: -30rem;
  730. }
  731. 100% {
  732. top: -36rem;
  733. }
  734. }
  735. @keyframes key_down {
  736. 0% {
  737. bottom: 0;
  738. }
  739. 50% {
  740. bottom: -28.3rem;
  741. }
  742. 100% {
  743. bottom: -32.3rem;
  744. }
  745. }
  746. </style>