red-packet.vue 35 KB

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