index.vue 17 KB

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