give-dialog.vue 76 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216
  1. <template>
  2. <div class="overlay" v-if="visible">
  3. <div class="content"
  4. :style="{
  5. height: dialogHeight + 'px',
  6. width: showComType != 'preview' ? '600px' : '880px'}">
  7. <div class="pop-mask"
  8. v-show="showCurrencyPop || showCurrencySelect"
  9. @click.stop="showCurrencyPop = false; showCurrencySelect=false"></div>
  10. <!-- 头部 -->
  11. <div class="head">
  12. <div class="left">
  13. <!-- 关闭按钮 -->
  14. <div class="close-btn" @click="close">
  15. <img class="icon-close"
  16. :src="require('@/assets/svg/icon-close.svg')"
  17. v-if="showComType == 'default'"/>
  18. <img class="icon-close"
  19. :src="require('@/assets/svg/icon-back.svg')"
  20. v-else/>
  21. </div>
  22. <!-- 标题 -->
  23. <div class="title">
  24. {{ currentComData[showComType]["title"] }}
  25. </div>
  26. </div>
  27. <div class="right">
  28. <!-- 更多按钮 -->
  29. <img :src="require('@/assets/svg/icon-more-l.svg')"
  30. class="more"
  31. @click="showMoreOption = true">
  32. <div class="area-option"
  33. v-if="showMoreOption"
  34. @click="showMoreOption = false">
  35. <div class="option">
  36. <div class="item" @click="goTransactionsList()">
  37. <img :src="require('@/assets/svg/icon-menu.svg')">
  38. <span>Transaction History</span>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. <!-- 内容 -->
  45. <div class="body">
  46. <img src="@/assets/gif/icon-guide-select.gif"
  47. class="icon-guide-select"
  48. v-if="!currentCurrencyInfo.currencyCode && showComType == 'default'">
  49. <!-- 充值组件 -->
  50. <top-up v-if="showComType == 'topUp'"
  51. :asyncIng="asyncIng"
  52. :currentCurrencyInfo="tempCurrentCurrencyInfo"
  53. @topUpDone="topUpDone"></top-up>
  54. <!-- 表单填写容器 -->
  55. <div class="body-content" v-if="showComType != 'topUp'">
  56. <!-- 货币列表 -->
  57. <div class="currency-pop" v-show="showCurrencyPop">
  58. <currency-list
  59. ref="currencyListDom"
  60. @selectCurrency="selectCurrency"
  61. @setCurrencyList="setCurrentCurrencyInfo"></currency-list>
  62. </div>
  63. <div class="currency-pop-select" v-show="showCurrencySelect">
  64. <currency-select
  65. ref="currencySelectDom"
  66. :list="tempCurrentCurrencyList"
  67. @selectCurrency="selectCurrencyAfter">
  68. </currency-select>
  69. </div>
  70. <div class="left" v-if="showComType != 'preview'">
  71. <div class="gift-pack-wrapper">
  72. <img class="icon"
  73. :src="require('@/assets/svg/icon-gift-pack.svg')"/>
  74. </div>
  75. <div class="bottom">
  76. </div>
  77. </div>
  78. <div class="right"
  79. :class="{'fill-right': showComType == 'preview'}">
  80. <global-tip :type="'2'"></global-tip>
  81. <div class="form-wrapper" v-if="showComType == 'default'">
  82. <img
  83. class="img-mode"
  84. :src="require('@/assets/svg/img-mode.svg')"
  85. />
  86. <!-- 金额、数量 -->
  87. <div class="form-base">
  88. <div class="item currency-select-wrapper">
  89. <div
  90. class="label currency-select"
  91. :class="{'selected': currentCurrencyInfo.currencyCode}"
  92. @click="selectCurrencyPopHandle"
  93. >
  94. <img v-if="currentCurrencyInfo.iconPath"
  95. class="icon"
  96. :src="currentCurrencyInfo.iconPath"
  97. />
  98. <div class="text">
  99. {{currentCurrencyInfo.currencyCode == 'USD' ? 'USD' : currentCurrencyInfo.tokenSymbol || 'Select a reward'}}
  100. </div>
  101. <img
  102. class="arrow"
  103. :src="currentCurrencyInfo.currencyCode ?
  104. require('@/assets/svg/icon-form-arrow-down.svg') : require('@/assets/svg/icon-form-white-arrow-down.svg')
  105. "
  106. />
  107. </div>
  108. <input
  109. v-model="baseFormData.amountValue"
  110. placeholder="0"
  111. autofocus
  112. @input="onAmountInput"
  113. @blur="onAmountBlur"
  114. />
  115. </div>
  116. <div class="item">
  117. <div class="label">
  118. <img
  119. class="icon"
  120. :src="
  121. require('@/assets/svg/icon-winners.svg')
  122. "
  123. />
  124. Winners
  125. </div>
  126. <input
  127. v-model="baseFormData.totalCount"
  128. placeholder="0"
  129. @input="onCountInput"
  130. @blur="onCountBlur"
  131. />
  132. </div>
  133. </div>
  134. <!-- 刷新按钮、充值 -->
  135. <div class="form-base-help" v-show="currentCurrencyInfo.currencyCode">
  136. <div class="currency-operation">
  137. <div class="balance">
  138. <img
  139. :src="
  140. require('@/assets/svg/icon-balance.svg')
  141. "
  142. />
  143. Balance
  144. </div>
  145. <div class="amount">
  146. <a-tooltip :title="currentCurrencyInfo.balance">
  147. {{ getBit(currentCurrencyInfo.balance) }}
  148. </a-tooltip>
  149. <img
  150. :class="{ 'icon-refresh-rotate': refreshRotate }"
  151. @click="updateCurrencyBanlce"
  152. :src="
  153. require('@/assets/svg/icon-form-refresh.svg')
  154. "
  155. />
  156. </div>
  157. <div v-if="currentCurrencyInfo.currencyCode != 'USD'" class="top-up" @click="goTopUp">Deposit</div>
  158. </div>
  159. <div class="msg">
  160. Recommend winners 100~10000
  161. </div>
  162. </div>
  163. <div class="form-label">
  164. <div>
  165. Tasks
  166. </div>
  167. <!-- <div>
  168. <el-dropdown trigger="click">
  169. <img src="@/assets/svg/icon-add-task.svg"
  170. class="icon-add-task"
  171. v-show="formList.some(item => !item.show)">
  172. <template #dropdown>
  173. <el-dropdown-menu>
  174. <div v-for="(item, key) in formList" :key="key"
  175. @click="clickDropdown(item, key)">
  176. <el-dropdown-item style="height: 50px;width: 240px" v-if="!item.show">
  177. <img :src="item.icon" style="width: 20px; height: 20px;margin-right: 12px" />
  178. {{item.label}}
  179. </el-dropdown-item>
  180. </div>
  181. </el-dropdown-menu>
  182. </template>
  183. </el-dropdown>
  184. </div> -->
  185. </div>
  186. <!-- 转推、like、关注 -->
  187. <div class="form-require">
  188. <div
  189. v-for="(item, index) in formList"
  190. :key="index"
  191. >
  192. <div v-if="item.show" class="form-item"
  193. :class="{ 'border-hide': formList.length - 1 == index }">
  194. <div class="item-left">
  195. <div class="label">
  196. <img
  197. class="icon"
  198. :src="item.icon"
  199. />
  200. {{ item.label }}
  201. </div>
  202. <div
  203. class="control"
  204. v-if="item.nodeType == 'textarea'"
  205. >
  206. <follow-input
  207. :isAddSelf="!isBack"
  208. :atUserList="atUserList"
  209. @addUser="addFollowUser"
  210. @setUser="setFollowUser"
  211. @delUser="delFollowUser"
  212. ></follow-input>
  213. </div>
  214. <!-- join discord -->
  215. <div
  216. class="control"
  217. v-if="item.nodeType == 'input'"
  218. >
  219. <div v-if="showDiscordInvitePop"
  220. class="discord-invite-info"
  221. @click="showDiscordInvitePop = false">
  222. <img class="icon" :src="discordInviteInfo.icon || require('@/assets/svg/icon-discord-mini.svg')" />
  223. <span class="name">{{discordInviteInfo.name}}</span>
  224. </div>
  225. <input v-model="item.text"
  226. placeholder="Enter discord invite link"
  227. class="discord-address"
  228. @input="onIptDiscordAddress($event, index)"
  229. @blur="onBlurDiscordAddress($event, index)" />
  230. </div>
  231. </div>
  232. <div>
  233. <el-switch
  234. v-if="item.type > 3"
  235. v-model="item.checked"
  236. @change="formSwitchChange($event, item, index)"
  237. />
  238. <!-- <img src="@/assets/svg/icon-task-close.svg"
  239. class="icon-task-close"
  240. @click="hideTask(item, index)"> -->
  241. </div>
  242. <!--
  243. v-if="item.type == 2 || item.type == 3 || item.type == 7 || item.type == 8 || item.type == 9"
  244. <img
  245. v-if="item.type == 3"
  246. :src="
  247. require('@/assets/svg/icon-option-checked.svg')
  248. "
  249. /> -->
  250. </div>
  251. </div>
  252. </div>
  253. <!-- 机器人 -->
  254. <!-- <div class="anti-bot-wrapper">
  255. <div class="label">
  256. <img
  257. :src="
  258. require('@/assets/svg/icon-anti-bot.svg')
  259. "
  260. class="icon-bot"
  261. />
  262. Anti Bot
  263. <img
  264. :src="
  265. require('@/assets/svg/icon-beta.svg')
  266. "
  267. class="icon-beta"
  268. />
  269. <img
  270. :src="
  271. require('@/assets/svg/icon-question.svg')
  272. "
  273. class="icon-question"
  274. />
  275. </div>
  276. <el-switch v-model="openAntiBot" />
  277. </div> -->
  278. <!-- 提示 -->
  279. <ul class="tips-wrapper">
  280. <li class="row">
  281. Rewards can only be claimed after the target user completes all tasks you set.
  282. </li>
  283. <li class="row">
  284. Each user can only receive a reward once per task.
  285. </li>
  286. <li class="row">
  287. The reward will expire in 7 days once issued. Please promote it as much as possible within this period. After the experiment, the remaining rewards will be returned to your DeNet Wallet.
  288. </li>
  289. </ul>
  290. <div class="submit-btn-wrapper">
  291. <div class="submit-btn"
  292. :class="{ 'disabled-submit': iptErrMsgTxt != '' && !depositGuide }"
  293. @click="confirm">
  294. <img class="icon-loading"
  295. v-if="submitIng"
  296. :src="require('@/assets/svg/icon-btn-loading.svg')"
  297. />
  298. {{iptErrMsgTxt ? iptErrMsgTxt : 'NEXT'}}
  299. </div>
  300. </div>
  301. </div>
  302. <!-- 预览 -->
  303. <template v-else-if="showComType == 'preview'">
  304. <div class="preview">
  305. <div
  306. class="card"
  307. :class="{ center: Number(baseFormData.amountValue) <= Number(currentCurrencyInfo.balance) }">
  308. <div class="card-title">
  309. <img
  310. class="img"
  311. v-if="Number(baseFormData.amountValue) > Number(currentCurrencyInfo.balance)"
  312. :src=" require('@/assets/subject/top-01.svg') " />
  313. <div class="font">
  314. Preview: <span>{{installStatus ? 'After' : 'Before' }}</span> DeNet Installed
  315. </div>
  316. </div>
  317. <div class="flash">
  318. <preview-card
  319. :currentCurrencyInfo="currentCurrencyInfo"
  320. :postData="publishRes"
  321. :baseFormData="baseFormData"
  322. :amountFontSize="previewFontSize"
  323. ></preview-card>
  324. </div>
  325. </div>
  326. <!-- 需充值 -->
  327. <div class="card-content" v-if="Number(baseFormData.amountValue) > Number(currentCurrencyInfo.balance)">
  328. <template v-if="currentCurrencyInfo.currencyCode === 'USD'">
  329. <div class="card-title">
  330. <img class="img" :src=" require('@/assets/subject/top-02.svg') " />
  331. <div class="font">Deposit to Send Giveaway</div>
  332. </div>
  333. <div class="card-list">
  334. <div class="item">
  335. <div class="l">Giveaway Amount</div>
  336. <div class="r"></div>
  337. </div>
  338. <div class="item">
  339. <div class="l">Balance</div>
  340. <div class="r"></div>
  341. </div>
  342. <div class="item">
  343. <div class="l">Paypal charges fee ()</div>
  344. <div class="r"></div>
  345. </div>
  346. <div class="item">
  347. <div class="l">Deposit Amount</div>
  348. <div class="r"></div>
  349. </div>
  350. </div>
  351. </template>
  352. <template v-else>
  353. <div class="card-title">
  354. <img class="img" :src=" require('@/assets/subject/top-02.svg') " />
  355. <div class="font">Deposit to Send Giveaway</div>
  356. </div>
  357. <top-up2
  358. :asyncIng="asyncIng"
  359. :currentCurrencyInfo="tempCurrentCurrencyInfo"
  360. @topUpDone="topUpDone">
  361. </top-up2>
  362. <div class="card-title">
  363. <img class="img" :src=" require('@/assets/subject/top-03.svg') " />
  364. <div class="font">Wait for the amount to arrive</div>
  365. </div>
  366. <div class="card-amount">
  367. <img class="icon" src="@/assets/subject/icon-balance.png" />
  368. <div class="con">
  369. <div class="desc">Balance</div>
  370. <div class="price">{{currentCurrencyInfo.balance}} {{currentCurrencyInfo.tokenSymbol}}</div>
  371. </div>
  372. <img
  373. class="refresh"
  374. :class="{ 'icon-refresh-rotate': refreshRotate }"
  375. @click="updateCurrencyBanlce"
  376. :src=" require('@/assets/svg/icon-form-refresh.svg') "
  377. />
  378. </div>
  379. </template>
  380. </div>
  381. </div>
  382. </template>
  383. <!-- paypal支付按钮 -->
  384. <div class="payment" v-show="showComType == 'preview'">
  385. <paypal-button
  386. :finalAmountData="finalAmountData"
  387. :payConfig="{
  388. paypalClientId,
  389. feeDesc: payConfig.feeDesc,
  390. paypalHtml,
  391. amount: baseFormData.amountValue,
  392. postId
  393. }"
  394. :currentCurrencyInfo="currentCurrencyInfo"
  395. @payPalFinsh="payPalFinsh"
  396. >
  397. <template v-slot:balance>
  398. <div class="balance" v-if="Number(baseFormData.amountValue) <= Number(currentCurrencyInfo.balance)">
  399. <img class="icon" src="@/assets/subject/icon-balance.png" />
  400. <div class="con">
  401. <div class="desc">Balance</div>
  402. <div class="price">{{currentCurrencyInfo.balance}} {{currentCurrencyInfo.tokenSymbol}}</div>
  403. </div>
  404. <img
  405. class="refresh"
  406. :class="{ 'icon-refresh-rotate': refreshRotate }"
  407. @click="updateCurrencyBanlce"
  408. :src=" require('@/assets/svg/icon-form-refresh.svg') "
  409. />
  410. </div>
  411. </template>
  412. </paypal-button>
  413. </div>
  414. </div>
  415. </div>
  416. </div>
  417. </div>
  418. <!-- 提示 -->
  419. <message-box
  420. :dialogVisible="showMessageBox"
  421. :title="messageBoxData.title"
  422. :content="messageBoxData.content"
  423. @cancel="messageBoxCancel"
  424. @confirm="messageBoxConfirm"
  425. ></message-box>
  426. </div>
  427. </template>
  428. <script setup>
  429. import { ref, watch, reactive, defineProps, defineEmits, onMounted, nextTick, provide } from "vue";
  430. import { postPublish, verifyPaypalResult, syncChainTokenRechargeRecord, getCurrencyInfoByCode } from "@/http/publishApi";
  431. import { getInviteGuildInfo, saveInviteGuildInfo } from "@/http/discordApi";
  432. import { payCalcFee, getPayConfig } from "@/http/pay";
  433. import { getFrontConfig } from "@/http/account";
  434. import {setChromeStorage, getChromeStorage} from "@/uilts/chromeExtension"
  435. import { debounce, getBit } from "@/uilts/help"
  436. import Report from "@/log-center/log"
  437. import { ElMessage, ElLoading, ElDropdown, ElDropdownMenu, ElDropdownItem } from "element-plus";
  438. import "element-plus/es/components/message/style/css";
  439. import {create, all} from "mathjs";
  440. import messageBox from "@/view/components/message-box.vue";
  441. import currencyList from "@/view/components/currency-list.vue";
  442. import currencySelect from "@/view/components/currency-select.vue";
  443. import previewCard from "@/view/iframe/publish/components/preview-card";
  444. import followInput from "@/view/iframe/publish/components/follow-input";
  445. import paypalButton from "@/view/iframe/publish/components/paypal-button";
  446. import topUp from "@/view/iframe/publish/components/top-up.vue";
  447. import topUp2 from "@/view/iframe/publish/components/top-up2.vue";
  448. import GlobalTip from '@/view/components/global-tip.vue'
  449. const config = {
  450. number: 'BigNumber',
  451. }
  452. const math = create(all, config);
  453. //临时货币信息
  454. let tempCurrentCurrencyInfo = ref({});
  455. let tempCurrentCurrencyList = ref([]);
  456. let paypalClientId = ref("");
  457. let payConfig = ref({});
  458. let paypalHtml = ref("");
  459. let installStatus = ref(false);
  460. let timer = ref(null);
  461. provide('installStatus', installStatus)
  462. // 发布后返回的结果
  463. let publishRes = reactive({});
  464. //弹窗是否展示
  465. let visible = ref(false);
  466. //弹窗高度
  467. let dialogHeight = ref(680);
  468. // 当前展示组件内容 default(表单) preview(预览) topUp(充值)
  469. let showComType = ref("default");
  470. let currentComData = {
  471. default: {
  472. title: "Giveaway",
  473. },
  474. preview: {
  475. title: "Giveaway",
  476. },
  477. topUp: {
  478. title: "Deposit",
  479. },
  480. };
  481. // 机器人开关
  482. let openAntiBot = ref(false);
  483. // 是否正在提交
  484. let submitIng = ref(false);
  485. // 艾特关注人列表
  486. let atUserList = ref([]);
  487. // 表单错误提示
  488. let iptErrMsgTxt = ref("Select a reward");
  489. // 是否返回
  490. let isBack = ref(false);
  491. // 展示消息提示
  492. let showMessageBox = ref(false);
  493. // 展示货币列表pop
  494. let showCurrencyPop = ref(false);
  495. let showCurrencySelect = ref(false);
  496. // 展示更多按钮下的选项
  497. let showMoreOption = ref(false);
  498. // 货币列表的dom
  499. let currencyListDom = ref('');
  500. // 刷新按钮旋转
  501. let refreshRotate = ref(false);
  502. // 预览字体大小
  503. let previewFontSize = ref(56);
  504. let postId = ref('');
  505. // 余额是否同步中
  506. let asyncIng = ref(false);
  507. // 提交按钮-充值引导提示
  508. let depositGuide = ref(false);
  509. let messageBoxData = ref({
  510. title: "",
  511. content: "",
  512. });
  513. // 真实支付金额数据
  514. let finalAmountData = ref({
  515. currencyCode: '',
  516. feeAmountValue: 0,
  517. finalAmountValue: 0,
  518. requestAmountValue: 0,
  519. });
  520. // 表单数据
  521. let baseFormData = reactive({
  522. amountCurrencyCode: '',
  523. amountValue: "",
  524. totalCount: "",
  525. });
  526. // 当前选择的货币信息
  527. let currentCurrencyInfo = ref({
  528. currencyCode: "",
  529. currencyName: "",
  530. balance: "",
  531. currencyType: "",
  532. iconPath: "",
  533. minAmount: "",
  534. tokenChain: "",
  535. tokenSymbol: "",
  536. usdEstimateBalance: ""
  537. });
  538. const discordIptErrTxt = 'Discord invite link is wrong';
  539. const discordIptEmptyErrTxt = 'Enter discord invite link';
  540. const discordIptNerverExpiresErrTxt = 'Make sure the Discord link never expires'
  541. let iptErrType = ''; //discord
  542. let formList = reactive([
  543. {
  544. label: "Follow",
  545. icon: require("@/assets/svg/icon-task-twitter.svg"),
  546. nodeType: "textarea",
  547. type: 1,
  548. text: [],
  549. checked: true,
  550. show: true
  551. },
  552. {
  553. label: "Retweet & Like",
  554. icon: require("@/assets/svg/icon-task-twitter.svg"),
  555. nodeType: "div",
  556. type: 3,
  557. checked: true,
  558. show: true
  559. },
  560. {
  561. label: "Like Tweet",
  562. icon: require("@/assets/svg/icon-task-twitter.svg"),
  563. nodeType: "div",
  564. type: 2,
  565. checked: true,
  566. show: false
  567. },
  568. {
  569. label: "Comment and Tag 3 friends",
  570. icon: require("@/assets/svg/icon-task-twitter.svg"),
  571. nodeType: "div",
  572. type: 9,
  573. checked: true,
  574. show: true
  575. },
  576. {
  577. label: "Repost to Facebook",
  578. icon: require("@/assets/svg/icon-task-facebook.svg"),
  579. nodeType: "div",
  580. text: '',
  581. type: 8,
  582. checked: true,
  583. show: true
  584. },
  585. {
  586. label: "Join Discord",
  587. icon: require("@/assets/svg/icon-discord-mini.svg"),
  588. nodeType: "input",
  589. text: '',
  590. type: 7,
  591. checked: true,
  592. show: true
  593. },
  594. ]);
  595. const discordInviteInfo = ref({});
  596. let showDiscordInvitePop = ref(false);
  597. const props = defineProps({
  598. dialogVisible: {
  599. type: Boolean,
  600. default: false,
  601. },
  602. });
  603. watch(
  604. () => props.dialogVisible,
  605. (newVal) => {
  606. console.log("watch", newVal);
  607. visible.value = newVal;
  608. if (newVal) {
  609. Report.reportLog({
  610. pageSource: Report.pageSource.publisherDialog,
  611. businessType: Report.businessType.pageView,
  612. });
  613. getLocalCurrencyInfoByCode();
  614. setTimeout(() => {
  615. setDialogHeight();
  616. }, 300);
  617. // 更新余额
  618. clearInterval(timer.value);
  619. timer.value = setInterval(() => {
  620. getCurrencyInfo();
  621. }, 10000)
  622. } else {
  623. clearInterval(timer.value);
  624. }
  625. }
  626. );
  627. const emits = defineEmits(["close", "confirm", "payPalFinsh"]);
  628. const close = () => {
  629. if (showComType.value != "default") {
  630. showComType.value = "default";
  631. calcDomZoom();
  632. isBack.value = true;
  633. } else {
  634. initParams();
  635. emits("close", false);
  636. }
  637. };
  638. /**
  639. * 设置弹窗高度
  640. */
  641. const setDialogHeight = (resize = false) => {
  642. nextTick(() => {
  643. let clientHeight = window.innerHeight;
  644. let gapSafe = 40;
  645. console.log('resize',resize)
  646. if (dialogHeight.value > clientHeight - gapSafe) {
  647. dialogHeight.value = clientHeight - gapSafe;
  648. } else {
  649. if(resize) {
  650. dialogHeight.value = 680;
  651. }
  652. }
  653. })
  654. };
  655. const selectCurrencyPopHandle = () => {
  656. Report.reportLog({
  657. pageSource: Report.pageSource.currencySelectorPage,
  658. businessType: Report.businessType.pageView,
  659. });
  660. showCurrencyPop.value = true;
  661. nextTick(() => {
  662. if(currencyListDom.value) {
  663. currencyListDom.value.getCurrencyInfoList && currencyListDom.value.getCurrencyInfoList();
  664. }
  665. })
  666. }
  667. /**
  668. * 获取实际支付金额
  669. */
  670. const getPayAmount = async (amountValue) => {
  671. let res = await payCalcFee({
  672. params: {
  673. amountValue,
  674. currencyCode: currentCurrencyInfo.value.currencyCode,
  675. payChannel: 'paypal',
  676. },
  677. });
  678. if (res.code == 0) {
  679. let { finalAmountValue, feeDesc } = res.data;
  680. payConfig.value.feeDesc = feeDesc;
  681. if (finalAmountValue > 0) {
  682. finalAmountData.value = res.data;
  683. }
  684. }
  685. return res.data;
  686. };
  687. const saveDiscordGuildInfo = () => {
  688. let {guildId, inviteCode, inviteUrl} = discordInviteInfo.value;
  689. if(guildId && inviteCode && inviteUrl) {
  690. saveInviteGuildInfo({
  691. params: {
  692. guildId,
  693. inviteCode,
  694. inviteUrl
  695. }
  696. })
  697. }
  698. }
  699. const confirm = () => {
  700. if(depositGuide.value) { //余额不够去充值
  701. goTopUp();
  702. return;
  703. }
  704. if (submitIng.value || iptErrMsgTxt.value) {
  705. return;
  706. }
  707. let { totalCount = 0 } = baseFormData;
  708. if (!totalCount) {
  709. return;
  710. }
  711. saveDiscordGuildInfo();
  712. submitRequest();
  713. };
  714. /**
  715. * 货币列表-选中货币
  716. */
  717. const selectCurrency = (params) => {
  718. tempCurrentCurrencyList.value = params;
  719. depositGuide.value = false;
  720. if (params.length > 1) {
  721. showCurrencyPop.value = false;
  722. showCurrencySelect.value = true;
  723. } else {
  724. selectCurrencyAfter(params[0])
  725. }
  726. };
  727. const selectCurrencyAfter = (params, openWindow = true) => {
  728. tempCurrentCurrencyInfo.value = params;
  729. depositGuide.value = false;
  730. showCurrencySelect.value = false;
  731. currentCurrencyInfo.value = params;
  732. setLocalSelectCurrencyInfo(currentCurrencyInfo.value);
  733. if (openWindow === false) {
  734. return
  735. };
  736. if (params.currencyCode != "USD" && params.balance < params.minAmount) {
  737. let tokenSymbol = params.currencyCode == 'USD' ? 'USD' : params.tokenSymbol;
  738. messageBoxBlock({
  739. title: `Whether to deposit ${tokenSymbol}`,
  740. content: `Insufficient ${tokenSymbol} balance`,
  741. });
  742. } else {
  743. setCurrentCurrencyListInfo(tempCurrentCurrencyList.value);
  744. showCurrencyPop.value = false;
  745. finalAmountData.value.currencyCode = currentCurrencyInfo.value.currencyCode;
  746. calcDomZoom();
  747. resetFormIpt();
  748. onIptSetErrorTxt();
  749. }
  750. }
  751. const calcDomZoom = () => {
  752. nextTick(() => {
  753. let maxWidth = 68;
  754. var textWidth = document.querySelector('.text').offsetWidth;
  755. if(textWidth > 68) {
  756. var scale = maxWidth / textWidth;
  757. document.querySelector('.text').style.zoom = scale;
  758. }
  759. })
  760. }
  761. const resetFormIpt = () => {
  762. baseFormData.amountValue = "";
  763. baseFormData.totalCount = "";
  764. }
  765. const setLocalSelectCurrencyInfo = (params = {}) => {
  766. setChromeStorage({ selectCurrencyInfo : JSON.stringify(params)})
  767. }
  768. const setCurrentCurrencyListInfo = (params = {}) => {
  769. setChromeStorage({ selectCurrencyList : JSON.stringify(params)})
  770. }
  771. /**
  772. * 获取完货币列表
  773. */
  774. const setCurrentCurrencyInfo = (params) => {
  775. }
  776. const messageBoxBlock = ({ title = "", content = "" }) => {
  777. showMessageBox.value = true;
  778. messageBoxData.value.title = title;
  779. messageBoxData.value.content = content;
  780. };
  781. /**
  782. * 确定
  783. */
  784. const messageBoxConfirm = () => {
  785. showMessageBox.value = false;
  786. goTopUp();
  787. };
  788. /**
  789. * 取消
  790. */
  791. const messageBoxCancel = () => {
  792. currentCurrencyInfo.value = tempCurrentCurrencyInfo.value;
  793. setLocalSelectCurrencyInfo(currentCurrencyInfo.value);
  794. setCurrentCurrencyListInfo(tempCurrentCurrencyList.value);
  795. showMessageBox.value = false;
  796. showCurrencyPop.value = false;
  797. showCurrencySelect.value = false;
  798. calcDomZoom();
  799. resetFormIpt();
  800. onIptSetErrorTxt();
  801. };
  802. /**
  803. * 去充值
  804. */
  805. const goTopUp = () => {
  806. Report.reportLog({
  807. pageSource: Report.pageSource.rechargePage,
  808. businessType: Report.businessType.pageView,
  809. });
  810. showComType.value = 'topUp';
  811. }
  812. /**
  813. * 充值done事件
  814. */
  815. const topUpDone = () => {
  816. currentCurrencyInfo.value = tempCurrentCurrencyInfo.value;
  817. asyncIng.value = true;
  818. depositGuide.value = false;
  819. asyncIng.value = false;
  820. showCurrencyPop.value = false;
  821. showCurrencySelect.value = false;
  822. showComType.value = 'default';
  823. calcDomZoom();
  824. onIptSetErrorTxt()
  825. asyncTokenRechRecord((res) => {
  826. if(res.code == 0 && res.data && res.data.length) {
  827. let currencyInfo = res.data[0];
  828. if(currencyInfo.currencyCode == currentCurrencyInfo.value.currencyCode) {
  829. currentCurrencyInfo.value.balance = currencyInfo.balance;
  830. onIptSetErrorTxt()
  831. }
  832. }
  833. })
  834. }
  835. /**
  836. * 更新货币余额
  837. */
  838. const updateCurrencyBanlce = () => {
  839. if(!refreshRotate.value) {
  840. refreshRotate.value = true;
  841. setTimeout(() => {
  842. refreshRotate.value = false;
  843. }, 1000)
  844. }
  845. asyncTokenRechRecord((res) => {
  846. if(res.code == 0 && res.data && res.data.length) {
  847. let currencyInfo = res.data[0];
  848. if(currencyInfo.currencyCode == currentCurrencyInfo.value.currencyCode) {
  849. currentCurrencyInfo.value.balance = currencyInfo.balance;
  850. }
  851. }
  852. })
  853. }
  854. /**
  855. * 同步链上交易
  856. */
  857. const asyncTokenRechRecord = (cb) => {
  858. syncChainTokenRechargeRecord({
  859. params: {
  860. currencyCode: currentCurrencyInfo.value.currencyCode
  861. }
  862. }).then(res => {
  863. cb && cb(res)
  864. })
  865. }
  866. /**
  867. * 提交表单请求
  868. */
  869. const submitRequest = async () => {
  870. let { amountValue = 0, totalCount = 0 } = baseFormData;
  871. baseFormData.amountCurrencyCode = currentCurrencyInfo.value.currencyCode;
  872. // 组装提交参数
  873. let finishConditions = [];
  874. for (let i = 0; i < formList.length; i++) {
  875. let item = {};
  876. item.type = formList[i]["type"];
  877. if (item.type == 1 && atUserList.value.length) {
  878. // follow 参数
  879. let relatedUsers = atUserList.value.filter(item => item.name);
  880. item.relatedUsers = relatedUsers;
  881. finishConditions.push(item);
  882. } else if (formList[i]["type"] == 7) {
  883. // join discord
  884. if(formList[i]["checked"] && formList[i]["text"]) {
  885. item.bizData = JSON.stringify({inviteUrl: formList[i]["text"]});
  886. finishConditions.push(item);
  887. }
  888. } else if (formList[i]["checked"]) {
  889. // 其余任务
  890. finishConditions.push(item);
  891. }
  892. }
  893. let receiveConditions = openAntiBot.value ? "" : [];
  894. // 提交参数
  895. let formData = {
  896. amountCurrencyCode: baseFormData.amountCurrencyCode,
  897. amountValue,
  898. totalCount,
  899. finishConditions,
  900. receiveConditions,
  901. payAmountValue: amountValue
  902. };
  903. submitIng.value = true;
  904. // 法币支付需要计算费率
  905. if(formData.amountCurrencyCode == "USD") {
  906. let payAmountRes = await getPayAmount(amountValue);
  907. formData["payAmountValue"] = payAmountRes.finalAmountValue;
  908. }
  909. let data = {
  910. params: {
  911. postBizData: JSON.stringify(formData),
  912. postSrc: 1, //1 twitter
  913. postType: 1, //1 红包
  914. },
  915. };
  916. postPublish(data).then((res) => {
  917. submitIng.value = false;
  918. if (res.code == 0) {
  919. publishRes = res.data;
  920. postId.value = res.data.postId;
  921. Report.reportLog({
  922. pageSource: Report.pageSource.previewPage,
  923. businessType: Report.businessType.pageView,
  924. });
  925. showComType.value = "preview";
  926. previewFontSize.value = calcFontSize(baseFormData.amountValue, 238, 56);
  927. isBack.value = false;
  928. } else {
  929. console.log(res);
  930. }
  931. })
  932. .catch((err) => {
  933. console.log(err);
  934. });
  935. };
  936. const calcFontSize = (str, domWidth, maxSize) => {
  937. let lenstr = str.length;
  938. let num = parseInt(domWidth / lenstr);
  939. let fontSize = num < maxSize ? num : maxSize
  940. return fontSize;
  941. }
  942. /**
  943. * 初始化提交参数
  944. */
  945. const initParams = () => {
  946. resetFormIpt();
  947. // clear follow value
  948. atUserList.value = [];
  949. submitIng.value = false;
  950. isBack.value = false;
  951. showCurrencyPop.value = false;
  952. showCurrencySelect.value = false;
  953. openAntiBot.value = false;
  954. tempCurrentCurrencyInfo.value = {};
  955. currentCurrencyInfo.value = {};
  956. // clear discord value
  957. setDiscordIptTxt({text: ''});
  958. discordInviteInfo.value = {};
  959. };
  960. const setDiscordIptTxt = ({text}) => {
  961. const index = formList.findIndex(item => item.type == 7);
  962. formList[index]['text'] = text;
  963. }
  964. /**
  965. * 支付完成回调
  966. */
  967. const payPalFinsh = (params) => {
  968. let {payNetwork, payStatus} = params;
  969. // token 支付
  970. if(payNetwork == 'bsc') {
  971. payStatusHandle(payStatus);
  972. } else {
  973. // 法币支付
  974. let transaction = params.transaction;
  975. let loadingInstance = ElLoading.service({
  976. background: "rgba(0,0,0,.3)",
  977. });
  978. verifyPaypalResult({
  979. params: {
  980. paypalTransactionId: transaction.id,
  981. postId: publishRes.postId,
  982. paypalClientId: paypalClientId.value,
  983. },
  984. }).then((res) => {
  985. loadingInstance.close();
  986. if (res.code == 0) {
  987. if (res.data) {
  988. payStatusHandle(res.data.payStatus)
  989. }
  990. }
  991. })
  992. .catch(() => {
  993. loadingInstance.close();
  994. });
  995. }
  996. };
  997. const payStatusHandle = (payStatus) => {
  998. //支付状态 0:未支付,1:支付成功,2:支付失败,3:已关闭,4:已退款
  999. switch (payStatus) {
  1000. case 1:
  1001. emits("payPalFinsh", { publishRes });
  1002. showComType.value = "default";
  1003. initParams();
  1004. break;
  1005. case 2:
  1006. // ElMessage({
  1007. // message: "Pay Fail",
  1008. // type: "warning",
  1009. // });
  1010. break;
  1011. case 3:
  1012. // ElMessage({
  1013. // message: "Pay Exceptions",
  1014. // type: "warning",
  1015. // });
  1016. break;
  1017. case 4:
  1018. // ElMessage({
  1019. // message: "Pay Exceptions",
  1020. // type: "warning",
  1021. // });
  1022. break;
  1023. }
  1024. }
  1025. /**
  1026. * follow组件触发新增关注人
  1027. */
  1028. const addFollowUser = (params) => {
  1029. atUserList.value.push(params);
  1030. };
  1031. const setFollowUser = (params) => {
  1032. atUserList.value[params.index]["name"] = params.name;
  1033. };
  1034. const delFollowUser = (params) => {
  1035. atUserList.value.splice(params.index, 1);
  1036. };
  1037. const onAmountInput = () => {
  1038. let val = baseFormData.amountValue;
  1039. // val = val.replace(/[^\d^\.]+/g, "");
  1040. val = val.replace(/^\D*(\d*(?:\.\d{0,18})?).*$/g, '$1');
  1041. if(val == '00') {
  1042. val = '0'
  1043. }
  1044. if(val.indexOf('.') > -1){ //校验 例:00.12 => 0.12
  1045. let arr = val.split('.');
  1046. if(arr[0].startsWith('0')) {
  1047. let num = +arr[0];
  1048. val = num + '.' + arr[1];
  1049. }
  1050. }
  1051. baseFormData.amountValue = val;
  1052. setInputErrorMsg({from: 'amount', type:'input'});
  1053. return val;
  1054. };
  1055. const onCountInput = () => {
  1056. let val = baseFormData.totalCount;
  1057. if (val == 0) {
  1058. val = "";
  1059. }
  1060. // val = val.replace(/[^\d]/g, "");
  1061. val = val.replace(/^\D*(\d*(?:\.\d{0,18})?).*$/g, '$1');
  1062. baseFormData.totalCount = val;
  1063. setInputErrorMsg({from: 'count', type:'input'});
  1064. return val;
  1065. };
  1066. /**
  1067. * 金额输入失焦
  1068. */
  1069. const onAmountBlur = () => {
  1070. setInputErrorMsg({from: 'amount', type:'blur'});
  1071. };
  1072. /**
  1073. * count失焦,校验输入结果
  1074. */
  1075. const onCountBlur = () => {
  1076. setInputErrorMsg({from: 'count', type:'blur'});
  1077. };
  1078. /**
  1079. * 输入结果金额和数量 (金额/数量)是否小于最小货币单位
  1080. */
  1081. const calcIptValue = (cb) => {
  1082. let amountValue = baseFormData.amountValue;
  1083. let totalCount = baseFormData.totalCount;
  1084. let flag = true;
  1085. if (!amountValue || !totalCount) {
  1086. return {
  1087. flag
  1088. };
  1089. }
  1090. if (math.format(math.evaluate(`${baseFormData.amountValue} / ${baseFormData.totalCount}`)) < +currentCurrencyInfo.value.minAmount) {
  1091. flag = false;
  1092. }
  1093. return {
  1094. flag,
  1095. count: Math.floor(math.format(math.evaluate(`${baseFormData.amountValue} / ${currentCurrencyInfo.value.minAmount}`)))
  1096. }
  1097. };
  1098. /**
  1099. * 设置输入提示语
  1100. */
  1101. const setInputErrorMsg = () => {
  1102. onIptSetErrorTxt();
  1103. };
  1104. /**
  1105. * 输入时 检测设置错误信息
  1106. */
  1107. const onIptSetErrorTxt = (params = {}) => {
  1108. depositGuide.value = false;
  1109. if(!currentCurrencyInfo.value.currencyCode) {
  1110. iptErrMsgTxt.value = "Select a reward"
  1111. } else if (!baseFormData.amountValue || baseFormData.amountValue == '0') {
  1112. iptErrMsgTxt.value = "Enter an amount";
  1113. } else if (!baseFormData.totalCount || baseFormData.totalCount == '0') {
  1114. iptErrMsgTxt.value = "Enter the number of winners";
  1115. } else if(+baseFormData.amountValue <= +currentCurrencyInfo.value.balance) {
  1116. let res = calcIptValue();
  1117. if (!res.flag) {
  1118. iptErrMsgTxt.value = `${baseFormData.amountValue} ${currentCurrencyInfo.value.tokenSymbol} Can send up to ${res.count} winners`;
  1119. } else {
  1120. iptErrMsgTxt.value = "";
  1121. if(params.actionType != 'discord_blur') {
  1122. setDiscordErrTxt({getDuildId: true});
  1123. }
  1124. }
  1125. } else {
  1126. setDiscordErrTxt({getDuildId: true}, () => {
  1127. iptErrMsgTxt.value = '';
  1128. });
  1129. }
  1130. }
  1131. /**
  1132. * 监听开关触发事件
  1133. */
  1134. const formSwitchChange = (val, params, index) => {
  1135. closeDiscordTask(val, params, index);
  1136. }
  1137. const hideTask = (params, index) => {
  1138. formList[index]['checked'] = false;
  1139. formList[index]['show'] = false;
  1140. closeDiscordTask(false, {type: 7}, index)
  1141. }
  1142. const clickDropdown = (params, index) => {
  1143. formList[index]['show'] = true;
  1144. formList[index]['checked'] = true;
  1145. }
  1146. const closeDiscordTask = (val, params, index) => {
  1147. if(params.type == 7) {
  1148. if(!val) {
  1149. //错误类型 discord 清空discord错误校验
  1150. if(iptErrType == 'discord') {
  1151. iptErrMsgTxt.value = '';
  1152. formList[index]['text'] = '';
  1153. onIptSetErrorTxt();
  1154. }
  1155. } else {
  1156. onIptSetErrorTxt();
  1157. }
  1158. }
  1159. }
  1160. /** 监听 discord 输入 */
  1161. const onIptDiscordAddress = (e, index) => {
  1162. let val = formList[index].text;
  1163. let checked = formList[index].checked;
  1164. if(val && !checked) {
  1165. checked = true;
  1166. formList[index].checked = checked;
  1167. formList[index].text = formList[index].text.replace(/\s/g,'');
  1168. } else if(!val){
  1169. discordInviteInfo.value = {};
  1170. }
  1171. onIptDiscordDebounce()
  1172. }
  1173. const onBlurDiscordAddress = (e, index) => {
  1174. setDiscordErrTxt({fromType: 'discord', showPop: false, actionType: 'discord_blur'});
  1175. }
  1176. const getDiscordIptData = () => {
  1177. let discordItem = formList.find(item => item.type == 7);
  1178. return discordItem;
  1179. }
  1180. /**
  1181. * 设置输入discord错误提示信息
  1182. */
  1183. const setDiscordErrTxt = (params = {showPop: false}, cb) => {
  1184. let discordData = getDiscordIptData() || {};
  1185. if(discordData.checked) {
  1186. if(discordData.text) {
  1187. let validata = checkInviteUrl(discordData.text);
  1188. if(validata) {
  1189. getDiscordInviteInfo({inviteUrl: discordData.text, getDuildId: params.getDuildId}, (res) => {
  1190. console.log('discordData',res)
  1191. // 未知的邀请链接
  1192. if(res.inviteCode != res.data.code || !res.data.guildId) {
  1193. iptErrMsgTxt.value = discordIptErrTxt;
  1194. iptErrType = 'discord';
  1195. } else {
  1196. if(res.data.expires !== null) {
  1197. // 不是永久邀请链接
  1198. iptErrMsgTxt.value = discordIptNerverExpiresErrTxt;
  1199. iptErrType = '';
  1200. } else {
  1201. if(iptErrMsgTxt.value) {
  1202. iptErrMsgTxt.value = '';
  1203. iptErrType = '';
  1204. }
  1205. if(params.showPop && res.data) {
  1206. showDiscordInvitePop.value = true;
  1207. setTimeout(() => {
  1208. showDiscordInvitePop.value = false;
  1209. }, 2000)
  1210. }
  1211. if(params.fromType == 'discord') {
  1212. onIptSetErrorTxt();
  1213. }
  1214. }
  1215. }
  1216. cb && cb(res)
  1217. })
  1218. } else {
  1219. iptErrMsgTxt.value = discordIptErrTxt;
  1220. iptErrType = 'discord';
  1221. }
  1222. } else {
  1223. if(params.actionType == 'discord_blur') {
  1224. onIptSetErrorTxt({acitonType: 'discord_blur'});
  1225. } else {
  1226. // 设置空提示
  1227. iptErrMsgTxt.value = discordIptEmptyErrTxt;
  1228. iptErrType = 'discord';
  1229. }
  1230. }
  1231. } else {
  1232. cb && cb();
  1233. }
  1234. }
  1235. const onIptDiscordDebounce = debounce(function() {
  1236. setDiscordErrTxt({fromType: 'discord', showPop: true});
  1237. }, 800)
  1238. /**
  1239. * 校验 discord邀请url
  1240. */
  1241. const checkInviteUrl = (inviteUrl) => {
  1242. let flag = false;
  1243. const INVITE_URL_PREFIX_1 = 'https://discord.gg/';
  1244. const INVITE_URL_PREFIX_2 = 'https://discord.com/invite/';
  1245. const INVITE_URL_PREFIX_3 = 'http://discord.gg/';
  1246. const INVITE_URL_PREFIX_4 = 'http://discord.com/invite/';
  1247. const INVITE_URL_PREFIX_5 = 'discord.gg/';
  1248. const INVITE_URL_PREFIX_6 = 'discord.com/invite/';
  1249. const arr = [INVITE_URL_PREFIX_1, INVITE_URL_PREFIX_2, INVITE_URL_PREFIX_3, INVITE_URL_PREFIX_4, INVITE_URL_PREFIX_5, INVITE_URL_PREFIX_6]
  1250. if(inviteUrl) {
  1251. if(arr.indexOf(inviteUrl) > -1) {
  1252. flag = false;
  1253. } else {
  1254. let isPass = false;
  1255. for(let i = 0; i < arr.length; i++) {
  1256. let item = arr[i];
  1257. if(inviteUrl.startsWith(item)) {
  1258. isPass = true;
  1259. break;
  1260. }
  1261. }
  1262. flag = isPass;
  1263. }
  1264. }
  1265. return flag;
  1266. }
  1267. /**获取discord 邀请信息 */
  1268. const getDiscordInviteInfo = ({inviteUrl, getDuildId}, cb) => {
  1269. if(!inviteUrl) return;
  1270. let inviteCode = '';
  1271. let arr = inviteUrl.split('/');
  1272. if(arr.length > 0) {
  1273. inviteCode = arr[arr.length - 1];
  1274. }
  1275. if(!getDuildId && discordInviteInfo.value.guildId && discordInviteInfo.value.inviteCode == inviteCode) {
  1276. return;
  1277. }
  1278. getInviteGuildInfo({
  1279. inviteCode
  1280. }).then(res => {
  1281. if(!res) {
  1282. res = {};
  1283. }
  1284. let {name, icon, id} = res.guild || {};
  1285. icon = icon && id ? `https://cdn.discordapp.com/icons/${id}/${icon}.png` : '';
  1286. let resData = {
  1287. inviteCode,
  1288. data: {
  1289. code: res.code,
  1290. guildId: id,
  1291. inviteUrl,
  1292. inviteCode,
  1293. expires: res.expires_at,
  1294. name,
  1295. icon,
  1296. }
  1297. }
  1298. discordInviteInfo.value = resData.data;
  1299. cb && cb(resData);
  1300. }).catch((err) => {
  1301. if(iptErrMsgTxt.value && iptErrType == 'discord') {
  1302. iptErrMsgTxt.value = '';
  1303. iptErrType = '';
  1304. }
  1305. });
  1306. }
  1307. /**
  1308. * 获取支付配置(paypalClientId)
  1309. */
  1310. const setPayConfig = () => {
  1311. getPayConfig({
  1312. params: {},
  1313. }).then((res) => {
  1314. if (res.code == 0) {
  1315. payConfig.value = res.data;
  1316. paypalClientId.value = res.data.paypalClientId;
  1317. }
  1318. });
  1319. };
  1320. /**
  1321. * 获取配置
  1322. */
  1323. const setFrontConfig = () => {
  1324. getFrontConfig({
  1325. params: {},
  1326. }).then((res) => {
  1327. if (res.code == 0) {
  1328. paypalHtml.value = res.data.paypalHtml;
  1329. }
  1330. });
  1331. };
  1332. const goTransactionsList = () => {
  1333. window.open(`${chrome.runtime.getURL('/iframe/home.html#/transactions')}`)
  1334. }
  1335. /**
  1336. * 默认获取上次选中的货币信息
  1337. */
  1338. const getLocalCurrencyInfoByCode = () => {
  1339. if(!currentCurrencyInfo.value.currencyCode) {
  1340. getCurrencyInfo();
  1341. }
  1342. }
  1343. const getCurrencyInfo = async () => {
  1344. let {accessToken = ''} = await getChromeStorage('userInfo') || {};
  1345. if (accessToken) {
  1346. getChromeStorage('selectCurrencyInfo', (res) => {
  1347. if(res && res.currencyCode) {
  1348. getCurrencyInfoByCode({
  1349. params: {
  1350. currencyCode: res.currencyCode
  1351. }
  1352. }).then(res => {
  1353. if(res.code == 0 && res.data) {
  1354. currentCurrencyInfo.value = res.data;
  1355. tempCurrentCurrencyInfo.value = res.data;
  1356. onIptSetErrorTxt();
  1357. }
  1358. });
  1359. }
  1360. })
  1361. getChromeStorage('selectCurrencyList', (res) => {
  1362. if (showCurrencySelect.value === false) {
  1363. tempCurrentCurrencyList.value = res;
  1364. }
  1365. })
  1366. }
  1367. }
  1368. onMounted(() => {
  1369. setFrontConfig();
  1370. setPayConfig();
  1371. getLocalCurrencyInfoByCode();
  1372. document.onkeydown = function (e) {
  1373. var keyNum = window.event ? e.keyCode : e.which;
  1374. let escKey = 27;
  1375. if (keyNum == escKey) {
  1376. if (visible.value) {
  1377. // close();
  1378. }
  1379. }
  1380. };
  1381. window.addEventListener('resize', function () {
  1382. setDialogHeight(true);
  1383. })
  1384. });
  1385. </script>
  1386. <style lang="scss" scoped>
  1387. .overlay {
  1388. position: fixed;
  1389. top: 0;
  1390. right: 0;
  1391. bottom: 0;
  1392. left: 0;
  1393. z-index: 1000;
  1394. height: 100%;
  1395. background-color: rgba(0, 0, 0, 0.5);
  1396. overflow: auto;
  1397. .content {
  1398. height: 620px;
  1399. background: #ffffff;
  1400. border-radius: 20px;
  1401. position: absolute;
  1402. left: 50%;
  1403. top: 50%;
  1404. transform: translate(-50%, -50%);
  1405. box-sizing: border-box;
  1406. z-index: 2000;
  1407. .pop-mask {
  1408. width: 100%;
  1409. height:100%;
  1410. position: absolute;
  1411. z-index:900;
  1412. }
  1413. .head {
  1414. border-bottom: 1px solid #ececec;
  1415. height: 48px;
  1416. box-sizing: border-box;
  1417. display: flex;
  1418. align-items: center;
  1419. justify-content: space-between;
  1420. padding: 0 14px;
  1421. .left {
  1422. display: flex;
  1423. align-items: center;
  1424. .title {
  1425. font-size: 16px;
  1426. font-weight: 500;
  1427. }
  1428. .close-btn {
  1429. display: flex;
  1430. align-items: center;
  1431. width: max-content;
  1432. margin-right: 12px;
  1433. cursor: pointer;
  1434. }
  1435. }
  1436. .right {
  1437. .more {
  1438. cursor: pointer;
  1439. }
  1440. .area-option {
  1441. width: 100%;
  1442. height: 100%;
  1443. position: absolute;
  1444. top: 0;
  1445. left: 0;
  1446. z-index: 111;
  1447. .option {
  1448. position: absolute;
  1449. top: 43px;
  1450. right: 15px;
  1451. background: #fff;
  1452. filter: drop-shadow(0px 3px 20px rgba(0, 0, 0, 0.2));
  1453. width: 240px;
  1454. border-radius: 15px;
  1455. overflow: hidden;
  1456. .item {
  1457. width: 100%;
  1458. height: 50px;
  1459. display: flex;
  1460. align-items: center;
  1461. cursor: pointer;
  1462. border-top: 1px solid #E9E9E9;
  1463. img {
  1464. margin-left: 15px;
  1465. width: 30px;
  1466. height: 30px;
  1467. margin-right: 6px;
  1468. }
  1469. span {
  1470. font-weight: 500;
  1471. font-size: 14px;
  1472. }
  1473. }
  1474. .item:first-child {
  1475. border-top: 0;
  1476. }
  1477. .item:hover {
  1478. background: #F5F5F5;
  1479. }
  1480. }
  1481. }
  1482. }
  1483. }
  1484. .body {
  1485. box-sizing: border-box;
  1486. height: calc(100% - 48px);
  1487. display: flex;
  1488. position: relative;
  1489. .icon-guide-select {
  1490. width: 40px;
  1491. position: absolute;
  1492. top: 78px;
  1493. left: 25px;
  1494. z-index: 1000;
  1495. }
  1496. .body-content {
  1497. display:flex;
  1498. width:100%;
  1499. }
  1500. .currency-pop {
  1501. position: absolute;
  1502. width: 375px;
  1503. height: 480px;
  1504. top: 85px;
  1505. left: 88px;
  1506. z-index: 1000;
  1507. box-shadow: 0px 4px 30px rgba(0, 0, 0, 0.3);
  1508. background-color: #fff;
  1509. border-radius: 20px;
  1510. overflow-y: scroll;
  1511. }
  1512. .currency-pop-select {
  1513. position: absolute;
  1514. width: 375px;
  1515. max-height: 480px;
  1516. top: 85px;
  1517. left: 88px;
  1518. z-index: 1000;
  1519. box-shadow: 0px 4px 30px rgba(0, 0, 0, 0.3);
  1520. background-color: #fff;
  1521. border-radius: 20px;
  1522. overflow-y: scroll;
  1523. }
  1524. .left,
  1525. .right {
  1526. height: 100%;
  1527. }
  1528. .left {
  1529. width: 50px;
  1530. display: flex;
  1531. flex-direction: column;
  1532. justify-content: space-between;
  1533. align-items: center;
  1534. .gift-pack-wrapper {
  1535. width: 100%;
  1536. height: 55px;
  1537. background: #f5f5f5;
  1538. display: flex;
  1539. align-items: center;
  1540. justify-content: center;
  1541. }
  1542. .bottom {
  1543. .icon {
  1544. display: block;
  1545. margin-bottom: 26px;
  1546. }
  1547. }
  1548. }
  1549. .right {
  1550. width: calc(100% - 50px);
  1551. box-sizing: border-box;
  1552. position: relative;
  1553. border-left: 1px solid #ececec;
  1554. .form-wrapper {
  1555. padding: 0px 18px 18px 18px;
  1556. height: calc(100% - 80px);
  1557. overflow-y: scroll;
  1558. overflow-x: hidden;
  1559. box-sizing: border-box;
  1560. .img-mode {
  1561. margin-left: -18px;
  1562. }
  1563. .form-base-help {
  1564. display: flex;
  1565. justify-content: space-between;
  1566. margin-top: 10px;
  1567. .currency-operation:before{
  1568. box-sizing: content-box;
  1569. width: 0px;
  1570. height: 0px;
  1571. position: absolute;
  1572. top: -16px;;
  1573. left:46px;
  1574. padding:0;
  1575. border-bottom:8px solid #FFFFFF;
  1576. border-top:8px solid transparent;
  1577. border-left:8px solid transparent;
  1578. border-right:8px solid transparent;
  1579. display: block;
  1580. content:'';
  1581. z-index: 12;
  1582. }
  1583. .currency-operation:after{
  1584. box-sizing: content-box;
  1585. width: 0px;
  1586. height: 0px;
  1587. position: absolute;
  1588. top: -18px;;
  1589. left:45px;
  1590. padding:0;
  1591. border-bottom:9px solid #EAEAEA;
  1592. border-top:9px solid transparent;
  1593. border-left:9px solid transparent;
  1594. border-right:9px solid transparent;
  1595. display: block;
  1596. content:'';
  1597. z-index:10
  1598. }
  1599. .currency-operation {
  1600. position: relative;
  1601. height: 36px;
  1602. border: 1px solid #EAEAEA;
  1603. box-sizing: border-box;
  1604. padding: 10px;
  1605. display: flex;
  1606. align-items: center;
  1607. border-radius: 100px;
  1608. .balance,
  1609. .amount {
  1610. display: flex;
  1611. align-items: center;
  1612. }
  1613. .balance {
  1614. font-weight: 400;
  1615. font-size: 13px;
  1616. img {
  1617. width: 16px;
  1618. height: 16px;
  1619. margin-right: 3px;
  1620. }
  1621. }
  1622. .amount {
  1623. font-weight: 500;
  1624. font-size: 13px;
  1625. color: #4e4e4e;
  1626. margin-left: 5px;
  1627. img {
  1628. margin-left: 5px;
  1629. cursor: pointer;
  1630. }
  1631. }
  1632. .top-up {
  1633. font-weight: 500;
  1634. font-size: 12px;
  1635. color: #ff9839;
  1636. cursor: pointer;
  1637. margin-left: 8px;
  1638. }
  1639. }
  1640. .msg {
  1641. font-weight: 400;
  1642. font-size: 12px;
  1643. color: #acacac;
  1644. }
  1645. }
  1646. .form-base {
  1647. display: flex;
  1648. justify-content: space-between;
  1649. align-items: center;
  1650. margin-top: 14px;
  1651. .item {
  1652. width: 250px;
  1653. height: 50px;
  1654. box-sizing: border-box;
  1655. border-radius: 14px;
  1656. border: 1px solid #D1D9DD;
  1657. display: flex;
  1658. align-items: center;
  1659. justify-content: space-between;
  1660. padding: 16px 14px;
  1661. input {
  1662. width: 102px;
  1663. text-align: right;
  1664. font-weight: 500;
  1665. font-size: 18px;
  1666. border: none;
  1667. outline: none;
  1668. box-sizing: border-box;
  1669. }
  1670. input::placeholder {
  1671. color: #c5c5c5;
  1672. }
  1673. .label {
  1674. font-weight: 500;
  1675. font-size: 15px;
  1676. display: flex;
  1677. align-items: center;
  1678. .icon {
  1679. width: 20px;
  1680. height: 20px;
  1681. margin-right: 8px;
  1682. }
  1683. }
  1684. }
  1685. .item:first-child {
  1686. margin-right: 14px
  1687. }
  1688. .currency-select-wrapper {
  1689. padding: 0 !important;
  1690. input {
  1691. padding-right: 14px;
  1692. }
  1693. .currency-select {
  1694. max-width: 136px;
  1695. cursor: pointer;
  1696. background: #1D9BF0;
  1697. margin-left: 6px;
  1698. padding: 6px 10px;
  1699. border-radius: 12px;
  1700. color: #fff;
  1701. .text {
  1702. white-space: nowrap;
  1703. zoom: 0.85;
  1704. }
  1705. .arrow {
  1706. margin-left: 5px;
  1707. }
  1708. }
  1709. .selected {
  1710. background: #F4F4F4 !important;
  1711. color: #000 !important;
  1712. }
  1713. }
  1714. }
  1715. .form-label {
  1716. margin-top: 14px;
  1717. margin-bottom: 10px;
  1718. font-weight: 500;
  1719. font-size: 14px;
  1720. display: flex;
  1721. align-items: center;
  1722. justify-content: space-between;
  1723. .icon-add-task {
  1724. cursor: pointer;
  1725. }
  1726. }
  1727. .form-require {
  1728. box-sizing: border-box;
  1729. border-radius: 15px;
  1730. margin-top: 12px;
  1731. border: 1px solid #D1D9DD;
  1732. .form-item {
  1733. min-height: 50px;
  1734. display: flex;
  1735. align-items: center;
  1736. justify-content: space-between;
  1737. margin: 0 16px;
  1738. border-bottom: 1px solid #ececec;
  1739. padding: 8px 0;
  1740. box-sizing: border-box;
  1741. .item-left {
  1742. display: flex;
  1743. }
  1744. .label {
  1745. min-width: 76px;
  1746. display: flex;
  1747. align-items: center;
  1748. font-size: 15px;
  1749. font-weight: 500;
  1750. .icon {
  1751. margin-right: 10px;
  1752. }
  1753. }
  1754. .control {
  1755. min-width: 258px;
  1756. margin-left: 18px;
  1757. box-sizing: border-box;
  1758. border-left: 1px solid #ECECEC;
  1759. position: relative;
  1760. .discord-address {
  1761. border: none;
  1762. outline: none;
  1763. color: #1D9BF0;
  1764. font-weight: 500;
  1765. font-size: 14px;
  1766. width: 100%;
  1767. height: 34px;
  1768. padding-left: 15px;
  1769. }
  1770. .discord-address::placeholder {
  1771. color: #c5c5c5;
  1772. }
  1773. .discord-invite-info {
  1774. position: absolute;
  1775. top: 40px;
  1776. left: 0;
  1777. box-shadow: 0px 4px 30px rgba(0, 0, 0, 0.3);
  1778. background: #fff;
  1779. border-radius: 16px;
  1780. padding: 16px;
  1781. box-sizing: border-box;
  1782. display: flex;
  1783. align-items: center;
  1784. cursor: pointer;
  1785. .icon {
  1786. width: 40px;
  1787. height: 40px;
  1788. margin-right: 10px;
  1789. border-radius: 50%;
  1790. }
  1791. .name {
  1792. font-weight: 600;
  1793. font-size: 16px;
  1794. color: #101419;
  1795. width: 193px;
  1796. height: 20px;
  1797. overflow: hidden;
  1798. white-space: nowrap;
  1799. text-overflow: ellipsis;
  1800. display: inline-block;
  1801. }
  1802. }
  1803. }
  1804. .icon-task-close {
  1805. margin-left: 6px;
  1806. cursor: pointer;
  1807. }
  1808. }
  1809. .border-hide {
  1810. border-bottom: none !important;
  1811. }
  1812. }
  1813. }
  1814. .anti-bot-wrapper {
  1815. width: 100%;
  1816. height: 50px;
  1817. display: flex;
  1818. align-items: center;
  1819. justify-content: space-between;
  1820. box-sizing: border-box;
  1821. border-radius: 15px;
  1822. padding: 0 18px;
  1823. margin-top: 14px;
  1824. border: 1px solid #D1D9DD;
  1825. .label {
  1826. display: flex;
  1827. align-items: center;
  1828. font-size: 15px;
  1829. font-weight: 500;
  1830. .icon-bot {
  1831. margin-right: 8px;
  1832. }
  1833. .icon-beta {
  1834. margin-left: 5px;
  1835. margin-right: 8px;
  1836. }
  1837. .icon-question {
  1838. cursor: pointer;
  1839. }
  1840. }
  1841. }
  1842. .tips-wrapper {
  1843. margin: 16px 0 0 12px !important;
  1844. padding: 0px !important;
  1845. .title,
  1846. .row {
  1847. font-weight: 400;
  1848. font-size: 12px;
  1849. color: #A39F9F;
  1850. }
  1851. .row {
  1852. box-sizing: border-box;
  1853. line-height: 16px;
  1854. }
  1855. .more {
  1856. color: #1D9BF0;
  1857. font-size: 13px;
  1858. padding-left: 4px;
  1859. cursor: pointer;
  1860. }
  1861. }
  1862. .submit-btn-wrapper {
  1863. width: 100%;
  1864. background: #fff;
  1865. position: absolute;
  1866. bottom: 18px;
  1867. left: 0;
  1868. box-sizing: border-box;
  1869. padding: 16px 18px 0 18px;
  1870. .submit-btn {
  1871. width: 100%;
  1872. height: 46px;
  1873. text-align: center;
  1874. background: #4a99e9;
  1875. border-radius: 100px;
  1876. color: #fff;
  1877. display: flex;
  1878. align-items: center;
  1879. justify-content: center;
  1880. font-size: 16px;
  1881. font-weight: 500;
  1882. cursor: pointer;
  1883. .icon-loading {
  1884. width: 20px;
  1885. height: 20px;
  1886. margin-right: 3px;
  1887. }
  1888. }
  1889. .disabled-submit {
  1890. background-color: #D9D9D9;
  1891. }
  1892. }
  1893. }
  1894. .fill-right {
  1895. width: 100% !important;
  1896. border-bottom-left-radius: 16px;
  1897. }
  1898. }
  1899. }
  1900. }
  1901. .preview {
  1902. padding: 30px 40px;
  1903. .card {
  1904. float: left;
  1905. position: relative;
  1906. .flash {
  1907. overflow: hidden;
  1908. height: 460px;
  1909. border-radius: 26px;
  1910. border: solid 1px #ECECEC;
  1911. }
  1912. &.center {
  1913. margin-left: 50%;
  1914. transform: translateX(-50%);
  1915. }
  1916. }
  1917. .card-title {
  1918. height: 32px;
  1919. .img {
  1920. float: left;
  1921. width: 20px;
  1922. height: 20px;
  1923. margin-right: 8px;
  1924. }
  1925. .font {
  1926. float: left;
  1927. font-size: 17px;
  1928. font-weight: 500;
  1929. span {
  1930. color: #0091e9;
  1931. }
  1932. }
  1933. }
  1934. .card-content {
  1935. float: right;
  1936. width: 430px;
  1937. }
  1938. .card-amount {
  1939. overflow: hidden;
  1940. display: flex;
  1941. height: 80px;
  1942. padding: 20px;
  1943. border-radius: 20px;
  1944. border: 1px solid #E6E6E6;
  1945. .icon {
  1946. width: 40px;
  1947. height: 40px;
  1948. }
  1949. .con {
  1950. flex: 1;
  1951. padding: 0 10px;
  1952. .desc {
  1953. color: rgba($color: #000000, $alpha: 0.5);
  1954. font-size: 12px;
  1955. margin-bottom: 4px;
  1956. }
  1957. .price {
  1958. font-size: 16px;
  1959. font-weight: bold;
  1960. }
  1961. }
  1962. .refresh {
  1963. cursor: pointer;
  1964. width: 50px;
  1965. height: 50px;
  1966. margin-top: -5px;
  1967. }
  1968. }
  1969. .card-list {
  1970. padding: 20px;
  1971. border-radius: 20px;
  1972. border: 1px solid #E6E6E6;
  1973. .item {
  1974. display: flex;
  1975. justify-content: space-between;
  1976. align-items: center;
  1977. height: 47px;
  1978. font-size: 14px;
  1979. font-weight: 500;
  1980. box-shadow: inset 0px -1px 0px #EAEAEA;
  1981. }
  1982. }
  1983. }
  1984. .icon-refresh-rotate {
  1985. transform: rotate(360deg);
  1986. transition-duration: 1s;
  1987. }
  1988. .payment {
  1989. .balance {
  1990. display: flex;
  1991. margin-right: 20px;
  1992. .icon {
  1993. width: 40px;
  1994. height: 40px;
  1995. }
  1996. .con {
  1997. padding: 0 5px;
  1998. .desc {
  1999. color: rgba($color: #000000, $alpha: 0.5);
  2000. font-size: 12px;
  2001. margin-bottom: 4px;
  2002. }
  2003. .price {
  2004. font-size: 14px;
  2005. font-weight: bold;
  2006. }
  2007. }
  2008. .refresh {
  2009. width: 40px;
  2010. cursor: pointer;
  2011. margin-left: -5px;
  2012. }
  2013. }
  2014. }
  2015. </style>