red-packet.vue 35 KB

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