give-dialog.vue 92 KB

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