red-packet.vue 73 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749
  1. <!-- 红包任务页面 -->
  2. <template>
  3. <div class="content">
  4. <!-- global-tip -->
  5. <global-tip :type="'1'"></global-tip>
  6. <!-- open -->
  7. <div v-show="state.status == 'opened'" class="opened">
  8. <!-- <div class="header" :style="{ 'backgroundImage': `url(${require('@/assets/subject/001-back-head-top.svg')})` }">
  9. <div class="title">AWESOME! YOU WILL GET</div>
  10. <div class="money">
  11. <img :src="state.detail.currencyIconPath" alt />
  12. <font-amount :amount="state.money" class="big" :fontSize="46"></font-amount>
  13. </div>
  14. </div> -->
  15. <div class="header" :style="{ 'backgroundImage': `url(${require('@/assets/subject/001-back-head-top-1.svg')})` }">
  16. <!-- -->
  17. <img :src="require('@/assets/subject/001-icon-red-packet.svg')" alt="">
  18. <div class="txt">
  19. <p>Complete tasks</p>
  20. <p>to Draw Prizes</p>
  21. </div>
  22. </div>
  23. <div class="list">
  24. <template v-for="item, i in state.detail.taskCondition" v-bind:key="i">
  25. <div class="item" v-if="item.type == 1 && item.relatedUsers && item.relatedUsers.length > 0">
  26. <div class="item-content">
  27. <div class="item-follow-title">
  28. <img :src="require('@/assets/svg/icon-task-twitter.svg')" alt />
  29. <!-- <img :src="require('@/assets/svg/icon-follow.svg')" alt /> -->
  30. <div class="item-title">Follow</div>
  31. <img :src="require('@/assets/gif/red-right.gif')" alt class="red-right"
  32. v-show="!state.done.follow && state.done.follow_red" />
  33. <img v-if="state.done.follow" :src="require('@/assets/svg/icon-true.svg')" alt />
  34. <div v-else class="btn" @click="clickFollowAll(item.relatedUsers, 'all')">Follow All</div>
  35. </div>
  36. <div class="item-follow-area">
  37. <template v-for="item2, i in item.relatedUsers" v-bind:key="i">
  38. <div class="item-follow" v-if="item2.finished">
  39. <span :class="{ finished: item2.finished }">@{{ item2.name }}</span>
  40. <img :src="require('@/assets/svg/icon-true-ed.svg')" alt />
  41. </div>
  42. <div class="item-follow" v-else @click="clickFollowAll([item2])">
  43. <span :class="{ finished: item2.finished }">@{{ item2.name }}</span>
  44. <img :src="require('@/assets/svg/icon-add.svg')" alt />
  45. </div>
  46. </template>
  47. </div>
  48. </div>
  49. </div>
  50. <div class="item" v-if="item.type == 2">
  51. <img :src="require('@/assets/svg/icon-task-twitter.svg')" alt />
  52. <!-- <img :src="require('@/assets/svg/icon-like.svg')" alt /> -->
  53. <div class="item-content">
  54. <div class="item-title">Like</div>
  55. </div>
  56. <img :src="require('@/assets/gif/red-right.gif')" alt class="red-right"
  57. v-show="!state.done.like && state.done.like_red" />
  58. <img v-if="state.done.like" :src="require('@/assets/svg/icon-true.svg')" alt />
  59. <div v-else class="btn" @click="clickLikeBtn">Like</div>
  60. </div>
  61. <div class="item" v-if="item.type == 3">
  62. <img :src="require('@/assets/svg/icon-task-twitter.svg')" alt />
  63. <!-- <img :src="require('@/assets/svg/icon-retweet.svg')" alt /> -->
  64. <div class="item-content">
  65. <div class="item-title">Retweet</div>
  66. </div>
  67. <img :src="require('@/assets/gif/red-right.gif')" alt class="red-right"
  68. v-show="!state.done.retweet && state.done.retweet_red" />
  69. <img v-if="state.done.retweet" :src="require('@/assets/svg/icon-true.svg')" alt />
  70. <div v-else class="btn" @click="clickRetweetBtn">Retweet</div>
  71. </div>
  72. <!-- Comment、艾特 friends -->
  73. <div class="item" v-if="item.type == 9">
  74. <img :src="require('@/assets/svg/icon-task-twitter.svg')" alt />
  75. <div class="item-content">
  76. <div class="item-title">Comment and Tag 3 friends</div>
  77. </div>
  78. <img :src="require('@/assets/gif/red-right.gif')" alt class="red-right"
  79. v-show="!state.done.reply && state.done.reply_red" />
  80. <img v-if="state.done.reply" :src="require('@/assets/svg/icon-true.svg')" alt />
  81. <div v-else class="btn" @click="clickReply(item)">Comment</div>
  82. </div>
  83. <!-- repost feacebook -->
  84. <div class="item" v-if="item.type == 8">
  85. <img :src="require('@/assets/svg/icon-task-facebook.svg')" alt />
  86. <div class="item-content">
  87. <div class="item-title">Repost to Facebook</div>
  88. </div>
  89. <img :src="require('@/assets/gif/red-right.gif')" alt class="red-right"
  90. v-show="!state.done.repost_facebook && state.done.repost_facebook_red" />
  91. <img v-if="state.done.repost_facebook" :src="require('@/assets/svg/icon-true.svg')" alt />
  92. <div v-else class="btn" @click="clickRepostFacebook(item)">Repost</div>
  93. </div>
  94. <!-- join discord -->
  95. <div class="item" v-if="item.type == 7">
  96. <img :src="require('@/assets/svg/icon-discord-mini.svg')" alt />
  97. <div class="item-content">
  98. <div class="item-title">Join Discord</div>
  99. </div>
  100. <img :src="require('@/assets/gif/red-right.gif')" alt class="red-right"
  101. v-show="!state.done.join_discord && state.done.join_discord_red" />
  102. <img v-if="state.done.join_discord" :src="require('@/assets/svg/icon-true.svg')" alt />
  103. <template v-else>
  104. <div v-if="joinDiscordIng" class="loading-wrapper">
  105. <img class="icon-loading" :src="require('@/assets/svg/icon-loading-gray.svg')" />
  106. </div>
  107. <div v-else class="btn" @click="joinDiscord">
  108. Join
  109. </div>
  110. </template>
  111. </div>
  112. </template>
  113. </div>
  114. <!-- <div class="people" @click="clickRoad">
  115. <div class="txt">
  116. {{ state.detail.receiveCount || 0 }}/{{ state.detail.totalCount || 0 }} Winners,{{
  117. state.detail.receiveAmountValue
  118. }}/{{ state.detail.amountValue }} {{ state.detail.currencySymbol }}</div>
  119. <div class="right" v-if="state.detail.allReceived">
  120. <img :src="require('@/assets/svg/icon-right.svg')" alt class="road" />
  121. </div>
  122. </div> -->
  123. <div class="footer">
  124. <div class="winner">
  125. <p>Winners</p>
  126. <div class="right">
  127. <template v-if="state.detail.allReceived" v-for="item, i in state.detail.allReceived.slice(0, 3)"
  128. v-bind:key="i">
  129. <img v-if="item.simpleUserInfoVO.avatarUrl" :src="item.simpleUserInfoVO.avatarUrl" alt
  130. :style="{ left: `${(i) * 16}px`, zIndex: `${10 - i}` }" />
  131. <img v-else :src="require('@/assets/svg/icon-twitter.svg')" alt
  132. :style="{ left: `${(i) * 16}px`, zIndex: `${10 - i}` }" />
  133. </template>
  134. <img v-if="state.detail.allReceived && state.detail.allReceived.length > 3"
  135. :src="require('@/assets/svg/icon-winner-more.svg')" alt
  136. :style="{ left: `${3 * 16}px`, zIndex: `${10 - 3}` }" />
  137. </div>
  138. </div>
  139. <div class="btn" @click="clickGetGiveaways">Complete</div>
  140. </div>
  141. </div>
  142. <!-- success -->
  143. <div v-if="state.status == 'success'" class="success">
  144. <div class="header" :style="{ 'backgroundImage': `url(${require('@/assets/subject/001-back-head-top.svg')})` }">
  145. <div class="money">
  146. <img :src="state.detail.currencyIconPath" alt />
  147. <font-amount :amount="state.receiveAmount" class="big" :fontSize="46"></font-amount>
  148. <!-- <span class="small">{{ state.detail.currencySymbol }}</span> -->
  149. </div>
  150. <div class="done" @click="clickDone">
  151. <img :src="require('@/assets/subject/001-icon-done.svg')" alt class="icon-done" />
  152. <span>View Rewards In Wallet</span>
  153. <img :src="require('@/assets/svg/icon-right.svg')" alt class="icon-right" />
  154. </div>
  155. </div>
  156. <div class="luck-list-title">
  157. <div>{{ state.detail.receiveCount || 0 }}/{{ state.detail.totalCount || 0 }} Winners</div>
  158. <div class="right">
  159. <span class="text">
  160. <a-tooltip :title="state.detail.receiveAmountValue">
  161. {{ getBit(state.detail.receiveAmountValue) }}
  162. </a-tooltip>
  163. /
  164. <a-tooltip :title="state.detail.amountValue">
  165. {{ getBit(state.detail.amountValue) || '' }}
  166. </a-tooltip>
  167. </span>
  168. {{ state.detail.currencySymbol || '' }}
  169. </div>
  170. </div>
  171. <div class="luck-list max" @scroll="handleScroll($event)">
  172. <div class="luck-item" v-for="item, i in state.detail.allReceived" v-bind:key="i">
  173. <img v-if="item.simpleUserInfoVO.avatarUrl" :src="item.simpleUserInfoVO.avatarUrl"
  174. @click="openTwitterDetail(item)" alt />
  175. <img v-else :src="require('@/assets/svg/icon-twitter.svg')" alt />
  176. <div class="luck-content">
  177. <div class="luck-title" v-if="item.simpleUserInfoVO.nickName">{{ item.simpleUserInfoVO.nickName }}</div>
  178. <div class="luck-title" v-else>Twitter User</div>
  179. <div class="luck-time">{{ moment(item.receiveTimestamp).format('MM-DD HH:mm') }}</div>
  180. </div>
  181. <div class="luck-money">
  182. <img :src="state.detail.currencyIconPath" alt />
  183. <div class="luck-money-txt">
  184. <a-tooltip :title="item.amountValue">
  185. {{ getBit(item.amountValue) }}
  186. </a-tooltip>
  187. </div>
  188. </div>
  189. <div class="luck-king" v-if="item.maxAmount">
  190. <img :src="require('@/assets/svg/icon-king-hat.svg')" alt />
  191. <span>Luckiest Draw</span>
  192. </div>
  193. </div>
  194. </div>
  195. <get-more></get-more>
  196. </div>
  197. <!-- no-open -->
  198. <div v-else-if="state.status == 'not-open'" class="not-open">
  199. <img :src="require('@/assets/subject/001-card.png')" alt="">
  200. <img class="open-gif" :src="require('@/assets/gif/001.gif')" />
  201. <img :src="require('@/assets/svg/icon-open.svg')" alt="" class="open" @click="clickOpenRedPacket">
  202. <div class="title" v-if="state.detail.postUserInfo">
  203. <img :src="state.detail.postUserInfo.avatarUrl" alt />
  204. <span>{{ state.detail.postUserInfo.nickName || 'FutureDoctor' }}</span>
  205. </div>
  206. <div class="money-area">
  207. <div class="txt">{{ state.detail.currencySymbol }} GIVEAWAY</div>
  208. <div class="coin">
  209. <img :src="state.detail.currencyIconPath" alt />
  210. <font-amount :amount="state.detail.amountValue" style="color:#fff;"></font-amount>
  211. </div>
  212. <div class="people">{{ state.detail.totalCount }} WINNERS TO SHARE</div>
  213. </div>
  214. </div>
  215. <!-- 领取列表 -->
  216. <div v-else-if="state.status == 'luck-peopel-list'" class="luck-peopel-list">
  217. <div class="head">
  218. <img :src="require('@/assets/svg/icon-back.svg')" alt />
  219. </div>
  220. <div class="luck-list-title">
  221. <div>{{ state.detail.receiveCount || 0 }}/{{ state.detail.totalCount || 0 }} Winners</div>
  222. <div class="right">
  223. <span class="text">
  224. <a-tooltip :title="state.detail.receiveAmountValue">
  225. {{ getBit(state.detail.receiveAmountValue) }}
  226. </a-tooltip>
  227. /
  228. <a-tooltip :title="state.detail.amountValue">
  229. {{ getBit(state.detail.amountValue) || '' }}
  230. </a-tooltip>
  231. </span> {{
  232. state.detail.currencySymbol || ''
  233. }}
  234. </div>
  235. </div>
  236. <div class="luck-list" @scroll="handleScroll">
  237. <div class="luck-item" v-for="item, i in state.detail.allReceived" v-bind:key="i">
  238. <img v-if="item.simpleUserInfoVO.avatarUrl" :src="item.simpleUserInfoVO.avatarUrl" alt
  239. @click="openTwitterDetail(item)" />
  240. <img v-else :src="require('@/assets/svg/icon-twitter.svg')" alt />
  241. <div class="luck-content">
  242. <div class="luck-title" v-if="item.simpleUserInfoVO.nickName">{{ item.simpleUserInfoVO.nickName }}</div>
  243. <div class="luck-title" v-else>Twitter User</div>
  244. <div class="luck-time">{{ moment(item.receiveTimestamp).format('MM-DD HH:mm:ss') }}</div>
  245. </div>
  246. <div class="luck-money">
  247. <img :src="state.detail.currencyIconPath" alt />
  248. <div class="luck-money-txt">
  249. <a-tooltip :title="item.amountValue">
  250. {{ getBit(item.amountValue) }}
  251. </a-tooltip>
  252. </div>
  253. </div>
  254. <div class="luck-king" v-if="item.maxAmount">
  255. <img :src="require('@/assets/svg/icon-king-hat.svg')" alt />
  256. <span>Luckiest Draw</span>
  257. </div>
  258. </div>
  259. </div>
  260. </div>
  261. <!-- 关闭状态 -->
  262. <div v-else-if="state.status == 'close'" class="close">
  263. <!-- 红包被领完了 -->
  264. <div class="header" :style="{ 'backgroundImage': `url(${require('@/assets/subject/001-back-head-top.svg')})` }"
  265. v-show="state.close_status == '红包过期了'">
  266. <div class="close-title" v-for="item in state.close_text">{{ item }}</div>
  267. </div>
  268. <!-- 没有领取到钱 -->
  269. <div class="header" :style="{ 'backgroundImage': `url(${require('@/assets/subject/001-back-head-top.svg')})` }"
  270. v-show="state.close_status == '没有领到钱'">
  271. <div class="rabbit">
  272. <img :src="require('@/assets/subject/001-icon-rabbit.svg')" alt />
  273. <p>Sorry, you missed this chance</p>
  274. <p>Come Earlier Next Time!</p>
  275. </div>
  276. </div>
  277. <div class="luck-list-title">
  278. <div>{{ state.detail.receiveCount || 0 }}/{{ state.detail.totalCount || 0 }} Winners</div>
  279. <div class="right">
  280. <span class="text">
  281. <a-tooltip :title="state.detail.receiveAmountValue">
  282. {{ getBit(state.detail.receiveAmountValue) }}
  283. </a-tooltip>
  284. /
  285. <a-tooltip :title="state.detail.amountValue">
  286. {{ getBit(state.detail.amountValue || '') }}
  287. </a-tooltip>
  288. </span> {{
  289. state.detail.currencySymbol || ''
  290. }}
  291. </div>
  292. </div>
  293. <div class="luck-list max" @scroll="handleScroll">
  294. <div class="luck-item" v-for="item, i in state.detail.allReceived" v-bind:key="i">
  295. <img v-if="item.simpleUserInfoVO.avatarUrl" :src="item.simpleUserInfoVO.avatarUrl" alt
  296. @click="openTwitterDetail(item)" />
  297. <img v-else :src="require('@/assets/svg/icon-twitter.svg')" alt />
  298. <div class="luck-content">
  299. <div class="luck-title" v-if="item.simpleUserInfoVO.nickName">{{ item.simpleUserInfoVO.nickName }}</div>
  300. <div class="luck-title" v-else>Twitter User</div>
  301. <div class="luck-time">{{ moment(item.receiveTimestamp).format('MM-DD HH:mm:ss') }}</div>
  302. </div>
  303. <div class="luck-money">
  304. <img :src="state.detail.currencyIconPath" alt />
  305. <div class="luck-money-txt">
  306. <a-tooltip :title="item.amountValue">
  307. {{ getBit(item.amountValue) }}
  308. </a-tooltip>
  309. </div>
  310. </div>
  311. <div class="luck-king" v-if="item.maxAmount">
  312. <img :src="require('@/assets/svg/icon-king-hat.svg')" alt />
  313. <span>Luckiest Draw</span>
  314. </div>
  315. </div>
  316. <div class="empty" v-show="state.detail.allReceived && state.detail.allReceived.length == 0">
  317. <img :src="require('@/assets/svg/icon-error.svg')" alt />
  318. </div>
  319. </div>
  320. <get-more></get-more>
  321. </div>
  322. <!-- error -->
  323. <div v-else-if="state.status == 'error'" class="error">
  324. <img :src="require('@/assets/svg/icon-error.svg')" alt />
  325. <div class="txt">
  326. {{ state.error_txt }}
  327. </div>
  328. <div class="retry" v-show="state.retry" @click="clickRetry">
  329. Retry
  330. </div>
  331. </div>
  332. <!-- loading -->
  333. <div v-show="state.loading_show" class="loading">
  334. <img :src="require('@/assets/svg/icon-loading.svg')" alt />
  335. </div>
  336. <div v-show="state.loading_redbag" class="redbag">
  337. <img :src="require('@/assets/img/icon-loading-redbag.gif')" alt />
  338. </div>
  339. </div>
  340. <div style="width: 100%; height: 30px; position: fixed; color: red; top:0;" v-if="state.process_mode != 'production'">
  341. {{ state.detail.validity }}</div>
  342. </template>
  343. <script>
  344. export default {
  345. name: 'redPacket',
  346. }
  347. </script>
  348. <script setup>
  349. import { onMounted, reactive, ref } from "vue";
  350. import { getPostDetail, getRedPacket, finishRedPacket, oneKeyLike, oneKeyReTweet, oneKeyFollow, getTaskDetail, getReceivedList, addFinishEvent } from '@/http/redPacket.js'
  351. import { getQueryString, guid, getBit } from '@/uilts/help.js'
  352. import { message } from 'ant-design-vue';
  353. import FontAmount from '@/view/components/font-amount.vue'
  354. import GetMore from '@/view/iframe/publish/components/get-more.vue'
  355. import { setChromeStorage, getChromeStorage, sendChromeTabMessage } from '@/uilts/chromeExtension.js'
  356. import Report from "@/log-center/log"
  357. import { srcPublishSuccess } from '@/http/publishApi'
  358. import { discordAuthUrl, checkGuildJoined } from '@/http/discordApi'
  359. import { discordAuthRedirectUri, faceShareRedirectUrl } from '@/http/configAPI'
  360. import { getFrontConfig } from "@/http/account";
  361. import { getInviteGuildInfo } from "@/http/discordApi";
  362. import GlobalTip from '@/view/components/global-tip.vue'
  363. var moment = require('moment');
  364. let discordAuthorizeRequired = false;
  365. let joinDiscordActionState = 'default'; //authAndJoinIng joinIng reAuth
  366. let joinDiscordIng = ref(false);
  367. let facebookAppConfig = {
  368. facebookAppId: "",
  369. faceShareRedirectUrl
  370. };
  371. let reportParams = {
  372. discordFans: '',
  373. twitterFans: '',
  374. done: {
  375. },
  376. hasReport: false,
  377. }
  378. let discordTaskDetail = null;
  379. let state = reactive({
  380. status: '',
  381. userId: '',
  382. loading_show: false,
  383. loading_redbag: true,
  384. detail: {},
  385. luck_list_end: false,
  386. page_index: 1,
  387. page_size: 20,
  388. srcContentId: '',
  389. error_txt: `oops, new accounts cannot participate in this event,`,
  390. receiveAmount: 0,
  391. money: 0,
  392. // 状态
  393. done: {
  394. follow: false,
  395. like: false,
  396. retweet: false,
  397. join_discord: false,
  398. repost_facebook: false,
  399. reply: false
  400. }
  401. })
  402. let fullName = '';
  403. function clickRetry() {
  404. init()
  405. }
  406. let follow_open_tabs = []
  407. async function clickLikeBtn() {
  408. let _userInfo = await checkIsLogin()
  409. if (!_userInfo) {
  410. return
  411. }
  412. state.detail.finishTaskTypeV2 = state.detail.finishTaskTypeV2.toString() || ''
  413. if (state.window_origin.indexOf('facebook.com') >= 0) {
  414. state.detail.finishTaskTypeV2 = '2'
  415. }
  416. switch (state.detail.finishTaskTypeV2) {
  417. case '1':
  418. state.loading_show = true
  419. oneKeyLike({
  420. params: {
  421. tweetId: state.srcContentId
  422. }
  423. }).then((res) => {
  424. state.loading_show = false
  425. if (res.code == 0) {
  426. if (res.data.result) {
  427. state.done.like = true
  428. } else {
  429. state.done.like = false
  430. window.open(`https://twitter.com/intent/like?tweet_id=${state.tweetId}`)
  431. }
  432. } else {
  433. window.open(`https://twitter.com/intent/like?tweet_id=${state.tweetId}`)
  434. state.done.like = false
  435. }
  436. }).catch(() => {
  437. state.loading_show = false
  438. })
  439. break
  440. case '2':
  441. window.open(`https://twitter.com/intent/like?tweet_id=${state.tweetId}`)
  442. break
  443. case '3':
  444. state.loading_show = true
  445. chrome.tabs.getCurrent((tab) => {
  446. chrome.tabs.sendMessage(tab.id, {
  447. actionType: "IFRAME_TWITTER_API_DO_TASK", task_data: {
  448. tweet_Id: state.tweetId
  449. }, task_type: 'like'
  450. }, (res) => { console.log(res) });
  451. })
  452. break
  453. default:
  454. window.open(`https://twitter.com/intent/like?tweet_id=${state.tweetId}`)
  455. break
  456. }
  457. // 埋点
  458. Report.reportLog({
  459. objectType: Report.objectType.like,
  460. pageSource: Report.pageSource.task_page,
  461. businessType: Report.businessType.buttonClick,
  462. postId: state.postId,
  463. srcContentId: state.tweetId,
  464. senderId: state.userId,
  465. });
  466. }
  467. function clickDone() {
  468. window.open(`${chrome.runtime.getURL('/iframe/home.html')}`)
  469. // 埋点
  470. Report.reportLog({
  471. objectType: Report.objectType.wallet_button,
  472. pageSource: Report.pageSource.received_success_page,
  473. businessType: Report.businessType.buttonClick,
  474. postId: state.postId,
  475. srcContentId: state.tweetId,
  476. senderId: state.userId,
  477. });
  478. }
  479. function handleScroll(e) {
  480. if (state.luck_list_end) {
  481. return
  482. }
  483. e = e.target
  484. if ((e.clientHeight + e.scrollTop) / e.scrollHeight > .8) {
  485. state.luck_list_end = true
  486. state.page_index++
  487. handleReceivedList()
  488. }
  489. }
  490. function handleReceivedList() {
  491. getReceivedList({
  492. params: {
  493. pageNum: state.page_index,
  494. pageSize: state.page_size,
  495. postId: state.postId
  496. }
  497. }).then((res) => {
  498. if (res.code == 0) {
  499. if (res.data.length > 0) {
  500. state.detail.allReceived = state.detail.allReceived.concat(res.data)
  501. state.luck_list_end = false
  502. } else {
  503. state.luck_list_end = true
  504. }
  505. } else {
  506. console.log('getReceivedList', res)
  507. }
  508. })
  509. }
  510. const openTwitterDetail = (item) => {
  511. if (item.simpleUserInfoVO.nickName) {
  512. window.open(`https://twitter.com/${item.simpleUserInfoVO.nickName}`)
  513. }
  514. }
  515. async function clickRetweetBtn() {
  516. let _userInfo = await checkIsLogin()
  517. if (!_userInfo) {
  518. return
  519. }
  520. state.detail.finishTaskTypeV2 = state.detail.finishTaskTypeV2.toString() || ''
  521. if (state.window_origin.indexOf('facebook.com') >= 0) {
  522. state.detail.finishTaskTypeV2 = '2'
  523. }
  524. switch (state.detail.finishTaskTypeV2) {
  525. case '1':
  526. state.loading_show = true
  527. oneKeyReTweet({
  528. params: {
  529. tweetId: state.srcContentId
  530. }
  531. }).then((res) => {
  532. state.loading_show = false
  533. if (res.code == 0) {
  534. if (res.data.result) {
  535. state.done.retweet = true
  536. } else {
  537. window.open(`https://twitter.com/intent/retweet?tweet_id=${state.tweetId}`)
  538. state.done.retweet = false
  539. }
  540. } else {
  541. window.open(`https://twitter.com/retweet/like?tweet_id=${state.tweetId}`)
  542. state.done.retweet = false
  543. }
  544. }).catch(() => {
  545. state.loading_show = false
  546. })
  547. break;
  548. case '2':
  549. window.open(`https://twitter.com/intent/retweet?tweet_id=${state.tweetId}`)
  550. break
  551. case '3':
  552. state.loading_show = true
  553. chrome.tabs.getCurrent((tab) => {
  554. chrome.tabs.sendMessage(tab.id, {
  555. actionType: "IFRAME_TWITTER_API_DO_TASK", task_data: {
  556. tweet_Id: state.tweetId
  557. }, task_type: 'retweet'
  558. }, (res) => { console.log(res) });
  559. })
  560. break
  561. default:
  562. window.open(`https://twitter.com/intent/retweet?tweet_id=${state.tweetId}`)
  563. break;
  564. }
  565. // 埋点
  566. Report.reportLog({
  567. objectType: Report.objectType.retweet,
  568. pageSource: Report.pageSource.task_page,
  569. businessType: Report.businessType.buttonClick,
  570. postId: state.postId,
  571. srcContentId: state.tweetId,
  572. senderId: state.userId,
  573. });
  574. }
  575. function onTweetReplyClick(params) {
  576. let replyData = {
  577. postId: state.postId,
  578. type: params.type,
  579. taskLuckdropId: state.detail.taskLuckdropId
  580. }
  581. window.parent.postMessage({ actionType: "IFRAME_RED_PACKET_ON_TWEET_REPLY_CLICK", data: replyData }, "*");
  582. }
  583. async function clickReply(params) {
  584. let _userInfo = await checkIsLogin()
  585. if (!_userInfo) {
  586. return
  587. }
  588. let replyData = {
  589. postId: state.postId,
  590. type: params.type,
  591. taskLuckdropId: state.detail.taskLuckdropId
  592. }
  593. if (state.window_origin.indexOf('facebook.com') > -1) {
  594. let url = `https://twitter.com/${state.tweet_author}/status/${state.tweetId}?actionType=denetFacebookToTwitterReply&deReplyParams=${JSON.stringify(replyData)}`
  595. window.open(url)
  596. } else {
  597. window.parent.postMessage({ actionType: "IFRAME_RED_PACKET_REPLY_CLICK", data: replyData }, "*");
  598. }
  599. // 埋点
  600. Report.reportLog({
  601. objectType: Report.objectType.comment_and_tag,
  602. pageSource: Report.pageSource.task_page,
  603. businessType: Report.businessType.buttonClick,
  604. postId: state.postId,
  605. srcContentId: state.tweetId,
  606. senderId: state.userId,
  607. redPacketType: 0
  608. });
  609. }
  610. /**
  611. * 点击repost facebook
  612. */
  613. async function clickRepostFacebook(params) {
  614. let _userInfo = await checkIsLogin()
  615. if (!_userInfo) {
  616. return
  617. }
  618. let deUrlParams = {
  619. fullName,
  620. tweetId: state.tweetId
  621. }
  622. let href = `${state.postRedirectUrl}?deUrlParams=${JSON.stringify(deUrlParams)}`;
  623. console.log(href);
  624. let shareUrlparams = {
  625. href,
  626. type: params.type,
  627. taskLuckdropId: state.detail.taskLuckdropId
  628. }
  629. setChromeStorage({
  630. shareFacebookData: JSON.stringify({
  631. contentStr: state.srcContent
  632. })
  633. })
  634. let shareUrl = feacebookShareUrl(shareUrlparams);
  635. openShareFacebookWindow({ url: shareUrl });
  636. // 埋点
  637. Report.reportLog({
  638. objectType: Report.objectType.share_facebook,
  639. pageSource: Report.pageSource.task_page,
  640. businessType: Report.businessType.buttonClick,
  641. postId: state.postId,
  642. srcContentId: state.tweetId,
  643. senderId: state.userId,
  644. redPacketType: 0
  645. });
  646. }
  647. /**
  648. * 分享到facebook
  649. */
  650. function openShareFacebookWindow({ url }) {
  651. const width = 800;
  652. chrome.windows.create({
  653. width,
  654. type: 'normal',
  655. url
  656. }, function (window) {
  657. })
  658. }
  659. /**
  660. * 分享fecebook 地址
  661. */
  662. function feacebookShareUrl(params = {}) {
  663. let { href = '', type = '', taskLuckdropId } = params;
  664. let cbParams = JSON.stringify({
  665. type,
  666. taskLuckdropId
  667. })
  668. let shareUrl = `https://www.facebook.com/dialog/share?app_id=${facebookAppConfig.facebookAppId}&display=popup&href=${href}&redirect_uri=${facebookAppConfig.faceShareRedirectUrl}?params=${cbParams}`;
  669. return shareUrl;
  670. }
  671. /**
  672. * 分享成功
  673. */
  674. function facebookShareSuccess(params) {
  675. let { taskLuckdropId } = params;
  676. if (taskLuckdropId == state.detail.taskLuckdropId) {
  677. state.done.repost_facebook = true;
  678. state.done.repost_facebook_red = false;
  679. }
  680. }
  681. function getValidity() {
  682. let _d1, _d2, _d3, _h, _m, _s
  683. if (!state.detail.myReceived.taskEndTimestamp) {
  684. return
  685. }
  686. let timer = setInterval(() => {
  687. let _time = new Date().getTime()
  688. _d3 = state.detail.myReceived.taskEndTimestamp - _time
  689. if (_d3 > 0) {
  690. _d1 = moment(state.detail.myReceived.taskEndTimestamp)
  691. _d2 = moment(_time)
  692. _h = moment.duration(_d1.diff(_d2)).hours()
  693. if (_h < 10) {
  694. _h = '0' + _h
  695. }
  696. _m = moment.duration(_d1.diff(_d2)).minutes()
  697. if (_m < 10) {
  698. _m = '0' + _m
  699. }
  700. _s = moment.duration(_d1.diff(_d2)).seconds()
  701. if (_s < 10) {
  702. _s = '0' + _s
  703. }
  704. state.detail.validity = `${_h}:${_m}:${_s}`
  705. } else {
  706. state.detail.validity = `00:00:00`
  707. clearInterval(timer)
  708. }
  709. }, 1000)
  710. }
  711. const openFollowTabs = (arr_name) => {
  712. let array_finish = arr_name.filter((item) => { return !item.finished })
  713. // let array_finish = state.detail.taskCondition[0].relatedUsers.filter((item) => { return item.finished == false })
  714. let url
  715. if (array_finish.length > 0) {
  716. state.done.follow = false
  717. // 打开标签页的方法
  718. array_finish.forEach((item) => {
  719. url = `https://twitter.com/intent/follow?screen_name=${item.name}&tweet_id=${state.tweetId}`
  720. chrome.tabs.create({ url }, (tab) => {
  721. if (follow_open_tabs.filter((item) => { return item.url == tab.url }).length == 0) {
  722. follow_open_tabs.push(tab)
  723. }
  724. })
  725. })
  726. }
  727. }
  728. async function clickFollowAll(item, is_all) {
  729. let _userInfo = await checkIsLogin()
  730. if (!_userInfo) {
  731. return
  732. }
  733. let arr_name = []
  734. for (let i in item) {
  735. if (!item[i].finished) {
  736. arr_name.push(item[i])
  737. }
  738. }
  739. // ----
  740. state.detail.finishTaskTypeV2 = state.detail.finishTaskTypeV2.toString() || ''
  741. if (state.window_origin.indexOf('facebook.com') >= 0) {
  742. state.detail.finishTaskTypeV2 = '2'
  743. }
  744. switch (state.detail.finishTaskTypeV2) {
  745. case '1':
  746. // openapi
  747. state.loading_show = true
  748. oneKeyFollow({
  749. params: {
  750. names: arr_name
  751. }
  752. }).then((res) => {
  753. state.loading_show = false
  754. if (res.code == 0) {
  755. res.data.forEach((item1) => {
  756. state.detail.taskCondition[0].relatedUsers.forEach(item2 => {
  757. if (item1.name == item2.name && item1.finished) {
  758. item2.finished = true
  759. }
  760. });
  761. })
  762. openFollowTabs(arr_name)
  763. }
  764. }).catch(() => {
  765. state.loading_show = false
  766. })
  767. break
  768. case '2':
  769. openFollowTabs(arr_name)
  770. break
  771. case '3':
  772. if (arr_name.filter((item) => { return !item.twitterUserId }).length > 0) {
  773. openFollowTabs(arr_name)
  774. return
  775. }
  776. let follow_data = []
  777. arr_name.forEach((item) => {
  778. follow_data.push(item)
  779. })
  780. state.loading_show = true
  781. chrome.tabs.getCurrent((tab) => {
  782. chrome.tabs.sendMessage(tab.id, {
  783. actionType: "IFRAME_TWITTER_API_DO_TASK",
  784. task_data: {
  785. tweet_Id: state.tweetId,
  786. follow_data: follow_data,
  787. },
  788. task_type: 'follow'
  789. }, (res) => { console.log(res) });
  790. })
  791. break
  792. default:
  793. openFollowTabs(arr_name)
  794. break
  795. }
  796. // -------- 埋点 --------
  797. let _log_obj = {
  798. pageSource: Report.pageSource.task_page,
  799. businessType: Report.businessType.buttonClick,
  800. objectType: Report.objectType.follow
  801. }
  802. if (is_all) {
  803. _log_obj.objectType = Report.objectType.follow_button
  804. }
  805. Report.reportLog(_log_obj, {
  806. postId: state.postId,
  807. srcContentId: state.tweetId,
  808. senderId: state.userId,
  809. });
  810. }
  811. // 重新绑定
  812. const reSetBindTwtterId = (_params) => {
  813. let postBizData = JSON.parse(_params.postBizData);
  814. let { taskCondition } = postBizData;
  815. let discordTask = JSON.parse(taskCondition).find(item => item.type == 7);
  816. getChromeStorage('userInfo', (_userInfo) => {
  817. if (_userInfo.uid == _params.uid) {
  818. srcPublishSuccess({
  819. params: {
  820. postId: state.postId,
  821. srcContentId: state.tweetId
  822. }
  823. }).then((res) => {
  824. if (res.code == 0 || res.code == 3003) {
  825. init({ from: 'reSetBindTwtterId' })
  826. reportBindTweetSuccess({ discordTask, ..._params });
  827. }
  828. })
  829. }
  830. })
  831. }
  832. const reportBindTweetSuccess = (params) => {
  833. let { discordTask, srcUserId } = params || {};
  834. discordTaskDetail = discordTask;
  835. sendChromeTabMessage({
  836. actionType: "IFRAME_API_GET_TWEET_USER_INFO_REQ",
  837. data: {
  838. screen_name: srcUserId
  839. }
  840. })
  841. if (discordTask) {
  842. getDiscordInfo({ inviteUrl: JSON.parse(discordTask.bizData).inviteUrl }, (res) => {
  843. if (res.inviteCode == res.code) {
  844. reportParams.discordFans = res.approximate_member_count;
  845. if (reportParams.twitterFans !== '' && !reportParams.hasReport) {
  846. reportParams.hasReport = true;
  847. Report.reportLog({
  848. objectType: Report.objectType.tweetPostBinded,
  849. twitterFans: reportParams.twitterFans,
  850. discordFans: reportParams.discordFans,
  851. redPacketType: 0
  852. });
  853. }
  854. }
  855. })
  856. }
  857. }
  858. const getDiscordInfo = (params, cb) => {
  859. let { inviteUrl } = params;
  860. if (!inviteUrl) return;
  861. let inviteCode = '';
  862. let arr = inviteUrl.split('/');
  863. if (arr.length > 0) {
  864. inviteCode = arr[arr.length - 1];
  865. }
  866. if (!inviteCode) {
  867. return;
  868. }
  869. getInviteGuildInfo({
  870. inviteCode
  871. }).then(res => {
  872. cb && cb({
  873. ...res,
  874. inviteCode
  875. })
  876. }).catch((err) => {
  877. });
  878. }
  879. const showCloseEndTimePage = () => {
  880. state.status = 'close'
  881. state.close_status = '红包过期了'
  882. state.close_text = [`This Giveaways`, `expired on ${moment(state.detail.endTimestamp).format('MM-DD')}`]
  883. }
  884. const showCloseEndTimePageReport = () => {
  885. // 埋点
  886. Report.reportLog({
  887. pageSource: Report.pageSource.expired_page,
  888. businessType: Report.businessType.pageView,
  889. postId: state.postId,
  890. srcContentId: state.tweetId,
  891. senderId: state.userId,
  892. });
  893. }
  894. const showSuccessPage = () => {
  895. state.status = 'success'
  896. // 埋点
  897. Report.reportLog({
  898. pageSource: Report.pageSource.received_success_page,
  899. businessType: Report.businessType.pageView,
  900. postId: state.postId,
  901. srcContentId: state.tweetId,
  902. senderId: state.userId,
  903. isOldTwitterFans: reportParams.done.follow,
  904. isOldDiscordFans: reportParams.done.join_discord,
  905. redPacketType: 0
  906. });
  907. }
  908. const showNotOpenPage = () => {
  909. state.status = 'not-open'
  910. Report.reportLog({
  911. pageSource: Report.pageSource.pending_page,
  912. businessType: Report.businessType.pageView,
  913. postId: state.postId,
  914. srcContentId: state.tweetId,
  915. senderId: state.userId,
  916. });
  917. }
  918. const showOpenedPage = () => {
  919. state.status = 'opened'
  920. initTaskDetail(() => {
  921. showOpenedPageReport()
  922. })
  923. }
  924. const showOpenedPageReport = () => {
  925. reportParams.done.follow = state.done.follow;
  926. reportParams.done.join_discord = state.done.join_discord;
  927. // 埋点
  928. Report.reportLog({
  929. pageSource: Report.pageSource.task_page,
  930. businessType: Report.businessType.pageView,
  931. postId: state.postId,
  932. srcContentId: state.tweetId,
  933. senderId: state.userId,
  934. isOldTwitterFans: state.done.follow,
  935. isOldDiscordFans: state.done.join_discord,
  936. redPacketType: 0
  937. });
  938. }
  939. const showRabbitPage = () => {
  940. state.status = 'close'
  941. state.close_status = '没有领到钱'
  942. }
  943. const showRabbitPageReport = () => {
  944. Report.reportLog({
  945. pageSource: Report.pageSource.received_empty_rewards_page,
  946. businessType: Report.businessType.pageView,
  947. postId: state.postId,
  948. srcContentId: state.tweetId,
  949. senderId: state.userId,
  950. });
  951. }
  952. const handleStatusPage = () => {
  953. // status 红包状态(0:未开始,1:进行中,2:已结束,3:已终止,4:终止退款进行中)
  954. // myReceived 我是否领取过
  955. // taskFinishStatus 任务完成状态(0:未完成,1:已完成,2:已过期)
  956. // receiveTimeExpired 是否已经过了红包的领取截止时间
  957. // ---- 判断结构 ----
  958. // 如果 红包状态 = 未开始
  959. // 显示未打开页面 return
  960. //
  961. // 如果 我领取过了
  962. // 如果 任务完成状态 = 未完成
  963. // 显示任务未完成页面
  964. // 如果 任务完成状态 = 已经完成
  965. // 如果 领取到红包金额 = 0
  966. // 显示兔子页面
  967. // 否则
  968. // 显示成功页面
  969. // 如果 任务完成状态 = 已经过期
  970. // 如果 红包状态 = 进行中
  971. // 显示未打开页面
  972. // 否则
  973. // 显示已经过期页面
  974. // 如果 我没有领取过 & 红包状态 = 进行中
  975. // 如果 过了红包的领取截止时间 = true
  976. // 显示已经过期页面
  977. // 如果 过了红包的领取截止时间 = false
  978. // 显示未打开页面
  979. // 如果 我没有领取过 & 红包状态 = 已结束 | 已终止 | 终止退款进行中
  980. // 显示过期页面
  981. // -------- 华丽的分割线 --------
  982. // 如果 红包状态 = 未开始
  983. if (state.detail.status == 0) {
  984. showNotOpenPage()
  985. return
  986. }
  987. // 如果 我领取过了
  988. if (state.detail.myReceived) {
  989. state.receiveAmount = state.detail.myReceived.amountValue || 0
  990. state.detail.taskCondition = JSON.parse(state.detail.taskCondition)
  991. // 如果 任务完成状态 = 未完成
  992. if (state.detail.myReceived.taskFinishStatus == 0) {
  993. // 显示任务未完成页面
  994. showOpenedPage()
  995. if (state.process_mode != 'production') {
  996. getValidity()
  997. }
  998. //如果 任务完成状态 = 已经完成
  999. } else if (state.detail.myReceived.taskFinishStatus == 1) {
  1000. // 领取到空红包
  1001. if (state.receiveAmount == 0) {
  1002. showRabbitPage()
  1003. showRabbitPageReport()
  1004. } else {
  1005. // 显示成功页面
  1006. showSuccessPage()
  1007. }
  1008. // 如果 任务完成状态 = 已经过期
  1009. } else {
  1010. // 如果 红包状态 = 进行中
  1011. if (state.detail.status == 1) {
  1012. // 显示未打开页面
  1013. showNotOpenPage()
  1014. // 否则
  1015. } else {
  1016. // 显示已经过期页面
  1017. showCloseEndTimePage()
  1018. showCloseEndTimePageReport()
  1019. }
  1020. }
  1021. // 如果 我没有领取过
  1022. } else {
  1023. // 如果 红包状态 = 进行中
  1024. if (state.detail.status == 1) {
  1025. // 如果 过了红包的领取截止时间 = true
  1026. if (state.detail.receiveTimeExpired) {
  1027. // 显示过期页面
  1028. showCloseEndTimePage()
  1029. showCloseEndTimePageReport()
  1030. // 如果 过了红包的领取截止时间 = false
  1031. } else {
  1032. // 显示未打开页面
  1033. showNotOpenPage()
  1034. }
  1035. // 红包状态 = 已经结束了 | 已经终止 | 终止退款中
  1036. } else {
  1037. // 显示过期页面
  1038. showCloseEndTimePage()
  1039. showCloseEndTimePageReport()
  1040. }
  1041. }
  1042. }
  1043. function setFrontConfig() {
  1044. getFrontConfig({
  1045. params: {},
  1046. }).then((res) => {
  1047. if (res.code == 0) {
  1048. facebookAppConfig.facebookAppId = res.data.fbClientId;
  1049. }
  1050. });
  1051. };
  1052. function init(initParams) {
  1053. let { type } = initParams || {};
  1054. onPageVisbile();
  1055. onWindowMessage();
  1056. setFrontConfig();
  1057. getPostDetail({
  1058. params: {
  1059. postId: state.postId
  1060. }
  1061. }).then((res) => {
  1062. state.loading_show = false
  1063. // 领取0元为空红包继续流程
  1064. // ---- 完成任务接口 ----
  1065. // 如果金额是0
  1066. // 显示没有领到钱
  1067. if (res.code == 0) {
  1068. state.srcContent = res.data.srcContent;
  1069. state.postRedirectUrl = res.data.postRedirectUrl;
  1070. // 判断推特id,绑定逻辑
  1071. state.srcContentId = res.data.srcContentId
  1072. if (!state.srcContentId) {
  1073. reSetBindTwtterId(res.data)
  1074. return
  1075. }
  1076. state.detail = JSON.parse(res.data.postBizData)
  1077. state.detail.taskCondition = state.detail.taskCondition || []
  1078. state.tweetId = state.srcContentId;
  1079. state.userId = res.data.srcUserId;
  1080. state.tweet_author = state.detail.postUserInfo && state.detail.postUserInfo.nickName || '';
  1081. // 不要删除这个console
  1082. console.log('postBizData', state.detail)
  1083. checkFacebookReply();
  1084. handleStatusPage()
  1085. } else {
  1086. handleErrorCode(res)
  1087. }
  1088. }).finally(() => {
  1089. state.loading_redbag = false
  1090. })
  1091. }
  1092. function initTaskDetail(cb) {
  1093. getChromeStorage('userInfo', (_userInfo) => {
  1094. if (_userInfo.uid) {
  1095. // 任务详情
  1096. getTaskDetail({
  1097. params: {
  1098. postId: state.postId
  1099. }
  1100. }).then((res) => {
  1101. if (res.code.toString()) {
  1102. for (let i in res.data) {
  1103. switch (res.data[i].type) {
  1104. case 1:
  1105. state.done.follow = res.data[i].finished
  1106. state.detail.taskCondition[0].relatedUsers = res.data[i].detail
  1107. break
  1108. case 2:
  1109. state.done.like = res.data[i].finished
  1110. break
  1111. case 3:
  1112. state.done.retweet = res.data[i].finished
  1113. break
  1114. case 7:
  1115. state.done.join_discord = res.data[i].finished
  1116. discordAuthorizeRequired = res.data[i].discordAuthorizeRequired
  1117. break
  1118. case 8:
  1119. state.done.repost_facebook = res.data[i].finished;
  1120. break;
  1121. case 9:
  1122. state.done.reply = res.data[i].finished;
  1123. if (!state.done.reply) {
  1124. onTweetReplyClick({ type: 9 });
  1125. }
  1126. break;
  1127. }
  1128. }
  1129. } else {
  1130. handleErrorCode(res)
  1131. }
  1132. cb && cb()
  1133. })
  1134. }
  1135. })
  1136. }
  1137. let tab_index = 0
  1138. const doTaskReport = (req, sender) => {
  1139. state.loading_show = false
  1140. let follow_name = req.task_data.follow_name || ''
  1141. // 1 Twitter follow Twitter ScreenName
  1142. // 2 Tweet like
  1143. // 3 Retweet
  1144. let event_type = 0
  1145. switch (req.task_type) {
  1146. case 'retweet':
  1147. event_type = 3
  1148. state.done.retweet = req.task_done
  1149. if (!req.task_done && req.do_type == 'api') {
  1150. window.open(`https://twitter.com/intent/retweet?tweet_id=${state.tweetId}`)
  1151. }
  1152. break;
  1153. case 'like':
  1154. event_type = 2
  1155. state.done.like = req.task_done
  1156. //
  1157. if (!req.task_done && req.do_type == 'api') {
  1158. window.open(`https://twitter.com/intent/like?tweet_id=${state.tweetId}`)
  1159. }
  1160. break
  1161. case 'follow':
  1162. event_type = 1
  1163. // for (let i = 0; i < follow_open_tabs.length; i++) {
  1164. // if (follow_open_tabs[i].id == sender.tab.id) {
  1165. // follow_open_tabs.splice(i, 1)
  1166. // break
  1167. // }
  1168. // }
  1169. // chrome.tabs.getCurrent((tab) => {
  1170. // if (follow_open_tabs.length > 0) {
  1171. // tab_index = follow_open_tabs[follow_open_tabs.length - 1].index
  1172. // } else {
  1173. // tab_index = tab.index
  1174. // }
  1175. // chrome.tabs.highlight({ windowId: tab.windowId, tabs: tab_index })
  1176. // })
  1177. let has_no_finished = false
  1178. state.detail.taskCondition[0].relatedUsers.forEach((item) => {
  1179. if (follow_name == item.name) {
  1180. item.finished = req.task_done
  1181. }
  1182. })
  1183. state.detail.taskCondition[0].relatedUsers.forEach((item) => {
  1184. if (!item.finished) {
  1185. has_no_finished = true
  1186. }
  1187. })
  1188. if (!has_no_finished) {
  1189. state.done.follow = true
  1190. state.done.follow_red = false
  1191. openFollowTabs(state.detail.taskCondition[0].relatedUsers)
  1192. }
  1193. break
  1194. }
  1195. if (req.do_type != 'api') {
  1196. chrome.tabs.remove(sender.tab.id)
  1197. }
  1198. if (req.task_done) {
  1199. addFinishEvent({
  1200. params: {
  1201. eventData: follow_name,
  1202. eventType: event_type,
  1203. luckdropId: state.detail.taskLuckdropId
  1204. }
  1205. })
  1206. }
  1207. }
  1208. onMounted(() => {
  1209. state.process_mode = process.env.NODE_ENV
  1210. state.postId = getQueryString('postId')
  1211. state.window_origin = getQueryString('window_origin') || '';
  1212. if (state.window_origin.indexOf('twitter.com') > -1) {
  1213. state.tweetId = getQueryString('tweetId')
  1214. state.tweet_author = getQueryString('tweet_author');
  1215. }
  1216. getTweetAuthor();
  1217. init()
  1218. onRuntimeMsg();
  1219. // state.loading_show = true
  1220. // state.status = 'opened'
  1221. // state.close_status = '没有领到钱'
  1222. })
  1223. function getTweetAuthor() {
  1224. if (state.window_origin.indexOf('twitter.com') > -1) {
  1225. window.parent.postMessage({
  1226. actionType: "IFRAME_RED_PACKET_GET_TWEET_AUTHOR", data: {
  1227. postId: state.postId,
  1228. taskLuckdropId: state.detail.taskLuckdropId
  1229. }
  1230. }, "*");
  1231. }
  1232. }
  1233. function checkFacebookReply() {
  1234. console.log('checkFacebookReply')
  1235. if (state.window_origin.indexOf('twitter.com') > -1) {
  1236. window.parent.postMessage({
  1237. actionType: "IFRAME_RED_PACKET_CHECK_FACEBOOK_REPLY", data: {
  1238. postId: state.postId
  1239. }
  1240. }, "*");
  1241. }
  1242. }
  1243. // 点击领取
  1244. function clickOpenRedPacket() {
  1245. callEventPageMethod('CONTENT_GET_PINED', {})
  1246. handleRedPacket()
  1247. }
  1248. function handleRedPacket() {
  1249. state.loading_show = true
  1250. getRedPacket({
  1251. params: {
  1252. postId: state.postId
  1253. }
  1254. }).then((res) => {
  1255. state.loading_show = false
  1256. if (res.code == 0) {
  1257. showOpenedPage()
  1258. init()
  1259. } else {
  1260. handleErrorCode(res)
  1261. }
  1262. }).catch(() => {
  1263. state.loading_show = false
  1264. })
  1265. // 埋点
  1266. Report.reportLog({
  1267. pageSource: Report.pageSource.pending_page,
  1268. businessType: Report.businessType.buttonClick,
  1269. objectType: Report.objectType.open_button,
  1270. postId: state.postId,
  1271. srcContentId: state.tweetId,
  1272. senderId: state.userId,
  1273. redPacketType: 0
  1274. });
  1275. }
  1276. chrome.storage.onChanged.addListener(changes => {
  1277. if (changes.userInfo) {
  1278. // let item = JSON.parse(changes.userInfo.newValue)
  1279. state.loading_show = false
  1280. init()
  1281. }
  1282. })
  1283. // 校验是否封路
  1284. function checkIsLogin() {
  1285. return new Promise((resolve) => {
  1286. getChromeStorage('userInfo', (_userInfo) => {
  1287. if (!_userInfo) {
  1288. state.loading_show = true
  1289. setTimeout(() => {
  1290. state.loading_show = false
  1291. }, 3000)
  1292. chrome.runtime.sendMessage(
  1293. { actionType: "POPUP_LOGIN", data: "" },
  1294. (response) => {
  1295. console.log("res", response);
  1296. }
  1297. )
  1298. resolve(_userInfo)
  1299. } else {
  1300. resolve(_userInfo)
  1301. }
  1302. })
  1303. })
  1304. }
  1305. async function clickGetGiveaways() {
  1306. let _userInfo = await checkIsLogin()
  1307. if (_userInfo) {
  1308. handleFinishRedPacket()
  1309. }
  1310. }
  1311. function handleFinishRedPacket() {
  1312. state.loading_show = true
  1313. finishRedPacket({
  1314. params: {
  1315. postId: state.postId
  1316. }
  1317. }).then((res) => {
  1318. state.loading_show = false
  1319. if (res.code == 0) {
  1320. if (res.data.finished) {
  1321. state.receiveAmount = res.data.receiveAmount
  1322. if (state.receiveAmount == 0) {
  1323. showRabbitPage()
  1324. } else {
  1325. state.status = 'success'
  1326. }
  1327. init()
  1328. // 埋点
  1329. Report.reportLog({
  1330. pageSource: Report.pageSource.task_page,
  1331. businessType: Report.businessType.buttonClick,
  1332. objectType: Report.objectType.get_giveaway,
  1333. postId: state.postId,
  1334. srcContentId: state.tweetId,
  1335. senderId: state.userId,
  1336. }, {
  1337. get_giveaway_result: Report.extParams.success
  1338. });
  1339. } else {
  1340. let _data = res.data.conditionResult
  1341. for (let i in _data) {
  1342. switch (_data[i].type.toString()) {
  1343. case '1':
  1344. state.detail.taskCondition[0].relatedUsers = _data[i].detail
  1345. if (_data[i].finished) {
  1346. state.done.follow = true
  1347. state.done.follow_red = false
  1348. } else {
  1349. // alert('Please complete the task: follow')
  1350. state.done.follow = false
  1351. state.done.follow_red = true
  1352. }
  1353. break
  1354. case '2':
  1355. if (_data[i].finished) {
  1356. state.done.like = true
  1357. state.done.like_red = false
  1358. } else {
  1359. // alert('Please complete the task: like tweet')
  1360. state.done.like = false
  1361. state.done.like_red = true
  1362. }
  1363. break
  1364. case '3':
  1365. if (_data[i].finished) {
  1366. state.done.retweet = true
  1367. state.done.retweet_red = false
  1368. } else {
  1369. // alert('Please complete the task: Retweet')
  1370. state.done.retweet_red = true
  1371. state.done.retweet = false
  1372. }
  1373. break
  1374. case '7':
  1375. //join discord
  1376. discordAuthorizeRequired = _data[i].discordAuthorizeRequired;
  1377. if (_data[i].finished) {
  1378. state.done.join_discord = true
  1379. state.done.join_discord_red = false
  1380. } else {
  1381. state.done.join_discord = false;
  1382. state.done.join_discord_red = true
  1383. }
  1384. break
  1385. case '8':
  1386. //repost feacebook
  1387. if (_data[i].finished) {
  1388. state.done.repost_facebook = true
  1389. state.done.repost_facebook_red = false
  1390. } else {
  1391. state.done.repost_facebook = false;
  1392. state.done.repost_facebook_red = true
  1393. }
  1394. break
  1395. case '9':
  1396. //reply
  1397. if (_data[i].finished) {
  1398. state.done.reply = true
  1399. state.done.reply_red = false
  1400. } else {
  1401. state.done.reply = false;
  1402. state.done.reply_red = true
  1403. }
  1404. break
  1405. }
  1406. }
  1407. // 埋点
  1408. Report.reportLog({
  1409. pageSource: Report.pageSource.task_page,
  1410. businessType: Report.businessType.buttonClick,
  1411. objectType: Report.objectType.get_giveaway,
  1412. postId: state.postId,
  1413. srcContentId: state.tweetId,
  1414. senderId: state.userId,
  1415. }, {
  1416. get_giveaway_result: Report.extParams.failure,
  1417. });
  1418. if (discordAuthorizeRequired) {
  1419. discordAuth('reAuth');
  1420. }
  1421. }
  1422. } else {
  1423. // 埋点
  1424. Report.reportLog({
  1425. pageSource: Report.pageSource.task_page,
  1426. businessType: Report.businessType.buttonClick,
  1427. objectType: Report.objectType.get_giveaway,
  1428. postId: state.postId,
  1429. srcContentId: state.tweetId,
  1430. senderId: state.userId,
  1431. }, {
  1432. get_giveaway_result: Report.extParams.failure,
  1433. });
  1434. handleErrorCode(res)
  1435. }
  1436. }).catch(() => {
  1437. state.loading_show = false
  1438. })
  1439. }
  1440. function handleErrorCode(res) {
  1441. switch (res.code.toString()) {
  1442. // 数据异常,请联系管理员
  1443. case '-102':
  1444. break
  1445. //系统错误
  1446. case '-101':
  1447. break
  1448. // 参数不对
  1449. case '-103':
  1450. break
  1451. // 接口被限流
  1452. case '-105':
  1453. break
  1454. // 访问凭证不存在
  1455. case '-107':
  1456. break
  1457. // 重复操作过于频繁
  1458. case '-106':
  1459. message.error('Clicking too often, wait a moment and click again')
  1460. state.loading_show = false
  1461. break
  1462. // 红包不存在
  1463. case '2001':
  1464. // message.error(res.msg)
  1465. break
  1466. // 还未到红包领取时间
  1467. case '2002':
  1468. // message.error(res.msg)
  1469. break
  1470. // 已超过红包领取时间
  1471. case '2003':
  1472. init()
  1473. break
  1474. // 红包支付状态异常 没有可提交的任务红包
  1475. case '2004':
  1476. init()
  1477. break
  1478. // 红包活动已结束
  1479. case '2006':
  1480. init()
  1481. break
  1482. // 红包金额已经被领取完了
  1483. case '2007':
  1484. state.status = 'close'
  1485. state.close_status = '红包过期了'
  1486. state.close_text = [`This Giveaways`, `expired on ${moment(state.detail.endTimestamp).format('MM-DD')}`]
  1487. init()
  1488. break
  1489. // 红包个数已经被领取完了
  1490. case '2008':
  1491. state.status = 'close'
  1492. state.close_status = '红包过期了'
  1493. state.close_text = [`This Giveaways`, `expired on ${moment(state.detail.endTimestamp).format('MM-DD')}`]
  1494. init()
  1495. break
  1496. // 该用户不满足领取条件
  1497. case '2009':
  1498. state.error_txt = [`oops, new accounts cannot participate in this event,`]
  1499. state.status = 'error'
  1500. state.retry = true
  1501. // 埋点
  1502. Report.reportLog({
  1503. pageSource: Report.pageSource.robot_detection_failed_page,
  1504. businessType: Report.businessType.pageView,
  1505. postId: state.postId,
  1506. srcContentId: state.tweetId,
  1507. senderId: state.userId,
  1508. });
  1509. break
  1510. // 无法校验用户Twitter信息
  1511. case '2010':
  1512. // message.error(res.msg)
  1513. break
  1514. // 用户已经领过该红包
  1515. case '2011':
  1516. // message.error(res.msg)
  1517. break
  1518. // 推文不存在
  1519. case '2022':
  1520. // message.error(res.msg)
  1521. break
  1522. // 推文未发布 and 不是红包任务的推文
  1523. case '2023':
  1524. // message.error(res.msg)
  1525. break
  1526. // 没有可提交的任务红包
  1527. case '2024':
  1528. state.status = 'not-open'
  1529. break
  1530. // 红包任务已完成
  1531. case '2025':
  1532. break
  1533. // 任务已经过期
  1534. case '2026':
  1535. break
  1536. // 任务未完成
  1537. case '2027':
  1538. break
  1539. // 红包金额每人不足1分钱
  1540. case '2028':
  1541. break
  1542. // 推文未发布
  1543. case '2029':
  1544. message.error('Tweet not posted')
  1545. break
  1546. // 不是红包任务的推文
  1547. case '2030':
  1548. break
  1549. case '2037':
  1550. showCloseEndTimePage()
  1551. init()
  1552. break
  1553. //用户没有领取过红包,无法重抽
  1554. case '2031':
  1555. break
  1556. // 需要重新授权 discord
  1557. case '1010':
  1558. discordAuth('reAuth');
  1559. break
  1560. }
  1561. }
  1562. // function clickBack() {
  1563. // state.status = 'opened'
  1564. // // 埋点
  1565. // Report.reportLog({
  1566. // pageSource: Report.pageSource.task_page,
  1567. // businessType: Report.businessType.pageView,
  1568. // });
  1569. // }
  1570. // function clickRoad() {
  1571. // state.status = 'luck-peopel-list'
  1572. // // 埋点
  1573. // Report.reportLog({
  1574. // pageSource: Report.pageSource.task_page,
  1575. // businessType: Report.businessType.buttonClick,
  1576. // objectType: Report.objectType.received_list
  1577. // });
  1578. // // 埋点
  1579. // Report.reportLog({
  1580. // pageSource: Report.pageSource.received_list_page,
  1581. // businessType: Report.businessType.pageView
  1582. // });
  1583. // }
  1584. function onWindowMessage() {
  1585. window.addEventListener("message", function (event) {
  1586. if (event.data) {
  1587. switch (event.data.actionType) {
  1588. case 'CONTENT_RED_PACKET_REPLY_RASK_FINSH':
  1589. state.done.reply = true;
  1590. state.done.reply_red = false;
  1591. break;
  1592. case 'CONTENT_RED_PACKET_GET_TWEET_AUTHOR':
  1593. fullName = event.data.data.fullName
  1594. break;
  1595. case 'CONTENT_RED_PACKET_FACEBOOK_REPLY':
  1596. clickReply(event.data.data)
  1597. break;
  1598. }
  1599. }
  1600. });
  1601. }
  1602. function onPageVisbile() {
  1603. document.addEventListener('visibilitychange', function () {
  1604. let isHidden = document.hidden;
  1605. if (!isHidden) {
  1606. checkJoinDiscord();
  1607. }
  1608. });
  1609. }
  1610. function onRuntimeMsg() {
  1611. chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
  1612. sendResponse('');
  1613. switch (req.actionType) {
  1614. case 'BACK_DISCORD_LOGIN_SUCCESS':
  1615. discordLoginSuccess();
  1616. break;
  1617. case 'BG_FACEBOOK_SHARE_SUCCESS':
  1618. facebookShareSuccess(req.data);
  1619. break;
  1620. case 'DO_TASK':
  1621. if (!req.task_type || state.tweetId != req.tweet_Id) {
  1622. return
  1623. }
  1624. state.loading_show = false
  1625. doTaskReport(req, sender);
  1626. break;
  1627. case 'CONTENT_RED_PACKET_REPLY_RASK_FINSH':
  1628. if (req.data && req.data.postId == state.postId) {
  1629. state.done.reply = true;
  1630. state.done.reply_red = false;
  1631. }
  1632. break;
  1633. case 'CONTENT_API_GET_TWEET_USER_INFO_RES':
  1634. let { user } = req.data || {};
  1635. if (user && user.result && user.result.legacy) {
  1636. let legacy = user.result.legacy;
  1637. reportParams.twitterFans = legacy.followers_count;
  1638. if (!discordTaskDetail) {
  1639. if (reportParams.hasReport) return;
  1640. reportParams.hasReport = true;
  1641. Report.reportLog({
  1642. objectType: Report.objectType.tweetPostBinded,
  1643. twitterFans: reportParams.twitterFans,
  1644. redPacketType: 0
  1645. });
  1646. } else {
  1647. if (reportParams.discordFans !== '') {
  1648. if (reportParams.hasReport) return;
  1649. reportParams.hasReport = true;
  1650. Report.reportLog({
  1651. objectType: Report.objectType.tweetPostBinded,
  1652. twitterFans: reportParams.twitterFans,
  1653. discordFans: reportParams.discordFans,
  1654. redPacketType: 0
  1655. });
  1656. }
  1657. }
  1658. }
  1659. break;
  1660. }
  1661. })
  1662. }
  1663. /**
  1664. * 检查是否加入discord
  1665. */
  1666. function checkJoinDiscord() {
  1667. // 如果上次的状态是 joinIng 检查是否真正join
  1668. if (joinDiscordActionState == 'joinIng') {
  1669. joinDiscordActionState = 'default';
  1670. let url = getInviteUrl();
  1671. if (url) {
  1672. joinDiscordIng.value = true;
  1673. checkGuildJoinedStatus({ url }, (res = {}) => {
  1674. joinDiscordIng.value = false;
  1675. if (res.code == 0) {
  1676. let { joined } = res.data || {};
  1677. if (joined) {
  1678. state.done.join_discord = true;
  1679. } else {
  1680. state.done.join_discord = false;
  1681. }
  1682. } else if (res.code == 1010) {
  1683. discordAuth('reAuth');
  1684. }
  1685. })
  1686. }
  1687. }
  1688. }
  1689. const checkGuildJoinedStatus = ({ url }, cb) => {
  1690. checkGuildJoined({
  1691. params: {
  1692. inviteUrl: url
  1693. }
  1694. }).then(res => {
  1695. cb && cb(res);
  1696. }).catch(err => {
  1697. cb && cb({ catch: true })
  1698. })
  1699. }
  1700. /**
  1701. * 加入discord 事件
  1702. */
  1703. async function joinDiscord() {
  1704. let _userInfo = await checkIsLogin();
  1705. if (!_userInfo) {
  1706. return
  1707. }
  1708. if (joinDiscordIng.value) {
  1709. return;
  1710. }
  1711. // 埋点
  1712. Report.reportLog({
  1713. objectType: Report.objectType.join_discord,
  1714. pageSource: Report.pageSource.task_page,
  1715. businessType: Report.businessType.buttonClick,
  1716. postId: state.postId,
  1717. srcContentId: state.tweetId,
  1718. senderId: state.userId,
  1719. redPacketType: 0
  1720. });
  1721. let url = getInviteUrl();
  1722. if (url) {
  1723. joinDiscordIng.value = true;
  1724. checkGuildJoinedStatus({ url }, (res) => {
  1725. setTimeout(() => {
  1726. joinDiscordIng.value = false;
  1727. }, 1500);
  1728. if (res.code == 0) {
  1729. let { joined } = res.data || {};
  1730. if (joined) {
  1731. state.done.join_discord = true;
  1732. } else {
  1733. state.done.join_discord = false;
  1734. if (discordAuthorizeRequired) {
  1735. discordAuth('authAndJoinIng');
  1736. } else {
  1737. openInviteUrl();
  1738. }
  1739. }
  1740. } else if (res.code == 1010) {
  1741. discordAuth('authAndJoinIng');
  1742. }
  1743. if (res.catch) {
  1744. //判断是否需要授权
  1745. if (discordAuthorizeRequired) {
  1746. discordAuth('authAndJoinIng');
  1747. } else {
  1748. openInviteUrl();
  1749. }
  1750. }
  1751. })
  1752. }
  1753. }
  1754. /**
  1755. * discord授权
  1756. */
  1757. function discordAuth(actionState = 'default') {
  1758. let state = guid();
  1759. discordAuthUrl({
  1760. params: {
  1761. redirectUrl: discordAuthRedirectUri,
  1762. state
  1763. }
  1764. }).then(res => {
  1765. if (res.code == 0) {
  1766. let { authorizeUrl = '' } = res.data || {};
  1767. if (authorizeUrl) {
  1768. joinDiscordActionState = actionState;
  1769. const width = 500;
  1770. chrome.windows.create({
  1771. width,
  1772. type: 'normal',
  1773. url: authorizeUrl
  1774. }, function (window) {
  1775. let windowId = window.id;
  1776. callEventPageMethod("RED_PACKET_SAVE_DISCORD_AUTH_WINDOW_ID", {
  1777. windowId: windowId
  1778. }, function (response) {
  1779. });
  1780. })
  1781. }
  1782. }
  1783. })
  1784. }
  1785. /**
  1786. * sendMessage
  1787. */
  1788. const callEventPageMethod = (actionType, data, callback) => {
  1789. chrome.runtime.sendMessage(
  1790. {
  1791. actionType: actionType,
  1792. data: data
  1793. },
  1794. function (response) {
  1795. if (typeof callback === "function") callback(response);
  1796. }
  1797. );
  1798. };
  1799. /**
  1800. * discord 授权成功
  1801. */
  1802. function discordLoginSuccess() {
  1803. console.log('discordloginSuccess');
  1804. // 如果是授权并join 默认打开 邀请链接
  1805. if (joinDiscordActionState == 'authAndJoinIng') {
  1806. openInviteUrl();
  1807. }
  1808. if (discordAuthorizeRequired) {
  1809. discordAuthorizeRequired = false;
  1810. }
  1811. }
  1812. /**
  1813. * 获取discord邀请链接
  1814. */
  1815. function getInviteUrl() {
  1816. let inviteData = state.detail.taskCondition.find(item => {
  1817. return item.type == 7;
  1818. });
  1819. let url;
  1820. if (inviteData && inviteData.bizData) {
  1821. url = JSON.parse(inviteData.bizData).inviteUrl;
  1822. }
  1823. return url;
  1824. }
  1825. /**
  1826. * 打开邀请discord链接
  1827. */
  1828. function openInviteUrl() {
  1829. joinDiscordActionState = 'joinIng';
  1830. let url = getInviteUrl();
  1831. if (url) {
  1832. if (!url.startsWith('http')) {
  1833. url = 'https://' + url;
  1834. }
  1835. window.open(url);
  1836. }
  1837. }
  1838. </script>
  1839. <style lang="scss" scoped>
  1840. html,
  1841. body {
  1842. margin: 0;
  1843. padding: 0;
  1844. width: 375px;
  1845. height: 500px;
  1846. background-color: unset !important;
  1847. }
  1848. .content {
  1849. position: relative;
  1850. width: 375px;
  1851. height: 500px;
  1852. background: #fafafa;
  1853. border-radius: 11px;
  1854. overflow: hidden;
  1855. box-sizing: border-box;
  1856. border: 1px solid #DCDCDC;
  1857. font-family: "SF Pro Display";
  1858. font-style: normal;
  1859. .loading {
  1860. background: #FFFFFF;
  1861. opacity: 0.8;
  1862. z-index: 222;
  1863. text-align: center;
  1864. width: 375px;
  1865. height: 500px;
  1866. position: fixed;
  1867. top: 0;
  1868. left: 0;
  1869. img {
  1870. margin-top: 216px;
  1871. width: 70px;
  1872. height: 70px;
  1873. }
  1874. }
  1875. .redbag {
  1876. z-index: 222;
  1877. text-align: center;
  1878. width: 375px;
  1879. height: 500px;
  1880. position: fixed;
  1881. top: 0;
  1882. left: 0;
  1883. img {
  1884. margin-top: 172px;
  1885. width: 130px;
  1886. height: 130px;
  1887. }
  1888. }
  1889. .error {
  1890. width: 100%;
  1891. height: 100%;
  1892. text-align: center;
  1893. position: relative;
  1894. img {
  1895. width: 100px;
  1896. height: 100px;
  1897. margin-top: 100px;
  1898. }
  1899. .txt {
  1900. font-weight: 500;
  1901. font-size: 22px;
  1902. line-height: 26px;
  1903. text-align: center;
  1904. letter-spacing: 0.3px;
  1905. color: #a8a8a8;
  1906. margin: 34px 44px 0 44px;
  1907. }
  1908. .retry {
  1909. position: absolute;
  1910. bottom: 30px;
  1911. left: 50%;
  1912. margin-left: -167.5px;
  1913. width: 335px;
  1914. height: 46px;
  1915. line-height: 46px;
  1916. text-align: center;
  1917. border-radius: 100px;
  1918. border: 1px solid #1D9BF0;
  1919. background: rgba(196, 196, 196, 0.01);
  1920. color: #1D9BF0;
  1921. font-size: 16px;
  1922. font-weight: 500;
  1923. cursor: pointer;
  1924. }
  1925. }
  1926. .success,
  1927. .close,
  1928. .luck-peopel-list {
  1929. filter: drop-shadow(0px 4px 94px rgba(0, 0, 0, 0.3));
  1930. width: 100%;
  1931. height: 100%;
  1932. border-radius: 11px;
  1933. background: #fff;
  1934. overflow: hidden;
  1935. display: flex;
  1936. flex-direction: column;
  1937. .close-title {
  1938. width: 100%;
  1939. font-weight: 600;
  1940. font-size: 27px;
  1941. line-height: 32px;
  1942. text-align: center;
  1943. letter-spacing: 0.3px;
  1944. font-weight: 800;
  1945. font-size: 22px;
  1946. color: #ffffff;
  1947. }
  1948. .head {
  1949. padding: 14px 16px;
  1950. img {
  1951. cursor: pointer;
  1952. width: 24px;
  1953. height: 24px;
  1954. }
  1955. }
  1956. .header {
  1957. text-align: center;
  1958. min-height: 150px;
  1959. width: 100%;
  1960. background: #fff;
  1961. // padding-top: 30px;
  1962. background-size: 100% 100%;
  1963. position: relative;
  1964. display: flex;
  1965. align-content: center;
  1966. flex-wrap: wrap;
  1967. .rabbit {
  1968. width: 100%;
  1969. height: 100%;
  1970. display: flex;
  1971. align-items: center;
  1972. align-content: center;
  1973. flex-wrap: wrap;
  1974. justify-content: center;
  1975. img {
  1976. width: 150px;
  1977. height: 80px;
  1978. margin-bottom: 6px;
  1979. }
  1980. p {
  1981. width: 100%;
  1982. margin: 0;
  1983. padding: 0;
  1984. color: #fff;
  1985. text-align: center;
  1986. font-weight: 600;
  1987. font-size: 15px;
  1988. letter-spacing: 0.3px;
  1989. }
  1990. }
  1991. .done {
  1992. cursor: pointer;
  1993. position: absolute;
  1994. top: 107px;
  1995. left: 50%;
  1996. margin-left: -150px;
  1997. width: 300px;
  1998. height: 60px;
  1999. display: flex;
  2000. align-items: center;
  2001. border-radius: 100px;
  2002. background: #ffffff;
  2003. box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.1);
  2004. justify-content: center;
  2005. span {
  2006. color: #000000;
  2007. font-size: 14px;
  2008. }
  2009. .icon-done {
  2010. width: 24px;
  2011. height: 24px;
  2012. margin-right: 10px;
  2013. }
  2014. .icon-right {
  2015. margin-left: 5px;
  2016. width: 7px;
  2017. height: 14px;
  2018. }
  2019. }
  2020. .title {
  2021. margin-top: 30px;
  2022. color: #fff7e4;
  2023. opacity: 0.6;
  2024. font-weight: 700;
  2025. font-size: 18px;
  2026. line-height: 21px;
  2027. letter-spacing: -0.3px;
  2028. }
  2029. .money {
  2030. margin-bottom: 30px;
  2031. width: 100%;
  2032. display: flex;
  2033. justify-content: center;
  2034. align-items: center;
  2035. img {
  2036. width: 40px;
  2037. height: 40px;
  2038. margin-right: 9px;
  2039. border-radius: 50%;
  2040. border: solid 2px #fff;
  2041. }
  2042. .big {
  2043. font-weight: 700;
  2044. font-size: 46px;
  2045. line-height: 55px;
  2046. /* identical to box height */
  2047. letter-spacing: 0.3px;
  2048. color: #fff;
  2049. }
  2050. .small {
  2051. margin-left: 4px;
  2052. font-weight: 700;
  2053. font-size: 13px;
  2054. line-height: 16px;
  2055. /* identical to box height */
  2056. letter-spacing: 0.5px;
  2057. color: #fff;
  2058. }
  2059. }
  2060. }
  2061. .luck-list-title {
  2062. /* margin-top: 47px;*/
  2063. margin: 0 16px;
  2064. padding: 14px 0 11px 0;
  2065. background: #fff;
  2066. display: flex;
  2067. justify-content: space-between;
  2068. color: #B0B0B0;
  2069. font-weight: 500;
  2070. border-bottom: 1px solid #F2F2F2;
  2071. div:last-child {
  2072. text-align: right;
  2073. }
  2074. .text {
  2075. cursor: pointer;
  2076. }
  2077. }
  2078. .luck-list {
  2079. background: #fff;
  2080. overflow: auto;
  2081. &.max {
  2082. height: 250px;
  2083. }
  2084. .empty {
  2085. width: 100%;
  2086. height: 100%;
  2087. text-align: center;
  2088. img {
  2089. margin-top: 70px;
  2090. width: 100px;
  2091. height: 100px;
  2092. }
  2093. }
  2094. .luck-item {
  2095. display: flex;
  2096. padding: 10px 0;
  2097. margin: 0 16px;
  2098. border-bottom: 1px solid #F2F2F2;
  2099. justify-content: space-between;
  2100. position: relative;
  2101. img:first-child {
  2102. border-radius: 50%;
  2103. }
  2104. .luck-king {
  2105. position: absolute;
  2106. top: 36px;
  2107. right: 0px;
  2108. display: flex;
  2109. align-items: center;
  2110. img {
  2111. width: 22px;
  2112. height: 19px;
  2113. margin: 0;
  2114. }
  2115. span {
  2116. font-weight: 500;
  2117. font-size: 12px;
  2118. line-height: 14px;
  2119. letter-spacing: 0.3px;
  2120. color: #f5b945;
  2121. }
  2122. }
  2123. img {
  2124. cursor: pointer;
  2125. width: 42px;
  2126. height: 42px;
  2127. margin-right: 12px;
  2128. }
  2129. .luck-content {
  2130. flex: auto;
  2131. .luck-title {
  2132. color: #444444;
  2133. font-weight: 500;
  2134. font-size: 16px;
  2135. letter-spacing: 0.3px;
  2136. margin-bottom: 5px;
  2137. }
  2138. .luck-time {
  2139. font-weight: 400;
  2140. font-size: 12px;
  2141. line-height: 14px;
  2142. color: #B0B0B0;
  2143. }
  2144. }
  2145. .luck-money {
  2146. display: flex;
  2147. height: 17px;
  2148. align-items: center;
  2149. height: 100%;
  2150. img {
  2151. width: 14px;
  2152. height: 14px;
  2153. margin-right: 6px;
  2154. }
  2155. .luck-money-txt {
  2156. font-weight: 500;
  2157. font-size: 14px;
  2158. word-break: break-all;
  2159. /* identical to box height */
  2160. text-align: right;
  2161. letter-spacing: 0.3px;
  2162. color: #444444;
  2163. }
  2164. }
  2165. }
  2166. .luck-item:last-child {
  2167. border: 0;
  2168. }
  2169. }
  2170. }
  2171. .success {
  2172. .luck-list-title {
  2173. margin-top: 17px;
  2174. border-bottom: 1px solid #ECECEC;
  2175. }
  2176. }
  2177. .opened {
  2178. filter: drop-shadow(0px 4px 94px rgba(0, 0, 0, 0.3));
  2179. width: 100%;
  2180. height: 100%;
  2181. display: flex;
  2182. flex-direction: column;
  2183. justify-content: space-between;
  2184. border-radius: 11px;
  2185. overflow: hidden;
  2186. .header {
  2187. text-align: center;
  2188. min-height: 110px;
  2189. width: 100%;
  2190. background: #fff;
  2191. // padding-top: 30px;
  2192. background-size: 100% 100%;
  2193. display: flex;
  2194. flex-wrap: wrap;
  2195. align-content: center;
  2196. justify-content: center;
  2197. img {
  2198. width: 52px;
  2199. height: 52px;
  2200. margin-right: 14px;
  2201. }
  2202. .txt {
  2203. color: #FFFFFF;
  2204. font-weight: 700;
  2205. font-size: 18px;
  2206. letter-spacing: 0.3px;
  2207. p {
  2208. margin: 0;
  2209. padding: 0;
  2210. text-align: left;
  2211. }
  2212. }
  2213. }
  2214. .list {
  2215. overflow-y: auto;
  2216. padding: 0 16px 0 16px;
  2217. background: #ffffff;
  2218. flex: 1;
  2219. .item {
  2220. display: flex;
  2221. align-items: center;
  2222. // min-height: 50px;
  2223. border-bottom: 1px solid #f0f0f0;
  2224. padding: 12px 0;
  2225. box-sizing: border-box;
  2226. img {
  2227. width: 24px;
  2228. height: 24px;
  2229. }
  2230. .red-right {
  2231. width: 35px;
  2232. height: 24px;
  2233. }
  2234. .item-content {
  2235. width: 100%;
  2236. flex: 1;
  2237. .item-follow-title {
  2238. display: flex;
  2239. align-items: center;
  2240. margin-top: 20px;
  2241. margin-bottom: 11px;
  2242. position: relative;
  2243. .btn {
  2244. // position: absolute;
  2245. // right: 0;
  2246. }
  2247. }
  2248. .item-title {
  2249. flex: 1;
  2250. margin-left: 10px;
  2251. font-weight: 500;
  2252. font-size: 15px;
  2253. letter-spacing: 0.3px;
  2254. color: #000000;
  2255. }
  2256. .item-follow-area {
  2257. display: flex;
  2258. flex-wrap: wrap;
  2259. .item-follow {
  2260. cursor: pointer;
  2261. border: 1px solid #ebebeb;
  2262. border-radius: 1000px;
  2263. height: 26px;
  2264. margin-right: 5px;
  2265. margin-bottom: 5px;
  2266. display: flex;
  2267. align-items: center;
  2268. .finished {
  2269. text-decoration: line-through;
  2270. color: #949494;
  2271. }
  2272. span {
  2273. margin-left: 8px;
  2274. margin-right: 2px;
  2275. color: #1D9BF0;
  2276. opacity: 1;
  2277. }
  2278. img {
  2279. width: 16px;
  2280. height: 16px;
  2281. margin-right: 7px;
  2282. }
  2283. }
  2284. }
  2285. span {
  2286. font-weight: 400;
  2287. font-size: 11px;
  2288. line-height: 13px;
  2289. letter-spacing: 0.3px;
  2290. color: #000000;
  2291. opacity: 0.4;
  2292. }
  2293. }
  2294. .btn {
  2295. width: 90px;
  2296. height: 29px;
  2297. line-height: 29px;
  2298. background: rgba(56, 154, 255, 0.1);
  2299. border-radius: 500px;
  2300. text-align: center;
  2301. letter-spacing: 0.3px;
  2302. color: #1D9BF0;
  2303. cursor: pointer;
  2304. }
  2305. .loading-wrapper {
  2306. width: 90px;
  2307. text-align: center;
  2308. .icon-loading {
  2309. animation: loading 1s infinite linear;
  2310. }
  2311. }
  2312. }
  2313. }
  2314. .people {
  2315. cursor: pointer;
  2316. padding-left: 16px;
  2317. height: 38px;
  2318. line-height: 38px;
  2319. background: #fff;
  2320. box-shadow: 0px 1px 0px #f2f2f2;
  2321. display: flex;
  2322. align-items: center;
  2323. justify-content: space-between;
  2324. .txt {
  2325. width: 90%;
  2326. font-weight: 400;
  2327. font-size: 12px;
  2328. line-height: 14px;
  2329. letter-spacing: 0.3px;
  2330. color: #000000;
  2331. opacity: 0.4;
  2332. }
  2333. }
  2334. .footer {
  2335. background: #ffffff;
  2336. display: flex;
  2337. padding: 15px 22px 15px 17px;
  2338. .winner {
  2339. flex: 1;
  2340. height: 100%;
  2341. background: #fff;
  2342. align-items: center;
  2343. display: flex;
  2344. align-content: center;
  2345. flex-wrap: wrap;
  2346. p {
  2347. color: #959595;
  2348. font-size: 12px;
  2349. margin: 0;
  2350. padding: 0;
  2351. }
  2352. .right {
  2353. width: 100%;
  2354. height: 22px;
  2355. position: relative;
  2356. img {
  2357. position: absolute;
  2358. width: 22px;
  2359. height: 22px;
  2360. border: 2px solid #fff;
  2361. border-radius: 50%;
  2362. }
  2363. .more {
  2364. border: 0;
  2365. }
  2366. }
  2367. }
  2368. .btn {
  2369. background: #1D9BF0;
  2370. border-radius: 100px;
  2371. color: #fff;
  2372. width: 258px;
  2373. height: 52px;
  2374. font-weight: 600;
  2375. font-size: 18px;
  2376. line-height: 52px;
  2377. text-align: center;
  2378. cursor: pointer;
  2379. }
  2380. }
  2381. }
  2382. .not-open {
  2383. width: 100%;
  2384. height: 100%;
  2385. filter: drop-shadow(0px 2px 20px rgba(0, 0, 0, 0.1));
  2386. position: relative;
  2387. overflow: hidden;
  2388. border-radius: 11px;
  2389. .money-area {
  2390. width: 100%;
  2391. position: absolute;
  2392. top: 65px;
  2393. display: flex;
  2394. flex-wrap: wrap;
  2395. align-items: center;
  2396. justify-content: center;
  2397. .txt {
  2398. font-weight: 800;
  2399. font-size: 16px;
  2400. text-align: center;
  2401. letter-spacing: 0.3px;
  2402. color: #FFFFFF;
  2403. }
  2404. .coin {
  2405. text-align: center;
  2406. margin-top: 6px;
  2407. margin-bottom: 7px;
  2408. display: flex;
  2409. justify-content: center;
  2410. align-items: center;
  2411. width: 90%;
  2412. img {
  2413. width: 46px;
  2414. height: 46px;
  2415. border-radius: 50%;
  2416. border: 3px solid #FFFFFF;
  2417. }
  2418. span {
  2419. margin-left: 12px;
  2420. font-weight: 800;
  2421. font-size: 60px;
  2422. line-height: 76px;
  2423. color: #FFFFFF;
  2424. }
  2425. }
  2426. .people {
  2427. font-weight: 800;
  2428. font-size: 13px;
  2429. line-height: 16px;
  2430. letter-spacing: 0.05em;
  2431. text-align: center;
  2432. color: #FFFFFF;
  2433. }
  2434. }
  2435. .title {
  2436. position: absolute;
  2437. top: 15px;
  2438. left: 15px;
  2439. z-index: 3;
  2440. display: flex;
  2441. align-items: center;
  2442. img {
  2443. width: 24px;
  2444. height: 24px;
  2445. border: 2px solid #FFF;
  2446. border-radius: 50%;
  2447. }
  2448. span {
  2449. margin-left: 10px;
  2450. font-weight: 600;
  2451. font-size: 16px;
  2452. letter-spacing: 0.3px;
  2453. color: #fff;
  2454. }
  2455. }
  2456. // .txt {
  2457. // width: 100%;
  2458. // position: absolute;
  2459. // font-style: normal;
  2460. // font-weight: 700;
  2461. // font-size: 42px;
  2462. // line-height: 50px;
  2463. // text-align: center;
  2464. // color: #FFF2D3;
  2465. // top: 90px;
  2466. // z-index: 3;
  2467. // }
  2468. img {
  2469. width: 100%;
  2470. }
  2471. .up {
  2472. position: absolute;
  2473. top: 0;
  2474. // box-shadow: 0px 4px 44px rgba(0, 0, 0, 0.1);
  2475. z-index: 1;
  2476. }
  2477. .down {
  2478. position: absolute;
  2479. top: 253px;
  2480. }
  2481. .open {
  2482. width: 335px;
  2483. height: 50px;
  2484. cursor: pointer;
  2485. position: absolute;
  2486. bottom: 28px;
  2487. left: 50%;
  2488. margin-left: -167.5px;
  2489. z-index: 4;
  2490. }
  2491. .open-gif {
  2492. width: 200px;
  2493. height: 200px;
  2494. text-align: center;
  2495. position: absolute;
  2496. bottom: 70px;
  2497. left: 50%;
  2498. margin-left: -100px;
  2499. z-index: 3;
  2500. }
  2501. }
  2502. @keyframes loading {
  2503. from {
  2504. transform: rotate(0deg);
  2505. }
  2506. to {
  2507. transform: rotate(360deg);
  2508. }
  2509. }
  2510. }
  2511. .none {
  2512. display: flex;
  2513. align-item: center;
  2514. justify-content: center;
  2515. width: 100%;
  2516. height: 100%;
  2517. }
  2518. </style>