give-dialog.vue 94 KB

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