red-packet.vue 35 KB

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