red-packet.vue 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105
  1. <!-- 红包任务页面 -->
  2. <template>
  3. <div class="content">
  4. <!-- open -->
  5. <div v-show="state.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="state.detail.currencyIconPath" alt />
  10. <font-amount :amount="state.money" class="big" :fontSize="46"></font-amount>
  11. </div>
  12. </div> -->
  13. <div class="header" :style="{ 'backgroundImage': `url(${require('@/assets/subject/001-back-head-top-1.svg')})` }">
  14. <!-- -->
  15. <img :src="require('@/assets/subject/001-icon-red-packet.svg')" alt="">
  16. <div class="txt">
  17. <p>Complete tasks</p>
  18. <p>to Draw Prizes</p>
  19. </div>
  20. </div>
  21. <div class="list">
  22. <div class="item" v-for="item, i in state.detail.taskCondition" v-bind:key="i">
  23. <template v-if="item.type == 1 && item.relatedUsers && item.relatedUsers.length > 0">
  24. <div class="item-content">
  25. <div class="item-follow-title">
  26. <img :src="require('@/assets/svg/icon-follow.svg')" alt />
  27. <div class="item-title">Follow</div>
  28. <img :src="require('@/assets/gif/red-right.gif')" alt class="red-right"
  29. v-show="!state.done.follow && state.done.follow_red" />
  30. <img v-if="state.done.follow" :src="require('@/assets/svg/icon-true.svg')" alt />
  31. <div v-else class="btn" @click="clickFollowAll(item.relatedUsers, 'all')">Follow All</div>
  32. </div>
  33. <div class="item-follow-area">
  34. <template v-for="item2, i in item.relatedUsers" v-bind:key="i">
  35. <div class="item-follow" v-if="item2.finished">
  36. <span :class="{ finished: item2.finished }">@{{ item2.name }}</span>
  37. <img :src="require('@/assets/svg/icon-true-ed.svg')" alt />
  38. </div>
  39. <div class="item-follow" v-else @click="clickFollowAll([{ name: item2.name }])">
  40. <span :class="{ finished: item2.finished }">@{{ item2.name }}</span>
  41. <img :src="require('@/assets/svg/icon-add.svg')" alt />
  42. </div>
  43. </template>
  44. </div>
  45. </div>
  46. </template>
  47. <template v-if="item.type == 2">
  48. <img :src="require('@/assets/svg/icon-like.svg')" alt />
  49. <div class="item-content">
  50. <div class="item-title">Like</div>
  51. </div>
  52. <img :src="require('@/assets/gif/red-right.gif')" alt class="red-right"
  53. v-show="!state.done.like && state.done.like_red" />
  54. <img v-if="state.done.like" :src="require('@/assets/svg/icon-true.svg')" alt />
  55. <div v-else class="btn" @click="clickLikeBtn">Like</div>
  56. </template>
  57. <template v-if="item.type == 3">
  58. <img :src="require('@/assets/svg/icon-retweet.svg')" alt />
  59. <div class="item-content">
  60. <div class="item-title">Retweet</div>
  61. </div>
  62. <img :src="require('@/assets/gif/red-right.gif')" alt class="red-right"
  63. v-show="!state.done.retweet && state.done.retweet_red" />
  64. <img v-if="state.done.retweet" :src="require('@/assets/svg/icon-true.svg')" alt />
  65. <div v-else class="btn" @click="clickRetweetBtn">Retweet</div>
  66. </template>
  67. <template v-if="item.type == 7">
  68. <img :src="require('@/assets/svg/icon-discord-mini.svg')" alt />
  69. <div class="item-content">
  70. <div class="item-title">Join Discord</div>
  71. </div>
  72. <img :src="require('@/assets/gif/red-right.gif')" alt class="red-right"
  73. v-show="!state.done.join_discord && state.done.join_discord_red" />
  74. <img v-if="state.done.join_discord" :src="require('@/assets/svg/icon-true.svg')" alt />
  75. <template v-else>
  76. <div v-if="joinDiscordIng" class="loading-wrapper">
  77. <img class="icon-loading" :src="require('@/assets/svg/icon-loading-gray.svg')" />
  78. </div>
  79. <div v-else class="btn" @click="joinDiscord">
  80. Join
  81. </div>
  82. </template>
  83. </template>
  84. </div>
  85. </div>
  86. <!-- <div class="people" @click="clickRoad">
  87. <div class="txt">
  88. {{ state.detail.receiveCount || 0 }}/{{ state.detail.totalCount || 0 }} Winners,{{
  89. state.detail.receiveAmountValue
  90. }}/{{ state.detail.amountValue }} {{ state.detail.currencySymbol }}</div>
  91. <div class="right" v-if="state.detail.allReceived">
  92. <img :src="require('@/assets/svg/icon-right.svg')" alt class="road" />
  93. </div>
  94. </div> -->
  95. <div class="footer">
  96. <div class="winner">
  97. <p>Winners</p>
  98. <div class="right">
  99. <template v-if="state.detail.allReceived" v-for="item, i in state.detail.allReceived.slice(0, 3)"
  100. v-bind:key="i">
  101. <img v-if="item.simpleUserInfoVO.avatarUrl" :src="item.simpleUserInfoVO.avatarUrl" alt
  102. :style="{ left: `${(i) * 16}px`, zIndex: `${10 - i}` }" />
  103. <img v-else :src="require('@/assets/svg/icon-twitter.svg')" alt
  104. :style="{ left: `${(i) * 16}px`, zIndex: `${10 - i}` }" />
  105. </template>
  106. <img v-if="state.detail.allReceived && state.detail.allReceived.length > 3"
  107. :src="require('@/assets/svg/icon-winner-more.svg')" alt
  108. :style="{ left: `${3 * 16}px`, zIndex: `${10 - 3}` }" />
  109. </div>
  110. </div>
  111. <div class="btn" @click="clickGetGiveaways">Complete</div>
  112. </div>
  113. </div>
  114. <!-- success -->
  115. <div v-if="state.status == 'success'" class="success">
  116. <div class="header" :style="{ 'backgroundImage': `url(${require('@/assets/subject/001-back-head-top.svg')})` }">
  117. <div class="money">
  118. <img :src="state.detail.currencyIconPath" alt />
  119. <font-amount :amount="state.receiveAmount" class="big" :fontSize="46"></font-amount>
  120. <!-- <span class="small">{{ state.detail.currencySymbol }}</span> -->
  121. </div>
  122. <div class="done" @click="clickDone">
  123. <img :src="require('@/assets/subject/001-icon-done.svg')" alt class="icon-done" />
  124. <span>View Rewards In Wallet</span>
  125. <img :src="require('@/assets/svg/icon-right.svg')" alt class="icon-right" />
  126. </div>
  127. </div>
  128. <div class="luck-list-title">
  129. <div>{{ state.detail.receiveCount || 0 }}/{{ state.detail.totalCount || 0 }} Winners</div>
  130. <div class="right">
  131. <span class="text">
  132. <a-tooltip :title="state.detail.receiveAmountValue">
  133. {{ getBit(state.detail.receiveAmountValue) }}
  134. </a-tooltip>
  135. /
  136. <a-tooltip :title="state.detail.amountValue">
  137. {{ getBit(state.detail.amountValue) || ''}}
  138. </a-tooltip>
  139. </span>
  140. {{ state.detail.currencySymbol || '' }}
  141. </div>
  142. </div>
  143. <div class="luck-list max" @scroll="handleScroll($event)">
  144. <div class="luck-item" v-for="item, i in state.detail.allReceived" v-bind:key="i">
  145. <img v-if="item.simpleUserInfoVO.avatarUrl" :src="item.simpleUserInfoVO.avatarUrl"
  146. @click="openTwitterDetail(item)" alt />
  147. <img v-else :src="require('@/assets/svg/icon-twitter.svg')" alt />
  148. <div class="luck-content">
  149. <div class="luck-title" v-if="item.simpleUserInfoVO.nickName">{{ item.simpleUserInfoVO.nickName }}</div>
  150. <div class="luck-title" v-else>Twitter User</div>
  151. <div class="luck-time">{{ moment(item.receiveTimestamp).format('MM-DD HH:mm:ss') }}</div>
  152. </div>
  153. <div class="luck-money">
  154. <img :src="state.detail.currencyIconPath" alt />
  155. <div class="luck-money-txt">
  156. <a-tooltip :title="item.amountValue">
  157. {{ getBit(item.amountValue) }}
  158. </a-tooltip>
  159. </div>
  160. </div>
  161. <div class="luck-king" v-if="item.maxAmount">
  162. <img :src="require('@/assets/svg/icon-king-hat.svg')" alt />
  163. <span>Luckiest Draw</span>
  164. </div>
  165. </div>
  166. </div>
  167. <get-more></get-more>
  168. </div>
  169. <!-- no-open -->
  170. <div v-else-if="state.status == 'not-open'" class="not-open">
  171. <img :src="require('@/assets/subject/001-card.png')" alt="">
  172. <img class="open-gif" :src="require('@/assets/gif/001.gif')" />
  173. <img :src="require('@/assets/svg/icon-open.svg')" alt="" class="open" @click="clickOpenRedPacket">
  174. <div class="title" v-if="state.detail.postUserInfo">
  175. <img :src="state.detail.postUserInfo.avatarUrl" alt />
  176. <span>{{ state.detail.postUserInfo.nickName || 'FutureDoctor' }}</span>
  177. </div>
  178. <div class="money-area">
  179. <div class="txt">{{ state.detail.currencySymbol }} GIVEAWAY</div>
  180. <div class="coin">
  181. <img :src="state.detail.currencyIconPath" alt />
  182. <font-amount :amount="state.detail.amountValue"></font-amount>
  183. </div>
  184. <div class="people">{{ state.detail.totalCount }} WINNERS TO SHARE</div>
  185. </div>
  186. </div>
  187. <!-- 领取列表 -->
  188. <div v-else-if="state.status == 'luck-peopel-list'" class="luck-peopel-list">
  189. <div class="head">
  190. <img :src="require('@/assets/svg/icon-back.svg')" alt />
  191. </div>
  192. <div class="luck-list-title">
  193. <div>{{ state.detail.receiveCount || 0 }}/{{ state.detail.totalCount || 0 }} Winners</div>
  194. <div class="right">
  195. <span class="text">
  196. <a-tooltip :title="state.detail.receiveAmountValue">
  197. {{ getBit(state.detail.receiveAmountValue) }}
  198. </a-tooltip>
  199. /
  200. <a-tooltip :title="state.detail.amountValue">
  201. {{ getBit(state.detail.amountValue) || '' }}
  202. </a-tooltip>
  203. </span> {{
  204. state.detail.currencySymbol || ''
  205. }}</div>
  206. </div>
  207. <div class="luck-list" @scroll="handleScroll">
  208. <div class="luck-item" v-for="item, i in state.detail.allReceived" v-bind:key="i">
  209. <img v-if="item.simpleUserInfoVO.avatarUrl" :src="item.simpleUserInfoVO.avatarUrl" alt
  210. @click="openTwitterDetail(item)" />
  211. <img v-else :src="require('@/assets/svg/icon-twitter.svg')" alt />
  212. <div class="luck-content">
  213. <div class="luck-title" v-if="item.simpleUserInfoVO.nickName">{{ item.simpleUserInfoVO.nickName }}</div>
  214. <div class="luck-title" v-else>Twitter User</div>
  215. <div class="luck-time">{{ moment(item.receiveTimestamp).format('MM-DD HH:mm:ss') }}</div>
  216. </div>
  217. <div class="luck-money">
  218. <img :src="state.detail.currencyIconPath" alt />
  219. <div class="luck-money-txt">
  220. <a-tooltip :title="item.amountValue">
  221. {{ getBit(item.amountValue) }}
  222. </a-tooltip>
  223. </div>
  224. </div>
  225. <div class="luck-king" v-if="item.maxAmount">
  226. <img :src="require('@/assets/svg/icon-king-hat.svg')" alt />
  227. <span>Luckiest Draw</span>
  228. </div>
  229. </div>
  230. </div>
  231. </div>
  232. <!-- 关闭状态 -->
  233. <div v-else-if="state.status == 'close'" class="close">
  234. <!-- 红包被领完了 -->
  235. <div class="header" :style="{ 'backgroundImage': `url(${require('@/assets/subject/001-back-head-top.svg')})` }"
  236. v-show="state.close_status == '红包过期了'">
  237. <div class="close-title" v-for="item in state.close_text">{{ item }}</div>
  238. </div>
  239. <!-- 没有领取到钱 -->
  240. <div class="header" :style="{ 'backgroundImage': `url(${require('@/assets/subject/001-back-head-top.svg')})` }"
  241. v-show="state.close_status == '没有领到钱'">
  242. <div class="rabbit">
  243. <img :src="require('@/assets/subject/001-icon-rabbit.svg')" alt />
  244. <p>Sorry, you missed this chance</p>
  245. <p>Come Earlier Next Time!</p>
  246. </div>
  247. </div>
  248. <div class="luck-list-title">
  249. <div>{{ state.detail.receiveCount || 0 }}/{{ state.detail.totalCount || 0 }} Winners</div>
  250. <div class="right">
  251. <span class="text">
  252. <a-tooltip :title="state.detail.receiveAmountValue">
  253. {{ getBit(state.detail.receiveAmountValue) }}
  254. </a-tooltip>
  255. /
  256. <a-tooltip :title="state.detail.amountValue">
  257. {{ getBit(state.detail.amountValue || '') }}
  258. </a-tooltip>
  259. </span> {{
  260. state.detail.currencySymbol || ''
  261. }}</div>
  262. </div>
  263. <div class="luck-list max" @scroll="handleScroll">
  264. <div class="luck-item" v-for="item, i in state.detail.allReceived" v-bind:key="i">
  265. <img v-if="item.simpleUserInfoVO.avatarUrl" :src="item.simpleUserInfoVO.avatarUrl" alt
  266. @click="openTwitterDetail(item)" />
  267. <img v-else :src="require('@/assets/svg/icon-twitter.svg')" alt />
  268. <div class="luck-content">
  269. <div class="luck-title" v-if="item.simpleUserInfoVO.nickName">{{ item.simpleUserInfoVO.nickName }}</div>
  270. <div class="luck-title" v-else>Twitter User</div>
  271. <div class="luck-time">{{ moment(item.receiveTimestamp).format('MM-DD HH:mm:ss') }}</div>
  272. </div>
  273. <div class="luck-money">
  274. <img :src="state.detail.currencyIconPath" alt />
  275. <div class="luck-money-txt">
  276. <a-tooltip :title="item.amountValue">
  277. {{ getBit(item.amountValue) }}
  278. </a-tooltip>
  279. </div>
  280. </div>
  281. <div class="luck-king" v-if="item.maxAmount">
  282. <img :src="require('@/assets/svg/icon-king-hat.svg')" alt />
  283. <span>Luckiest Draw</span>
  284. </div>
  285. </div>
  286. <div class="empty" v-show="state.detail.allReceived && state.detail.allReceived.length == 0">
  287. <img :src="require('@/assets/svg/icon-error.svg')" alt />
  288. </div>
  289. </div>
  290. <get-more></get-more>
  291. </div>
  292. <!-- error -->
  293. <div v-else-if="state.status == 'error'" class="error">
  294. <img :src="require('@/assets/svg/icon-error.svg')" alt />
  295. <div class="txt">
  296. {{ state.error_txt }}
  297. </div>
  298. <div class="retry" v-show="state.retry" @click="clickRetry">
  299. Retry
  300. </div>
  301. </div>
  302. <!-- loading -->
  303. <div v-show="state.loading_show" class="loading">
  304. <img :src="require('@/assets/svg/icon-loading.svg')" alt />
  305. </div>
  306. </div>
  307. <div style="width: 100%; height: 30px; position: fixed; color: red; top:0;" v-if="state.process_mode != 'production'">
  308. {{ state.detail.validity }}</div>
  309. </template>
  310. <script>
  311. export default {
  312. name: 'redPacket',
  313. }
  314. </script>
  315. <script setup>
  316. import { onMounted, reactive, ref } from "vue";
  317. import { getPostDetail, getRedPacket, finishRedPacket, oneKeyLike, oneKeyReTweet, oneKeyFollow, getTaskDetail, getReceivedList } from '@/http/redPacket.js'
  318. import { getQueryString, guid, getBit } from '@/uilts/help.js'
  319. import { message } from 'ant-design-vue';
  320. import FontAmount from '@/view/components/font-amount.vue'
  321. import GetMore from '@/view/iframe/publish/components/get-more.vue'
  322. import { getChromeStorage } from '@/uilts/chromeExtension.js'
  323. import Report from "@/log-center/log"
  324. import { srcPublishSuccess } from '@/http/publishApi'
  325. import { discordAuthUrl, checkGuildJoined } from '@/http/discordApi'
  326. import { discordAuthRedirectUri } from '@/http/configAPI'
  327. var moment = require('moment');
  328. let discordAuthorizeRequired = false;
  329. let joinDiscordActionState = 'default'; //authAndJoinIng joinIng reAuth
  330. let joinDiscordIng = ref(false);
  331. let state = reactive({
  332. status: '',
  333. loading_show: false,
  334. detail: {},
  335. luck_list_end: false,
  336. page_index: 1,
  337. page_size: 20,
  338. srcContentId: '',
  339. error_txt: `oops, new accounts cannot participate in this event,`,
  340. receiveAmount: 0,
  341. money: 0,
  342. // 状态
  343. done: {
  344. follow: false,
  345. like: false,
  346. retweet: false,
  347. join_discord: false
  348. }
  349. })
  350. function clickRetry() {
  351. init()
  352. }
  353. async function clickLikeBtn() {
  354. let _userInfo = await checkIsLogin()
  355. if (!_userInfo) {
  356. return
  357. }
  358. state.loading_show = true
  359. oneKeyLike({
  360. params: {
  361. tweetId: state.srcContentId
  362. }
  363. }).then((res) => {
  364. state.loading_show = false
  365. if (res.code == 0) {
  366. if (res.data.result) {
  367. state.done.like = true
  368. } else {
  369. state.done.like = false
  370. }
  371. } else {
  372. state.done.like = false
  373. console.log(res)
  374. }
  375. })
  376. // 埋点
  377. Report.reportLog({
  378. objectType: Report.objectType.like,
  379. pageSource: Report.pageSource.task_page,
  380. businessType: Report.businessType.buttonClick
  381. });
  382. }
  383. function clickDone() {
  384. window.open(`${chrome.runtime.getURL('/iframe/home.html')}`)
  385. // 埋点
  386. Report.reportLog({
  387. objectType: Report.objectType.wallet_button,
  388. pageSource: Report.pageSource.received_success_page,
  389. businessType: Report.businessType.buttonClick
  390. });
  391. }
  392. function handleScroll(e) {
  393. if (state.luck_list_end) {
  394. return
  395. }
  396. e = e.target
  397. if ((e.clientHeight + e.scrollTop) / e.scrollHeight > .8) {
  398. state.luck_list_end = true
  399. state.page_index++
  400. handleReceivedList()
  401. }
  402. }
  403. function handleReceivedList() {
  404. getReceivedList({
  405. params: {
  406. pageNum: state.page_index,
  407. pageSize: state.page_size,
  408. postId: state.postId
  409. }
  410. }).then((res) => {
  411. if (res.code == 0) {
  412. if (res.data.length > 0) {
  413. state.detail.allReceived = state.detail.allReceived.concat(res.data)
  414. state.luck_list_end = false
  415. } else {
  416. state.luck_list_end = true
  417. }
  418. } else {
  419. console.log('getReceivedList', res)
  420. }
  421. })
  422. }
  423. const openTwitterDetail = (item) => {
  424. if (item.simpleUserInfoVO.nickName) {
  425. window.open(`https://twitter.com/${item.simpleUserInfoVO.nickName}`)
  426. }
  427. }
  428. async function clickRetweetBtn() {
  429. let _userInfo = await checkIsLogin()
  430. if (!_userInfo) {
  431. return
  432. }
  433. state.loading_show = true
  434. oneKeyReTweet({
  435. params: {
  436. tweetId: state.srcContentId
  437. }
  438. }).then((res) => {
  439. state.loading_show = false
  440. if (res.code == 0) {
  441. if (res.data.result) {
  442. state.done.retweet = true
  443. } else {
  444. state.done.retweet = false
  445. }
  446. } else {
  447. state.done.retweet = false
  448. console.log(res)
  449. }
  450. })
  451. // 埋点
  452. Report.reportLog({
  453. objectType: Report.objectType.retweet,
  454. pageSource: Report.pageSource.task_page,
  455. businessType: Report.businessType.buttonClick
  456. });
  457. }
  458. function getValidity() {
  459. let _d1, _d2, _d3, _h, _m, _s
  460. if (!state.detail.myReceived.taskEndTimestamp) {
  461. return
  462. }
  463. let timer = setInterval(() => {
  464. let _time = new Date().getTime()
  465. _d3 = state.detail.myReceived.taskEndTimestamp - _time
  466. if (_d3 > 0) {
  467. _d1 = moment(state.detail.myReceived.taskEndTimestamp)
  468. _d2 = moment(_time)
  469. _h = moment.duration(_d1.diff(_d2)).hours()
  470. if (_h < 10) {
  471. _h = '0' + _h
  472. }
  473. _m = moment.duration(_d1.diff(_d2)).minutes()
  474. if (_m < 10) {
  475. _m = '0' + _m
  476. }
  477. _s = moment.duration(_d1.diff(_d2)).seconds()
  478. if (_s < 10) {
  479. _s = '0' + _s
  480. }
  481. state.detail.validity = `${_h}:${_m}:${_s}`
  482. } else {
  483. state.detail.validity = `00:00:00`
  484. clearInterval(timer)
  485. }
  486. }, 1000)
  487. }
  488. async function clickFollowAll(item, is_all) {
  489. let _userInfo = await checkIsLogin()
  490. if (!_userInfo) {
  491. return
  492. }
  493. state.loading_show = true
  494. let arr_name = []
  495. for (let i in item) {
  496. arr_name.push(item[i].name)
  497. }
  498. oneKeyFollow({
  499. params: {
  500. names: arr_name
  501. }
  502. }).then((res) => {
  503. state.loading_show = false
  504. if (res.code == 0) {
  505. res.data.forEach((item1) => {
  506. state.detail.taskCondition[0].relatedUsers.forEach(item2 => {
  507. if (item1.name == item2.name) {
  508. item2.finished = true
  509. }
  510. });
  511. })
  512. let _len = state.detail.taskCondition[0].relatedUsers.filter((item) => { return item.finished == false }).length
  513. if (_len > 0) {
  514. state.done.follow = false
  515. } else {
  516. state.done.follow = true
  517. }
  518. } else {
  519. state.detail.taskCondition[0].relatedUsers.forEach(item => {
  520. item.finished = false
  521. });
  522. }
  523. })
  524. let _log_obj = {
  525. pageSource: Report.pageSource.task_page,
  526. businessType: Report.businessType.buttonClick,
  527. objectType: Report.objectType.follow
  528. }
  529. if (is_all) {
  530. // 埋点
  531. _log_obj.objectType = Report.objectType.follow_button
  532. }
  533. Report.reportLog(_log_obj);
  534. }
  535. // 重新绑定
  536. const reSetBindTwtterId = (_params) => {
  537. getChromeStorage('userInfo', (_userInfo) => {
  538. if (_userInfo.uid == _params.uid) {
  539. srcPublishSuccess({
  540. params: {
  541. postId: state.postId,
  542. srcContentId: state.tweetId
  543. }
  544. }).then((res) => {
  545. if (res.code == 0 || res.code == 3003) {
  546. Report.reportLog({
  547. objectType: Report.objectType.tweetPostBinded
  548. });
  549. init()
  550. }
  551. })
  552. }
  553. })
  554. }
  555. function showLastTwoPlace(n) {
  556. return n
  557. }
  558. const showCloseEndTimePage = () => {
  559. state.status = 'close'
  560. state.close_status = '红包过期了'
  561. state.close_text = [`This Giveaways`, `expired on ${moment(state.detail.endTimestamp).format('MM-DD')}`]
  562. }
  563. const showCloseEndTimePageReport = () => {
  564. // 埋点
  565. Report.reportLog({
  566. pageSource: Report.pageSource.expired_page,
  567. businessType: Report.businessType.pageView,
  568. });
  569. }
  570. const showSuccessPage = () => {
  571. state.status = 'success'
  572. // 埋点
  573. Report.reportLog({
  574. pageSource: Report.pageSource.task_page,
  575. businessType: Report.businessType.pageView,
  576. objectType: Report.objectType.get_giveaway
  577. }, {
  578. get_giveaway_result: Report.extParams.success
  579. });
  580. }
  581. const showNotOpenPage = () => {
  582. state.status = 'not-open'
  583. Report.reportLog({
  584. pageSource: Report.pageSource.pending_page,
  585. businessType: Report.businessType.pageView
  586. });
  587. }
  588. const showOpenedPage = () => {
  589. state.status = 'opened'
  590. initTaskDetail()
  591. }
  592. const showOpenedPageReport = () => {
  593. // 埋点
  594. Report.reportLog({
  595. pageSource: Report.pageSource.task_page,
  596. businessType: Report.businessType.pageView,
  597. });
  598. }
  599. const showRabbitPage = () => {
  600. state.status = 'close'
  601. state.close_status = '没有领到钱'
  602. }
  603. const showRabbitPageReport = () => {
  604. Report.reportLog({
  605. pageSource: Report.pageSource.received_empty_rewards_page,
  606. businessType: Report.businessType.pageView,
  607. });
  608. }
  609. const handleStatusPage = () => {
  610. // status 红包状态(0:未开始,1:进行中,2:已结束,3:已终止,4:终止退款进行中)
  611. // myReceived 我是否领取过
  612. // taskFinishStatus 任务完成状态(0:未完成,1:已完成,2:已过期)
  613. // receiveTimeExpired 是否已经过了红包的领取截止时间
  614. // ---- 判断结构 ----
  615. // 如果 红包状态 = 未开始
  616. // 显示未打开页面 return
  617. //
  618. // 如果 我领取过了
  619. // 如果 任务完成状态 = 未完成
  620. // 显示任务未完成页面
  621. // 如果 任务完成状态 = 已经完成
  622. // 如果 领取到红包金额 = 0
  623. // 显示兔子页面
  624. // 否则
  625. // 显示成功页面
  626. // 如果 任务完成状态 = 已经过期
  627. // 如果 红包状态 = 进行中
  628. // 显示未打开页面
  629. // 否则
  630. // 显示已经过期页面
  631. // 如果 我没有领取过 & 红包状态 = 进行中
  632. // 如果 过了红包的领取截止时间 = true
  633. // 显示已经过期页面
  634. // 如果 过了红包的领取截止时间 = false
  635. // 显示未打开页面
  636. // 如果 我没有领取过 & 红包状态 = 已结束 | 已终止 | 终止退款进行中
  637. // 显示过期页面
  638. // -------- 华丽的分割线 --------
  639. // 如果 红包状态 = 未开始
  640. if (state.detail.status == 0) {
  641. showNotOpenPage()
  642. return
  643. }
  644. // 如果 我领取过了
  645. if (state.detail.myReceived) {
  646. state.receiveAmount = state.detail.myReceived.amountValue || 0
  647. state.detail.taskCondition = JSON.parse(state.detail.taskCondition)
  648. // 如果 任务完成状态 = 未完成
  649. if (state.detail.myReceived.taskFinishStatus == 0) {
  650. // 显示任务未完成页面
  651. showOpenedPage()
  652. showOpenedPageReport()
  653. if (state.process_mode != 'production') {
  654. getValidity()
  655. }
  656. //如果 任务完成状态 = 已经完成
  657. } else if (state.detail.myReceived.taskFinishStatus == 1) {
  658. // 领取到空红包
  659. if (state.receiveAmount == 0) {
  660. showRabbitPage()
  661. showRabbitPageReport()
  662. } else {
  663. // 显示成功页面
  664. showSuccessPage()
  665. }
  666. // 如果 任务完成状态 = 已经过期
  667. } else {
  668. // 如果 红包状态 = 进行中
  669. if (state.detail.status == 1) {
  670. // 显示未打开页面
  671. showNotOpenPage()
  672. // 否则
  673. } else {
  674. // 显示已经过期页面
  675. showCloseEndTimePage()
  676. showCloseEndTimePageReport()
  677. }
  678. }
  679. // 如果 我没有领取过
  680. } else {
  681. // 如果 红包状态 = 进行中
  682. if (state.detail.status == 1) {
  683. // 如果 过了红包的领取截止时间 = true
  684. if (state.detail.receiveTimeExpired) {
  685. // 显示过期页面
  686. showCloseEndTimePage()
  687. showCloseEndTimePageReport()
  688. // 如果 过了红包的领取截止时间 = false
  689. } else {
  690. // 显示未打开页面
  691. showNotOpenPage()
  692. }
  693. // 红包状态 = 已经结束了 | 已经终止 | 终止退款中
  694. } else {
  695. // 显示过期页面
  696. showCloseEndTimePage()
  697. showCloseEndTimePageReport()
  698. }
  699. }
  700. }
  701. function init() {
  702. onRuntimeMsg();
  703. onPageVisbile();
  704. getPostDetail({
  705. params: {
  706. postId: state.postId
  707. }
  708. }).then((res) => {
  709. state.loading_show = false
  710. // 领取0元为空红包继续流程
  711. // ---- 完成任务接口 ----
  712. // 如果金额是0
  713. // 显示没有领到钱
  714. if (res.code == 0) {
  715. // 判断推特id,绑定逻辑
  716. state.srcContentId = res.data.srcContentId
  717. if (!state.srcContentId) {
  718. reSetBindTwtterId(res.data)
  719. return
  720. }
  721. state.detail = JSON.parse(res.data.postBizData)
  722. state.detail.taskCondition = state.detail.taskCondition || []
  723. console.log(state.detail)
  724. handleStatusPage()
  725. } else {
  726. handleErrorCode(res)
  727. }
  728. })
  729. }
  730. function initTaskDetail() {
  731. // 任务详情
  732. getTaskDetail({
  733. params: {
  734. postId: state.postId
  735. }
  736. }).then((res) => {
  737. if (res.code.toString()) {
  738. for (let i in res.data) {
  739. switch (res.data[i].type) {
  740. case 1:
  741. state.done.follow = res.data[i].finished
  742. state.detail.taskCondition[0].relatedUsers = res.data[i].detail
  743. break
  744. case 2:
  745. state.done.like = res.data[i].finished
  746. break
  747. case 3:
  748. state.done.retweet = res.data[i].finished
  749. break
  750. case 7:
  751. state.done.join_discord = res.data[i].finished
  752. discordAuthorizeRequired = res.data[i].discordAuthorizeRequired
  753. break
  754. }
  755. }
  756. } else {
  757. handleErrorCode(res)
  758. }
  759. })
  760. }
  761. onMounted(() => {
  762. state.process_mode = process.env.NODE_ENV
  763. console.log('state.process_mode',state.process_mode)
  764. state.postId = getQueryString('postId')
  765. state.tweetId = getQueryString('tweetId')
  766. init()
  767. // state.loading_show = true
  768. // state.status = 'opened'
  769. // state.close_status = '没有领到钱'
  770. })
  771. // 点击领取
  772. function clickOpenRedPacket() {
  773. chrome.runtime.sendMessage({
  774. actionType: 'CONTENT_GET_PINED'
  775. }, res => {
  776. console.log(res);
  777. })
  778. handleRedPacket()
  779. }
  780. function handleRedPacket() {
  781. getRedPacket({
  782. params: {
  783. postId: state.postId
  784. }
  785. }).then((res) => {
  786. if (res.code == 0) {
  787. showOpenedPage()
  788. init()
  789. } else {
  790. handleErrorCode(res)
  791. }
  792. })
  793. // 埋点
  794. Report.reportLog({
  795. pageSource: Report.pageSource.pending_page,
  796. businessType: Report.businessType.buttonClick,
  797. objectType: Report.objectType.open_button
  798. });
  799. }
  800. chrome.storage.onChanged.addListener(changes => {
  801. if (changes.userInfo) {
  802. // let item = JSON.parse(changes.userInfo.newValue)
  803. state.loading_show = false
  804. init()
  805. }
  806. })
  807. // 校验是否封路
  808. function checkIsLogin() {
  809. return new Promise((resolve) => {
  810. getChromeStorage('userInfo', (_userInfo) => {
  811. if (!_userInfo) {
  812. state.loading_show = true
  813. setTimeout(() => {
  814. state.loading_show = false
  815. }, 3000)
  816. chrome.runtime.sendMessage(
  817. { actionType: "POPUP_LOGIN", data: "" },
  818. (response) => {
  819. console.log("res", response);
  820. }
  821. )
  822. resolve(_userInfo)
  823. } else {
  824. resolve(_userInfo)
  825. }
  826. })
  827. })
  828. }
  829. async function clickGetGiveaways() {
  830. let _userInfo = await checkIsLogin()
  831. if (_userInfo) {
  832. handleFinishRedPacket()
  833. }
  834. }
  835. function handleFinishRedPacket() {
  836. state.loading_show = true
  837. finishRedPacket({
  838. params: {
  839. postId: state.postId
  840. }
  841. }).then((res) => {
  842. state.loading_show = false
  843. if (res.code == 0) {
  844. if (res.data.finished) {
  845. state.receiveAmount = res.data.receiveAmount
  846. if (state.receiveAmount == 0) {
  847. showRabbitPage()
  848. } else {
  849. state.status = 'success'
  850. }
  851. init()
  852. // 埋点
  853. Report.reportLog({
  854. pageSource: Report.pageSource.task_page,
  855. businessType: Report.businessType.buttonClick,
  856. objectType: Report.objectType.get_giveaway
  857. }, {
  858. get_giveaway_result: Report.extParams.success
  859. });
  860. } else {
  861. let _data = res.data.conditionResult
  862. for (let i in _data) {
  863. switch (_data[i].type.toString()) {
  864. case '1':
  865. state.detail.taskCondition[0].relatedUsers = _data[i].detail
  866. if (_data[i].finished) {
  867. state.done.follow = true
  868. state.done.follow_red = false
  869. } else {
  870. // alert('Please complete the task: follow')
  871. state.done.follow = false
  872. state.done.follow_red = true
  873. }
  874. break
  875. case '2':
  876. if (_data[i].finished) {
  877. state.done.like = true
  878. state.done.like_red = false
  879. } else {
  880. // alert('Please complete the task: like tweet')
  881. state.done.like = false
  882. state.done.like_red = true
  883. }
  884. break
  885. case '3':
  886. if (_data[i].finished) {
  887. state.done.retweet = true
  888. state.done.retweet_red = false
  889. } else {
  890. // alert('Please complete the task: Retweet')
  891. state.done.retweet_red = true
  892. state.done.retweet = false
  893. }
  894. break
  895. case '7':
  896. discordAuthorizeRequired = _data[i].discordAuthorizeRequired;
  897. if (_data[i].finished) {
  898. state.done.join_discord = true
  899. state.done.join_discord_red = false
  900. } else {
  901. state.done.join_discord = false;
  902. state.done.join_discord_red = true
  903. }
  904. break
  905. }
  906. }
  907. // 埋点
  908. Report.reportLog({
  909. pageSource: Report.pageSource.task_page,
  910. businessType: Report.businessType.buttonClick,
  911. objectType: Report.objectType.get_giveaway
  912. }, {
  913. get_giveaway_result: Report.extParams.failure
  914. });
  915. if (discordAuthorizeRequired) {
  916. discordAuth('reAuth');
  917. }
  918. }
  919. } else {
  920. // 埋点
  921. Report.reportLog({
  922. pageSource: Report.pageSource.task_page,
  923. businessType: Report.businessType.buttonClick,
  924. objectType: Report.objectType.get_giveaway
  925. }, {
  926. get_giveaway_result: Report.extParams.failure
  927. });
  928. handleErrorCode(res)
  929. }
  930. })
  931. }
  932. function handleErrorCode(res) {
  933. switch (res.code.toString()) {
  934. // 数据异常,请联系管理员
  935. case '-102':
  936. break
  937. //系统错误
  938. case '-101':
  939. break
  940. // 参数不对
  941. case '-103':
  942. break
  943. // 接口被限流
  944. case '-105':
  945. break
  946. // 访问凭证不存在
  947. case '-107':
  948. break
  949. // 重复操作过于频繁
  950. case '-106':
  951. message.error('Clicking too often, wait a moment and click again')
  952. state.loading_show = false
  953. break
  954. // 红包不存在
  955. case '2001':
  956. // message.error(res.msg)
  957. break
  958. // 还未到红包领取时间
  959. case '2002':
  960. // message.error(res.msg)
  961. break
  962. // 已超过红包领取时间
  963. case '2003':
  964. init()
  965. break
  966. // 红包支付状态异常 没有可提交的任务红包
  967. case '2004':
  968. init()
  969. break
  970. // 红包活动已结束
  971. case '2006':
  972. init()
  973. break
  974. // 红包金额已经被领取完了
  975. case '2007':
  976. state.status = 'close'
  977. state.close_status = '红包过期了'
  978. state.close_text = [`This Giveaways`, `expired on ${moment(state.detail.endTimestamp).format('MM-DD')}`]
  979. init()
  980. break
  981. // 红包个数已经被领取完了
  982. case '2008':
  983. state.status = 'close'
  984. state.close_status = '红包过期了'
  985. state.close_text = [`This Giveaways`, `expired on ${moment(state.detail.endTimestamp).format('MM-DD')}`]
  986. init()
  987. break
  988. // 该用户不满足领取条件
  989. case '2009':
  990. state.error_txt = [`oops, new accounts cannot participate in this event,`]
  991. state.status = 'error'
  992. state.retry = true
  993. // 埋点
  994. Report.reportLog({
  995. pageSource: Report.pageSource.robot_detection_failed_page,
  996. businessType: Report.businessType.pageView,
  997. });
  998. break
  999. // 无法校验用户Twitter信息
  1000. case '2010':
  1001. // message.error(res.msg)
  1002. break
  1003. // 用户已经领过该红包
  1004. case '2011':
  1005. // message.error(res.msg)
  1006. break
  1007. // 推文不存在
  1008. case '2022':
  1009. // message.error(res.msg)
  1010. break
  1011. // 推文未发布 and 不是红包任务的推文
  1012. case '2023':
  1013. // message.error(res.msg)
  1014. break
  1015. // 没有可提交的任务红包
  1016. case '2024':
  1017. state.status = 'not-open'
  1018. break
  1019. // 红包任务已完成
  1020. case '2025':
  1021. break
  1022. // 任务已经过期
  1023. case '2026':
  1024. break
  1025. // 任务未完成
  1026. case '2027':
  1027. break
  1028. // 红包金额每人不足1分钱
  1029. case '2028':
  1030. break
  1031. // 推文未发布
  1032. case '2029':
  1033. message.error('Tweet not posted')
  1034. break
  1035. // 不是红包任务的推文
  1036. case '2030':
  1037. break
  1038. case '2037':
  1039. showCloseEndTimePage()
  1040. init()
  1041. break
  1042. //用户没有领取过红包,无法重抽
  1043. case '2031':
  1044. break
  1045. // 需要重新授权 discord
  1046. case '1010':
  1047. discordAuth('reAuth');
  1048. break
  1049. }
  1050. }
  1051. // function clickBack() {
  1052. // state.status = 'opened'
  1053. // // 埋点
  1054. // Report.reportLog({
  1055. // pageSource: Report.pageSource.task_page,
  1056. // businessType: Report.businessType.pageView,
  1057. // });
  1058. // }
  1059. // function clickRoad() {
  1060. // state.status = 'luck-peopel-list'
  1061. // // 埋点
  1062. // Report.reportLog({
  1063. // pageSource: Report.pageSource.task_page,
  1064. // businessType: Report.businessType.buttonClick,
  1065. // objectType: Report.objectType.received_list
  1066. // });
  1067. // // 埋点
  1068. // Report.reportLog({
  1069. // pageSource: Report.pageSource.received_list_page,
  1070. // businessType: Report.businessType.pageView
  1071. // });
  1072. // }
  1073. function onPageVisbile() {
  1074. document.addEventListener('visibilitychange', function () {
  1075. let isHidden = document.hidden;
  1076. console.log('joinDiscordActionState', joinDiscordActionState);
  1077. if (!isHidden) {
  1078. checkJoinDiscord();
  1079. }
  1080. });
  1081. }
  1082. function onRuntimeMsg() {
  1083. chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
  1084. sendResponse('');
  1085. switch (req.actionType) {
  1086. case 'BACK_DISCORD_LOGIN_SUCCESS':
  1087. discordLoginSuccess();
  1088. break;
  1089. }
  1090. })
  1091. }
  1092. /**
  1093. * 检查是否加入discord
  1094. */
  1095. function checkJoinDiscord() {
  1096. // 如果上次的状态是 joinIng 检查是否真正join
  1097. if (joinDiscordActionState == 'joinIng') {
  1098. joinDiscordActionState = 'default';
  1099. let url = getInviteUrl();
  1100. if (url) {
  1101. joinDiscordIng.value = true;
  1102. checkGuildJoinedStatus({ url }, (res = {}) => {
  1103. joinDiscordIng.value = false;
  1104. if (res.code == 0) {
  1105. let { joined } = res.data || {};
  1106. if (joined) {
  1107. state.done.join_discord = true;
  1108. } else {
  1109. state.done.join_discord = false;
  1110. }
  1111. } else if (res.code == 1010) {
  1112. discordAuth('reAuth');
  1113. }
  1114. })
  1115. }
  1116. }
  1117. }
  1118. const checkGuildJoinedStatus = ({ url }, cb) => {
  1119. checkGuildJoined({
  1120. params: {
  1121. inviteUrl: url
  1122. }
  1123. }).then(res => {
  1124. cb && cb(res);
  1125. }).catch(err => {
  1126. cb && cb({ catch: true })
  1127. })
  1128. }
  1129. /**
  1130. * 加入discord 事件
  1131. */
  1132. async function joinDiscord() {
  1133. let _userInfo = await checkIsLogin();
  1134. if (!_userInfo) {
  1135. return
  1136. }
  1137. if (joinDiscordIng.value) {
  1138. return;
  1139. }
  1140. let url = getInviteUrl();
  1141. if (url) {
  1142. joinDiscordIng.value = true;
  1143. checkGuildJoinedStatus({ url }, (res) => {
  1144. setTimeout(() => {
  1145. joinDiscordIng.value = false;
  1146. }, 1500);
  1147. if (res.code == 0) {
  1148. let { joined } = res.data || {};
  1149. if (joined) {
  1150. state.done.join_discord = true;
  1151. } else {
  1152. state.done.join_discord = false;
  1153. if(discordAuthorizeRequired) {
  1154. discordAuth('authAndJoinIng');
  1155. } else {
  1156. openInviteUrl();
  1157. }
  1158. }
  1159. } else if (res.code == 1010) {
  1160. discordAuth('authAndJoinIng');
  1161. }
  1162. if (res.catch) {
  1163. //判断是否需要授权
  1164. if (discordAuthorizeRequired) {
  1165. discordAuth('authAndJoinIng');
  1166. } else {
  1167. openInviteUrl();
  1168. }
  1169. }
  1170. })
  1171. }
  1172. }
  1173. /**
  1174. * discord授权
  1175. */
  1176. function discordAuth(actionState = 'default') {
  1177. let state = guid();
  1178. discordAuthUrl({
  1179. params: {
  1180. redirectUrl: discordAuthRedirectUri,
  1181. state
  1182. }
  1183. }).then(res => {
  1184. if (res.code == 0) {
  1185. let { authorizeUrl = '' } = res.data || {};
  1186. if (authorizeUrl) {
  1187. joinDiscordActionState = actionState;
  1188. const width = 500;
  1189. chrome.windows.create({
  1190. width,
  1191. type: 'normal',
  1192. url: authorizeUrl
  1193. }, function (window) {
  1194. let windowId = window.id;
  1195. callEventPageMethod("RED_PACKET_SAVE_DISCORD_AUTH_WINDOW_ID", {
  1196. windowId: windowId
  1197. }, function (response) {
  1198. });
  1199. })
  1200. }
  1201. }
  1202. })
  1203. }
  1204. /**
  1205. * sendMessage
  1206. */
  1207. const callEventPageMethod = (actionType, data, callback) => {
  1208. chrome.runtime.sendMessage(
  1209. {
  1210. actionType: actionType,
  1211. data: data
  1212. },
  1213. function (response) {
  1214. if (typeof callback === "function") callback(response);
  1215. }
  1216. );
  1217. };
  1218. /**
  1219. * discord 授权成功
  1220. */
  1221. function discordLoginSuccess() {
  1222. console.log('discordloginSuccess');
  1223. // 如果是授权并join 默认打开 邀请链接
  1224. if (joinDiscordActionState == 'authAndJoinIng') {
  1225. openInviteUrl();
  1226. }
  1227. if(discordAuthorizeRequired) {
  1228. discordAuthorizeRequired = false;
  1229. }
  1230. }
  1231. /**
  1232. * 获取discord邀请链接
  1233. */
  1234. function getInviteUrl() {
  1235. let inviteData = state.detail.taskCondition.find(item => {
  1236. return item.type == 7;
  1237. });
  1238. let url;
  1239. if (inviteData && inviteData.bizData) {
  1240. url = JSON.parse(inviteData.bizData).inviteUrl;
  1241. }
  1242. return url;
  1243. }
  1244. /**
  1245. * 打开邀请discord链接
  1246. */
  1247. function openInviteUrl() {
  1248. joinDiscordActionState = 'joinIng';
  1249. let url = getInviteUrl();
  1250. if (url) {
  1251. if (!url.startsWith('http')) {
  1252. url = 'https://' + url;
  1253. }
  1254. window.open(url);
  1255. }
  1256. }
  1257. </script>
  1258. <style lang="scss">
  1259. html,
  1260. body {
  1261. margin: 0;
  1262. padding: 0;
  1263. width: 375px;
  1264. height: 500px;
  1265. background-color: unset !important;
  1266. }
  1267. .content {
  1268. width: 375px;
  1269. height: 500px;
  1270. background: #fafafa;
  1271. border-radius: 11px;
  1272. overflow: hidden;
  1273. box-sizing: border-box;
  1274. border: 1px solid #DCDCDC;
  1275. font-family: "SF Pro Display";
  1276. font-style: normal;
  1277. .loading {
  1278. background: #FFFFFF;
  1279. opacity: 0.8;
  1280. z-index: 222;
  1281. text-align: center;
  1282. width: 375px;
  1283. height: 500px;
  1284. position: fixed;
  1285. top: 0;
  1286. left: 0;
  1287. img {
  1288. margin-top: 216px;
  1289. width: 70px;
  1290. height: 70px;
  1291. }
  1292. }
  1293. .error {
  1294. width: 100%;
  1295. height: 100%;
  1296. text-align: center;
  1297. position: relative;
  1298. img {
  1299. width: 100px;
  1300. height: 100px;
  1301. margin-top: 100px;
  1302. }
  1303. .txt {
  1304. font-weight: 500;
  1305. font-size: 22px;
  1306. line-height: 26px;
  1307. text-align: center;
  1308. letter-spacing: 0.3px;
  1309. color: #a8a8a8;
  1310. margin: 34px 44px 0 44px;
  1311. }
  1312. .retry {
  1313. position: absolute;
  1314. bottom: 30px;
  1315. left: 50%;
  1316. margin-left: -167.5px;
  1317. width: 335px;
  1318. height: 46px;
  1319. line-height: 46px;
  1320. text-align: center;
  1321. border-radius: 100px;
  1322. border: 1px solid #1D9BF0;
  1323. background: rgba(196, 196, 196, 0.01);
  1324. color: #1D9BF0;
  1325. font-size: 16px;
  1326. font-weight: 500;
  1327. cursor: pointer;
  1328. }
  1329. }
  1330. .success,
  1331. .close,
  1332. .luck-peopel-list {
  1333. filter: drop-shadow(0px 4px 94px rgba(0, 0, 0, 0.3));
  1334. width: 100%;
  1335. height: 100%;
  1336. border-radius: 11px;
  1337. background: #fff;
  1338. overflow: hidden;
  1339. display: flex;
  1340. flex-direction: column;
  1341. .close-title {
  1342. width: 100%;
  1343. font-weight: 600;
  1344. font-size: 27px;
  1345. line-height: 32px;
  1346. text-align: center;
  1347. letter-spacing: 0.3px;
  1348. color: #ffffff;
  1349. }
  1350. .head {
  1351. padding: 14px 16px;
  1352. img {
  1353. cursor: pointer;
  1354. width: 24px;
  1355. height: 24px;
  1356. }
  1357. }
  1358. .header {
  1359. text-align: center;
  1360. min-height: 150px;
  1361. width: 100%;
  1362. background: #fff;
  1363. // padding-top: 30px;
  1364. background-size: 100% 100%;
  1365. position: relative;
  1366. display: flex;
  1367. align-content: center;
  1368. flex-wrap: wrap;
  1369. .rabbit {
  1370. width: 100%;
  1371. height: 100%;
  1372. display: flex;
  1373. align-items: center;
  1374. align-content: center;
  1375. flex-wrap: wrap;
  1376. justify-content: center;
  1377. img {
  1378. width: 150px;
  1379. height: 80px;
  1380. margin-bottom: 6px;
  1381. }
  1382. p {
  1383. margin: 0;
  1384. padding: 0;
  1385. color: #fff;
  1386. text-align: center;
  1387. font-weight: 600;
  1388. font-size: 15px;
  1389. letter-spacing: 0.3px;
  1390. }
  1391. }
  1392. .done {
  1393. cursor: pointer;
  1394. position: absolute;
  1395. top: 107px;
  1396. left: 50%;
  1397. margin-left: -150px;
  1398. width: 300px;
  1399. height: 60px;
  1400. display: flex;
  1401. align-items: center;
  1402. border-radius: 100px;
  1403. background: #ffffff;
  1404. box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.1);
  1405. justify-content: center;
  1406. span {
  1407. color: #000000;
  1408. font-size: 14px;
  1409. }
  1410. .icon-done {
  1411. width: 24px;
  1412. height: 24px;
  1413. margin-right: 10px;
  1414. }
  1415. .icon-right {
  1416. margin-left: 5px;
  1417. width: 7px;
  1418. height: 14px;
  1419. }
  1420. }
  1421. .title {
  1422. margin-top: 30px;
  1423. color: #fff7e4;
  1424. opacity: 0.6;
  1425. font-weight: 700;
  1426. font-size: 18px;
  1427. line-height: 21px;
  1428. letter-spacing: -0.3px;
  1429. }
  1430. .money {
  1431. margin-bottom: 30px;
  1432. width: 100%;
  1433. display: flex;
  1434. justify-content: center;
  1435. align-items: center;
  1436. img {
  1437. width: 40px;
  1438. height: 40px;
  1439. margin-right: 9px;
  1440. }
  1441. .big {
  1442. font-weight: 700;
  1443. font-size: 46px;
  1444. line-height: 55px;
  1445. /* identical to box height */
  1446. letter-spacing: 0.3px;
  1447. color: #fff;
  1448. }
  1449. .small {
  1450. margin-left: 4px;
  1451. font-weight: 700;
  1452. font-size: 13px;
  1453. line-height: 16px;
  1454. /* identical to box height */
  1455. letter-spacing: 0.5px;
  1456. color: #fff;
  1457. }
  1458. }
  1459. }
  1460. .luck-list-title {
  1461. /* margin-top: 47px;*/
  1462. margin: 0 16px;
  1463. padding: 14px 0 11px 0;
  1464. background: #fff;
  1465. display: flex;
  1466. justify-content: space-between;
  1467. color: #B0B0B0;
  1468. border-bottom: 1px solid #F2F2F2;
  1469. div:last-child {
  1470. text-align: right;
  1471. }
  1472. .text {
  1473. cursor: pointer;
  1474. }
  1475. }
  1476. .luck-list {
  1477. background: #fff;
  1478. overflow: auto;
  1479. &.max {
  1480. height: 250px;
  1481. }
  1482. .empty {
  1483. width: 100%;
  1484. height: 100%;
  1485. text-align: center;
  1486. img {
  1487. margin-top: 90px;
  1488. width: 100px;
  1489. height: 100px;
  1490. }
  1491. }
  1492. .luck-item {
  1493. display: flex;
  1494. padding: 10px 0;
  1495. margin: 0 16px;
  1496. border-bottom: 1px solid #F2F2F2;
  1497. justify-content: space-between;
  1498. position: relative;
  1499. img:first-child {
  1500. border-radius: 50%;
  1501. }
  1502. .luck-king {
  1503. position: absolute;
  1504. top: 36px;
  1505. right: 0px;
  1506. display: flex;
  1507. align-items: center;
  1508. img {
  1509. width: 22px;
  1510. height: 19px;
  1511. margin: 0;
  1512. }
  1513. span {
  1514. font-weight: 500;
  1515. font-size: 12px;
  1516. line-height: 14px;
  1517. letter-spacing: 0.3px;
  1518. color: #f5b945;
  1519. }
  1520. }
  1521. img {
  1522. cursor: pointer;
  1523. width: 42px;
  1524. height: 42px;
  1525. margin-right: 12px;
  1526. }
  1527. .luck-content {
  1528. flex: auto;
  1529. .luck-title {
  1530. font-weight: 500;
  1531. font-size: 16px;
  1532. letter-spacing: 0.3px;
  1533. color: #444444;
  1534. }
  1535. .luck-time {
  1536. font-weight: 400;
  1537. font-size: 12px;
  1538. line-height: 14px;
  1539. color: #9b9b9b;
  1540. }
  1541. }
  1542. .luck-money {
  1543. display: flex;
  1544. height: 17px;
  1545. align-items: center;
  1546. height: 100%;
  1547. img {
  1548. width: 14px;
  1549. height: 14px;
  1550. margin-right: 6px;
  1551. }
  1552. .luck-money-txt {
  1553. font-weight: 500;
  1554. font-size: 14px;
  1555. word-break: break-all;
  1556. /* identical to box height */
  1557. text-align: right;
  1558. letter-spacing: 0.3px;
  1559. color: #444444;
  1560. }
  1561. }
  1562. }
  1563. .luck-item:last-child {
  1564. border: 0;
  1565. }
  1566. }
  1567. }
  1568. .success {
  1569. .luck-list-title {
  1570. margin-top: 17px;
  1571. margin-bottom: 11px;
  1572. border-bottom: 1px solid #D1D1D1;
  1573. }
  1574. }
  1575. .opened {
  1576. filter: drop-shadow(0px 4px 94px rgba(0, 0, 0, 0.3));
  1577. width: 100%;
  1578. height: 100%;
  1579. display: flex;
  1580. flex-direction: column;
  1581. justify-content: space-between;
  1582. border-radius: 11px;
  1583. overflow: hidden;
  1584. .header {
  1585. text-align: center;
  1586. min-height: 110px;
  1587. width: 100%;
  1588. background: #fff;
  1589. // padding-top: 30px;
  1590. background-size: 100% 100%;
  1591. display: flex;
  1592. flex-wrap: wrap;
  1593. align-content: center;
  1594. justify-content: center;
  1595. img {
  1596. width: 52px;
  1597. height: 52px;
  1598. margin-right: 14px;
  1599. }
  1600. .txt {
  1601. color: #FFFFFF;
  1602. font-weight: 700;
  1603. font-size: 18px;
  1604. letter-spacing: 0.3px;
  1605. p {
  1606. margin: 0;
  1607. padding: 0;
  1608. text-align: left;
  1609. }
  1610. }
  1611. }
  1612. .list {
  1613. padding: 0 16px 0 16px;
  1614. background: #ffffff;
  1615. flex: 1;
  1616. .item {
  1617. display: flex;
  1618. align-items: center;
  1619. min-height: 50px;
  1620. border-bottom: 1px solid #f0f0f0;
  1621. img {
  1622. width: 24px;
  1623. height: 24px;
  1624. }
  1625. .red-right {
  1626. width: 35px;
  1627. height: 24px;
  1628. }
  1629. .item-content {
  1630. width: 100%;
  1631. flex: 1;
  1632. .item-follow-title {
  1633. display: flex;
  1634. align-items: center;
  1635. margin-top: 20px;
  1636. margin-bottom: 11px;
  1637. position: relative;
  1638. .btn {
  1639. // position: absolute;
  1640. // right: 0;
  1641. }
  1642. }
  1643. .item-title {
  1644. flex: 1;
  1645. margin-left: 10px;
  1646. font-weight: 500;
  1647. font-size: 16px;
  1648. letter-spacing: 0.3px;
  1649. color: #000000;
  1650. }
  1651. .item-follow-area {
  1652. display: flex;
  1653. flex-wrap: wrap;
  1654. .item-follow {
  1655. cursor: pointer;
  1656. border: 1px solid #ebebeb;
  1657. border-radius: 1000px;
  1658. height: 26px;
  1659. margin-right: 5px;
  1660. margin-bottom: 5px;
  1661. display: flex;
  1662. align-items: center;
  1663. .finished {
  1664. text-decoration: line-through;
  1665. color: #949494;
  1666. }
  1667. span {
  1668. margin-left: 8px;
  1669. margin-right: 2px;
  1670. color: #1D9BF0;
  1671. opacity: 1;
  1672. }
  1673. img {
  1674. width: 16px;
  1675. height: 16px;
  1676. margin-right: 7px;
  1677. }
  1678. }
  1679. }
  1680. span {
  1681. font-weight: 400;
  1682. font-size: 11px;
  1683. line-height: 13px;
  1684. letter-spacing: 0.3px;
  1685. color: #000000;
  1686. opacity: 0.4;
  1687. }
  1688. }
  1689. .btn {
  1690. width: 90px;
  1691. height: 29px;
  1692. line-height: 29px;
  1693. background: rgba(56, 154, 255, 0.1);
  1694. border-radius: 500px;
  1695. text-align: center;
  1696. letter-spacing: 0.3px;
  1697. color: #1D9BF0;
  1698. cursor: pointer;
  1699. }
  1700. .loading-wrapper {
  1701. width: 90px;
  1702. text-align: center;
  1703. .icon-loading {
  1704. animation: loading 1s infinite linear;
  1705. }
  1706. }
  1707. }
  1708. }
  1709. .people {
  1710. cursor: pointer;
  1711. padding-left: 16px;
  1712. height: 38px;
  1713. line-height: 38px;
  1714. background: #fff;
  1715. box-shadow: 0px 1px 0px #f2f2f2;
  1716. display: flex;
  1717. align-items: center;
  1718. justify-content: space-between;
  1719. .txt {
  1720. width: 90%;
  1721. font-weight: 400;
  1722. font-size: 12px;
  1723. line-height: 14px;
  1724. letter-spacing: 0.3px;
  1725. color: #000000;
  1726. opacity: 0.4;
  1727. }
  1728. }
  1729. .footer {
  1730. background: #ffffff;
  1731. display: flex;
  1732. padding: 15px 22px 15px 17px;
  1733. .winner {
  1734. flex: 1;
  1735. height: 100%;
  1736. background: #fff;
  1737. align-items: center;
  1738. display: flex;
  1739. align-content: center;
  1740. flex-wrap: wrap;
  1741. p {
  1742. color: #959595;
  1743. font-size: 12px;
  1744. margin: 0;
  1745. padding: 0;
  1746. }
  1747. .right {
  1748. width: 100%;
  1749. height: 22px;
  1750. position: relative;
  1751. img {
  1752. position: absolute;
  1753. width: 22px;
  1754. height: 22px;
  1755. border: 2px solid #fff;
  1756. border-radius: 50%;
  1757. }
  1758. .more {
  1759. border: 0;
  1760. }
  1761. }
  1762. }
  1763. .btn {
  1764. background: #1D9BF0;
  1765. border-radius: 100px;
  1766. color: #fff;
  1767. width: 258px;
  1768. height: 52px;
  1769. font-weight: 600;
  1770. font-size: 18px;
  1771. line-height: 52px;
  1772. text-align: center;
  1773. cursor: pointer;
  1774. }
  1775. }
  1776. }
  1777. .not-open {
  1778. width: 100%;
  1779. height: 100%;
  1780. filter: drop-shadow(0px 2px 20px rgba(0, 0, 0, 0.1));
  1781. position: relative;
  1782. overflow: hidden;
  1783. border-radius: 11px;
  1784. .money-area {
  1785. width: 100%;
  1786. position: absolute;
  1787. top: 65px;
  1788. display: flex;
  1789. flex-wrap: wrap;
  1790. align-items: center;
  1791. justify-content: center;
  1792. .txt {
  1793. font-weight: 800;
  1794. font-size: 16px;
  1795. text-align: center;
  1796. letter-spacing: 0.3px;
  1797. color: #FFFFFF;
  1798. }
  1799. .coin {
  1800. text-align: center;
  1801. margin-top: 6px;
  1802. margin-bottom: 7px;
  1803. display: flex;
  1804. justify-content: center;
  1805. align-items: center;
  1806. width: 90%;
  1807. img {
  1808. width: 46px;
  1809. height: 46px;
  1810. border-radius: 50%;
  1811. border: 3px solid #FFFFFF;
  1812. }
  1813. span {
  1814. margin-left: 12px;
  1815. font-weight: 800;
  1816. font-size: 60px;
  1817. line-height: 76px;
  1818. color: #FFFFFF;
  1819. }
  1820. }
  1821. .people {
  1822. font-weight: 800;
  1823. font-size: 13px;
  1824. line-height: 16px;
  1825. letter-spacing: 0.05em;
  1826. text-align: center;
  1827. color: #FFFFFF;
  1828. }
  1829. }
  1830. .title {
  1831. position: absolute;
  1832. top: 15px;
  1833. left: 15px;
  1834. z-index: 3;
  1835. display: flex;
  1836. align-items: center;
  1837. img {
  1838. width: 24px;
  1839. height: 24px;
  1840. border: 2px solid #FFF;
  1841. border-radius: 50%;
  1842. }
  1843. span {
  1844. margin-left: 10px;
  1845. font-weight: 600;
  1846. font-size: 16px;
  1847. letter-spacing: 0.3px;
  1848. color: #fff;
  1849. }
  1850. }
  1851. // .txt {
  1852. // width: 100%;
  1853. // position: absolute;
  1854. // font-style: normal;
  1855. // font-weight: 700;
  1856. // font-size: 42px;
  1857. // line-height: 50px;
  1858. // text-align: center;
  1859. // color: #FFF2D3;
  1860. // top: 90px;
  1861. // z-index: 3;
  1862. // }
  1863. img {
  1864. width: 100%;
  1865. }
  1866. .up {
  1867. position: absolute;
  1868. top: 0;
  1869. // box-shadow: 0px 4px 44px rgba(0, 0, 0, 0.1);
  1870. z-index: 1;
  1871. }
  1872. .down {
  1873. position: absolute;
  1874. top: 253px;
  1875. }
  1876. .open {
  1877. width: 335px;
  1878. height: 50px;
  1879. cursor: pointer;
  1880. position: absolute;
  1881. bottom: 28px;
  1882. left: 50%;
  1883. margin-left: -167.5px;
  1884. z-index: 4;
  1885. }
  1886. .open-gif {
  1887. width: 200px;
  1888. height: 200px;
  1889. text-align: center;
  1890. position: absolute;
  1891. bottom: 70px;
  1892. left: 50%;
  1893. margin-left: -100px;
  1894. z-index: 3;
  1895. }
  1896. }
  1897. @keyframes loading {
  1898. from {
  1899. transform: rotate(0deg);
  1900. }
  1901. to {
  1902. transform: rotate(360deg);
  1903. }
  1904. }
  1905. }
  1906. .none {
  1907. display: flex;
  1908. align-item: center;
  1909. justify-content: center;
  1910. width: 100%;
  1911. height: 100%;
  1912. }
  1913. </style>