red-packet.vue 38 KB

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