give-dialog.vue 70 KB

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