index.vue 17 KB

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