give-dialog.vue 92 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669
  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.usdLimitEnable 当前选中的token是否开启usd最小金额判断
  1245. */
  1246. const checkUsdMinNumber = (isInTemplate) => {
  1247. let forbiddenText = '';
  1248. const { usdPrice, luckdropPostConfig } = currentCurrencyInfo.value;
  1249. if (baseFormData.rewardType === RewardType.money && luckdropPostConfig?.usdLimitEnable === 1) {
  1250. const { amountValue, totalCount } = baseFormData;
  1251. if (luckdropPostConfig?.minTotalUsdAmount === 0 || luckdropPostConfig?.minAvgUsdAmount === 0) {
  1252. // 当前token允许的usd最小金额为0 或单个红包最小金额为0,则无限制
  1253. return forbiddenText;
  1254. } else {
  1255. const isAmountForbidden = luckdropPostConfig?.minTotalUsdAmount ? math.format(math.evaluate(amountValue * usdPrice)) < luckdropPostConfig.minTotalUsdAmount : false;
  1256. const isAvgForbidden = luckdropPostConfig?.minAvgUsdAmount ? math.format(math.evaluate(amountValue / totalCount * usdPrice)) < luckdropPostConfig.minAvgUsdAmount : false;
  1257. forbiddenText = isAmountForbidden && isAvgForbidden ?
  1258. `The prize pool must be above
  1259. ${isInTemplate ? ('<span class="font-color-1D9BF0">$' + luckdropPostConfig.minTotalUsdAmount + '</span>') : ('$' + luckdropPostConfig.minTotalUsdAmount)}
  1260. or the average prize must be above
  1261. ${isInTemplate ? ('<span class="font-color-1D9BF0">$' + luckdropPostConfig.minAvgUsdAmount +' per person.</span>' ): ('$' + luckdropPostConfig.minAvgUsdAmount + ' per person.') }`
  1262. : '';
  1263. }
  1264. }
  1265. return forbiddenText;
  1266. };
  1267. /**
  1268. * 设置输入提示语
  1269. */
  1270. const setInputErrorMsg = () => {
  1271. onIptSetErrorTxt();
  1272. };
  1273. /**
  1274. * 输入时 检测设置错误信息
  1275. */
  1276. const onIptSetErrorTxt = (params = {}) => {
  1277. if((baseFormData.rewardType === RewardType.money && !currentCurrencyInfo.value.currencyCode)
  1278. || (baseFormData.rewardType === RewardType.custom && !baseFormData.customizedReward)) {
  1279. iptErrMsgTxt.value = "Select a reward"
  1280. } else if (!baseFormData.amountValue || baseFormData.amountValue == '0') {
  1281. iptErrMsgTxt.value = "Enter an amount";
  1282. } else if (!baseFormData.totalCount || baseFormData.totalCount == '0') {
  1283. iptErrMsgTxt.value = "Enter the number of winners";
  1284. } else if (iptErrMsgTxt.value = checkUsdMinNumber()) {
  1285. // 最小法币金额限制
  1286. return isShowUsdMinMessage.value = true;
  1287. } else if(baseFormData.rewardType === RewardType.money && +baseFormData.amountValue <= +currentCurrencyInfo.value.balance) {
  1288. // 输入金额 小于 余额
  1289. let res = calcIptValue();
  1290. if (!res.flag) {
  1291. iptErrMsgTxt.value = `${baseFormData.amountValue} ${currentCurrencyInfo.value.tokenSymbol} Can send up to ${res.count} winners`;
  1292. } else {
  1293. if(baseFormData.type == PlayType.lottery && !baseFormData.validityDuration) {
  1294. iptErrMsgTxt.value = "Enter Automatically Draw";
  1295. } else {
  1296. //清空错误提示
  1297. iptErrMsgTxt.value = "";
  1298. if(params.actionType != 'discord_blur') {
  1299. setDiscordErrTxt({getDuildId: true});
  1300. }
  1301. }
  1302. }
  1303. } else if(baseFormData.type == PlayType.lottery && !baseFormData.validityDuration) {
  1304. // 抽奖模式 没有输入时长
  1305. iptErrMsgTxt.value = "Enter Automatically Draw";
  1306. } else {
  1307. setDiscordErrTxt({getDuildId: true}, () => {
  1308. iptErrMsgTxt.value = '';
  1309. });
  1310. }
  1311. }
  1312. /**
  1313. * 监听开关触发事件
  1314. */
  1315. const formSwitchChange = (val, params, index) => {
  1316. closeDiscordTask(val, params, index);
  1317. }
  1318. const closeDiscordTask = (val, params, index) => {
  1319. if(params.type == TaskType.joinDiscord) {
  1320. if(!val) {
  1321. //错误类型 discord 清空discord错误校验
  1322. if(iptErrType == 'discord') {
  1323. iptErrMsgTxt.value = '';
  1324. formList[index]['text'] = '';
  1325. onIptSetErrorTxt();
  1326. }
  1327. } else {
  1328. onIptSetErrorTxt();
  1329. }
  1330. }
  1331. }
  1332. /** 监听 discord 输入 */
  1333. const onIptDiscordAddress = (e, index) => {
  1334. let val = formList[index].text;
  1335. let checked = formList[index].checked;
  1336. if(val && !checked) {
  1337. checked = true;
  1338. formList[index].checked = checked;
  1339. formList[index].text = formList[index].text.replace(/\s/g,'');
  1340. } else if(!val){
  1341. discordInviteInfo.value = {};
  1342. }
  1343. onIptDiscordDebounce()
  1344. }
  1345. const onBlurDiscordAddress = (e, index) => {
  1346. setDiscordErrTxt({fromType: 'discord', showPop: false, actionType: 'discord_blur'});
  1347. }
  1348. const getDiscordIptData = () => {
  1349. let discordItem = formList.find(item => item.type == TaskType.joinDiscord);
  1350. return discordItem;
  1351. }
  1352. /**
  1353. * 设置输入discord错误提示信息
  1354. */
  1355. const setDiscordErrTxt = (params = {showPop: false}, cb) => {
  1356. let discordData = getDiscordIptData() || {};
  1357. if(discordData.checked) {
  1358. if(discordData.text) {
  1359. let validata = checkInviteUrl(discordData.text);
  1360. if(validata) {
  1361. getDiscordInviteInfo({inviteUrl: discordData.text, getDuildId: params.getDuildId}, (res) => {
  1362. console.log('discordData',res)
  1363. // 未知的邀请链接
  1364. if(res.inviteCode != res.data.code || !res.data.guildId) {
  1365. iptErrMsgTxt.value = discordIptErrTxt;
  1366. iptErrType = 'discord';
  1367. } else {
  1368. if(res.data.expires !== null) {
  1369. // 不是永久邀请链接
  1370. iptErrMsgTxt.value = discordIptNerverExpiresErrTxt;
  1371. iptErrType = '';
  1372. } else {
  1373. if(iptErrMsgTxt.value) {
  1374. iptErrMsgTxt.value = '';
  1375. iptErrType = '';
  1376. }
  1377. if(params.showPop && res.data) {
  1378. showDiscordInvitePop.value = true;
  1379. setTimeout(() => {
  1380. showDiscordInvitePop.value = false;
  1381. }, 2000)
  1382. }
  1383. if(params.fromType == 'discord') {
  1384. onIptSetErrorTxt();
  1385. }
  1386. }
  1387. }
  1388. cb && cb(res)
  1389. })
  1390. } else {
  1391. iptErrMsgTxt.value = discordIptErrTxt;
  1392. iptErrType = 'discord';
  1393. }
  1394. } else {
  1395. if(params.actionType == 'discord_blur') {
  1396. onIptSetErrorTxt({acitonType: 'discord_blur'});
  1397. } else {
  1398. // 设置空提示
  1399. iptErrMsgTxt.value = discordIptEmptyErrTxt;
  1400. iptErrType = 'discord';
  1401. }
  1402. }
  1403. } else {
  1404. cb && cb();
  1405. }
  1406. }
  1407. const onIptDiscordDebounce = debounce(function() {
  1408. setDiscordErrTxt({fromType: 'discord', showPop: true});
  1409. }, 800)
  1410. /**
  1411. * 校验 discord邀请url
  1412. */
  1413. const checkInviteUrl = (inviteUrl) => {
  1414. let flag = false;
  1415. const INVITE_URL_PREFIX_1 = 'https://discord.gg/';
  1416. const INVITE_URL_PREFIX_2 = 'https://discord.com/invite/';
  1417. const INVITE_URL_PREFIX_3 = 'http://discord.gg/';
  1418. const INVITE_URL_PREFIX_4 = 'http://discord.com/invite/';
  1419. const INVITE_URL_PREFIX_5 = 'discord.gg/';
  1420. const INVITE_URL_PREFIX_6 = 'discord.com/invite/';
  1421. 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]
  1422. if(inviteUrl) {
  1423. if(arr.indexOf(inviteUrl) > -1) {
  1424. flag = false;
  1425. } else {
  1426. let isPass = false;
  1427. for(let i = 0; i < arr.length; i++) {
  1428. let item = arr[i];
  1429. if(inviteUrl.startsWith(item)) {
  1430. isPass = true;
  1431. break;
  1432. }
  1433. }
  1434. flag = isPass;
  1435. }
  1436. }
  1437. return flag;
  1438. }
  1439. /**获取discord 邀请信息 */
  1440. const getDiscordInviteInfo = ({inviteUrl, getDuildId}, cb) => {
  1441. if(!inviteUrl) return;
  1442. let inviteCode = '';
  1443. let arr = inviteUrl.split('/');
  1444. if(arr.length > 0) {
  1445. inviteCode = arr[arr.length - 1];
  1446. }
  1447. if(!getDuildId && discordInviteInfo.value.guildId && discordInviteInfo.value.inviteCode == inviteCode) {
  1448. return;
  1449. }
  1450. getInviteGuildInfo({
  1451. inviteCode
  1452. }).then(res => {
  1453. let resData = inviteGuildResHandler(res, {inviteCode, inviteUrl});
  1454. if(resData.data.guildId) {
  1455. cb && cb(resData);
  1456. } else {
  1457. //DISCORD 接口未获取到服务器信息 resdata
  1458. Report.reportLog({
  1459. pageSource: Report.pageSource.publisherDialog,
  1460. businessType: Report.businessType.buttonClick,
  1461. objectType: Report.objectType.getDiscordGuildNoData
  1462. }, {
  1463. resData: resData
  1464. });
  1465. getGuildInfoByOpenApi({inviteCode}, cb);
  1466. }
  1467. }).catch((err) => {
  1468. //DISCORD 接口 catch
  1469. Report.reportLog({
  1470. pageSource: Report.pageSource.publisherDialog,
  1471. businessType: Report.businessType.buttonClick,
  1472. objectType: Report.objectType.getDiscordGuildCatch
  1473. }, {
  1474. err: err
  1475. });
  1476. let errMsg = err;
  1477. if(typeof errMsg == 'object') {
  1478. errMsg = JSON.stringify(err);
  1479. }
  1480. if(errMsg.indexOf('code 404') > -1) {
  1481. discordInviteInfo.value = {};
  1482. iptErrMsgTxt.value = discordIptErrTxt;
  1483. } else {
  1484. getGuildInfoByOpenApi({inviteCode}, cb);
  1485. }
  1486. });
  1487. }
  1488. const getGuildInfoByOpenApi = (params, cb) => {
  1489. let { inviteCode } = params;
  1490. getInviteGuildInfoByOpenApi({
  1491. inviteCode
  1492. }).then(res => {
  1493. let resData = inviteGuildResHandler(res, {inviteCode, inviteUrl});
  1494. if(resData.data.guildId) {
  1495. cb && cb(resData);
  1496. } else {
  1497. //OPENAPI 接口未获取到服务器信息 resdata
  1498. Report.reportLog({
  1499. pageSource: Report.pageSource.publisherDialog,
  1500. businessType: Report.businessType.buttonClick,
  1501. objectType: Report.objectType.getDiscordGuildOpenApiNoData
  1502. }, {
  1503. resData: resData
  1504. });
  1505. }
  1506. }).catch((err) => {
  1507. // OPENAPI 接口 catch 限频
  1508. Report.reportLog({
  1509. pageSource: Report.pageSource.publisherDialog,
  1510. businessType: Report.businessType.buttonClick,
  1511. objectType: Report.objectType.getDiscordGuildOpenApiCatch
  1512. }, {
  1513. err: err
  1514. });
  1515. if(iptErrMsgTxt.value && iptErrType == 'discord') {
  1516. iptErrMsgTxt.value = '';
  1517. iptErrType = '';
  1518. }
  1519. });
  1520. }
  1521. const inviteGuildResHandler = (res, params) => {
  1522. let {inviteCode, inviteUrl} = params;
  1523. if(!res) {
  1524. res = {};
  1525. }
  1526. let {name, icon, id} = res.guild || {};
  1527. icon = icon && id ? `https://cdn.discordapp.com/icons/${id}/${icon}.png` : '';
  1528. let resData = {
  1529. inviteCode,
  1530. data: {
  1531. code: res.code,
  1532. guildId: id,
  1533. inviteUrl,
  1534. inviteCode,
  1535. expires: res.expires_at,
  1536. name,
  1537. icon,
  1538. }
  1539. }
  1540. if(res.code == inviteCode) {
  1541. discordInviteInfo.value = resData.data;
  1542. } else {
  1543. discordInviteInfo.value = {};
  1544. iptErrMsgTxt.value = discordIptErrTxt;
  1545. }
  1546. return resData;
  1547. };
  1548. /**
  1549. * 获取支付配置(paypalClientId)
  1550. */
  1551. const setPayConfig = () => {
  1552. getPayConfig({
  1553. params: {},
  1554. }).then((res) => {
  1555. if (res.code == 0) {
  1556. payConfig.value = res.data;
  1557. }
  1558. });
  1559. };
  1560. /**
  1561. * 获取配置
  1562. */
  1563. const setFrontConfig = () => {
  1564. getFrontConfig({
  1565. params: {},
  1566. }).then((res) => {
  1567. if (res.code == 0) {
  1568. lotteryMaxHourDuration = res.data.lotteryMaxHourDuration;
  1569. toolBoxPageData.postEditorLinkInputDescImage = res.data.postEditorLinkInputDescImage;
  1570. toolBoxPageData.postEditorDefaultLinkTitle = res.data.postEditorDefaultLinkTitle;
  1571. }
  1572. });
  1573. };
  1574. /**
  1575. * 默认获取上次选中的货币信息
  1576. */
  1577. const getLocalCurrencyInfoByCode = () => {
  1578. if(!currentCurrencyInfo.value.currencyCode) {
  1579. getCurrencyInfo();
  1580. }
  1581. }
  1582. const getCurrencyInfo = async (_params) => {
  1583. let { loop = false} = _params || {};
  1584. let {accessToken = ''} = await getChromeStorage('userInfo') || {};
  1585. if (accessToken) {
  1586. let {currencyCode = ''} = await getChromeStorage('selectCurrencyInfo') || {};
  1587. if(currencyCode) {
  1588. let currencyInfoRes = await getCurrencyByCode({currencyCode});
  1589. if(currencyInfoRes.code == 0 && currencyInfoRes.data) {
  1590. currentCurrencyInfo.value = currencyInfoRes.data;
  1591. tempCurrentCurrencyInfo.value = currencyInfoRes.data;
  1592. if(!loop) {
  1593. onIptSetErrorTxt();
  1594. }
  1595. }
  1596. }
  1597. getChromeStorage('selectCurrencyList', (res) => {
  1598. if (showCurrencySelect.value === false) {
  1599. tempCurrentCurrencyList.value = res;
  1600. }
  1601. })
  1602. }
  1603. }
  1604. const getCurrencyByCode = async (params) => {
  1605. let res = await getCurrencyInfoByCode({
  1606. params: {
  1607. currencyCode: params.currencyCode
  1608. }
  1609. })
  1610. return res || {};
  1611. }
  1612. const selectPublishMode = (params, index) => {
  1613. selectModeInfo.index = index;
  1614. selectModeInfo.type = params.type;
  1615. baseFormData.type = params.type;
  1616. setInputErrorMsg();
  1617. }
  1618. const clickLeftTab = (params, index) => {
  1619. publishType.value = params.type;
  1620. }
  1621. const onToolBoxPageChange = (params) => {
  1622. toolBoxPageData.activePage = params.page;
  1623. };
  1624. const toolBoxPublishFinish = (params) => {
  1625. toolBoxPageData.activePage = 'EDITOR';
  1626. emits("postPublishFinish", { publishRes: params.publishRes });
  1627. }
  1628. // 截图相关
  1629. const showDialog = () => {
  1630. cropperDialog.value = true;
  1631. }
  1632. const hiddenDialog = () => {
  1633. cropperDialog.value = false;
  1634. cropperLoading.value = false;
  1635. }
  1636. const selectImage = (option) => {
  1637. // 设置图片
  1638. cropperOption.value.img = option.file
  1639. // 选取比例
  1640. if (option && option.type && option.type == 2) {
  1641. cropperType.value = 'after';
  1642. cropperOption.value.fixedNumber = [1, 1];
  1643. } else {
  1644. cropperType.value = 'before';
  1645. cropperOption.value.fixedNumber = [16, 8.396];
  1646. }
  1647. nextTick(() => {
  1648. showDialog()
  1649. })
  1650. }
  1651. const confirmImage = () => {
  1652. let contentType = 'image/png';
  1653. cropperLoading.value = true;
  1654. if (refCropper.value) {
  1655. refCropper.value.getCropBlob(imgData => {
  1656. uploadSignature({
  1657. params: {
  1658. bizType: 1,
  1659. fileType: 1,
  1660. contentType: contentType,
  1661. fileSuffix: 'png',
  1662. }
  1663. }).then(res => {
  1664. let { code, data } = res;
  1665. if (code === 0) {
  1666. let reader = new FileReader()
  1667. reader.readAsArrayBuffer(imgData)
  1668. reader.onload = function(e) {
  1669. let execFile = e.target.result;
  1670. uploadFile({
  1671. url: data.url,
  1672. data: new Blob([execFile]),
  1673. headers: {
  1674. 'Authorization': data.authorization,
  1675. 'x-amz-date': data.date,
  1676. 'Content-Type': contentType
  1677. }
  1678. }).then(res => {
  1679. let { status } = res
  1680. if (status == 200) {
  1681. successImage(data)
  1682. }
  1683. }).finally(() => {
  1684. cropperLoading.value = false;
  1685. })
  1686. }
  1687. }
  1688. })
  1689. })
  1690. }
  1691. }
  1692. const successImage = (data) => {
  1693. hiddenDialog()
  1694. // setPosterInfo
  1695. customPosterInfo.value[cropperType.value] = data;
  1696. }
  1697. const confirmData = (data) => {
  1698. close()
  1699. customPosterData.value = customPosterInfo.value;
  1700. }
  1701. /**
  1702. * 显示通用奖品名称编辑框
  1703. */
  1704. const addCustomizedRewardHandle = () => {
  1705. showCurrencyPop.value = false;
  1706. showCustomizedRewardEditPopup.value = true;
  1707. }
  1708. const closeRewardPopup = () => {
  1709. showCustomizedRewardEditPopup.value = false;
  1710. }
  1711. const removeReward = () => {
  1712. showCustomizedRewardEditPopup.value = false;
  1713. resetFormIpt(false);
  1714. onIptSetErrorTxt();
  1715. }
  1716. // 提交通用奖品
  1717. const submitReward = (reward) => {
  1718. if(baseFormData.customizedReward !== reward) {
  1719. // 有修改时,重置之前已提交的数据
  1720. resetFormIpt(false);
  1721. }
  1722. baseFormData.rewardType = RewardType.custom;
  1723. baseFormData.customizedReward = reward;
  1724. showCustomizedRewardEditPopup.value = false;
  1725. currentCurrencyInfo.value = defaultCurrentCurrencyInfo;
  1726. setLocalSelectCurrencyInfo(defaultCurrentCurrencyInfo);
  1727. onIptSetErrorTxt();
  1728. }
  1729. const updateUSDeposit = async () => {
  1730. if(showDepositMessageBox.value) {
  1731. let currencyInfoRes = await getCurrencyByCode({currencyCode: currentCurrencyInfo.value.currencyCode});
  1732. if(currencyInfoRes.code == 0 && currencyInfoRes.data) {
  1733. currentCurrencyInfo.value = currencyInfoRes.data;
  1734. let {balance} = currencyInfoRes.data;
  1735. if(balance >= finalAmountData.value.orderAmountValue) {
  1736. USDepositStatus.value = 'SUCCESS';
  1737. }
  1738. }
  1739. }
  1740. };
  1741. const depositAchCancel = async () => {
  1742. showDepositMessageBox.value = false;
  1743. let currencyInfoRes = await getCurrencyByCode({currencyCode: currentCurrencyInfo.value.currencyCode});
  1744. if(currencyInfoRes.code == 0 && currencyInfoRes.data) {
  1745. currentCurrencyInfo.value = currencyInfoRes.data;
  1746. let {balance} = currencyInfoRes.data;
  1747. if(balance >= finalAmountData.value.orderAmountValue) {
  1748. USDepositStatus.value = 'SUCCESS';
  1749. }
  1750. }
  1751. }
  1752. const depositAchConfirm = async () => {
  1753. let currencyInfoRes = await getCurrencyByCode({currencyCode: currentCurrencyInfo.value.currencyCode});
  1754. if(currencyInfoRes.code == 0 && currencyInfoRes.data) {
  1755. showDepositMessageBox.value = false;
  1756. currentCurrencyInfo.value = currencyInfoRes.data;
  1757. let {balance} = currencyInfoRes.data;
  1758. if(balance >= finalAmountData.value.orderAmountValue) {
  1759. USDepositStatus.value = 'SUCCESS';
  1760. payButtonDom.value && payButtonDom.value.balancePay();
  1761. } else {
  1762. message.info('Deposit failed, please try again later');
  1763. }
  1764. }
  1765. }
  1766. const onPageVisbile = () => {
  1767. document.addEventListener('visibilitychange', function () {
  1768. let isHidden = document.hidden;
  1769. if (!isHidden) {
  1770. updateUSDeposit();
  1771. }
  1772. });
  1773. }
  1774. onMounted(() => {
  1775. setFrontConfig();
  1776. setPayConfig();
  1777. getLocalCurrencyInfoByCode();
  1778. onPageVisbile();
  1779. window.addEventListener('resize', function () {
  1780. setDialogStyle(true);
  1781. })
  1782. // showNewImage
  1783. getChromeStorage('custom_poster_guide', (info) => {
  1784. if (!info) {
  1785. customShowNewImage.value = true
  1786. }
  1787. })
  1788. });
  1789. </script>
  1790. <style lang="scss">
  1791. .font-color-1D9BF0 {
  1792. color: #1D9BF0;
  1793. }
  1794. </style>
  1795. <style lang="scss" scoped>
  1796. :deep() .ant-switch {
  1797. background-color: #E9ECEE;
  1798. height: 14px;
  1799. line-height: 16px;
  1800. min-width: 36px;
  1801. }
  1802. :deep() .ant-switch-checked {
  1803. background-color: #AED8F5 !important;
  1804. }
  1805. :deep() .ant-switch::after {
  1806. width: 20px;
  1807. height: 20px;
  1808. top: -4px;
  1809. left: -1px;
  1810. }
  1811. :deep() .ant-switch-checked::after {
  1812. background-color: #1D9BF0 !important;
  1813. margin-left: 3px;
  1814. left: 100% !important;
  1815. }
  1816. .overlay {
  1817. position: fixed;
  1818. top: 0;
  1819. right: 0;
  1820. bottom: 0;
  1821. left: 0;
  1822. z-index: 1000;
  1823. width: 100%;
  1824. height: 100%;
  1825. background-color: rgba(0, 0, 0, 0.5);
  1826. overflow: auto;
  1827. .content {
  1828. height: 620px;
  1829. background: #ffffff;
  1830. border-radius: 20px;
  1831. position: absolute;
  1832. left: 50%;
  1833. top: 50%;
  1834. transform: translate(-50%, -50%);
  1835. box-sizing: border-box;
  1836. z-index: 2000;
  1837. max-height: 825px;
  1838. .pop-mask {
  1839. width: 100%;
  1840. height:100%;
  1841. position: absolute;
  1842. z-index:900;
  1843. }
  1844. .body {
  1845. box-sizing: border-box;
  1846. height: calc(100% - 48px);
  1847. display: flex;
  1848. position: relative;
  1849. .body-content {
  1850. display:flex;
  1851. width:100%;
  1852. }
  1853. .currency-pop {
  1854. position: absolute;
  1855. width: 375px;
  1856. height: 480px;
  1857. top: 85px;
  1858. left: 88px;
  1859. z-index: 1000;
  1860. box-shadow: 0px 4px 30px rgba(0, 0, 0, 0.3);
  1861. background-color: #fff;
  1862. border-radius: 20px;
  1863. overflow-y: auto;
  1864. }
  1865. .currency-pop-select {
  1866. position: absolute;
  1867. width: 375px;
  1868. max-height: 480px;
  1869. top: 85px;
  1870. left: 88px;
  1871. z-index: 1000;
  1872. box-shadow: 0px 4px 30px rgba(0, 0, 0, 0.3);
  1873. background-color: #fff;
  1874. border-radius: 20px;
  1875. overflow-y: scroll;
  1876. }
  1877. .left,
  1878. .right {
  1879. height: 100%;
  1880. }
  1881. .left {
  1882. width: 50px;
  1883. display: flex;
  1884. flex-direction: column;
  1885. align-items: center;
  1886. .tab-item {
  1887. width: 100%;
  1888. height: 55px;
  1889. display: flex;
  1890. align-items: center;
  1891. justify-content: center;
  1892. cursor: pointer;
  1893. }
  1894. .active-tab {
  1895. background-color: #D2EAFC;
  1896. }
  1897. .bottom {
  1898. .icon {
  1899. display: block;
  1900. margin-bottom: 26px;
  1901. }
  1902. }
  1903. }
  1904. .right {
  1905. width: calc(100% - 50px);
  1906. box-sizing: border-box;
  1907. position: relative;
  1908. border-left: 1px solid #ececec;
  1909. .form-wrapper {
  1910. padding: 18px 18px 18px 18px;
  1911. height: calc(100% - 80px);
  1912. overflow: auto;
  1913. box-sizing: border-box;
  1914. display: flex;
  1915. .task-wrapper {
  1916. width: 480px;
  1917. }
  1918. .form-cell-item {
  1919. height: 100%;
  1920. .title {
  1921. display: flex;
  1922. align-items: center;
  1923. font-weight: 500;
  1924. font-size: 15px;
  1925. .icon {
  1926. width: 20px;
  1927. height: 20px;
  1928. margin-right: 5px;
  1929. }
  1930. }
  1931. .form-cell-content {
  1932. margin-top: 12px;
  1933. box-sizing: border-box;
  1934. }
  1935. }
  1936. .base-form-wrapper {
  1937. width: 450px;
  1938. margin-right: 30px;
  1939. .form-cell-content {
  1940. .select-mode-ele {
  1941. display: flex;
  1942. cursor: pointer;
  1943. img:first-child {
  1944. margin-right: 10px;
  1945. }
  1946. img {
  1947. -webkit-user-drag: none;
  1948. width: 220px;
  1949. height: 90px;
  1950. }
  1951. }
  1952. .form-base {
  1953. margin-top: 20px;
  1954. border: 1px solid #D1D9DD;
  1955. border-radius: 14px;
  1956. box-sizing: border-box;
  1957. padding-left: 14px;
  1958. .item {
  1959. box-sizing: border-box;
  1960. padding: 7px 0;
  1961. min-height: 76px;
  1962. display: flex;
  1963. align-items: center;
  1964. justify-content: space-between;
  1965. input {
  1966. width: 178px;
  1967. text-align: right;
  1968. font-weight: 700;
  1969. font-size: 26px;
  1970. border: none;
  1971. outline: none;
  1972. box-sizing: border-box;
  1973. }
  1974. input::placeholder {
  1975. color: #c5c5c5;
  1976. }
  1977. input:disabled {
  1978. color: #c5c5c5;
  1979. background-color: #fff;
  1980. }
  1981. input {
  1982. padding-right: 16px;
  1983. }
  1984. .label {
  1985. font-weight: 500;
  1986. font-size: 15px;
  1987. display: flex;
  1988. align-items: center;
  1989. .icon {
  1990. width: 20px;
  1991. height: 20px;
  1992. margin-right: 8px;
  1993. }
  1994. }
  1995. }
  1996. .currency-select-wrapper {
  1997. overflow: hidden;
  1998. .currency-select {
  1999. cursor: pointer;
  2000. background: #1D9BF0;
  2001. padding: 6px 10px;
  2002. border-radius: 12px;
  2003. color: #fff;
  2004. width: max-content;
  2005. max-width: 234px;
  2006. .text {
  2007. word-break: break-all;
  2008. }
  2009. .arrow {
  2010. margin-left: 5px;
  2011. }
  2012. }
  2013. .selected {
  2014. background: #F4F4F4 !important;
  2015. color: #000 !important;
  2016. }
  2017. }
  2018. .winners-count-input {
  2019. border-top: 1px solid #D1D9DD;
  2020. .msg {
  2021. font-weight: 400;
  2022. font-size: 12px;
  2023. color: #A39F9F;
  2024. margin-top: 8px
  2025. }
  2026. }
  2027. .automatically-input {
  2028. border-top: 1px solid #D1D9DD;
  2029. .input-wrapper {
  2030. margin-right: 16px;
  2031. box-sizing: border-box;
  2032. input {
  2033. padding-right: 4px !important;
  2034. }
  2035. .unit {
  2036. font-weight: 700;
  2037. font-size: 26px;
  2038. opacity: 0.5;
  2039. }
  2040. }
  2041. }
  2042. }
  2043. }
  2044. }
  2045. .currency-operation {
  2046. position: relative;
  2047. box-sizing: border-box;
  2048. display: flex;
  2049. align-items: center;
  2050. margin-top: 8px;
  2051. .balance,
  2052. .amount {
  2053. display: flex;
  2054. align-items: center;
  2055. }
  2056. .amount {
  2057. font-weight: 400;
  2058. font-size: 12px;
  2059. color: #A39F9F;
  2060. img {
  2061. margin-left: 6px;
  2062. cursor: pointer;
  2063. }
  2064. }
  2065. .top-up {
  2066. font-weight: 500;
  2067. font-size: 12px;
  2068. color: #1D9BF0;
  2069. cursor: pointer;
  2070. margin-left: 4px;
  2071. }
  2072. }
  2073. .form-label {
  2074. margin-top: 14px;
  2075. margin-bottom: 10px;
  2076. font-weight: 500;
  2077. font-size: 14px;
  2078. display: flex;
  2079. align-items: center;
  2080. justify-content: space-between;
  2081. .icon-add-task {
  2082. cursor: pointer;
  2083. }
  2084. }
  2085. .form-require {
  2086. box-sizing: border-box;
  2087. border-radius: 15px;
  2088. border: 1px solid #D1D9DD;
  2089. .form-item {
  2090. min-height: 54px;
  2091. display: flex;
  2092. align-items: center;
  2093. justify-content: space-between;
  2094. margin: 0 16px;
  2095. border-bottom: 1px solid #ececec;
  2096. padding: 8px 0;
  2097. box-sizing: border-box;
  2098. .item-left {
  2099. display: flex;
  2100. }
  2101. .label {
  2102. min-width: 76px;
  2103. display: flex;
  2104. align-items: center;
  2105. font-size: 15px;
  2106. font-weight: 500;
  2107. .icon {
  2108. margin-right: 10px;
  2109. }
  2110. }
  2111. .control {
  2112. min-width: 258px;
  2113. margin-left: 6px;
  2114. box-sizing: border-box;
  2115. position: relative;
  2116. .discord-address {
  2117. border: none;
  2118. outline: none;
  2119. color: #1D9BF0;
  2120. font-weight: 500;
  2121. font-size: 14px;
  2122. width: 100%;
  2123. height: 34px;
  2124. padding-left: 15px;
  2125. }
  2126. .discord-address::placeholder {
  2127. color: #c5c5c5;
  2128. }
  2129. .discord-invite-info {
  2130. position: absolute;
  2131. top: 40px;
  2132. left: 0;
  2133. box-shadow: 0px 4px 30px rgba(0, 0, 0, 0.3);
  2134. background: #fff;
  2135. border-radius: 16px;
  2136. padding: 16px;
  2137. box-sizing: border-box;
  2138. display: flex;
  2139. align-items: center;
  2140. cursor: pointer;
  2141. .icon {
  2142. width: 40px;
  2143. height: 40px;
  2144. margin-right: 10px;
  2145. border-radius: 50%;
  2146. }
  2147. .name {
  2148. font-weight: 600;
  2149. font-size: 16px;
  2150. color: #101419;
  2151. width: 193px;
  2152. height: 20px;
  2153. overflow: hidden;
  2154. white-space: nowrap;
  2155. text-overflow: ellipsis;
  2156. display: inline-block;
  2157. }
  2158. }
  2159. }
  2160. .icon-task-close {
  2161. margin-left: 6px;
  2162. cursor: pointer;
  2163. }
  2164. }
  2165. .border-hide {
  2166. border-bottom: none !important;
  2167. }
  2168. }
  2169. }
  2170. .usd-min-message {
  2171. font-style: normal;
  2172. font-weight: 400;
  2173. font-size: 12px;
  2174. line-height: 16px;
  2175. letter-spacing: 0.3px;
  2176. color: #C88726;
  2177. margin-top: 8px;
  2178. }
  2179. .giveaway-poster {
  2180. display: flex;
  2181. align-items: center;
  2182. flex-direction: row;
  2183. cursor: pointer;
  2184. height: 84px;
  2185. margin-top: 20px;
  2186. border-radius: 14px;
  2187. border: 1px solid #D1D9DD;
  2188. .show-img {
  2189. display: flex;
  2190. align-items: center;
  2191. justify-content: center;
  2192. width: 45px;
  2193. height: 60px;
  2194. margin-left: 14px;
  2195. margin-right: 14px;
  2196. position: relative;
  2197. }
  2198. .show-font {
  2199. position: relative;
  2200. font-size: 15px;
  2201. font-weight: 500;
  2202. .new {
  2203. width: 40px;
  2204. height: 18px;
  2205. margin-left: 10px;
  2206. }
  2207. }
  2208. .show-placeholder {
  2209. flex: 1;
  2210. color: #1D9BF0;
  2211. font-size: 15px;
  2212. font-weight: 500;
  2213. text-align: right;
  2214. }
  2215. .arrow {
  2216. width: 18px;
  2217. height: 24px;
  2218. margin-left: 2px;
  2219. margin-right: 12px;
  2220. }
  2221. }
  2222. .tips-wrapper {
  2223. margin: 16px 0 0 12px !important;
  2224. padding: 0px !important;
  2225. .title,
  2226. .row {
  2227. font-weight: 400;
  2228. font-size: 12px;
  2229. color: #A39F9F;
  2230. }
  2231. .row {
  2232. box-sizing: border-box;
  2233. line-height: 16px;
  2234. }
  2235. }
  2236. .submit-btn-wrapper {
  2237. width: 100%;
  2238. background: #fff;
  2239. position: absolute;
  2240. bottom: 18px;
  2241. left: 0;
  2242. box-sizing: border-box;
  2243. padding: 16px 18px 0 18px;
  2244. .submit-btn {
  2245. width: 100%;
  2246. height: 46px;
  2247. text-align: center;
  2248. background: #4a99e9;
  2249. border-radius: 100px;
  2250. color: #fff;
  2251. display: flex;
  2252. align-items: center;
  2253. justify-content: center;
  2254. font-size: 16px;
  2255. font-weight: 500;
  2256. cursor: pointer;
  2257. .icon-loading {
  2258. width: 20px;
  2259. height: 20px;
  2260. margin-right: 3px;
  2261. }
  2262. }
  2263. .disabled-submit {
  2264. background-color: #D9D9D9;
  2265. }
  2266. }
  2267. }
  2268. .fill-right {
  2269. width: 100% !important;
  2270. border-bottom-left-radius: 16px;
  2271. }
  2272. }
  2273. }
  2274. }
  2275. .icon-refresh-rotate {
  2276. transform: rotate(360deg);
  2277. transition-duration: 1s;
  2278. }
  2279. .payment {
  2280. .balance {
  2281. display: flex;
  2282. margin-right: 20px;
  2283. .icon {
  2284. width: 40px;
  2285. height: 40px;
  2286. }
  2287. .con {
  2288. padding: 0 5px;
  2289. .desc {
  2290. color: rgba($color: #000000, $alpha: 0.5);
  2291. font-size: 12px;
  2292. margin-bottom: 4px;
  2293. }
  2294. .price {
  2295. font-size: 14px;
  2296. font-weight: bold;
  2297. word-break: break-all;
  2298. }
  2299. }
  2300. .refresh {
  2301. width: 40px;
  2302. cursor: pointer;
  2303. margin-left: -5px;
  2304. }
  2305. }
  2306. .btn-wrap {
  2307. width: 100%;
  2308. height: 80px;
  2309. background-color: #fff;
  2310. position: absolute;
  2311. left: 0;
  2312. bottom: 0;
  2313. box-shadow: 0px -1px 0px #ececec;
  2314. border-bottom-right-radius: 16px;
  2315. padding: 12px 30px;
  2316. box-sizing: border-box;
  2317. display: flex;
  2318. align-items: center;
  2319. justify-content: flex-end;
  2320. border-bottom-left-radius: 16px;
  2321. z-index: 999;
  2322. .custom-submit {
  2323. width: 200px;
  2324. height: 50px;
  2325. background: #1D9BF0;
  2326. border-radius: 50px;
  2327. font-weight: 700;
  2328. font-size: 18px;
  2329. line-height: 50px;
  2330. text-align: center;
  2331. letter-spacing: 0.3px;
  2332. color: #FFFFFF;
  2333. cursor: pointer;
  2334. }
  2335. }
  2336. }
  2337. .dialog {
  2338. position: absolute;
  2339. z-index: 2002;
  2340. top: 50%;
  2341. left: 50%;
  2342. transform: translate(-50%, -50%);
  2343. width: 800px;
  2344. height: calc(100% - 100px);
  2345. border-radius: 20px;
  2346. background-color: #ffffff;
  2347. .corp-title {
  2348. display: flex;
  2349. height: 48px;
  2350. align-items: center;
  2351. .back {
  2352. cursor: pointer;
  2353. width: 24px;
  2354. height: 24px;
  2355. margin: 0 12px;
  2356. }
  2357. span {
  2358. font-size: 16px;
  2359. font-weight: 500;
  2360. }
  2361. }
  2362. .corp-content {
  2363. width: 472px;
  2364. margin: auto;
  2365. height: calc(100% - 130px);
  2366. }
  2367. .corp-footer {
  2368. display: flex;
  2369. align-items: center;
  2370. justify-content: right;
  2371. height: 80px;
  2372. text-align: right;
  2373. padding-right: 30px;
  2374. .confirm {
  2375. cursor: pointer;
  2376. border: 0;
  2377. width: 200px;
  2378. height: 50px;
  2379. color: #ffffff;
  2380. font-size: 18px;
  2381. font-weight: 700;
  2382. border-radius: 25px;
  2383. background: #1D9BF0;
  2384. &.disable {
  2385. background: #D9D9D9;
  2386. img {
  2387. width: 20px;
  2388. margin-right: 10px;
  2389. }
  2390. }
  2391. }
  2392. }
  2393. }
  2394. .dialog-mask {
  2395. position: absolute;
  2396. z-index: 2001;
  2397. top: 0;
  2398. left: 0;
  2399. width: 100%;
  2400. height: 100%;
  2401. background-color: rgba(0, 0, 0, 0.5);
  2402. }
  2403. :deep() .vue-cropper {
  2404. background-image: none;
  2405. }
  2406. :deep() .cropper-modal {
  2407. background: rgba(0, 0, 0, .05);
  2408. }
  2409. </style>