give-dialog.vue 88 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598
  1. <template>
  2. <div class="overlay" v-if="visible">
  3. <div class="content"
  4. :style="{
  5. height: showComType === 'preview' ? 'calc(100vh - 40px)' : dialogStyle.dialogHeight + 'px',
  6. width: dialogStyle.dialogContentWidth + 'px',
  7. }">
  8. <div class="pop-mask"
  9. v-show="showCurrencyPop || showCurrencySelect"
  10. @click.stop="showCurrencyPop = false; showCurrencySelect=false">
  11. </div>
  12. <!-- head -->
  13. <give-dialog-head
  14. :title="publishType == 'REDPACKET' ? currentComData[showComType]['title'] : 'Tool Box'"
  15. :publishType="publishType"
  16. :showComType="showComType"
  17. :toolBoxPageData="toolBoxPageData"
  18. @close="close"></give-dialog-head>
  19. <!-- 内容 -->
  20. <div class="body">
  21. <!-- 充值组件 -->
  22. <top-up
  23. v-if="showComType == 'topUp'"
  24. :currentCurrencyInfo="tempCurrentCurrencyInfo"
  25. @topUpDone="topUpDone">
  26. </top-up>
  27. <!-- 自定义红包封面 -->
  28. <giveaway-poster
  29. v-else-if="showComType == 'poster'"
  30. :baseFormData="baseFormData"
  31. :currentCurrencyInfo="currentCurrencyInfo"
  32. :customPosterInfo="customPosterInfo"
  33. @selectImage="selectImage"
  34. @confirmData="confirmData">
  35. </giveaway-poster>
  36. <!-- 表单填写容器 -->
  37. <div class="body-content" v-else>
  38. <!-- 货币列表 -->
  39. <div class="currency-pop" v-show="showCurrencyPop">
  40. <currency-list
  41. ref="currencyListDom"
  42. :showGeneralLottery="true"
  43. @selectCurrency="selectCurrency"
  44. @setCurrencyList="setCurrentCurrencyInfo"
  45. @addGeneralLottery="addCustomizedRewardHandle"></currency-list>
  46. </div>
  47. <!-- 通用奖品编辑弹窗 -->
  48. <div class="customized-reward-edit-popup" v-if="showCustomizedRewardEditPopup">
  49. <customized-reward-edit-popup
  50. ref="rewardEditDom"
  51. :customizedReward="baseFormData.customizedReward"
  52. :rewardType="baseFormData.rewardType"
  53. @closeRewardPopup="closeRewardPopup"
  54. @removeReward="removeReward"
  55. @submitReward="submitReward"></customized-reward-edit-popup>
  56. </div>
  57. <div class="currency-pop-select" v-show="showCurrencySelect">
  58. <currency-select
  59. ref="currencySelectDom"
  60. :list="tempCurrentCurrencyList"
  61. @selectCurrency="selectCurrencyAfter"></currency-select>
  62. </div>
  63. <div class="left" v-if="showComType != 'preview' && toolBoxPageData.activePage != 'PREVIEW'">
  64. <div class="tab-item"
  65. :class="{'active-tab': item.type == publishType}"
  66. v-for="(item, index) in leftTabList"
  67. :key="index"
  68. @click="clickLeftTab(item, index)"
  69. >
  70. <img class="icon" :src="item.icon"/>
  71. </div>
  72. </div>
  73. <div class="right"
  74. :class="{'fill-right': showComType == 'preview' || toolBoxPageData.activePage == 'PREVIEW'}">
  75. <global-tip :type="'2'"></global-tip>
  76. <template v-if="publishType == 'TOOL_BOX'">
  77. <tool-box
  78. :pageData="{
  79. 'linkInputDescImage': toolBoxPageData.postEditorLinkInputDescImage,
  80. 'defaultLinkTitle': toolBoxPageData.postEditorDefaultLinkTitle
  81. }"
  82. :activePage="toolBoxPageData.activePage" @onPageChange="onToolBoxPageChange"
  83. @toolBoxPublishFinish="toolBoxPublishFinish"></tool-box>
  84. </template>
  85. <template v-else>
  86. <div class="form-wrapper" v-if="showComType == 'default'">
  87. <div class="form-cell-item base-form-wrapper">
  88. <div class="title">
  89. <img class="icon" :src="require('@/assets/svg/icon-reward-v2.svg')"/>
  90. Reward
  91. </div>
  92. <div class="form-cell-content">
  93. <div class="select-mode-ele">
  94. <img v-for="(item, index) in publishModeList"
  95. :key="index"
  96. :src="selectModeInfo.index == index ? item.imgActive : item.imgInActive"
  97. @click="selectPublishMode(item, index)">
  98. </div>
  99. <!-- 金额、数量 -->
  100. <div class="form-base">
  101. <div class="item currency-select-wrapper">
  102. <div>
  103. <div class="label currency-select"
  104. :class="{'selected': currencySelectCpd}"
  105. @click="selectCurrencyPopHandle">
  106. <img class="icon"
  107. v-if="currentIconCpd"
  108. :src="currentIconCpd"/>
  109. <div class="text">
  110. {{currentPrizeCpd}}
  111. </div>
  112. <img class="arrow"
  113. :src="currentArrowCpd"/>
  114. </div>
  115. <!-- 刷新按钮、充值 -->
  116. <div class="currency-operation"
  117. v-if="currentCurrencyInfo.currencyCode">
  118. <div class="amount">
  119. Balance:
  120. <a-tooltip :title="currentCurrencyInfo.balance">
  121. {{ getBit(currentCurrencyInfo.balance) }}
  122. </a-tooltip>
  123. <img :class="{ 'icon-refresh-rotate': refreshRotate }"
  124. :src="require('@/assets/svg/icon-form-refresh.svg')"
  125. @click="updateCurrencyBanlce"/>
  126. </div>
  127. <div v-if="currentCurrencyInfo.currencyCode != 'USD'"
  128. class="top-up"
  129. @click="goTopUp">Deposit</div>
  130. </div>
  131. </div>
  132. <input v-model="baseFormData.amountValue"
  133. placeholder="0"
  134. autofocus
  135. @input="onAmountInput"
  136. @blur="onAmountBlur"/>
  137. </div>
  138. <div class="item winners-count-input">
  139. <div>
  140. <div class="label">
  141. <img class="icon"
  142. :src="require('@/assets/svg/icon-winner-v2.svg')"/>
  143. Winner Count
  144. </div>
  145. <div class="msg" v-show="selectModeInfo.type == PlayType.common">Recommend Winners 100~10000</div>
  146. </div>
  147. <input v-model="baseFormData.totalCount"
  148. placeholder="0"
  149. :disabled="baseFormData.rewardType === RewardType.custom"
  150. @input="onCountInput"
  151. @blur="onCountBlur"/>
  152. </div>
  153. <div class="item automatically-input" v-if="selectModeInfo.type == PlayType.lottery">
  154. <div class="label">
  155. <img class="icon"
  156. :src="require('@/assets/svg/icon-automatically.svg')"/>
  157. Automatically Draw in
  158. </div>
  159. <div class="input-wrapper">
  160. <input v-model="baseFormData.validityDuration"
  161. placeholder="0"
  162. @input="onValidityDurationInput"
  163. @blur="onValidityDurationBlur"/>
  164. <span class="unit">h</span>
  165. </div>
  166. </div>
  167. </div>
  168. <div class="giveaway-poster" @click="customCoverImg">
  169. <div class="show-img">
  170. <div
  171. :style="{
  172. 'zoom': 55 / 500,
  173. 'position': 'absolute',
  174. 'width': '345px',
  175. }">
  176. <custom-card-cover
  177. :data="{
  178. totalCount: baseFormData.totalCount,
  179. amountValue: baseFormData.amountValue,
  180. tokenSymbol: currentCurrencyInfo.tokenSymbol,
  181. currencyIconUrl: currentCurrencyInfo.iconPath,
  182. type: baseFormData.type,
  183. validityDuration: baseFormData.validityDuration,
  184. customPosterUrl: customPosterData && customPosterData.after && customPosterData.after.imagePath || '',
  185. rewardType: baseFormData.rewardType,
  186. customizedReward: baseFormData.customizedReward
  187. }">
  188. </custom-card-cover>
  189. </div>
  190. </div>
  191. <div class="show-font">
  192. <span>Giveaway Poster</span>
  193. <img class="new" v-if="customShowNewImage" :src=" require('@/assets/svg/img-new.svg') " />
  194. </div>
  195. <div class="show-placeholder">Replace</div>
  196. <div class="arrow">
  197. <img :src=" require('@/assets/svg/icon-cell-arrow-right.svg') " />
  198. </div>
  199. </div>
  200. <!-- 提示 -->
  201. <ul class="tips-wrapper">
  202. <li class="row" style="white-space:nowrap;">
  203. Rewards can only be claimed after the target user completes all tasks you set.
  204. </li>
  205. <li class="row">
  206. Each user can only receive a reward once per task.
  207. </li>
  208. <li class="row" v-show="selectModeInfo.type == PlayType.common">
  209. 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.
  210. </li>
  211. </ul>
  212. </div>
  213. </div>
  214. <div class="form-cell-item task-wrapper">
  215. <div class="title">
  216. <img class="icon" :src="require('@/assets/svg/icon-tasks-v2.svg')"/>
  217. Tasks
  218. </div>
  219. <div class="form-cell-content form-require">
  220. <!-- 转推、like、关注 -->
  221. <div v-for="(item, index) in formList"
  222. :key="index">
  223. <div v-if="item.show" class="form-item"
  224. :class="{ 'border-hide': formList.length - 1 == index }">
  225. <div class="item-left">
  226. <div class="label">
  227. <img class="icon" :src="item.icon"/>
  228. {{ item.label }}
  229. </div>
  230. <div class="control"
  231. v-if="item.nodeType == 'textarea'">
  232. <follow-input
  233. :isAddSelf="!isBack"
  234. :atUserList="atUserList"
  235. @addUser="addFollowUser"
  236. @setUser="setFollowUser"
  237. @delUser="delFollowUser"></follow-input>
  238. </div>
  239. <div class="control"
  240. v-if="item.nodeType == 'input'">
  241. <div v-if="showDiscordInvitePop"
  242. class="discord-invite-info"
  243. @click="showDiscordInvitePop = false">
  244. <img class="icon" :src="discordInviteInfo.icon || require('@/assets/svg/icon-discord-mini.svg')" />
  245. <span class="name">{{discordInviteInfo.name}}</span>
  246. </div>
  247. <input v-model="item.text"
  248. placeholder="Enter discord invite link"
  249. class="discord-address"
  250. @input="onIptDiscordAddress($event, index)"
  251. @blur="onBlurDiscordAddress($event, index)" />
  252. </div>
  253. </div>
  254. <div>
  255. <a-switch
  256. v-if="item.type > 3"
  257. v-model:checked="item.checked"
  258. @change="formSwitchChange($event, item, index)"/>
  259. </div>
  260. </div>
  261. </div>
  262. </div>
  263. </div>
  264. <div class="submit-btn-wrapper">
  265. <div class="submit-btn"
  266. :class="{ 'disabled-submit': iptErrMsgTxt != ''}"
  267. @click="confirm">
  268. <img class="icon-loading"
  269. v-if="submitIng"
  270. :src="require('@/assets/svg/icon-btn-loading.svg')"/>
  271. {{iptErrMsgTxt ? iptErrMsgTxt : 'NEXT'}}
  272. </div>
  273. </div>
  274. </div>
  275. <!-- 预览 -->
  276. <template v-else-if="showComType == 'preview'">
  277. <preview-sheet :baseFormData="baseFormData"
  278. :currentCurrencyInfo="currentCurrencyInfo"
  279. :tempCurrentCurrencyInfo="tempCurrentCurrencyInfo"
  280. :publishRes="publishRes"
  281. :previewFontSize="previewFontSize"
  282. :customPosterData="customPosterData"
  283. :finalAmountData="finalAmountData"
  284. @onTopUpDone="topUpDone"
  285. @onUpdateCurrencyBanlce="updateCurrencyBanlce"></preview-sheet>
  286. </template>
  287. <!-- 支付按钮 -->
  288. <div class="payment" v-show="showComType == 'preview'">
  289. <pay-button
  290. ref="payButtonDom"
  291. v-if="isMoneyRewardCpd"
  292. :finalAmountData="finalAmountData"
  293. :payConfig="{
  294. feeDesc: payConfig.feeDesc,
  295. amount: baseFormData.amountValue,
  296. postId
  297. }"
  298. :currentCurrencyInfo="currentCurrencyInfo"
  299. :USDepositStatus = "USDepositStatus"
  300. @showDepositMask="showDepositMessageBox = true"
  301. @payFinish="payFinish">
  302. <template v-slot:balance>
  303. <div class="balance" v-if="Number(baseFormData.amountValue) <= Number(currentCurrencyInfo.balance) || currentCurrencyInfo.currencyCode == 'USD' ">
  304. <img class="icon" src="@/assets/subject/icon-balance.png" />
  305. <div class="con">
  306. <div class="desc">Balance</div>
  307. <div class="price">{{currentCurrencyInfo.balance}} {{currentCurrencyInfo.currencyCode == 'USD' ? '$' :currentCurrencyInfo.tokenSymbol}}</div>
  308. </div>
  309. <img class="refresh"
  310. :class="{ 'icon-refresh-rotate': refreshRotate }"
  311. :src=" require('@/assets/svg/icon-form-refresh.svg')"
  312. @click="updateCurrencyBanlce"/>
  313. </div>
  314. </template>
  315. </pay-button>
  316. <div v-else class="btn-wrap" @click="payStatusHandle(1)"><div class="custom-submit">Confirm</div></div>
  317. </div>
  318. </template>
  319. </div>
  320. </div>
  321. </div>
  322. </div>
  323. <!-- 提示 -->
  324. <message-box
  325. :dialogVisible="showMessageBox"
  326. :title="messageBoxData.title"
  327. :content="messageBoxData.content"
  328. cancelTxt="Not yet"
  329. confirmTxt="Deposit"
  330. @cancel="messageBoxCancel"
  331. @confirm="messageBoxConfirm"></message-box>
  332. <!-- 预览页充值 -->
  333. <message-box
  334. :dialogVisible="showDepositMessageBox"
  335. title="Is the Deposit Completed?"
  336. @cancel="depositAchCancel"
  337. @confirm="depositAchConfirm"></message-box>
  338. <!-- 裁剪 -->
  339. <div class="dialog" v-if="cropperDialog">
  340. <div class="corp-title">
  341. <img class="back" :src="require('@/assets/svg/icon-back.svg')" @click="hiddenDialog" />
  342. <span>Crop</span>
  343. </div>
  344. <div class="corp-content">
  345. <vue-cropper
  346. ref="refCropper"
  347. :img="cropperOption.img"
  348. :output-type="cropperOption.outputType"
  349. :infoTrue="cropperOption.infoTrue"
  350. :full="cropperOption.full"
  351. :fixed="cropperOption.fixed"
  352. :fixed-number="cropperOption.fixedNumber"
  353. :auto-crop="cropperOption.autoCrop"
  354. :auto-crop-width="cropperOption.autoCropWidth"
  355. :auto-crop-height="cropperOption.autoCropHeight"
  356. :center-box="cropperOption.centerBox"
  357. :high="cropperOption.high"
  358. :max-img-size="cropperOption.max">
  359. </vue-cropper>
  360. </div>
  361. <div class="corp-footer">
  362. <button v-if="cropperLoading" class="confirm disable">
  363. <img :src=" require('@/assets/svg/icon-btn-loading.svg') " />
  364. <span>Confirm</span>
  365. </button>
  366. <button v-else class="confirm" @click="confirmImage">Confirm</button>
  367. </div>
  368. </div>
  369. <div class="dialog-mask" v-if="cropperDialog"></div>
  370. </div>
  371. </template>
  372. <script setup>
  373. import { ref, watch, reactive, defineProps, defineEmits, onMounted, nextTick, provide, computed } from "vue";
  374. import { postPublish, syncChainTokenRechargeRecord, getCurrencyInfoByCode } from "@/http/publishApi";
  375. import { getInviteGuildInfo, getInviteGuildInfoByOpenApi, saveInviteGuildInfo } from "@/http/discordApi";
  376. import { payCalcFee, getPayConfig } from "@/http/pay";
  377. import { getFrontConfig, calcRechargePayAmount } from "@/http/account";
  378. import { uploadSignature, uploadFile } from '@/http/media';
  379. import {setChromeStorage, getChromeStorage} from "@/uilts/chromeExtension"
  380. import { debounce, getBit } from "@/uilts/help"
  381. import { PlayType, RewardType, TaskType } from '@/types';
  382. import Report from "@/log-center/log"
  383. import { ElMessage, ElLoading } from "element-plus";
  384. import "element-plus/es/components/message/style/css";
  385. import "element-plus/es/components/loading/style/css";
  386. import 'vue-cropper/dist/index.css'
  387. import { VueCropper } from "vue-cropper";
  388. import {create, all} from "mathjs";
  389. import { message } from 'ant-design-vue';
  390. import messageBox from "@/view/components/message-box.vue";
  391. import currencyList from "@/view/components/currency-list.vue";
  392. import currencySelect from "@/view/components/currency-select.vue";
  393. import followInput from "@/view/iframe/publish/components/follow-input";
  394. import payButton from "@/view/iframe/publish/components/pay-button";
  395. import topUp from "@/view/iframe/publish/components/top-up.vue";
  396. import toolBox from '@/view/iframe/publish/tool-box/index.vue'
  397. import giveawayPoster from '@/view/iframe/publish/components/giveaway-poster.vue';
  398. import giveDialogHead from "@/view/iframe/publish/components/give-dialog-head";
  399. import previewSheet from "@/view/iframe/publish/components/preview-sheet.vue";
  400. import GlobalTip from '@/view/components/global-tip.vue'
  401. import customCardCover from '@/view/components/custom-card-cover.vue'
  402. import CustomizedRewardEditPopup from '@/view/iframe/publish/components/customized-reward-edit';
  403. const config = {
  404. number: 'BigNumber',
  405. }
  406. const math = create(all, config);
  407. //临时货币信息
  408. let tempCurrentCurrencyInfo = ref({});
  409. let tempCurrentCurrencyList = ref([]);
  410. let payConfig = ref({});
  411. let timer = ref(null);
  412. // 发布后返回的结果
  413. let publishRes = reactive({});
  414. //弹窗是否展示
  415. let visible = ref(false);
  416. let publishType = ref('REDPACKET');
  417. //弹窗高度
  418. let dialogStyle = reactive({
  419. dialogHeight: 670,
  420. dialogContentWidth: 1100
  421. })
  422. let USDepositStatus = ref('DEFAULT');
  423. let cropperOption = ref({
  424. img: '',
  425. full: true,
  426. infoTrue: true,
  427. fixed: true,
  428. fixedNumber: [16, 8.396],
  429. outputType: 'png',
  430. autoCrop: true,
  431. autoCropWidth: 99999,
  432. autoCropHeight: 99999,
  433. centerBox: true,
  434. high: true,
  435. max: 99999,
  436. })
  437. let cropperDialog = ref(false)
  438. let cropperLoading = ref(false)
  439. let cropperType = ref('before')
  440. let customPosterInfo = ref({})
  441. let customPosterData = ref({})
  442. let customShowNewImage = ref(false)
  443. let refCropper = ref('')
  444. // 当前展示组件内容 default(表单) preview(预览) topUp(充值)
  445. let showComType = ref("default");
  446. let currentComData = {
  447. default: {
  448. title: "Giveaway",
  449. },
  450. preview: {
  451. title: "Giveaway",
  452. },
  453. topUp: {
  454. title: "Deposit",
  455. },
  456. poster: {
  457. title: "Giveaway Poster",
  458. }
  459. };
  460. // 机器人开关
  461. let openAntiBot = ref(false);
  462. // 是否正在提交
  463. let submitIng = ref(false);
  464. // 艾特关注人列表
  465. let atUserList = ref([]);
  466. // 表单错误提示
  467. let iptErrMsgTxt = ref("Select a reward");
  468. // 是否返回
  469. let isBack = ref(false);
  470. // 展示消息提示
  471. let showMessageBox = ref(false);
  472. let showDepositMessageBox = ref(false);
  473. // 展示货币列表pop
  474. let showCurrencyPop = ref(false);
  475. let showCurrencySelect = ref(false);
  476. // 货币列表的dom
  477. let currencyListDom = ref(null);
  478. let payButtonDom = ref(null);
  479. // 刷新按钮旋转
  480. let refreshRotate = ref(false);
  481. // 预览字体大小
  482. let previewFontSize = ref(56);
  483. let postId = ref('');
  484. let selectModeInfo = reactive({
  485. index: 0,
  486. type: PlayType.lottery // 1: 红包 2: 抽奖
  487. })
  488. // 余额是否同步中
  489. let asyncIng = ref(false);
  490. let messageBoxData = ref({
  491. title: "",
  492. content: "",
  493. });
  494. // 真实支付金额数据
  495. let finalAmountData = ref({
  496. currencyCode: '',
  497. feeAmountValue: 0,
  498. finalAmountValue: 0,
  499. requestAmountValue: 0,
  500. });
  501. // 表单数据
  502. let baseFormData = reactive({
  503. amountCurrencyCode: "",
  504. amountValue: "",
  505. totalCount: "",
  506. validityDuration: "",
  507. type: selectModeInfo.type,
  508. rewardType: RewardType.money,
  509. customizedReward: ""
  510. });
  511. const defaultCurrentCurrencyInfo = {
  512. currencyCode: "",
  513. currencyName: "",
  514. balance: "",
  515. currencyType: "",
  516. iconPath: "",
  517. minAmount: "",
  518. tokenChain: "",
  519. tokenSymbol: "",
  520. usdEstimateBalance: ""
  521. }
  522. // 当前选择的货币信息
  523. let currentCurrencyInfo = ref(defaultCurrentCurrencyInfo);
  524. const discordIptErrTxt = 'Discord invite link is wrong';
  525. const discordIptEmptyErrTxt = 'Enter discord invite link';
  526. const discordIptNerverExpiresErrTxt = 'Make sure the Discord link never expires'
  527. let iptErrType = ''; //discord
  528. let formList = reactive([
  529. {
  530. label: "Follow",
  531. icon: require("@/assets/svg/icon-task-twitter.svg"),
  532. nodeType: "textarea",
  533. type: TaskType.twitterFollow,
  534. text: [],
  535. checked: true,
  536. show: true
  537. },
  538. {
  539. label: "Retweet & Like",
  540. icon: require("@/assets/svg/icon-task-twitter.svg"),
  541. nodeType: "div",
  542. type: TaskType.twitterRetweet,
  543. checked: true,
  544. show: true
  545. },
  546. {
  547. label: "Like Tweet",
  548. icon: require("@/assets/svg/icon-task-twitter.svg"),
  549. nodeType: "div",
  550. type: TaskType.twitterLikeTweet,
  551. checked: true,
  552. show: false
  553. },
  554. {
  555. label: "Comment and Tag 3 friends",
  556. icon: require("@/assets/svg/icon-task-twitter.svg"),
  557. nodeType: "div",
  558. type: TaskType.twitterCommentAndTag,
  559. checked: true,
  560. show: true
  561. },
  562. {
  563. label: "Repost to Facebook",
  564. icon: require("@/assets/svg/icon-task-facebook.svg"),
  565. nodeType: "div",
  566. text: '',
  567. type: TaskType.repostToFacebook,
  568. checked: false,
  569. show: true
  570. },
  571. {
  572. label: "Join Discord",
  573. icon: require("@/assets/svg/icon-discord-mini.svg"),
  574. nodeType: "input",
  575. text: '',
  576. type: TaskType.joinDiscord,
  577. checked: false,
  578. show: true
  579. },
  580. ]);
  581. let publishModeList = reactive([
  582. {
  583. imgActive: require("@/assets/svg/img-A1.svg"),
  584. imgInActive: require("@/assets/svg/img-A0.svg"),
  585. type: PlayType.lottery
  586. },
  587. {
  588. imgActive: require("@/assets/svg/img-B1.svg"),
  589. imgInActive: require("@/assets/svg/img-B0.svg"),
  590. type: PlayType.common
  591. }
  592. ])
  593. let discordInviteInfo = ref({});
  594. let showDiscordInvitePop = ref(false);
  595. let showCustomizedRewardEditPopup = ref(false);
  596. let lotteryMaxHourDuration = 168;
  597. let leftTabList = reactive([
  598. {
  599. icon: require('@/assets/svg/icon-gift-pack.svg'),
  600. type: 'REDPACKET'
  601. },
  602. {
  603. icon: require('@/assets/svg/icon-tool-box-02.svg'),
  604. type: 'TOOL_BOX'
  605. }
  606. ])
  607. let toolBoxPageData = reactive({
  608. activePage: 'EDITOR', //EDITOR PREVIEW
  609. postEditorLinkInputDescImage: '',
  610. postEditorDefaultLinkTitle: ''
  611. })
  612. const props = defineProps({
  613. dialogData: {
  614. type: Object,
  615. default: () => {
  616. return {
  617. visible: false,
  618. type: 'REDPACKET'
  619. }
  620. },
  621. },
  622. });
  623. //selected prize icon cpd
  624. let currentIconCpd = computed(() => {
  625. if(baseFormData.rewardType === RewardType.custom) {
  626. return require("@/assets/svg/icon-gift.svg");
  627. } else {
  628. return currentCurrencyInfo.value.iconPath;
  629. }
  630. })
  631. // selected prize cpd
  632. let currentPrizeCpd = computed(() => {
  633. const {currencyCode, tokenSymbol} = currentCurrencyInfo.value
  634. if(baseFormData.rewardType === RewardType.custom) {
  635. return baseFormData.customizedReward;
  636. } else if(currencyCode == "USD") {
  637. return "USD";
  638. } else {
  639. return tokenSymbol || "Select a reward";
  640. }
  641. })
  642. let currencySelectCpd = computed(() => {
  643. return baseFormData.customizedReward || currentCurrencyInfo.value.currencyCode;
  644. })
  645. let currentArrowCpd = computed(() => {
  646. if(baseFormData.rewardType === RewardType.custom) {
  647. return require("@/assets/svg/icon-cell-arrow-right.svg");
  648. } else {
  649. return currentCurrencyInfo.value.currencyCode ? require("@/assets/svg/icon-form-arrow-down.svg") : require("@/assets/svg/icon-form-white-arrow-down.svg");
  650. }
  651. })
  652. let isMoneyRewardCpd =computed(() => baseFormData.rewardType === RewardType.money);
  653. watch(
  654. () => props.dialogData,
  655. (newVal) => {
  656. visible.value = newVal.visible;
  657. USDepositStatus.value = "DEFAULT"
  658. if (newVal.visible) {
  659. publishType.value = newVal.type;
  660. Report.reportLog({
  661. pageSource: Report.pageSource.publisherDialog,
  662. businessType: Report.businessType.pageView,
  663. });
  664. getLocalCurrencyInfoByCode();
  665. setTimeout(() => {
  666. setDialogStyle();
  667. }, 300);
  668. // 更新余额
  669. clearInterval(timer.value);
  670. timer.value = setInterval(() => {
  671. getCurrencyInfo({loop: true});
  672. }, 10000)
  673. } else {
  674. clearInterval(timer.value);
  675. }
  676. },
  677. {
  678. deep: true
  679. }
  680. );
  681. const emits = defineEmits(["close", "confirm", "postPublishFinish"]);
  682. const close = () => {
  683. USDepositStatus.value = "DEFAULT"
  684. if(publishType.value == 'TOOL_BOX') {
  685. closeToolBoxPage()
  686. } else {
  687. if (showComType.value != "default") {
  688. showComType.value = "default";
  689. isBack.value = true;
  690. } else {
  691. initParams();
  692. emits("close", false);
  693. }
  694. }
  695. };
  696. const closeToolBoxPage = () => {
  697. if(toolBoxPageData.activePage == "EDITOR") {
  698. emits("close", false);
  699. } else if(toolBoxPageData.activePage == "PREVIEW") {
  700. toolBoxPageData.activePage = "EDITOR";
  701. }
  702. };
  703. /**
  704. * 设置弹窗高度
  705. */
  706. const setDialogStyle = (resize = false) => {
  707. nextTick(() => {
  708. let clientHeight = window.innerHeight;
  709. let clientWidth = window.innerWidth;
  710. let gapSafe = 40;
  711. if (dialogStyle.dialogHeight > clientHeight - gapSafe) {
  712. dialogStyle.dialogHeight = clientHeight - gapSafe;
  713. } else {
  714. if(resize) {
  715. dialogStyle.dialogHeight = 680;
  716. }
  717. }
  718. if(dialogStyle.dialogContentWidth > clientWidth - gapSafe) {
  719. dialogStyle.dialogContentWidth = clientWidth - gapSafe;
  720. } else {
  721. if(resize) {
  722. dialogStyle.dialogContentWidth = 1080;
  723. }
  724. }
  725. })
  726. };
  727. const selectCurrencyPopHandle = () => {
  728. Report.reportLog({
  729. pageSource: Report.pageSource.currencySelectorPage,
  730. businessType: Report.businessType.pageView,
  731. });
  732. if(baseFormData.rewardType === RewardType.custom) {
  733. showCustomizedRewardEditPopup.value = true
  734. } else {
  735. showCurrencyPop.value = true;
  736. nextTick(() => {
  737. if(currencyListDom.value) {
  738. currencyListDom.value.getCurrencyInfoList && currencyListDom.value.getCurrencyInfoList({pageNum: 1});
  739. }
  740. })
  741. }
  742. }
  743. const saveDiscordGuildInfo = () => {
  744. let {guildId, inviteCode, inviteUrl} = discordInviteInfo.value;
  745. //保存服务器信息
  746. Report.reportLog({
  747. pageSource: Report.pageSource.publisherDialog,
  748. businessType: Report.businessType.buttonClick,
  749. objectType: Report.objectType.saveDiscordGuildData
  750. }, {
  751. reportData: discordInviteInfo.value
  752. });
  753. if(guildId && inviteCode && inviteUrl) {
  754. saveInviteGuildInfo({
  755. params: {
  756. guildId,
  757. inviteCode,
  758. inviteUrl
  759. }
  760. })
  761. }
  762. }
  763. const confirm = () => {
  764. if (submitIng.value || iptErrMsgTxt.value) {
  765. return;
  766. }
  767. let { totalCount = 0 } = baseFormData;
  768. if (!totalCount) {
  769. return;
  770. }
  771. saveDiscordGuildInfo();
  772. submitRequest();
  773. };
  774. /**
  775. * 货币列表-选中货币
  776. */
  777. const selectCurrency = (params) => {
  778. let { currencies } = params;
  779. tempCurrentCurrencyList.value = currencies;
  780. if (currencies.length > 1) {
  781. showCurrencyPop.value = false;
  782. showCurrencySelect.value = true;
  783. } else {
  784. selectCurrencyAfter(currencies[0])
  785. }
  786. };
  787. const selectCurrencyAfter = (params, openWindow = true) => {
  788. tempCurrentCurrencyInfo.value = params;
  789. showCurrencySelect.value = false;
  790. currentCurrencyInfo.value = params;
  791. setLocalSelectCurrencyInfo(currentCurrencyInfo.value);
  792. if (openWindow === false) {
  793. return
  794. };
  795. if (params.currencyCode != "USD" && params.balance < params.minAmount) {
  796. let tokenSymbol = params.currencyCode == 'USD' ? 'USD' : params.tokenSymbol;
  797. messageBoxBlock({
  798. title: `Whether to deposit ${tokenSymbol}`,
  799. content: `Insufficient ${tokenSymbol} balance`,
  800. });
  801. } else {
  802. setCurrentCurrencyListInfo(tempCurrentCurrencyList.value);
  803. showCurrencyPop.value = false;
  804. finalAmountData.value.currencyCode = currentCurrencyInfo.value.currencyCode;
  805. resetFormIpt(false);
  806. onIptSetErrorTxt();
  807. }
  808. baseFormData.customizedReward = "";
  809. baseFormData.rewardType = RewardType.money;
  810. }
  811. const resetFormIpt = (clearMode = true) => {
  812. baseFormData.amountValue = "";
  813. baseFormData.totalCount = "";
  814. baseFormData.validityDuration = "";
  815. baseFormData.rewardType = RewardType.money;
  816. baseFormData.customizedReward = "";
  817. if(clearMode) {
  818. selectModeInfo.index = 0;
  819. selectModeInfo.type = publishModeList[selectModeInfo.index]['type'];
  820. baseFormData.type = selectModeInfo.type;
  821. }
  822. }
  823. const setLocalSelectCurrencyInfo = (params = {}) => {
  824. setChromeStorage({ selectCurrencyInfo : JSON.stringify(params)})
  825. }
  826. const setCurrentCurrencyListInfo = (params = {}) => {
  827. setChromeStorage({ selectCurrencyList : JSON.stringify(params)})
  828. }
  829. /**
  830. * 获取完货币列表
  831. */
  832. const setCurrentCurrencyInfo = (params) => {
  833. }
  834. const messageBoxBlock = ({ title = "", content = "" }) => {
  835. showMessageBox.value = true;
  836. messageBoxData.value.title = title;
  837. messageBoxData.value.content = content;
  838. };
  839. /**
  840. * 确定
  841. */
  842. const messageBoxConfirm = () => {
  843. showMessageBox.value = false;
  844. goTopUp();
  845. };
  846. /**
  847. * 取消
  848. */
  849. const messageBoxCancel = () => {
  850. currentCurrencyInfo.value = tempCurrentCurrencyInfo.value;
  851. setLocalSelectCurrencyInfo(currentCurrencyInfo.value);
  852. setCurrentCurrencyListInfo(tempCurrentCurrencyList.value);
  853. showMessageBox.value = false;
  854. showCurrencyPop.value = false;
  855. showCurrencySelect.value = false;
  856. resetFormIpt(false);
  857. onIptSetErrorTxt();
  858. };
  859. /**
  860. * 去充值
  861. */
  862. const goTopUp = () => {
  863. Report.reportLog({
  864. pageSource: Report.pageSource.rechargePage,
  865. businessType: Report.businessType.pageView,
  866. });
  867. showComType.value = 'topUp';
  868. }
  869. /*
  870. * 自定义封面
  871. */
  872. const customCoverImg = () => {
  873. customPosterInfo.value = {}
  874. if (Object.keys(customPosterData.value).length > 0) {
  875. customPosterInfo.value = customPosterData.value;
  876. }
  877. showComType.value = 'poster';
  878. customShowNewImage.value = false;
  879. setChromeStorage({ custom_poster_guide: Date.now() });
  880. }
  881. /**
  882. * 充值done事件
  883. */
  884. const topUpDone = () => {
  885. currentCurrencyInfo.value = tempCurrentCurrencyInfo.value;
  886. showCurrencyPop.value = false;
  887. showCurrencySelect.value = false;
  888. showComType.value = 'default';
  889. onIptSetErrorTxt();
  890. asyncTokenRechRecord((res) => {
  891. if(res.code == 0 && res.data && res.data.length) {
  892. let currencyInfo = res.data[0];
  893. if(currencyInfo.currencyCode == currentCurrencyInfo.value.currencyCode) {
  894. currentCurrencyInfo.value.balance = currencyInfo.balance;
  895. onIptSetErrorTxt()
  896. }
  897. }
  898. })
  899. }
  900. /**
  901. * 更新货币余额
  902. */
  903. const updateCurrencyBanlce = () => {
  904. if(!refreshRotate.value) {
  905. refreshRotate.value = true;
  906. setTimeout(() => {
  907. refreshRotate.value = false;
  908. }, 1000)
  909. }
  910. asyncTokenRechRecord((res) => {
  911. if(res.code == 0 && res.data && res.data.length) {
  912. let currencyInfo = res.data[0];
  913. if(currencyInfo.currencyCode == currentCurrencyInfo.value.currencyCode) {
  914. currentCurrencyInfo.value.balance = currencyInfo.balance;
  915. }
  916. }
  917. })
  918. }
  919. /**
  920. * 同步链上交易
  921. */
  922. const asyncTokenRechRecord = (cb) => {
  923. if(asyncIng.value) {
  924. return;
  925. }
  926. asyncIng.value = true;
  927. syncChainTokenRechargeRecord({
  928. params: {
  929. currencyCode: currentCurrencyInfo.value.currencyCode
  930. }
  931. }).then(res => {
  932. asyncIng.value = false;
  933. cb && cb(res)
  934. }).catch((err) => {
  935. asyncIng.value = false;
  936. })
  937. }
  938. /**
  939. * 提交表单请求
  940. */
  941. const submitRequest = async () => {
  942. let {
  943. amountValue = 0,
  944. totalCount = 0,
  945. rewardType = RewardType.money,
  946. customizedReward = ""
  947. } = baseFormData;
  948. baseFormData.amountCurrencyCode = currentCurrencyInfo.value.currencyCode;
  949. // 组装提交参数
  950. let finishConditions = [];
  951. for (let i = 0; i < formList.length; i++) {
  952. let item = {};
  953. item.type = formList[i]["type"];
  954. if (item.type == TaskType.twitterFollow && atUserList.value.length) {
  955. // follow 参数
  956. let relatedUsers = atUserList.value.filter(item => item.name);
  957. item.relatedUsers = relatedUsers;
  958. finishConditions.push(item);
  959. } else if (formList[i]["type"] == TaskType.joinDiscord) {
  960. // join discord
  961. if(formList[i]["checked"] && formList[i]["text"]) {
  962. item.bizData = JSON.stringify({inviteUrl: formList[i]["text"]});
  963. finishConditions.push(item);
  964. }
  965. } else if (formList[i]["checked"]) {
  966. // 其余任务
  967. finishConditions.push(item);
  968. }
  969. }
  970. let receiveConditions = openAntiBot.value ? "" : [];
  971. let validityDuration = '';
  972. if(baseFormData.type == PlayType.lottery) {
  973. //小时转毫秒
  974. let unit = process.env.NODE_ENV != 'production' ? 60 * 1000 : 60 * 60 * 1000;
  975. // let unit = 60 * 60 * 1000
  976. validityDuration = baseFormData.validityDuration * unit;
  977. } else {
  978. validityDuration = '';
  979. }
  980. // 提交参数
  981. let formData = {
  982. amountValue,
  983. totalCount,
  984. finishConditions,
  985. receiveConditions,
  986. type: baseFormData.type,
  987. posterType: 1,
  988. validityDuration,
  989. rewardType
  990. };
  991. if(rewardType === RewardType.custom) {
  992. // 通用奖品 类型的活动,添加奖品名称
  993. formData.customizedReward = customizedReward;
  994. delete formData.amountValue;
  995. } else {
  996. // 货币类型 添加货币code
  997. formData.amountCurrencyCode = baseFormData.amountCurrencyCode;
  998. formData.payAmountValue = baseFormData.payAmountValue;
  999. }
  1000. submitIng.value = true;
  1001. // 自定义封面
  1002. if (Object.keys(customPosterData.value).length > 0) {
  1003. formData['posterType'] = 2;
  1004. if (customPosterData.value && customPosterData.value.after) {
  1005. formData['customPosterInstalled'] = customPosterData.value.after.objectKey || ''
  1006. }
  1007. if (customPosterData.value && customPosterData.value.before) {
  1008. formData['customPosterUninstalled'] = customPosterData.value.before.objectKey || ''
  1009. }
  1010. }
  1011. // 法币支付需要计算费率
  1012. if(formData.amountCurrencyCode == "USD") {
  1013. // 获取充值金额
  1014. await calcRechPayAmount({
  1015. currencyCode: currentCurrencyInfo.value.currencyCode,
  1016. orderAmountValue: baseFormData.amountValue,
  1017. payChannel: 'ach'
  1018. });
  1019. }
  1020. let data = {
  1021. params: {
  1022. postBizData: JSON.stringify(formData),
  1023. postSrc: 1, //1 twitter
  1024. postType: 1, //1 红包
  1025. },
  1026. };
  1027. postPublish(data).then((res) => {
  1028. submitIng.value = false;
  1029. if (res.code == 0) {
  1030. publishRes = res.data;
  1031. postId.value = res.data.postId;
  1032. Report.reportLog({
  1033. pageSource: Report.pageSource.previewPage,
  1034. businessType: Report.businessType.pageView,
  1035. });
  1036. showComType.value = "preview";
  1037. previewFontSize.value = calcFontSize(baseFormData.amountValue, 238, 56);
  1038. isBack.value = false;
  1039. } else {
  1040. console.log(res);
  1041. }
  1042. })
  1043. .catch((err) => {
  1044. console.log(err);
  1045. });
  1046. };
  1047. const calcFontSize = (str, domWidth, maxSize) => {
  1048. let lenstr = str.length;
  1049. let num = parseInt(domWidth / lenstr);
  1050. let fontSize = num < maxSize ? num : maxSize
  1051. return fontSize;
  1052. }
  1053. /**
  1054. * 初始化提交参数
  1055. */
  1056. const initParams = () => {
  1057. resetFormIpt();
  1058. // clear follow value
  1059. atUserList.value = [];
  1060. submitIng.value = false;
  1061. isBack.value = false;
  1062. showCurrencyPop.value = false;
  1063. showCurrencySelect.value = false;
  1064. openAntiBot.value = false;
  1065. tempCurrentCurrencyInfo.value = {};
  1066. currentCurrencyInfo.value = {};
  1067. publishType.value = 'REDPACKET';
  1068. // clear discord value
  1069. setDiscordIptTxt({text: ''});
  1070. discordInviteInfo.value = {};
  1071. customPosterInfo.value = {};
  1072. customPosterData.value = {};
  1073. };
  1074. const setDiscordIptTxt = ({text}) => {
  1075. const index = formList.findIndex(item => item.type == TaskType.joinDiscord);
  1076. formList[index]['text'] = text;
  1077. }
  1078. const calcRechPayAmount = async (params) => {
  1079. let res = await calcRechargePayAmount({
  1080. params : params
  1081. })
  1082. if (res.code == 0) {
  1083. let { feeDesc } = res.data;
  1084. payConfig.value.feeDesc = feeDesc;
  1085. finalAmountData.value = res.data;
  1086. }
  1087. return res.data;
  1088. }
  1089. /**
  1090. * 支付完成回调
  1091. */
  1092. const payFinish = (params) => {
  1093. let {payStatus} = params;
  1094. // 余额支付
  1095. payStatusHandle(payStatus);
  1096. };
  1097. const payStatusHandle = (payStatus) => {
  1098. //支付状态 0:未支付,1:支付成功,2:支付失败,3:已关闭,4:已退款
  1099. switch (payStatus) {
  1100. case 1:
  1101. emits("postPublishFinish", { publishRes });
  1102. showComType.value = "default";
  1103. initParams();
  1104. break;
  1105. case 2:
  1106. break;
  1107. case 3:
  1108. break;
  1109. case 4:
  1110. break;
  1111. }
  1112. }
  1113. /**
  1114. * follow组件触发新增关注人
  1115. */
  1116. const addFollowUser = (params) => {
  1117. atUserList.value.push(params);
  1118. };
  1119. const setFollowUser = (params) => {
  1120. atUserList.value[params.index]["name"] = params.name;
  1121. };
  1122. const delFollowUser = (params) => {
  1123. atUserList.value.splice(params.index, 1);
  1124. };
  1125. const onAmountInput = () => {
  1126. let val = baseFormData.amountValue;
  1127. // val = val.replace(/[^\d^\.]+/g, "");
  1128. val = val.replace(/^\D*(\d*(?:\.\d{0,18})?).*$/g, '$1');
  1129. const maxCount = baseFormData.rewardType === RewardType.money ? Number.MAX_SAFE_INTEGER : 100000000;
  1130. if(val == '00') {
  1131. val = '0'
  1132. }
  1133. if(val.indexOf('.') > -1){ //校验 例:00.12 => 0.12
  1134. let arr = val.split('.');
  1135. if(arr[0].startsWith('0')) {
  1136. let num = +arr[0];
  1137. val = num + '.' + arr[1];
  1138. }
  1139. }
  1140. if (baseFormData.rewardType === RewardType.custom) {
  1141. const maxCount = 100000000;
  1142. val = val.replace(/^(0)*/, '').replace(/\./, ''); // 通用奖品类型 过滤掉起始位的0和小数点符号
  1143. if (val > maxCount) {
  1144. val = maxCount
  1145. }
  1146. baseFormData.totalCount = val;
  1147. }
  1148. baseFormData.amountValue = val;
  1149. setInputErrorMsg({from: 'amount', type:'input'});
  1150. return val;
  1151. };
  1152. const onCountInput = () => {
  1153. let val = baseFormData.totalCount;
  1154. const maxCount = 100000000;
  1155. if (val == 0) {
  1156. val = "";
  1157. }
  1158. val = val.replace(/^\D*(\d*(?:\.\d{0,18})?).*$/g, '$1');
  1159. if(val > maxCount) {
  1160. val = maxCount
  1161. }
  1162. baseFormData.totalCount = val;
  1163. setInputErrorMsg({from: 'count', type:'input'});
  1164. return val;
  1165. };
  1166. const onValidityDurationInput = () => {
  1167. validityDurationHandler()
  1168. let val = setInputErrorMsg();
  1169. return val;
  1170. }
  1171. const onValidityDurationBlur = () => {
  1172. validityDurationHandler();
  1173. let val = setInputErrorMsg();
  1174. return val;
  1175. }
  1176. const validityDurationHandler = () => {
  1177. let val = baseFormData.validityDuration;
  1178. if (val == 0) {
  1179. val = "";
  1180. } else if(val > lotteryMaxHourDuration) {
  1181. val = lotteryMaxHourDuration+'';
  1182. }
  1183. val = val.replace(/[^\d]/g, "");
  1184. baseFormData.validityDuration = val;
  1185. return val;
  1186. }
  1187. /**
  1188. * 金额输入失焦
  1189. */
  1190. const onAmountBlur = () => {
  1191. setInputErrorMsg({from: 'amount', type:'blur'});
  1192. };
  1193. /**
  1194. * count失焦,校验输入结果
  1195. */
  1196. const onCountBlur = () => {
  1197. setInputErrorMsg({from: 'count', type:'blur'});
  1198. };
  1199. /**
  1200. * 输入结果金额和数量 (金额/数量)是否小于最小货币单位
  1201. */
  1202. const calcIptValue = (cb) => {
  1203. let amountValue = baseFormData.amountValue;
  1204. let totalCount = baseFormData.totalCount;
  1205. let flag = true;
  1206. if (!amountValue || !totalCount) {
  1207. return {
  1208. flag
  1209. };
  1210. }
  1211. if (math.format(math.evaluate(`${baseFormData.amountValue} / ${baseFormData.totalCount}`)) < +currentCurrencyInfo.value.minAmount) {
  1212. flag = false;
  1213. }
  1214. return {
  1215. flag,
  1216. count: Math.floor(math.format(math.evaluate(`${baseFormData.amountValue} / ${currentCurrencyInfo.value.minAmount}`)))
  1217. }
  1218. };
  1219. /**
  1220. * 设置输入提示语
  1221. */
  1222. const setInputErrorMsg = () => {
  1223. onIptSetErrorTxt();
  1224. };
  1225. /**
  1226. * 输入时 检测设置错误信息
  1227. */
  1228. const onIptSetErrorTxt = (params = {}) => {
  1229. if((baseFormData.rewardType === RewardType.money && !currentCurrencyInfo.value.currencyCode)
  1230. || (baseFormData.rewardType === RewardType.custom && !baseFormData.customizedReward)) {
  1231. iptErrMsgTxt.value = "Select a reward"
  1232. } else if (!baseFormData.amountValue || baseFormData.amountValue == '0') {
  1233. iptErrMsgTxt.value = "Enter an amount";
  1234. } else if (!baseFormData.totalCount || baseFormData.totalCount == '0') {
  1235. iptErrMsgTxt.value = "Enter the number of winners";
  1236. } else if(baseFormData.rewardType === RewardType.money && +baseFormData.amountValue <= +currentCurrencyInfo.value.balance) {
  1237. // 输入金额 小于 余额
  1238. let res = calcIptValue();
  1239. if (!res.flag) {
  1240. iptErrMsgTxt.value = `${baseFormData.amountValue} ${currentCurrencyInfo.value.tokenSymbol} Can send up to ${res.count} winners`;
  1241. } else {
  1242. if(baseFormData.type == PlayType.lottery && !baseFormData.validityDuration) {
  1243. iptErrMsgTxt.value = "Enter Automatically Draw";
  1244. } else {
  1245. //清空错误提示
  1246. iptErrMsgTxt.value = "";
  1247. if(params.actionType != 'discord_blur') {
  1248. setDiscordErrTxt({getDuildId: true});
  1249. }
  1250. }
  1251. }
  1252. } else if(baseFormData.type == PlayType.lottery && !baseFormData.validityDuration) {
  1253. // 抽奖模式 没有输入时长
  1254. iptErrMsgTxt.value = "Enter Automatically Draw";
  1255. } else {
  1256. setDiscordErrTxt({getDuildId: true}, () => {
  1257. iptErrMsgTxt.value = '';
  1258. });
  1259. }
  1260. }
  1261. /**
  1262. * 监听开关触发事件
  1263. */
  1264. const formSwitchChange = (val, params, index) => {
  1265. closeDiscordTask(val, params, index);
  1266. }
  1267. const closeDiscordTask = (val, params, index) => {
  1268. if(params.type == TaskType.joinDiscord) {
  1269. if(!val) {
  1270. //错误类型 discord 清空discord错误校验
  1271. if(iptErrType == 'discord') {
  1272. iptErrMsgTxt.value = '';
  1273. formList[index]['text'] = '';
  1274. onIptSetErrorTxt();
  1275. }
  1276. } else {
  1277. onIptSetErrorTxt();
  1278. }
  1279. }
  1280. }
  1281. /** 监听 discord 输入 */
  1282. const onIptDiscordAddress = (e, index) => {
  1283. let val = formList[index].text;
  1284. let checked = formList[index].checked;
  1285. if(val && !checked) {
  1286. checked = true;
  1287. formList[index].checked = checked;
  1288. formList[index].text = formList[index].text.replace(/\s/g,'');
  1289. } else if(!val){
  1290. discordInviteInfo.value = {};
  1291. }
  1292. onIptDiscordDebounce()
  1293. }
  1294. const onBlurDiscordAddress = (e, index) => {
  1295. setDiscordErrTxt({fromType: 'discord', showPop: false, actionType: 'discord_blur'});
  1296. }
  1297. const getDiscordIptData = () => {
  1298. let discordItem = formList.find(item => item.type == TaskType.joinDiscord);
  1299. return discordItem;
  1300. }
  1301. /**
  1302. * 设置输入discord错误提示信息
  1303. */
  1304. const setDiscordErrTxt = (params = {showPop: false}, cb) => {
  1305. let discordData = getDiscordIptData() || {};
  1306. if(discordData.checked) {
  1307. if(discordData.text) {
  1308. let validata = checkInviteUrl(discordData.text);
  1309. if(validata) {
  1310. getDiscordInviteInfo({inviteUrl: discordData.text, getDuildId: params.getDuildId}, (res) => {
  1311. console.log('discordData',res)
  1312. // 未知的邀请链接
  1313. if(res.inviteCode != res.data.code || !res.data.guildId) {
  1314. iptErrMsgTxt.value = discordIptErrTxt;
  1315. iptErrType = 'discord';
  1316. } else {
  1317. if(res.data.expires !== null) {
  1318. // 不是永久邀请链接
  1319. iptErrMsgTxt.value = discordIptNerverExpiresErrTxt;
  1320. iptErrType = '';
  1321. } else {
  1322. if(iptErrMsgTxt.value) {
  1323. iptErrMsgTxt.value = '';
  1324. iptErrType = '';
  1325. }
  1326. if(params.showPop && res.data) {
  1327. showDiscordInvitePop.value = true;
  1328. setTimeout(() => {
  1329. showDiscordInvitePop.value = false;
  1330. }, 2000)
  1331. }
  1332. if(params.fromType == 'discord') {
  1333. onIptSetErrorTxt();
  1334. }
  1335. }
  1336. }
  1337. cb && cb(res)
  1338. })
  1339. } else {
  1340. iptErrMsgTxt.value = discordIptErrTxt;
  1341. iptErrType = 'discord';
  1342. }
  1343. } else {
  1344. if(params.actionType == 'discord_blur') {
  1345. onIptSetErrorTxt({acitonType: 'discord_blur'});
  1346. } else {
  1347. // 设置空提示
  1348. iptErrMsgTxt.value = discordIptEmptyErrTxt;
  1349. iptErrType = 'discord';
  1350. }
  1351. }
  1352. } else {
  1353. cb && cb();
  1354. }
  1355. }
  1356. const onIptDiscordDebounce = debounce(function() {
  1357. setDiscordErrTxt({fromType: 'discord', showPop: true});
  1358. }, 800)
  1359. /**
  1360. * 校验 discord邀请url
  1361. */
  1362. const checkInviteUrl = (inviteUrl) => {
  1363. let flag = false;
  1364. const INVITE_URL_PREFIX_1 = 'https://discord.gg/';
  1365. const INVITE_URL_PREFIX_2 = 'https://discord.com/invite/';
  1366. const INVITE_URL_PREFIX_3 = 'http://discord.gg/';
  1367. const INVITE_URL_PREFIX_4 = 'http://discord.com/invite/';
  1368. const INVITE_URL_PREFIX_5 = 'discord.gg/';
  1369. const INVITE_URL_PREFIX_6 = 'discord.com/invite/';
  1370. 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]
  1371. if(inviteUrl) {
  1372. if(arr.indexOf(inviteUrl) > -1) {
  1373. flag = false;
  1374. } else {
  1375. let isPass = false;
  1376. for(let i = 0; i < arr.length; i++) {
  1377. let item = arr[i];
  1378. if(inviteUrl.startsWith(item)) {
  1379. isPass = true;
  1380. break;
  1381. }
  1382. }
  1383. flag = isPass;
  1384. }
  1385. }
  1386. return flag;
  1387. }
  1388. /**获取discord 邀请信息 */
  1389. const getDiscordInviteInfo = ({inviteUrl, getDuildId}, cb) => {
  1390. if(!inviteUrl) return;
  1391. let inviteCode = '';
  1392. let arr = inviteUrl.split('/');
  1393. if(arr.length > 0) {
  1394. inviteCode = arr[arr.length - 1];
  1395. }
  1396. if(!getDuildId && discordInviteInfo.value.guildId && discordInviteInfo.value.inviteCode == inviteCode) {
  1397. return;
  1398. }
  1399. getInviteGuildInfo({
  1400. inviteCode
  1401. }).then(res => {
  1402. let resData = inviteGuildResHandler(res, {inviteCode, inviteUrl});
  1403. if(resData.data.guildId) {
  1404. cb && cb(resData);
  1405. } else {
  1406. //DISCORD 接口未获取到服务器信息 resdata
  1407. Report.reportLog({
  1408. pageSource: Report.pageSource.publisherDialog,
  1409. businessType: Report.businessType.buttonClick,
  1410. objectType: Report.objectType.getDiscordGuildNoData
  1411. }, {
  1412. resData: resData
  1413. });
  1414. getGuildInfoByOpenApi({inviteCode}, cb);
  1415. }
  1416. }).catch((err) => {
  1417. //DISCORD 接口 catch
  1418. Report.reportLog({
  1419. pageSource: Report.pageSource.publisherDialog,
  1420. businessType: Report.businessType.buttonClick,
  1421. objectType: Report.objectType.getDiscordGuildCatch
  1422. }, {
  1423. err: err
  1424. });
  1425. let errMsg = err;
  1426. if(typeof errMsg == 'object') {
  1427. errMsg = JSON.stringify(err);
  1428. }
  1429. if(errMsg.indexOf('code 404') > -1) {
  1430. discordInviteInfo.value = {};
  1431. iptErrMsgTxt.value = discordIptErrTxt;
  1432. } else {
  1433. getGuildInfoByOpenApi({inviteCode}, cb);
  1434. }
  1435. });
  1436. }
  1437. const getGuildInfoByOpenApi = (params, cb) => {
  1438. let { inviteCode } = params;
  1439. getInviteGuildInfoByOpenApi({
  1440. inviteCode
  1441. }).then(res => {
  1442. let resData = inviteGuildResHandler(res, {inviteCode, inviteUrl});
  1443. if(resData.data.guildId) {
  1444. cb && cb(resData);
  1445. } else {
  1446. //OPENAPI 接口未获取到服务器信息 resdata
  1447. Report.reportLog({
  1448. pageSource: Report.pageSource.publisherDialog,
  1449. businessType: Report.businessType.buttonClick,
  1450. objectType: Report.objectType.getDiscordGuildOpenApiNoData
  1451. }, {
  1452. resData: resData
  1453. });
  1454. }
  1455. }).catch((err) => {
  1456. // OPENAPI 接口 catch 限频
  1457. Report.reportLog({
  1458. pageSource: Report.pageSource.publisherDialog,
  1459. businessType: Report.businessType.buttonClick,
  1460. objectType: Report.objectType.getDiscordGuildOpenApiCatch
  1461. }, {
  1462. err: err
  1463. });
  1464. if(iptErrMsgTxt.value && iptErrType == 'discord') {
  1465. iptErrMsgTxt.value = '';
  1466. iptErrType = '';
  1467. }
  1468. });
  1469. }
  1470. const inviteGuildResHandler = (res, params) => {
  1471. let {inviteCode, inviteUrl} = params;
  1472. if(!res) {
  1473. res = {};
  1474. }
  1475. let {name, icon, id} = res.guild || {};
  1476. icon = icon && id ? `https://cdn.discordapp.com/icons/${id}/${icon}.png` : '';
  1477. let resData = {
  1478. inviteCode,
  1479. data: {
  1480. code: res.code,
  1481. guildId: id,
  1482. inviteUrl,
  1483. inviteCode,
  1484. expires: res.expires_at,
  1485. name,
  1486. icon,
  1487. }
  1488. }
  1489. if(res.code == inviteCode) {
  1490. discordInviteInfo.value = resData.data;
  1491. } else {
  1492. discordInviteInfo.value = {};
  1493. iptErrMsgTxt.value = discordIptErrTxt;
  1494. }
  1495. return resData;
  1496. };
  1497. /**
  1498. * 获取支付配置(paypalClientId)
  1499. */
  1500. const setPayConfig = () => {
  1501. getPayConfig({
  1502. params: {},
  1503. }).then((res) => {
  1504. if (res.code == 0) {
  1505. payConfig.value = res.data;
  1506. }
  1507. });
  1508. };
  1509. /**
  1510. * 获取配置
  1511. */
  1512. const setFrontConfig = () => {
  1513. getFrontConfig({
  1514. params: {},
  1515. }).then((res) => {
  1516. if (res.code == 0) {
  1517. lotteryMaxHourDuration = res.data.lotteryMaxHourDuration;
  1518. toolBoxPageData.postEditorLinkInputDescImage = res.data.postEditorLinkInputDescImage;
  1519. toolBoxPageData.postEditorDefaultLinkTitle = res.data.postEditorDefaultLinkTitle;
  1520. }
  1521. });
  1522. };
  1523. /**
  1524. * 默认获取上次选中的货币信息
  1525. */
  1526. const getLocalCurrencyInfoByCode = () => {
  1527. if(!currentCurrencyInfo.value.currencyCode) {
  1528. getCurrencyInfo();
  1529. }
  1530. }
  1531. const getCurrencyInfo = async (_params) => {
  1532. let { loop = false} = _params || {};
  1533. let {accessToken = ''} = await getChromeStorage('userInfo') || {};
  1534. if (accessToken) {
  1535. let {currencyCode = ''} = await getChromeStorage('selectCurrencyInfo') || {};
  1536. if(currencyCode) {
  1537. let currencyInfoRes = await getCurrencyByCode({currencyCode});
  1538. if(currencyInfoRes.code == 0 && currencyInfoRes.data) {
  1539. currentCurrencyInfo.value = currencyInfoRes.data;
  1540. tempCurrentCurrencyInfo.value = currencyInfoRes.data;
  1541. if(!loop) {
  1542. onIptSetErrorTxt();
  1543. }
  1544. }
  1545. }
  1546. getChromeStorage('selectCurrencyList', (res) => {
  1547. if (showCurrencySelect.value === false) {
  1548. tempCurrentCurrencyList.value = res;
  1549. }
  1550. })
  1551. }
  1552. }
  1553. const getCurrencyByCode = async (params) => {
  1554. let res = await getCurrencyInfoByCode({
  1555. params: {
  1556. currencyCode: params.currencyCode
  1557. }
  1558. })
  1559. return res || {};
  1560. }
  1561. const selectPublishMode = (params, index) => {
  1562. selectModeInfo.index = index;
  1563. selectModeInfo.type = params.type;
  1564. baseFormData.type = params.type;
  1565. setInputErrorMsg();
  1566. }
  1567. const clickLeftTab = (params, index) => {
  1568. publishType.value = params.type;
  1569. }
  1570. const onToolBoxPageChange = (params) => {
  1571. toolBoxPageData.activePage = params.page;
  1572. };
  1573. const toolBoxPublishFinish = (params) => {
  1574. toolBoxPageData.activePage = 'EDITOR';
  1575. emits("postPublishFinish", { publishRes: params.publishRes });
  1576. }
  1577. // 截图相关
  1578. const showDialog = () => {
  1579. cropperDialog.value = true;
  1580. }
  1581. const hiddenDialog = () => {
  1582. cropperDialog.value = false;
  1583. cropperLoading.value = false;
  1584. }
  1585. const selectImage = (option) => {
  1586. // 设置图片
  1587. cropperOption.value.img = option.file
  1588. // 选取比例
  1589. if (option && option.type && option.type == 2) {
  1590. cropperType.value = 'after';
  1591. cropperOption.value.fixedNumber = [1, 1];
  1592. } else {
  1593. cropperType.value = 'before';
  1594. cropperOption.value.fixedNumber = [16, 8.396];
  1595. }
  1596. nextTick(() => {
  1597. showDialog()
  1598. })
  1599. }
  1600. const confirmImage = () => {
  1601. let contentType = 'image/png';
  1602. cropperLoading.value = true;
  1603. if (refCropper.value) {
  1604. refCropper.value.getCropBlob(imgData => {
  1605. uploadSignature({
  1606. params: {
  1607. bizType: 1,
  1608. fileType: 1,
  1609. contentType: contentType,
  1610. fileSuffix: 'png',
  1611. }
  1612. }).then(res => {
  1613. let { code, data } = res;
  1614. if (code === 0) {
  1615. let reader = new FileReader()
  1616. reader.readAsArrayBuffer(imgData)
  1617. reader.onload = function(e) {
  1618. let execFile = e.target.result;
  1619. uploadFile({
  1620. url: data.url,
  1621. data: new Blob([execFile]),
  1622. headers: {
  1623. 'Authorization': data.authorization,
  1624. 'x-amz-date': data.date,
  1625. 'Content-Type': contentType
  1626. }
  1627. }).then(res => {
  1628. let { status } = res
  1629. if (status == 200) {
  1630. successImage(data)
  1631. }
  1632. }).finally(() => {
  1633. cropperLoading.value = false;
  1634. })
  1635. }
  1636. }
  1637. })
  1638. })
  1639. }
  1640. }
  1641. const successImage = (data) => {
  1642. hiddenDialog()
  1643. // setPosterInfo
  1644. customPosterInfo.value[cropperType.value] = data;
  1645. }
  1646. const confirmData = (data) => {
  1647. close()
  1648. customPosterData.value = customPosterInfo.value;
  1649. }
  1650. /**
  1651. * 显示通用奖品名称编辑框
  1652. */
  1653. const addCustomizedRewardHandle = () => {
  1654. showCurrencyPop.value = false;
  1655. showCustomizedRewardEditPopup.value = true;
  1656. }
  1657. const closeRewardPopup = () => {
  1658. showCustomizedRewardEditPopup.value = false;
  1659. }
  1660. const removeReward = () => {
  1661. showCustomizedRewardEditPopup.value = false;
  1662. resetFormIpt(false);
  1663. onIptSetErrorTxt();
  1664. }
  1665. // 提交通用奖品
  1666. const submitReward = (reward) => {
  1667. if(baseFormData.customizedReward !== reward) {
  1668. // 有修改时,重置之前已提交的数据
  1669. resetFormIpt(false);
  1670. }
  1671. baseFormData.rewardType = RewardType.custom;
  1672. baseFormData.customizedReward = reward;
  1673. showCustomizedRewardEditPopup.value = false;
  1674. currentCurrencyInfo.value = defaultCurrentCurrencyInfo;
  1675. setLocalSelectCurrencyInfo(defaultCurrentCurrencyInfo);
  1676. onIptSetErrorTxt();
  1677. }
  1678. const updateUSDeposit = async () => {
  1679. if(showDepositMessageBox.value) {
  1680. let currencyInfoRes = await getCurrencyByCode({currencyCode: currentCurrencyInfo.value.currencyCode});
  1681. if(currencyInfoRes.code == 0 && currencyInfoRes.data) {
  1682. currentCurrencyInfo.value = currencyInfoRes.data;
  1683. let {balance} = currencyInfoRes.data;
  1684. if(balance >= finalAmountData.value.orderAmountValue) {
  1685. USDepositStatus.value = 'SUCCESS';
  1686. }
  1687. }
  1688. }
  1689. };
  1690. const depositAchCancel = async () => {
  1691. showDepositMessageBox.value = false;
  1692. let currencyInfoRes = await getCurrencyByCode({currencyCode: currentCurrencyInfo.value.currencyCode});
  1693. if(currencyInfoRes.code == 0 && currencyInfoRes.data) {
  1694. currentCurrencyInfo.value = currencyInfoRes.data;
  1695. let {balance} = currencyInfoRes.data;
  1696. if(balance >= finalAmountData.value.orderAmountValue) {
  1697. USDepositStatus.value = 'SUCCESS';
  1698. }
  1699. }
  1700. }
  1701. const depositAchConfirm = async () => {
  1702. let currencyInfoRes = await getCurrencyByCode({currencyCode: currentCurrencyInfo.value.currencyCode});
  1703. if(currencyInfoRes.code == 0 && currencyInfoRes.data) {
  1704. showDepositMessageBox.value = false;
  1705. currentCurrencyInfo.value = currencyInfoRes.data;
  1706. let {balance} = currencyInfoRes.data;
  1707. if(balance >= finalAmountData.value.orderAmountValue) {
  1708. USDepositStatus.value = 'SUCCESS';
  1709. payButtonDom.value && payButtonDom.value.balancePay();
  1710. } else {
  1711. message.info('Deposit failed, please try again later');
  1712. }
  1713. }
  1714. }
  1715. const onPageVisbile = () => {
  1716. document.addEventListener('visibilitychange', function () {
  1717. let isHidden = document.hidden;
  1718. if (!isHidden) {
  1719. updateUSDeposit();
  1720. }
  1721. });
  1722. }
  1723. onMounted(() => {
  1724. setFrontConfig();
  1725. setPayConfig();
  1726. getLocalCurrencyInfoByCode();
  1727. onPageVisbile();
  1728. window.addEventListener('resize', function () {
  1729. setDialogStyle(true);
  1730. })
  1731. // showNewImage
  1732. getChromeStorage('custom_poster_guide', (info) => {
  1733. if (!info) {
  1734. customShowNewImage.value = true
  1735. }
  1736. })
  1737. });
  1738. </script>
  1739. <style lang="scss" scoped>
  1740. :deep() .ant-switch {
  1741. background-color: #E9ECEE;
  1742. height: 14px;
  1743. line-height: 16px;
  1744. min-width: 36px;
  1745. }
  1746. :deep() .ant-switch-checked {
  1747. background-color: #AED8F5 !important;
  1748. }
  1749. :deep() .ant-switch::after {
  1750. width: 20px;
  1751. height: 20px;
  1752. top: -4px;
  1753. left: -1px;
  1754. }
  1755. :deep() .ant-switch-checked::after {
  1756. background-color: #1D9BF0 !important;
  1757. margin-left: 3px;
  1758. left: 100% !important;
  1759. }
  1760. .overlay {
  1761. position: fixed;
  1762. top: 0;
  1763. right: 0;
  1764. bottom: 0;
  1765. left: 0;
  1766. z-index: 1000;
  1767. width: 100%;
  1768. height: 100%;
  1769. background-color: rgba(0, 0, 0, 0.5);
  1770. overflow: auto;
  1771. .content {
  1772. height: 620px;
  1773. background: #ffffff;
  1774. border-radius: 20px;
  1775. position: absolute;
  1776. left: 50%;
  1777. top: 50%;
  1778. transform: translate(-50%, -50%);
  1779. box-sizing: border-box;
  1780. z-index: 2000;
  1781. max-height: 825px;
  1782. .pop-mask {
  1783. width: 100%;
  1784. height:100%;
  1785. position: absolute;
  1786. z-index:900;
  1787. }
  1788. .body {
  1789. box-sizing: border-box;
  1790. height: calc(100% - 48px);
  1791. display: flex;
  1792. position: relative;
  1793. .body-content {
  1794. display:flex;
  1795. width:100%;
  1796. }
  1797. .currency-pop {
  1798. position: absolute;
  1799. width: 375px;
  1800. height: 480px;
  1801. top: 85px;
  1802. left: 88px;
  1803. z-index: 1000;
  1804. box-shadow: 0px 4px 30px rgba(0, 0, 0, 0.3);
  1805. background-color: #fff;
  1806. border-radius: 20px;
  1807. overflow-y: auto;
  1808. }
  1809. .currency-pop-select {
  1810. position: absolute;
  1811. width: 375px;
  1812. max-height: 480px;
  1813. top: 85px;
  1814. left: 88px;
  1815. z-index: 1000;
  1816. box-shadow: 0px 4px 30px rgba(0, 0, 0, 0.3);
  1817. background-color: #fff;
  1818. border-radius: 20px;
  1819. overflow-y: scroll;
  1820. }
  1821. .left,
  1822. .right {
  1823. height: 100%;
  1824. }
  1825. .left {
  1826. width: 50px;
  1827. display: flex;
  1828. flex-direction: column;
  1829. align-items: center;
  1830. .tab-item {
  1831. width: 100%;
  1832. height: 55px;
  1833. display: flex;
  1834. align-items: center;
  1835. justify-content: center;
  1836. cursor: pointer;
  1837. }
  1838. .active-tab {
  1839. background-color: #D2EAFC;
  1840. }
  1841. .bottom {
  1842. .icon {
  1843. display: block;
  1844. margin-bottom: 26px;
  1845. }
  1846. }
  1847. }
  1848. .right {
  1849. width: calc(100% - 50px);
  1850. box-sizing: border-box;
  1851. position: relative;
  1852. border-left: 1px solid #ececec;
  1853. .form-wrapper {
  1854. padding: 18px 18px 18px 18px;
  1855. height: calc(100% - 80px);
  1856. overflow: auto;
  1857. box-sizing: border-box;
  1858. display: flex;
  1859. .task-wrapper {
  1860. width: 480px;
  1861. }
  1862. .form-cell-item {
  1863. height: 100%;
  1864. .title {
  1865. display: flex;
  1866. align-items: center;
  1867. font-weight: 500;
  1868. font-size: 15px;
  1869. .icon {
  1870. width: 20px;
  1871. height: 20px;
  1872. margin-right: 5px;
  1873. }
  1874. }
  1875. .form-cell-content {
  1876. margin-top: 12px;
  1877. box-sizing: border-box;
  1878. }
  1879. }
  1880. .base-form-wrapper {
  1881. width: 450px;
  1882. margin-right: 30px;
  1883. .form-cell-content {
  1884. .select-mode-ele {
  1885. display: flex;
  1886. cursor: pointer;
  1887. img:first-child {
  1888. margin-right: 10px;
  1889. }
  1890. img {
  1891. -webkit-user-drag: none;
  1892. width: 220px;
  1893. height: 90px;
  1894. }
  1895. }
  1896. .form-base {
  1897. margin-top: 20px;
  1898. border: 1px solid #D1D9DD;
  1899. border-radius: 14px;
  1900. box-sizing: border-box;
  1901. padding-left: 14px;
  1902. .item {
  1903. box-sizing: border-box;
  1904. padding: 7px 0;
  1905. min-height: 76px;
  1906. display: flex;
  1907. align-items: center;
  1908. justify-content: space-between;
  1909. input {
  1910. width: 178px;
  1911. text-align: right;
  1912. font-weight: 700;
  1913. font-size: 26px;
  1914. border: none;
  1915. outline: none;
  1916. box-sizing: border-box;
  1917. }
  1918. input::placeholder {
  1919. color: #c5c5c5;
  1920. }
  1921. input:disabled {
  1922. color: #c5c5c5;
  1923. background-color: #fff;
  1924. }
  1925. input {
  1926. padding-right: 16px;
  1927. }
  1928. .label {
  1929. font-weight: 500;
  1930. font-size: 15px;
  1931. display: flex;
  1932. align-items: center;
  1933. .icon {
  1934. width: 20px;
  1935. height: 20px;
  1936. margin-right: 8px;
  1937. }
  1938. }
  1939. }
  1940. .currency-select-wrapper {
  1941. overflow: hidden;
  1942. .currency-select {
  1943. cursor: pointer;
  1944. background: #1D9BF0;
  1945. padding: 6px 10px;
  1946. border-radius: 12px;
  1947. color: #fff;
  1948. width: max-content;
  1949. max-width: 234px;
  1950. .text {
  1951. word-break: break-all;
  1952. }
  1953. .arrow {
  1954. margin-left: 5px;
  1955. }
  1956. }
  1957. .selected {
  1958. background: #F4F4F4 !important;
  1959. color: #000 !important;
  1960. }
  1961. }
  1962. .winners-count-input {
  1963. border-top: 1px solid #D1D9DD;
  1964. .msg {
  1965. font-weight: 400;
  1966. font-size: 12px;
  1967. color: #A39F9F;
  1968. margin-top: 8px
  1969. }
  1970. }
  1971. .automatically-input {
  1972. border-top: 1px solid #D1D9DD;
  1973. .input-wrapper {
  1974. margin-right: 16px;
  1975. box-sizing: border-box;
  1976. input {
  1977. padding-right: 4px !important;
  1978. }
  1979. .unit {
  1980. font-weight: 700;
  1981. font-size: 26px;
  1982. opacity: 0.5;
  1983. }
  1984. }
  1985. }
  1986. }
  1987. }
  1988. }
  1989. .currency-operation {
  1990. position: relative;
  1991. box-sizing: border-box;
  1992. display: flex;
  1993. align-items: center;
  1994. margin-top: 8px;
  1995. .balance,
  1996. .amount {
  1997. display: flex;
  1998. align-items: center;
  1999. }
  2000. .amount {
  2001. font-weight: 400;
  2002. font-size: 12px;
  2003. color: #A39F9F;
  2004. img {
  2005. margin-left: 6px;
  2006. cursor: pointer;
  2007. }
  2008. }
  2009. .top-up {
  2010. font-weight: 500;
  2011. font-size: 12px;
  2012. color: #1D9BF0;
  2013. cursor: pointer;
  2014. margin-left: 4px;
  2015. }
  2016. }
  2017. .form-label {
  2018. margin-top: 14px;
  2019. margin-bottom: 10px;
  2020. font-weight: 500;
  2021. font-size: 14px;
  2022. display: flex;
  2023. align-items: center;
  2024. justify-content: space-between;
  2025. .icon-add-task {
  2026. cursor: pointer;
  2027. }
  2028. }
  2029. .form-require {
  2030. box-sizing: border-box;
  2031. border-radius: 15px;
  2032. border: 1px solid #D1D9DD;
  2033. .form-item {
  2034. min-height: 54px;
  2035. display: flex;
  2036. align-items: center;
  2037. justify-content: space-between;
  2038. margin: 0 16px;
  2039. border-bottom: 1px solid #ececec;
  2040. padding: 8px 0;
  2041. box-sizing: border-box;
  2042. .item-left {
  2043. display: flex;
  2044. }
  2045. .label {
  2046. min-width: 76px;
  2047. display: flex;
  2048. align-items: center;
  2049. font-size: 15px;
  2050. font-weight: 500;
  2051. .icon {
  2052. margin-right: 10px;
  2053. }
  2054. }
  2055. .control {
  2056. min-width: 258px;
  2057. margin-left: 6px;
  2058. box-sizing: border-box;
  2059. position: relative;
  2060. .discord-address {
  2061. border: none;
  2062. outline: none;
  2063. color: #1D9BF0;
  2064. font-weight: 500;
  2065. font-size: 14px;
  2066. width: 100%;
  2067. height: 34px;
  2068. padding-left: 15px;
  2069. }
  2070. .discord-address::placeholder {
  2071. color: #c5c5c5;
  2072. }
  2073. .discord-invite-info {
  2074. position: absolute;
  2075. top: 40px;
  2076. left: 0;
  2077. box-shadow: 0px 4px 30px rgba(0, 0, 0, 0.3);
  2078. background: #fff;
  2079. border-radius: 16px;
  2080. padding: 16px;
  2081. box-sizing: border-box;
  2082. display: flex;
  2083. align-items: center;
  2084. cursor: pointer;
  2085. .icon {
  2086. width: 40px;
  2087. height: 40px;
  2088. margin-right: 10px;
  2089. border-radius: 50%;
  2090. }
  2091. .name {
  2092. font-weight: 600;
  2093. font-size: 16px;
  2094. color: #101419;
  2095. width: 193px;
  2096. height: 20px;
  2097. overflow: hidden;
  2098. white-space: nowrap;
  2099. text-overflow: ellipsis;
  2100. display: inline-block;
  2101. }
  2102. }
  2103. }
  2104. .icon-task-close {
  2105. margin-left: 6px;
  2106. cursor: pointer;
  2107. }
  2108. }
  2109. .border-hide {
  2110. border-bottom: none !important;
  2111. }
  2112. }
  2113. }
  2114. .giveaway-poster {
  2115. display: flex;
  2116. align-items: center;
  2117. flex-direction: row;
  2118. cursor: pointer;
  2119. height: 84px;
  2120. margin-top: 20px;
  2121. border-radius: 14px;
  2122. border: 1px solid #D1D9DD;
  2123. .show-img {
  2124. display: flex;
  2125. align-items: center;
  2126. justify-content: center;
  2127. width: 45px;
  2128. height: 60px;
  2129. margin-left: 14px;
  2130. margin-right: 14px;
  2131. position: relative;
  2132. }
  2133. .show-font {
  2134. position: relative;
  2135. font-size: 15px;
  2136. font-weight: 500;
  2137. .new {
  2138. width: 40px;
  2139. height: 18px;
  2140. margin-left: 10px;
  2141. }
  2142. }
  2143. .show-placeholder {
  2144. flex: 1;
  2145. color: #1D9BF0;
  2146. font-size: 15px;
  2147. font-weight: 500;
  2148. text-align: right;
  2149. }
  2150. .arrow {
  2151. width: 18px;
  2152. height: 24px;
  2153. margin-left: 2px;
  2154. margin-right: 12px;
  2155. }
  2156. }
  2157. .tips-wrapper {
  2158. margin: 16px 0 0 12px !important;
  2159. padding: 0px !important;
  2160. .title,
  2161. .row {
  2162. font-weight: 400;
  2163. font-size: 12px;
  2164. color: #A39F9F;
  2165. }
  2166. .row {
  2167. box-sizing: border-box;
  2168. line-height: 16px;
  2169. }
  2170. }
  2171. .submit-btn-wrapper {
  2172. width: 100%;
  2173. background: #fff;
  2174. position: absolute;
  2175. bottom: 18px;
  2176. left: 0;
  2177. box-sizing: border-box;
  2178. padding: 16px 18px 0 18px;
  2179. .submit-btn {
  2180. width: 100%;
  2181. height: 46px;
  2182. text-align: center;
  2183. background: #4a99e9;
  2184. border-radius: 100px;
  2185. color: #fff;
  2186. display: flex;
  2187. align-items: center;
  2188. justify-content: center;
  2189. font-size: 16px;
  2190. font-weight: 500;
  2191. cursor: pointer;
  2192. .icon-loading {
  2193. width: 20px;
  2194. height: 20px;
  2195. margin-right: 3px;
  2196. }
  2197. }
  2198. .disabled-submit {
  2199. background-color: #D9D9D9;
  2200. }
  2201. }
  2202. }
  2203. .fill-right {
  2204. width: 100% !important;
  2205. border-bottom-left-radius: 16px;
  2206. }
  2207. }
  2208. }
  2209. }
  2210. .icon-refresh-rotate {
  2211. transform: rotate(360deg);
  2212. transition-duration: 1s;
  2213. }
  2214. .payment {
  2215. .balance {
  2216. display: flex;
  2217. margin-right: 20px;
  2218. .icon {
  2219. width: 40px;
  2220. height: 40px;
  2221. }
  2222. .con {
  2223. padding: 0 5px;
  2224. .desc {
  2225. color: rgba($color: #000000, $alpha: 0.5);
  2226. font-size: 12px;
  2227. margin-bottom: 4px;
  2228. }
  2229. .price {
  2230. font-size: 14px;
  2231. font-weight: bold;
  2232. word-break: break-all;
  2233. }
  2234. }
  2235. .refresh {
  2236. width: 40px;
  2237. cursor: pointer;
  2238. margin-left: -5px;
  2239. }
  2240. }
  2241. .btn-wrap {
  2242. width: 100%;
  2243. height: 80px;
  2244. background-color: #fff;
  2245. position: absolute;
  2246. left: 0;
  2247. bottom: 0;
  2248. box-shadow: 0px -1px 0px #ececec;
  2249. border-bottom-right-radius: 16px;
  2250. padding: 12px 30px;
  2251. box-sizing: border-box;
  2252. display: flex;
  2253. align-items: center;
  2254. justify-content: flex-end;
  2255. border-bottom-left-radius: 16px;
  2256. z-index: 999;
  2257. .custom-submit {
  2258. width: 200px;
  2259. height: 50px;
  2260. background: #1D9BF0;
  2261. border-radius: 50px;
  2262. font-weight: 700;
  2263. font-size: 18px;
  2264. line-height: 50px;
  2265. text-align: center;
  2266. letter-spacing: 0.3px;
  2267. color: #FFFFFF;
  2268. cursor: pointer;
  2269. }
  2270. }
  2271. }
  2272. .dialog {
  2273. position: absolute;
  2274. z-index: 2002;
  2275. top: 50%;
  2276. left: 50%;
  2277. transform: translate(-50%, -50%);
  2278. width: 800px;
  2279. height: calc(100% - 100px);
  2280. border-radius: 20px;
  2281. background-color: #ffffff;
  2282. .corp-title {
  2283. display: flex;
  2284. height: 48px;
  2285. align-items: center;
  2286. .back {
  2287. cursor: pointer;
  2288. width: 24px;
  2289. height: 24px;
  2290. margin: 0 12px;
  2291. }
  2292. span {
  2293. font-size: 16px;
  2294. font-weight: 500;
  2295. }
  2296. }
  2297. .corp-content {
  2298. width: 472px;
  2299. margin: auto;
  2300. height: calc(100% - 130px);
  2301. }
  2302. .corp-footer {
  2303. display: flex;
  2304. align-items: center;
  2305. justify-content: right;
  2306. height: 80px;
  2307. text-align: right;
  2308. padding-right: 30px;
  2309. .confirm {
  2310. cursor: pointer;
  2311. border: 0;
  2312. width: 200px;
  2313. height: 50px;
  2314. color: #ffffff;
  2315. font-size: 18px;
  2316. font-weight: 700;
  2317. border-radius: 25px;
  2318. background: #1D9BF0;
  2319. &.disable {
  2320. background: #D9D9D9;
  2321. img {
  2322. width: 20px;
  2323. margin-right: 10px;
  2324. }
  2325. }
  2326. }
  2327. }
  2328. }
  2329. .dialog-mask {
  2330. position: absolute;
  2331. z-index: 2001;
  2332. top: 0;
  2333. left: 0;
  2334. width: 100%;
  2335. height: 100%;
  2336. background-color: rgba(0, 0, 0, 0.5);
  2337. }
  2338. :deep() .vue-cropper {
  2339. background-image: none;
  2340. }
  2341. :deep() .cropper-modal {
  2342. background: rgba(0, 0, 0, .05);
  2343. }
  2344. </style>