1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010 |
- <template>
- <div class="overlay" v-if="visible">
- <div class="content"
- :style="{
- height: showComType === 'preview' ? 'calc(100vh - 40px)' : dialogStyle.dialogHeight + 'px',
- width: dialogStyle.dialogContentWidth + 'px',
- }">
- <div class="pop-mask"
- v-show="showCurrencyPop || showCurrencySelect"
- @click.stop="showCurrencyPop = false; showCurrencySelect=false">
- </div>
- <!-- head -->
- <give-dialog-head
- :title="publishType == 'REDPACKET' ? currentComData[showComType]['title'] : 'Tool Box'"
- :publishType="publishType"
- :showComType="showComType"
- :toolBoxPageData="toolBoxPageData"
- @close="close"></give-dialog-head>
- <!-- 内容 -->
- <div class="body">
- <!-- 充值组件 -->
- <top-up
- v-if="showComType == 'topUp'"
- :currentCurrencyInfo="tempCurrentCurrencyInfo"
- @topUpDone="topUpDone">
- </top-up>
- <!-- 自定义红包封面 -->
- <giveaway-poster
- v-else-if="showComType == 'poster'"
- :baseFormData="baseFormData"
- :currentCurrencyInfo="currentCurrencyInfo"
- :customPosterInfo="customPosterInfo"
- @selectImage="selectImage"
- @confirmData="confirmData">
- </giveaway-poster>
- <!-- 表单填写容器 -->
- <div class="body-content" v-else>
- <!-- 货币列表 -->
- <div class="currency-pop" v-show="showCurrencyPop">
- <currency-list
- ref="currencyListDom"
- :showGeneralLottery="showGeneralLottery"
- @selectCurrency="selectCurrency"
- @setCurrencyList="setCurrentCurrencyInfo"
- @addGeneralLottery="addCustomizedRewardHandle"></currency-list>
- </div>
- <!-- 通用奖品编辑弹窗 -->
- <div class="customized-reward-edit-popup" v-if="showCustomizedRewardEditPopup">
- <customized-reward-edit-popup
- ref="rewardEditDom"
- :customizedReward="baseFormData.customizedReward"
- :rewardType="baseFormData.rewardType"
- @closeRewardPopup="closeRewardPopup"
- @removeReward="removeReward"
- @submitReward="submitReward"></customized-reward-edit-popup>
- </div>
- <div class="currency-pop-select" v-show="showCurrencySelect">
- <currency-select
- ref="currencySelectDom"
- :list="tempCurrentCurrencyList"
- @selectCurrency="selectCurrencyAfter"></currency-select>
- </div>
- <div class="left" v-if="showComType != 'preview' && toolBoxPageData.activePage != 'PREVIEW'">
- <div class="tab-item"
- :class="{'active-tab': item.type == publishType}"
- v-for="(item, index) in leftTabList"
- :key="index"
- @click="clickLeftTab(item, index)"
- >
- <img class="icon" :src="item.icon"/>
- </div>
- </div>
- <div class="right"
- :class="{'fill-right': showComType == 'preview' || toolBoxPageData.activePage == 'PREVIEW'}">
- <global-tip :type="'2'"></global-tip>
- <template v-if="publishType == 'TOOL_BOX'">
- <tool-box
- :pageData="{
- 'linkInputDescImage': toolBoxPageData.postEditorLinkInputDescImage,
- 'defaultLinkTitle': toolBoxPageData.postEditorDefaultLinkTitle
- }"
- :activePage="toolBoxPageData.activePage" @onPageChange="onToolBoxPageChange"
- @toolBoxPublishFinish="toolBoxPublishFinish"></tool-box>
- </template>
- <template v-else>
- <div class="form-wrapper" v-if="showComType == 'default'">
- <div class="form-left-sheet">
- <div class="base-form-wrapper">
- <div class="form-cell-content">
- <div class="select-mode-ele">
- <template v-for="(item, index) in publishModeList" :key="index">
- <img class="img"
- :src="selectModeInfo.index == index ? item.imgActive : item.imgInActive"
- @click="selectPublishMode(item, index)">
- <img class="img-tips" :src="item.imgInfoSrc" v-if="selectModeInfo.index == index" />
- </template>
- </div>
- <!-- 金额 -->
- <div class="form-base">
- <div class="form-cell">
- <div class="cell-title">
- <img class="title-icon" :src="require('@/assets/svg/icon-form-amount.svg')" />
- Amount
- </div>
- <div class="cell-content flex">
- <div class="currency-select"
- :class="{'selected': currencySelectCpd}"
- @click="selectCurrencyPopHandle">
- <img class="icon"
- v-if="currentIconCpd"
- :src="currentIconCpd"/>
- <component-zoom width="100" :txt="currentPrizeCpd">
- <div class="text">
- {{currentPrizeCpd}}
- </div>
- </component-zoom>
- <img class="arrow"
- :src="currentArrowCpd"/>
- </div>
- <form-input class="margin-left-10"
- :suffix="baseFormData.rewardType === RewardType.custom ? 'items' : currentCurrencyInfo.currencyCode ? currentPrizeCpd : ''">
- <template v-slot:content>
- <input style="width: 100px"
- v-model="baseFormData.amountValue"
- placeholder="0"
- autofocus
- @input="onAmountInput"
- @blur="onAmountBlur"/>
- </template>
- </form-input>
- <form-input class="margin-left-10"
- v-if="currentCurrencyInfo.currencyCode != 'USD' && baseFormData.rewardType != RewardType.custom"
- prefix="=$"
- suffix="USD">
- <template v-slot:content>
- <input style="width: 85px"
- v-model="treasureFormData.usdEstimateOrderAmount"
- @input="onUsdEstimateOrderAmountInput"
- @blur="onUsdEstimateOrderAmountInput"
- placeholder="0"/>
- </template>
- </form-input>
- </div>
- <!-- 刷新按钮、充值 -->
- <div class="currency-operation"
- v-if="currentCurrencyInfo.currencyCode">
- <div class="amount">
- Balance:
- <a-tooltip :title="currentCurrencyInfo.balance">
- {{ getBit(currentCurrencyInfo.balance) }}
- </a-tooltip>
- <img :class="{ 'icon-refresh-rotate': refreshRotate }"
- :src="require('@/assets/svg/icon-form-refresh.svg')"
- @click="updateCurrencyBanlce"/>
- </div>
- <div v-if="currentCurrencyInfo.currencyCode != 'USD'"
- class="top-up"
- @click="goTopUp">Deposit</div>
- </div>
- <div class="usd-min-message" v-show="isShowUsdMinMessage" v-html="selectModeInfo.type != PlayType.treasure ? checkUsdMinNumber('inTemplate') : checkTreasureAmountRange('inTemplate')"></div>
- </div>
- <!-- 人数 -->
- <div class="form-cell">
- <div class="cell-title">
- <img class="title-icon" :src="require('@/assets/svg/icon-form-winners.svg')" />
- {{selectModeInfo.type != PlayType.treasure ? 'Winners' : 'Growing Target'}}
- </div>
- <div class="cell-content">
- <div class="count-input-wrapper">
- <form-input :suffix="selectModeInfo.type != PlayType.treasure ? 'People' : 'Follower'">
- <template v-slot:content>
- <input style="width: 120px"
- v-model="baseFormData.totalCount"
- placeholder="0"
- :disabled="baseFormData.rewardType === RewardType.custom"
- @input="onCountInput"
- @blur="onCountBlur"/>
- </template>
- </form-input>
- <div class="fans-unit-txt" v-if="selectModeInfo.type == PlayType.treasure && treasureFormData.fansUnitAmount">
- <span>${{treasureFormData.fansUnitAmount}}</span> per New Follower
- </div>
- </div>
- <div class="count-msg" v-show="selectModeInfo.type == PlayType.common">Recommend Winners 50~500</div>
- </div>
- </div>
- <!-- 开奖时间 -->
- <div class="form-cell" v-if="selectModeInfo.type == PlayType.lottery">
- <div class="cell-title">
- <img class="title-icon" :src="require('@/assets/svg/icon-form-time.svg')" />
- Automatically Draw in
- </div>
- <div class="cell-content">
- <form-input suffix="Hour">
- <template v-slot:content>
- <input v-model="baseFormData.validityDuration"
- placeholder="0"
- @input="onValidityDurationInput"
- @blur="onValidityDurationBlur"/>
- </template>
- </form-input>
- </div>
- </div>
- <!-- 夺宝 follow -->
- <div class="form-cell" v-if="selectModeInfo.type == PlayType.treasure">
- <div class="cell-title">
- <img class="title-icon" :src="require('@/assets/svg/icon-form-follow.svg')" />
- Follow
- </div>
- <div class="cell-content">
- <follow-input style="padding: 0"
- padding="10px 12px"
- :isAddSelf="!isBack"
- :atUserList="atUserList"
- @addUser="addFollowUser"
- @setUser="setFollowUser"
- @delUser="delFollowUser"></follow-input>
- </div>
- </div>
- <!-- 任务 -->
- <div class="form-cell" v-if="selectModeInfo.type != PlayType.treasure">
- <div class="cell-title">
- <img class="title-icon" :src="require('@/assets/svg/icon-form-task.svg')"/>
- Tasks
- </div>
- <div class="form-cell-content form-require">
- <!-- 转推、like、关注 -->
- <div v-for="(item, index) in formList"
- :key="index">
- <div v-if="item.show" class="form-item"
- :class="{ 'border-hide': formList.length - 1 == index }">
- <div class="item-left">
- <div class="label">
- <img class="icon" :src="item.icon"/>
- {{ item.label }}
- </div>
- <div class="control"
- v-if="item.nodeType == 'textarea'">
- <follow-input
- padding="4px 12px"
- :isAddSelf="!isBack"
- :atUserList="atUserList"
- @addUser="addFollowUser"
- @setUser="setFollowUser"
- @delUser="delFollowUser"></follow-input>
- </div>
- <div class="control"
- v-if="item.nodeType == 'input'">
- <div v-if="showDiscordInvitePop"
- class="discord-invite-info"
- @click="showDiscordInvitePop = false">
- <img class="icon" :src="discordInviteInfo.icon || require('@/assets/svg/icon-discord-mini.svg')" />
- <span class="name">{{discordInviteInfo.name}}</span>
- </div>
- <input v-model="item.text"
- placeholder="Enter discord invite link"
- class="discord-address"
- @input="onIptDiscordAddress($event, index)"
- @blur="onBlurDiscordAddress($event, index)" />
- </div>
- </div>
- <div>
- <a-switch
- v-if="item.type > 3"
- v-model:checked="item.checked"
- @change="formSwitchChange($event, item, index)"/>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- 提示 -->
- <ul class="tips-wrapper" v-if="selectModeInfo.type != PlayType.treasure">
- <li class="row" style="white-space:nowrap;">
- Rewards can only be claimed after the target user completes all tasks you set.
- </li>
- <li class="row">
- Each user can only receive a reward once per task.
- </li>
- <li class="row" v-show="selectModeInfo.type == PlayType.common">
- 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.
- </li>
- </ul>
- </div>
- </div>
- </div>
- <div class="form-right-sheet">
- <!-- 自定义封面事件 -->
- <div style="width: 375px;height: 500px; zoom: .74;margin-left: 80px">
- <custom-card-cover :data="{
- ...baseFormData,
- ...currentCurrencyInfo,
- usdEstimateOrderAmount: treasureFormData.usdEstimateOrderAmount,
- upGainAmountUsdValue: treasureFormData.upGainAmountUsdValue,
- currencyIconUrl: currentCurrencyInfo.iconPath,
- customPosterUrl: customPosterInfo && customPosterInfo.after && customPosterInfo.after.imagePath || '',
- userInfo: {
- nickName: userInfo.name,
- avatarUrl: userInfo.avatarUrl
- },
- }"></custom-card-cover>
- </div>
- <div class="custom-cover-btn"
- v-if="selectModeInfo.type != PlayType.treasure"
- @click="customCoverImg">
- <img :src="require('@/assets/svg/icon-custom-cover-btn.svg')" />
- Custom
- </div>
- </div>
- <div class="submit-btn-wrapper">
- <div class="submit-btn"
- :class="{ 'disabled-submit': iptErrMsgTxt != ''}"
- @click="confirm">
- <img class="icon-loading"
- v-if="submitIng"
- :src="require('@/assets/svg/icon-btn-loading.svg')"/>
- {{iptErrMsgTxt ? iptErrMsgTxt : 'NEXT'}}
- </div>
- </div>
- </div>
- <!-- 预览 -->
- <template v-else-if="showComType == 'preview'">
- <preview-sheet
- :baseFormData="{
- ...baseFormData,
- usdEstimateOrderAmount: treasureFormData.usdEstimateOrderAmount
- }"
- :upGainAmountUsdValue="treasureFormData.upGainAmountUsdValue"
- :currentCurrencyInfo="currentCurrencyInfo"
- :tempCurrentCurrencyInfo="tempCurrentCurrencyInfo"
- :publishRes="publishRes"
- :previewFontSize="previewFontSize"
- :customPosterData="customPosterData"
- :finalAmountData="finalAmountData"
- @onTopUpDone="topUpDone"
- @onUpdateCurrencyBanlce="updateCurrencyBanlce"></preview-sheet>
- </template>
- <!-- 支付按钮 -->
- <div class="payment" v-show="showComType == 'preview'">
- <pay-button
- ref="payButtonDom"
- v-if="isMoneyRewardCpd"
- :finalAmountData="finalAmountData"
- :payConfig="{
- feeDesc: payConfig.feeDesc,
- amount: baseFormData.amountValue,
- postId,
- }"
- :currentCurrencyInfo="currentCurrencyInfo"
- :USDepositStatus = "USDepositStatus"
- :bizType="selectModeInfo.type"
- @showDepositMask="showDepositMessageBox = true"
- @payFinish="payFinish">
- <template v-slot:balance>
- <div class="balance" v-if="Number(baseFormData.amountValue) <= Number(currentCurrencyInfo.balance) || currentCurrencyInfo.currencyCode == 'USD' ">
- <img class="icon" src="@/assets/subject/icon-balance.png" />
- <div class="con">
- <div class="desc">Balance</div>
- <div class="price">
- <template v-if="currentCurrencyInfo.currencyCode == 'USD'">
- $
- </template>
- {{currentCurrencyInfo.balance}}
- <template v-if="currentCurrencyInfo.currencyCode != 'USD'">
- {{currentCurrencyInfo.tokenSymbol}}
- </template>
- </div>
- </div>
- <img class="refresh"
- :class="{ 'icon-refresh-rotate': refreshRotate }"
- :src=" require('@/assets/svg/icon-form-refresh.svg')"
- @click="updateCurrencyBanlce"/>
- </div>
- </template>
- </pay-button>
- <div v-else class="btn-wrap" @click="payStatusHandle(1)"><div class="custom-submit">Confirm</div></div>
- </div>
- </template>
- </div>
- </div>
- </div>
- </div>
- <!-- 提示 -->
- <message-box
- :dialogVisible="showMessageBox"
- :title="messageBoxData.title"
- :content="messageBoxData.content"
- cancelTxt="Not yet"
- confirmTxt="Deposit"
- @cancel="messageBoxCancel"
- @confirm="messageBoxConfirm"></message-box>
- <!-- 预览页充值 -->
- <message-box
- :dialogVisible="showDepositMessageBox"
- title="Is the Deposit Completed?"
- @cancel="depositAchCancel"
- @confirm="depositAchConfirm"></message-box>
- <!-- 裁剪 -->
- <div class="dialog" v-if="cropperDialog">
- <div class="corp-title">
- <img class="back" :src="require('@/assets/svg/icon-back.svg')" @click="hiddenDialog" />
- <span>Crop</span>
- </div>
- <div class="corp-content">
- <vue-cropper
- ref="refCropper"
- :img="cropperOption.img"
- :output-type="cropperOption.outputType"
- :infoTrue="cropperOption.infoTrue"
- :full="cropperOption.full"
- :fixed="cropperOption.fixed"
- :fixed-number="cropperOption.fixedNumber"
- :auto-crop="cropperOption.autoCrop"
- :auto-crop-width="cropperOption.autoCropWidth"
- :auto-crop-height="cropperOption.autoCropHeight"
- :center-box="cropperOption.centerBox"
- :high="cropperOption.high"
- :max-img-size="cropperOption.max">
- </vue-cropper>
- </div>
- <div class="corp-footer">
- <button v-if="cropperLoading" class="confirm disable">
- <img :src=" require('@/assets/svg/icon-btn-loading.svg') " />
- <span>Confirm</span>
- </button>
- <button v-else class="confirm" @click="confirmImage">Confirm</button>
- </div>
- </div>
- <div class="dialog-mask" v-if="cropperDialog"></div>
- </div>
- </template>
- <script setup>
- import { ref, watch, reactive, defineProps, defineEmits, onMounted, nextTick, provide, computed } from "vue";
- import { postPublish, syncChainTokenRechargeRecord, getCurrencyInfoByCode, getUser } from "@/http/publishApi";
- import { getInviteGuildInfo, getInviteGuildInfoByOpenApi, saveInviteGuildInfo } from "@/http/discordApi";
- import { payCalcFee, getPayConfig } from "@/http/pay";
- import { upGainCalculate } from "@/http/treasureApi";
- import { getFrontConfig, calcRechargePayAmount } from "@/http/account";
- import { uploadSignature, uploadFile } from '@/http/media';
- import {setChromeStorage, getChromeStorage} from "@/uilts/chromeExtension"
- import { debounce, getBit } from "@/uilts/help"
- import { PlayType, RewardType, TaskType } from '@/types';
- import Report from "@/log-center/log"
- import { ElMessage, ElLoading } from "element-plus";
- import "element-plus/es/components/message/style/css";
- import "element-plus/es/components/loading/style/css";
- import 'vue-cropper/dist/index.css'
- import { VueCropper } from "vue-cropper";
- import {create, all} from "mathjs";
- import { message } from 'ant-design-vue';
- import messageBox from "@/view/components/message-box.vue";
- import currencyList from "@/view/components/currency-list.vue";
- import currencySelect from "@/view/components/currency-select.vue";
- import followInput from "@/view/iframe/publish/components/follow-input";
- import payButton from "@/view/iframe/publish/components/pay-button";
- import topUp from "@/view/iframe/publish/components/top-up.vue";
- import toolBox from '@/view/iframe/publish/tool-box/index.vue'
- import giveawayPoster from '@/view/iframe/publish/components/giveaway-poster.vue';
- import giveDialogHead from "@/view/iframe/publish/components/give-dialog-head";
- import previewSheet from "@/view/iframe/publish/components/preview-sheet.vue";
- import formInput from "@/view/iframe/publish/components/form-input.vue";
- import GlobalTip from '@/view/components/global-tip.vue'
- import customCardCover from '@/view/components/custom-card-cover.vue'
- import CustomizedRewardEditPopup from '@/view/iframe/publish/components/customized-reward-edit';
- import ComponentZoom from '@/view/components/component-zoom.vue'
- const config = {
- number: 'BigNumber',
- }
- const math = create(all, config);
- //临时货币信息
- let tempCurrentCurrencyInfo = ref({});
- let tempCurrentCurrencyList = ref([]);
- let payConfig = ref({});
- let timer = ref(null);
- // 发布后返回的结果
- let publishRes = reactive({});
- //弹窗是否展示
- let visible = ref(false);
- let publishType = ref('REDPACKET');
- let userInfo = ref({})
- //弹窗高度
- let dialogStyle = reactive({
- dialogHeight: 670,
- dialogContentWidth: 1100
- })
- let USDepositStatus = ref('DEFAULT');
- let cropperOption = ref({
- img: '',
- full: true,
- infoTrue: true,
- fixed: true,
- fixedNumber: [16, 8.396],
- outputType: 'png',
- autoCrop: true,
- autoCropWidth: 99999,
- autoCropHeight: 99999,
- centerBox: true,
- high: true,
- max: 99999,
- })
- let cropperDialog = ref(false)
- let cropperLoading = ref(false)
- let cropperType = ref('before')
- let customPosterInfo = ref({})
- let customPosterData = ref({})
- let customShowNewImage = ref(false)
- let refCropper = ref('')
- // 当前展示组件内容 default(表单) preview(预览) topUp(充值)
- let showComType = ref("default");
- let currentComData = {
- default: {
- title: "Giveaway",
- },
- preview: {
- title: "Giveaway",
- },
- topUp: {
- title: "Deposit",
- },
- poster: {
- title: "Giveaway Poster",
- }
- };
- // 机器人开关
- let openAntiBot = ref(false);
- // 是否正在提交
- let submitIng = ref(false);
- // 艾特关注人列表
- let atUserList = ref([]);
- // 表单错误提示
- let iptErrMsgTxt = ref("Select a reward");
- // usd最小金额限制提示展示
- let isShowUsdMinMessage = ref(false);
- // 是否返回
- let isBack = ref(false);
- // 展示消息提示
- let showMessageBox = ref(false);
- let showDepositMessageBox = ref(false);
- // 展示货币列表pop
- let showCurrencyPop = ref(false);
- let showCurrencySelect = ref(false);
- // 货币列表的dom
- let currencyListDom = ref(null);
- let payButtonDom = ref(null);
- // 刷新按钮旋转
- let refreshRotate = ref(false);
- // 预览字体大小
- let previewFontSize = ref(56);
- let postId = ref('');
- let showGeneralLottery = ref(false);
- let selectModeInfo = reactive({
- index: 0,
- type: PlayType.treasure
- })
- // 余额是否同步中
- let asyncIng = ref(false);
- let messageBoxData = ref({
- title: "",
- content: "",
- });
- // 真实支付金额数据
- let finalAmountData = ref({
- currencyCode: '',
- feeAmountValue: 0,
- finalAmountValue: 0,
- requestAmountValue: 0,
- });
- // 表单数据
- let baseFormData = reactive({
- amountCurrencyCode: "",
- amountValue: "",
- totalCount: "",
- validityDuration: "",
- type: selectModeInfo.type,
- rewardType: RewardType.money,
- customizedReward: "",
- });
- const defaultCurrentCurrencyInfo = {
- currencyCode: "",
- currencyName: "",
- balance: "",
- currencyType: "",
- iconPath: "",
- minAmount: "",
- tokenChain: "",
- tokenSymbol: "",
- usdEstimateBalance: ""
- }
- // 当前选择的货币信息
- let currentCurrencyInfo = ref(defaultCurrentCurrencyInfo);
- const discordIptErrTxt = 'Discord invite link is wrong';
- const discordIptEmptyErrTxt = 'Enter discord invite link';
- const discordIptNerverExpiresErrTxt = 'Make sure the Discord link never expires'
- const requireFollowTxt = 'Please add at least one user to follow at "Follow'
- let iptErrType = ''; //discord
- let formList = reactive([
- {
- label: "Follow",
- icon: require("@/assets/svg/icon-task-twitter.svg"),
- nodeType: "textarea",
- type: TaskType.twitterFollow,
- text: [],
- checked: true,
- show: true
- },
- {
- label: "Retweet & Like",
- icon: require("@/assets/svg/icon-task-twitter.svg"),
- nodeType: "div",
- type: TaskType.twitterRetweet,
- checked: true,
- show: true
- },
- {
- label: "Like Tweet",
- icon: require("@/assets/svg/icon-task-twitter.svg"),
- nodeType: "div",
- type: TaskType.twitterLikeTweet,
- checked: true,
- show: false
- },
- {
- label: "Comment and Tag 3 friends",
- icon: require("@/assets/svg/icon-task-twitter.svg"),
- nodeType: "div",
- type: TaskType.twitterCommentAndTag,
- checked: true,
- show: true
- },
- {
- label: "Repost to Facebook",
- icon: require("@/assets/svg/icon-task-facebook.svg"),
- nodeType: "div",
- text: '',
- type: TaskType.repostToFacebook,
- checked: false,
- show: true
- },
- {
- label: "Join Discord",
- icon: require("@/assets/svg/icon-discord-mini.svg"),
- nodeType: "input",
- text: '',
- type: TaskType.joinDiscord,
- checked: false,
- show: true
- },
- ]);
- let publishModeList = reactive([
- {
- imgActive: require("@/assets/svg/img-T1.svg"),
- imgInActive: require("@/assets/svg/img-T0.svg"),
- imgInfoSrc: require("@/assets/svg/img-P1.svg"),
- type: PlayType.treasure
- },
- {
- imgActive: require("@/assets/svg/img-LT1.svg"),
- imgInActive: require("@/assets/svg/img-LT0.svg"),
- imgInfoSrc: require("@/assets/svg/img-P2.svg"),
- type: PlayType.lottery
- },
- {
- imgActive: require("@/assets/svg/img-A1.svg"),
- imgInActive: require("@/assets/svg/img-A0.svg"),
- imgInfoSrc: require("@/assets/svg/img-P3.svg"),
- type: PlayType.common
- }
- ])
- let discordInviteInfo = ref({});
- let showDiscordInvitePop = ref(false);
- let showCustomizedRewardEditPopup = ref(false);
- let lotteryMaxHourDuration = 168;
- let leftTabList = reactive([
- {
- icon: require('@/assets/svg/icon-gift-pack.svg'),
- type: 'REDPACKET'
- },
- {
- icon: require('@/assets/svg/icon-tool-box-02.svg'),
- type: 'TOOL_BOX'
- }
- ])
- let toolBoxPageData = reactive({
- activePage: 'EDITOR', //EDITOR PREVIEW
- postEditorLinkInputDescImage: '',
- postEditorDefaultLinkTitle: ''
- })
- let treasureFormData = reactive({
- usdEstimateOrderAmount: '',
- fansUnitAmount: '',
- upGainAmountUsdValue: 0,
- })
- const props = defineProps({
- dialogData: {
- type: Object,
- default: () => {
- return {
- visible: false,
- type: 'REDPACKET'
- }
- },
- },
- });
- //selected prize icon cpd
- let currentIconCpd = computed(() => {
- if(baseFormData.rewardType === RewardType.custom) {
- return require("@/assets/svg/icon-gift.svg");
- } else {
- return currentCurrencyInfo.value.iconPath;
- }
- })
- // selected prize cpd
- let currentPrizeCpd = computed(() => {
- const {currencyCode, tokenSymbol} = currentCurrencyInfo.value
- if(baseFormData.rewardType === RewardType.custom) {
- return baseFormData.customizedReward;
- } else if(currencyCode == "USD") {
- return "USD";
- } else {
- return tokenSymbol || "Select a reward";
- }
- })
- let currencySelectCpd = computed(() => {
- return baseFormData.customizedReward || currentCurrencyInfo.value.currencyCode;
- })
- let currentArrowCpd = computed(() => {
- if(baseFormData.rewardType === RewardType.custom) {
- return require("@/assets/svg/icon-cell-arrow-right.svg");
- } else {
- return currentCurrencyInfo.value.currencyCode ? require("@/assets/svg/icon-form-arrow-down.svg") : require("@/assets/svg/icon-form-white-arrow-down.svg");
- }
- })
- let isMoneyRewardCpd =computed(() => baseFormData.rewardType === RewardType.money);
- watch(
- () => props.dialogData,
- (newVal) => {
- visible.value = newVal.visible;
- USDepositStatus.value = "DEFAULT"
- if (newVal.visible) {
- publishType.value = newVal.type;
- Report.reportLog({
- pageSource: Report.pageSource.publisherDialog,
- businessType: Report.businessType.pageView,
- }, {
- type: newVal.type == 'REDPACKET' ? Report.bizType.Treasure : Report.bizType.ToolBox
- });
- getLocalCurrencyInfoByCode();
- setTimeout(() => {
- setDialogStyle();
- }, 300);
- // 更新余额
- clearInterval(timer.value);
- timer.value = setInterval(() => {
- getCurrencyInfo({loop: true});
- }, 10000)
- } else {
- clearInterval(timer.value);
- }
- },
- {
- deep: true
- }
- );
- const emits = defineEmits(["close", "confirm", "postPublishFinish"]);
- const close = () => {
- USDepositStatus.value = "DEFAULT"
- if(publishType.value == 'TOOL_BOX') {
- closeToolBoxPage()
- } else {
- if (showComType.value != "default") {
- showComType.value = "default";
- isBack.value = true;
- } else {
- initParams();
- closeDialog();
- }
- }
- };
- const closeToolBoxPage = () => {
- if(toolBoxPageData.activePage == "EDITOR") {
- closeDialog();
- } else if(toolBoxPageData.activePage == "PREVIEW") {
- toolBoxPageData.activePage = "EDITOR";
- }
- };
- const closeDialog = () => {
- visible.value = false;
- emits("close", false);
- }
- /**
- * 设置弹窗高度
- */
- const setDialogStyle = (resize = false) => {
- nextTick(() => {
- let clientHeight = window.innerHeight;
- let clientWidth = window.innerWidth;
- let gapSafe = 40;
- if (dialogStyle.dialogHeight > clientHeight - gapSafe) {
- dialogStyle.dialogHeight = clientHeight - gapSafe;
- } else {
- if(resize) {
- dialogStyle.dialogHeight = 720;
- }
- }
- if(dialogStyle.dialogContentWidth > clientWidth - gapSafe) {
- dialogStyle.dialogContentWidth = clientWidth - gapSafe;
- } else {
- if(resize) {
- dialogStyle.dialogContentWidth = 1080;
- }
- }
- })
- };
- const selectCurrencyPopHandle = () => {
- Report.reportLog({
- pageSource: Report.pageSource.currencySelectorPage,
- businessType: Report.businessType.pageView,
- }, {
- type: Report.getCurrentBizType(selectModeInfo.type)
- });
- if(baseFormData.rewardType === RewardType.custom) {
- showCustomizedRewardEditPopup.value = true
- } else {
- showCurrencyPop.value = true;
- nextTick(() => {
- if(currencyListDom.value) {
- currencyListDom.value.getCurrencyInfoList && currencyListDom.value.getCurrencyInfoList({pageNum: 1});
- }
- })
- }
- }
- const saveDiscordGuildInfo = () => {
- let {guildId, inviteCode, inviteUrl} = discordInviteInfo.value;
- //保存服务器信息
- Report.reportLog({
- pageSource: Report.pageSource.publisherDialog,
- businessType: Report.businessType.buttonClick,
- objectType: Report.objectType.saveDiscordGuildData
- }, {
- reportData: discordInviteInfo.value
- });
- if(guildId && inviteCode && inviteUrl) {
- saveInviteGuildInfo({
- params: {
- guildId,
- inviteCode,
- inviteUrl
- }
- })
- }
- }
- const confirm = () => {
- if (submitIng.value || iptErrMsgTxt.value) {
- return;
- }
- let { totalCount = 0 } = baseFormData;
- if(selectModeInfo.type != PlayType.treasure) {
- if (!totalCount) {
- return;
- }
- saveDiscordGuildInfo();
- }
- submitRequest();
- };
- /**
- * 货币列表-选中货币
- */
- const selectCurrency = (params) => {
- let { currencies } = params;
- tempCurrentCurrencyList.value = currencies;
- if (currencies.length > 1) {
- showCurrencyPop.value = false;
- showCurrencySelect.value = true;
- } else {
- selectCurrencyAfter(currencies[0])
- }
- };
- const selectCurrencyAfter = (params, openWindow = true) => {
- tempCurrentCurrencyInfo.value = params;
- showCurrencySelect.value = false;
- currentCurrencyInfo.value = params;
- setLocalSelectCurrencyInfo(currentCurrencyInfo.value);
- if (openWindow === false) {
- return
- };
- if (params.currencyCode != "USD" && params.balance < params.minAmount) {
- let tokenSymbol = params.currencyCode == 'USD' ? 'USD' : params.tokenSymbol;
- messageBoxBlock({
- title: `Whether to deposit ${tokenSymbol}`,
- content: `Insufficient ${tokenSymbol} balance`,
- });
- } else {
- setCurrentCurrencyListInfo(tempCurrentCurrencyList.value);
- showCurrencyPop.value = false;
- finalAmountData.value.currencyCode = currentCurrencyInfo.value.currencyCode;
- resetFormIpt(false);
- onIptSetErrorTxt();
- }
- baseFormData.customizedReward = "";
- baseFormData.rewardType = RewardType.money;
- }
- const resetFormIpt = (clearMode = true) => {
- baseFormData.amountValue = "";
- baseFormData.totalCount = "";
- baseFormData.validityDuration = "";
- baseFormData.rewardType = RewardType.money;
- baseFormData.customizedReward = "";
- treasureFormData.usdEstimateOrderAmount = "";
- treasureFormData.upGainAmountUsdValue = "";
- if(clearMode) {
- selectModeInfo.index = 0;
- selectModeInfo.type = publishModeList[selectModeInfo.index]['type'];
- baseFormData.type = selectModeInfo.type;
- }
- }
- const setLocalSelectCurrencyInfo = (params = {}) => {
- setChromeStorage({ selectCurrencyInfo : JSON.stringify(params)})
- }
- const setCurrentCurrencyListInfo = (params = {}) => {
- setChromeStorage({ selectCurrencyList : JSON.stringify(params)})
- }
- /**
- * 获取完货币列表
- */
- const setCurrentCurrencyInfo = (params) => {
- }
- const messageBoxBlock = ({ title = "", content = "" }) => {
- showMessageBox.value = true;
- messageBoxData.value.title = title;
- messageBoxData.value.content = content;
- };
- /**
- * 确定
- */
- const messageBoxConfirm = () => {
- showMessageBox.value = false;
- goTopUp();
- };
- /**
- * 取消
- */
- const messageBoxCancel = () => {
- currentCurrencyInfo.value = tempCurrentCurrencyInfo.value;
- setLocalSelectCurrencyInfo(currentCurrencyInfo.value);
- setCurrentCurrencyListInfo(tempCurrentCurrencyList.value);
- showMessageBox.value = false;
- showCurrencyPop.value = false;
- showCurrencySelect.value = false;
- resetFormIpt(false);
- onIptSetErrorTxt();
- };
- /**
- * 去充值
- */
- const goTopUp = () => {
- Report.reportLog({
- pageSource: Report.pageSource.rechargePage,
- businessType: Report.businessType.pageView,
- }, {
- type: Report.getCurrentBizType(selectModeInfo.type)
- });
- showComType.value = 'topUp';
- }
- /*
- * 自定义封面
- */
- const customCoverImg = () => {
- customPosterInfo.value = {}
- if (Object.keys(customPosterData.value).length > 0) {
- customPosterInfo.value = customPosterData.value;
- }
- showComType.value = 'poster';
- customShowNewImage.value = false;
- setChromeStorage({ custom_poster_guide: Date.now() });
- }
- /**
- * 充值done事件
- */
- const topUpDone = () => {
- currentCurrencyInfo.value = tempCurrentCurrencyInfo.value;
- showCurrencyPop.value = false;
- showCurrencySelect.value = false;
- showComType.value = 'default';
- onIptSetErrorTxt();
- asyncTokenRechRecord((res) => {
- if(res.code == 0 && res.data && res.data.length) {
- let currencyInfo = res.data[0];
- if(currencyInfo.currencyCode == currentCurrencyInfo.value.currencyCode) {
- currentCurrencyInfo.value.balance = currencyInfo.balance;
- onIptSetErrorTxt()
- }
- }
- })
- }
- /**
- * 更新货币余额
- */
- const updateCurrencyBanlce = async () => {
- if(!refreshRotate.value) {
- refreshRotate.value = true;
- setTimeout(() => {
- refreshRotate.value = false;
- }, 1000)
- }
- if(currentCurrencyInfo.value.currencyCode == 'USD') {
- let currencyInfoRes = await getCurrencyByCode({currencyCode: currentCurrencyInfo.value.currencyCode});
- calcRechPayAmount({
- currencyCode: currentCurrencyInfo.value.currencyCode,
- orderAmountValue: baseFormData.amountValue,
- payChannel: 'ach'
- });
- if(currencyInfoRes.code == 0 && currencyInfoRes.data) {
- currentCurrencyInfo.value = currencyInfoRes.data;
- }
- } else {
- asyncTokenRechRecord((res) => {
- if(res.code == 0 && res.data && res.data.length) {
- let currencyInfo = res.data[0];
- if(currencyInfo.currencyCode == currentCurrencyInfo.value.currencyCode) {
- currentCurrencyInfo.value.balance = currencyInfo.balance;
- }
- }
- })
- }
- }
- /**
- * 同步链上交易
- */
- const asyncTokenRechRecord = (cb) => {
- if(asyncIng.value) {
- return;
- }
- asyncIng.value = true;
- syncChainTokenRechargeRecord({
- params: {
- currencyCode: currentCurrencyInfo.value.currencyCode
- }
- }).then(res => {
- asyncIng.value = false;
- cb && cb(res)
- }).catch((err) => {
- asyncIng.value = false;
- })
- }
- /**
- * 提交表单请求
- */
- const submitRequest = async () => {
- let {
- amountValue = 0,
- totalCount = 0,
- rewardType = RewardType.money,
- customizedReward = ""
- } = baseFormData;
- baseFormData.amountCurrencyCode = currentCurrencyInfo.value.currencyCode;
- // 组装提交参数
- let finishConditions = selectModeInfo.type != PlayType.treasure ? getFinishCondition() : getTreasureFinishCondition();
- let receiveConditions = openAntiBot.value ? "" : [];
- let validityDuration = '';
- if(baseFormData.type == PlayType.lottery) {
- //小时转毫秒
- let unit = process.env.NODE_ENV != 'production' ? 60 * 1000 : 60 * 60 * 1000;
- validityDuration = baseFormData.validityDuration * unit;
- } else {
- validityDuration = '';
- }
- // 提交参数
- let formData = {
- amountValue,
- totalCount,
- finishConditions,
- receiveConditions,
- type: baseFormData.type,
- posterType: 1,
- validityDuration,
- rewardType,
- };
- if(rewardType === RewardType.custom) {
- // 通用奖品 类型的活动,添加奖品名称
- formData.customizedReward = customizedReward;
- delete formData.amountValue;
- } else {
- // 货币类型 添加货币code
- formData.amountCurrencyCode = baseFormData.amountCurrencyCode;
- formData.payAmountValue = baseFormData.payAmountValue;
- }
- submitIng.value = true;
- // 自定义封面
- if (Object.keys(customPosterData.value).length > 0) {
- formData['posterType'] = 2;
- if (customPosterData.value && customPosterData.value.after) {
- formData['customPosterInstalled'] = customPosterData.value.after.objectKey || ''
- }
- if (customPosterData.value && customPosterData.value.before) {
- formData['customPosterUninstalled'] = customPosterData.value.before.objectKey || ''
- }
- }
- // 法币支付需要计算费率
- if(formData.amountCurrencyCode == "USD") {
- // 获取充值金额
- await calcRechPayAmount({
- currencyCode: currentCurrencyInfo.value.currencyCode,
- orderAmountValue: baseFormData.amountValue,
- payChannel: 'ach'
- });
- }
- let data = {
- params: {
- postBizData: JSON.stringify(formData),
- postSrc: 1, //1 twitter
- postType: 1, //1 红包
- },
- };
- postPublish(data).then((res) => {
- submitIng.value = false;
- if (res.code == 0) {
- publishRes = res.data;
- postId.value = res.data.postId;
- Report.reportLog({
- pageSource: Report.pageSource.previewPage,
- businessType: Report.businessType.pageView,
- }, {
- type: Report.getCurrentBizType(selectModeInfo.type)
- });
- showComType.value = "preview";
- previewFontSize.value = calcFontSize(baseFormData.amountValue, 238, 56);
- isBack.value = false;
- } else {
- console.log(res);
- }
- })
- .catch((err) => {
- console.log(err);
- });
- };
- const getFinishCondition = () => {
- let finishConditions = [];
- for (let i = 0; i < formList.length; i++) {
- let item = {};
- item.type = formList[i]["type"];
- if (item.type == TaskType.twitterFollow && atUserList.value.length) {
- // follow 参数
- let relatedUsers = atUserList.value.filter(item => item.name);
- item.relatedUsers = relatedUsers;
- finishConditions.push(item);
- } else if (formList[i]["type"] == TaskType.joinDiscord) {
- // join discord
- if(formList[i]["checked"] && formList[i]["text"]) {
- item.bizData = JSON.stringify({inviteUrl: formList[i]["text"]});
- finishConditions.push(item);
- }
- } else if (formList[i]["checked"]) {
- // 其余任务
- finishConditions.push(item);
- }
- }
- return finishConditions;
- }
- const getTreasureFinishCondition = () => {
- let finishConditions = [
- {
- type: TaskType.twitterLikeTweet
- },
- {
- type: TaskType.twitterRePost
- }
- ];
- if(atUserList.value.length) {
- let relatedUsers = atUserList.value.filter(item => item.name);
- finishConditions.push({
- relatedUsers,
- type: TaskType.twitterFollow
- });
- }
- return finishConditions;
- };
- const calcFontSize = (str, domWidth, maxSize) => {
- let lenstr = str.length;
- let num = parseInt(domWidth / lenstr);
- let fontSize = num < maxSize ? num : maxSize
- return fontSize;
- }
- /**
- * 初始化提交参数
- */
- const initParams = () => {
- resetFormIpt();
- // clear follow value
- atUserList.value = [];
- submitIng.value = false;
- isBack.value = false;
- showCurrencyPop.value = false;
- showCurrencySelect.value = false;
- openAntiBot.value = false;
- tempCurrentCurrencyInfo.value = {};
- currentCurrencyInfo.value = {};
- publishType.value = 'REDPACKET';
- // clear discord value
- setDiscordIptTxt({text: ''});
- discordInviteInfo.value = {};
- customPosterInfo.value = {};
- customPosterData.value = {};
- };
- const setDiscordIptTxt = ({text}) => {
- const index = formList.findIndex(item => item.type == TaskType.joinDiscord);
- formList[index]['text'] = text;
- }
- const calcRechPayAmount = async (params) => {
- let res = await calcRechargePayAmount({
- params : params
- })
- if (res.code == 0) {
- let { feeDesc } = res.data;
- payConfig.value.feeDesc = feeDesc;
- finalAmountData.value = res.data;
- }
- return res.data;
- }
- /**
- * 支付完成回调
- */
- const payFinish = (params) => {
- let {payStatus} = params;
- // 余额支付
- payStatusHandle(payStatus);
- };
- const payStatusHandle = (payStatus) => {
- //支付状态 0:未支付,1:支付成功,2:支付失败,3:已关闭,4:已退款
- switch (payStatus) {
- case 1:
- emits("postPublishFinish", { publishRes });
- showComType.value = "default";
- initParams();
- break;
- case 2:
- break;
- case 3:
- break;
- case 4:
- break;
- }
- }
- /**
- * follow组件触发新增关注人
- */
- const addFollowUser = (params) => {
- atUserList.value.push(params);
- };
- const setFollowUser = (params) => {
- atUserList.value[params.index]["name"] = params.name;
- let userList = atUserList.value.filter(item => item.name);
- if(selectModeInfo.type == PlayType.treasure) {
- if(!userList.length) {
- if(!iptErrMsgTxt.value) {
- iptErrMsgTxt.value = requireFollowTxt;
- }
- } else {
- if (iptErrMsgTxt.value == requireFollowTxt) {
- iptErrMsgTxt.value = ""
- }
- }
- }
- };
- const delFollowUser = (params) => {
- atUserList.value.splice(params.index, 1);
- let userList = atUserList.value.filter(item => item.name);
- if(selectModeInfo.type == PlayType.treasure) {
- if(!userList.length) {
- if(!iptErrMsgTxt.value) {
- iptErrMsgTxt.value = requireFollowTxt;
- }
- } else {
- if (iptErrMsgTxt.value == requireFollowTxt) {
- iptErrMsgTxt.value = ""
- }
- }
- }
- };
- const calcUsdEstimate = (params) => {
- if(!currentCurrencyInfo.value.currencyCode) {
- return;
- }
- let {type} = params;
- let calcData = {amount: 0, usdPrice: currentCurrencyInfo.value.usdPrice};
- switch (type) {
- case 'ORDER_AMOUNT':
- calcData.amount = baseFormData.amountValue;
- treasureFormData.usdEstimateOrderAmount = calcToken2UsdEstimate(calcData);
- break;
- }
- }
- const calcTokenEstimate = (params) => {
- if(!currentCurrencyInfo.value.currencyCode) {
- return;
- }
- let {type} = params;
- let calcData = {amount: 0, usdPrice: currentCurrencyInfo.value.usdPrice};
- switch (type) {
- case 'ORDER_AMOUNT':
- calcData.amount = treasureFormData.usdEstimateOrderAmount;
- baseFormData.amountValue = calcUsd2TokenEstimate(calcData);
- break;
- }
- }
- /**
- * token 转 USD 估值
- */
- const calcToken2UsdEstimate = (params) => {
- if(!params.amount) {
- return '';
- }
- let val = +math.format(math.evaluate(`${params.amount} * ${params.usdPrice}`));
- return Math.floor(val * 100) / 100;
- };
- /**
- * USD 转 token 估值
- */
- const calcUsd2TokenEstimate = (params) => {
- if(!params.amount) {
- return '';
- }
- let val = +math.format(math.evaluate(`${params.amount} / ${params.usdPrice}`)) ;
- return val;
- };
- /**
- * 计算粉丝单价
- */
- const calcFansUnitAmount = () => {
- if(!baseFormData.totalCount || !baseFormData.amountValue) {
- treasureFormData.upGainAmountUsdValue = ''
- treasureFormData.fansUnitAmount = '';
- return;
- }
- let unitAmount = baseFormData.amountValue / baseFormData.totalCount;
- setUpGainAmountUsdValue({totalAmount: baseFormData.amountValue, unitPrice: unitAmount});
- if(currentCurrencyInfo.value.currencyCode != 'USD') {
- unitAmount = calcToken2UsdEstimate({amount: unitAmount, usdPrice: currentCurrencyInfo.value.usdPrice });
- }
- return unitAmount;
- };
- const setUpGainAmountUsdValue = (params) => {
- const { usdPrice, currencyCode } = currentCurrencyInfo.value;
- let {totalAmount, unitPrice} = params;
- if(!currencyCode) return;
- upGainCalculate({
- params: {
- amountValue: +totalAmount,
- currencyUsdPrice: usdPrice,
- fansUnitAmountValue: unitPrice
- }
- }).then(res => {
- if(res.code == 0 && res.data) {
- treasureFormData.upGainAmountUsdValue = res.data.upGainAmountUsdValue
- }
- })
- }
- /**
- * 奖励总金额 美元估值
- */
- const onUsdEstimateOrderAmountInput = () => {
- let val = treasureFormData.usdEstimateOrderAmount;
- val = String(val).replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1');
- if(val == '00') {
- val = '0'
- }
- treasureFormData.usdEstimateOrderAmount = val;
- calcTokenEstimate({type: 'ORDER_AMOUNT'});
- onIptSetErrorTxt();
- if(selectModeInfo.type == PlayType.treasure) {
- treasureFormData.fansUnitAmount = calcFansUnitAmount();
- }
- return val;
- };
- const onAmountInput = () => {
- let val = baseFormData.amountValue;
- // val = val.replace(/[^\d^\.]+/g, "");
- val = String(val).replace(/^\D*(\d*(?:\.\d{0,18})?).*$/g, '$1');
- const maxCount = baseFormData.rewardType === RewardType.money ? Number.MAX_SAFE_INTEGER : 100000000;
- if(val == '00') {
- val = '0'
- }
- if(val.indexOf('.') > -1){ //校验 例:00.12 => 0.12
- let arr = val.split('.');
- if(arr[0].startsWith('0')) {
- let num = +arr[0];
- val = num + '.' + arr[1];
- }
- }
- if (baseFormData.rewardType === RewardType.custom) {
- val = val.replace(/^(0)*/, '').replace(/\./, ''); // 通用奖品类型 过滤掉起始位的0和小数点符号
- if (val > maxCount) {
- val = maxCount
- }
- baseFormData.totalCount = val;
- }
- baseFormData.amountValue = val;
- calcUsdEstimate({type: 'ORDER_AMOUNT'});
- if(selectModeInfo.type == PlayType.treasure) {
- treasureFormData.fansUnitAmount = calcFansUnitAmount();
- }
- onIptSetErrorTxt();
- return val;
- };
- const onCountInput = () => {
- let val = baseFormData.totalCount;
- const maxCount = 100000000;
- if (val == 0) {
- val = "";
- }
- val = val.replace(/[^\d]/g, "");
- if(val > maxCount) {
- val = maxCount
- }
- baseFormData.totalCount = val;
- if(selectModeInfo.type == PlayType.treasure) {
- treasureFormData.fansUnitAmount = calcFansUnitAmount();
- }
- onIptSetErrorTxt();
- return val;
- };
- const onValidityDurationInput = () => {
- validityDurationHandler()
- let val = onIptSetErrorTxt();
- return val;
- }
- const onValidityDurationBlur = () => {
- validityDurationHandler();
- let val = onIptSetErrorTxt();
- return val;
- }
- const validityDurationHandler = () => {
- let val = baseFormData.validityDuration;
- if (val == 0) {
- val = "";
- } else if(val > lotteryMaxHourDuration) {
- val = lotteryMaxHourDuration+'';
- }
- val = val.replace(/[^\d]/g, "");
- baseFormData.validityDuration = val;
- return val;
- }
- /**
- * 金额输入失焦
- */
- const onAmountBlur = () => {
- onIptSetErrorTxt();
- };
- /**
- * count失焦,校验输入结果
- */
- const onCountBlur = () => {
- onIptSetErrorTxt();
- };
- /**
- * 输入结果金额和数量 (金额/数量)是否小于最小货币单位
- */
- const calcIptValue = (cb) => {
- let amountValue = baseFormData.amountValue;
- let totalCount = baseFormData.totalCount;
- let flag = true;
- if (!amountValue || !totalCount) {
- return {
- flag
- };
- }
- if (math.format(math.evaluate(`${baseFormData.amountValue} / ${baseFormData.totalCount}`)) < +currentCurrencyInfo.value.minAmount) {
- flag = false;
- }
- return {
- flag,
- count: Math.floor(math.format(math.evaluate(`${baseFormData.amountValue} / ${currentCurrencyInfo.value.minAmount}`)))
- }
- };
- /**
- * usd最小金额判断
- * luckdropPostConfig是一个列表,需要根据当前的玩法选择对应的Limit信息比对
- * luckdropPostConfig[i].usdLimitEnable 当前选中的token是否开启usd最小金额判断
- */
- const checkUsdMinNumber = (isInTemplate) => {
- let forbiddenText = '';
- const { usdPrice, luckdropPostConfig = [] } = currentCurrencyInfo.value;
- let currentLuckDropConfig = luckdropPostConfig.find(item => item.luckdropType === selectModeInfo.type);
- if (baseFormData.rewardType === RewardType.money && currentLuckDropConfig?.usdLimitEnable === 1) {
- const { amountValue, totalCount } = baseFormData;
- if (currentLuckDropConfig?.minTotalUsdAmount === 0 || currentLuckDropConfig?.minAvgUsdAmount === 0) {
- // 当前token允许的usd最小金额为0 或单个红包最小金额为0,则无限制
- return forbiddenText;
- } else {
- const isAmountForbidden = currentLuckDropConfig?.minTotalUsdAmount ? math.format(math.evaluate(amountValue * usdPrice)) < currentLuckDropConfig.minTotalUsdAmount : false;
- const isAvgForbidden = currentLuckDropConfig?.minAvgUsdAmount ? math.format(math.evaluate(amountValue / totalCount * usdPrice)) < currentLuckDropConfig.minAvgUsdAmount : false;
- forbiddenText = isAmountForbidden && isAvgForbidden ?
- `The prize pool must be above ${isInTemplate ? ('<span class="font-color-1D9BF0">$' + currentLuckDropConfig.minTotalUsdAmount + '</span>') : ('$' + currentLuckDropConfig.minTotalUsdAmount)}
- or the average prize must be above
- ${isInTemplate ? ('<span class="font-color-1D9BF0">$' + currentLuckDropConfig.minAvgUsdAmount +' per person.</span>' ): ('$' + currentLuckDropConfig.minAvgUsdAmount + ' per person.') }`
- : '';
- }
- }
- return forbiddenText;
- };
- const checkTreasureAmountRange = (isInTemplate) => {
- let forbiddenText = '';
- const { usdPrice, minAmount, luckdropPostConfig = [] } = currentCurrencyInfo.value;
- let currentLuckDropConfig = luckdropPostConfig.find(item => item.luckdropType === selectModeInfo.type);
- if (currentLuckDropConfig?.usdLimitEnable === 1) {
- if (currentLuckDropConfig?.minTotalUsdAmount === 0 || currentLuckDropConfig?.minAvgUsdAmount === 0) {
- // 当前token允许的usd最小金额为0 或单个红包最小金额为0,则无限制
- return forbiddenText;
- } else {
- let txt = `The prize pool must be above ${isInTemplate ? ('<span class="font-color-1D9BF0">$' + currentLuckDropConfig.minTotalUsdAmount + '</span>') : ('$' + currentLuckDropConfig.minTotalUsdAmount)}
- and the average prize must be above
- ${isInTemplate ? ('<span class="font-color-1D9BF0">$' + currentLuckDropConfig.minAvgUsdAmount +' per person.</span>' ): ('$' + currentLuckDropConfig.minAvgUsdAmount + ' per person.') }`
- const isAmountForbidden = currentLuckDropConfig?.minTotalUsdAmount ? +math.format(math.evaluate(baseFormData.amountValue * usdPrice)) < currentLuckDropConfig?.minTotalUsdAmount : false;
- const isAvgForbidden = treasureFormData.fansUnitAmount !== '' && currentLuckDropConfig?.minAvgUsdAmount ? treasureFormData.fansUnitAmount < minAmount || treasureFormData.fansUnitAmount < currentLuckDropConfig?.minAvgUsdAmount : false;
- forbiddenText = isAmountForbidden || isAvgForbidden ? txt : '';
- }
- }
- return forbiddenText;
- };
- const treasureFormValidata = () => {
- console.log('treasureFormValidata')
- isShowUsdMinMessage.value = false;
- let userList = atUserList.value.filter(item => item.name);
- if(!currentCurrencyInfo.value.currencyCode) {
- iptErrMsgTxt.value = "Select a reward"
- } else if (!baseFormData.amountValue || baseFormData.amountValue == '0') {
- iptErrMsgTxt.value = "Enter an amount";
- } else if (iptErrMsgTxt.value = checkTreasureAmountRange()) {
- //amount 是否大于 最小总金额
- isShowUsdMinMessage.value = true;
- } else if (!baseFormData.totalCount || baseFormData.totalCount == '0') {
- // 输入Follower
- iptErrMsgTxt.value = 'Please enter "Growing Targe"';
- } else if(iptErrMsgTxt.value = checkTreasureAmountRange()) {
- // 粉丝单价是否 小于总金额规则 大于最小粉丝单价 、大于币种最小精度
- isShowUsdMinMessage.value = true;
- } else if(!userList.length) {
- iptErrMsgTxt.value = requireFollowTxt;
- } else {
- isShowUsdMinMessage.value = false;
- iptErrMsgTxt.value = "";
- }
- };
- /**
- * 输入时 检测设置错误信息
- */
- const onIptSetErrorTxt = (params = {}) => {
- if(baseFormData.type == PlayType.treasure) {
- treasureFormValidata();
- return;
- }
- if((baseFormData.rewardType === RewardType.money && !currentCurrencyInfo.value.currencyCode)
- || (baseFormData.rewardType === RewardType.custom && !baseFormData.customizedReward)) {
- iptErrMsgTxt.value = "Select a reward"
- } else if (!baseFormData.amountValue || baseFormData.amountValue == '0') {
- iptErrMsgTxt.value = "Enter an amount";
- } else if (baseFormData.type != PlayType.treasure && (!baseFormData.totalCount || baseFormData.totalCount == '0')) {
- iptErrMsgTxt.value = "Enter the number of winners";
- } else if (iptErrMsgTxt.value = checkUsdMinNumber()) {
- // 最小法币金额限制
- return isShowUsdMinMessage.value = true;
- } else if(baseFormData.rewardType === RewardType.money && baseFormData.type != PlayType.treasure && +baseFormData.amountValue <= +currentCurrencyInfo.value.balance) {
- // 输入金额 小于 余额
- let res = calcIptValue();
- if (!res.flag) {
- iptErrMsgTxt.value = `${baseFormData.amountValue} ${currentCurrencyInfo.value.tokenSymbol} Can send up to ${res.count} winners`;
- } else {
- if(baseFormData.type == PlayType.lottery && !baseFormData.validityDuration) {
- iptErrMsgTxt.value = "Enter Automatically Draw";
- } else {
- //清空错误提示
- iptErrMsgTxt.value = "";
- if(params.actionType != 'discord_blur') {
- setDiscordErrTxt({getDuildId: true});
- }
- }
- }
- } else if(baseFormData.type == PlayType.lottery && !baseFormData.validityDuration) {
- // 抽奖模式 没有输入时长
- iptErrMsgTxt.value = "Enter Automatically Draw";
- } else {
- if(baseFormData.type != PlayType.treasure) {
- setDiscordErrTxt({getDuildId: true}, () => {
- iptErrMsgTxt.value = '';
- });
- }
- }
- }
- /**
- * 监听开关触发事件
- */
- const formSwitchChange = (val, params, index) => {
- closeDiscordTask(val, params, index);
- }
- const closeDiscordTask = (val, params, index) => {
- if(params.type == TaskType.joinDiscord) {
- if(!val) {
- //错误类型 discord 清空discord错误校验
- if(iptErrType == 'discord') {
- iptErrMsgTxt.value = '';
- formList[index]['text'] = '';
- onIptSetErrorTxt();
- }
- } else {
- onIptSetErrorTxt();
- }
- }
- }
- /** 监听 discord 输入 */
- const onIptDiscordAddress = (e, index) => {
- let val = formList[index].text;
- let checked = formList[index].checked;
- if(val && !checked) {
- checked = true;
- formList[index].checked = checked;
- formList[index].text = formList[index].text.replace(/\s/g,'');
- } else if(!val){
- discordInviteInfo.value = {};
- }
- onIptDiscordDebounce()
- }
- const onBlurDiscordAddress = (e, index) => {
- setDiscordErrTxt({fromType: 'discord', showPop: false, actionType: 'discord_blur'});
- }
- const getDiscordIptData = () => {
- let discordItem = formList.find(item => item.type == TaskType.joinDiscord);
- return discordItem;
- }
- /**
- * 设置输入discord错误提示信息
- */
- const setDiscordErrTxt = (params = {showPop: false}, cb) => {
- let discordData = getDiscordIptData() || {};
- if(discordData.checked) {
- if(discordData.text) {
- let validata = checkInviteUrl(discordData.text);
- if(validata) {
- getDiscordInviteInfo({inviteUrl: discordData.text, getDuildId: params.getDuildId}, (res) => {
- console.log('discordData',res)
- // 未知的邀请链接
- if(res.inviteCode != res.data.code || !res.data.guildId) {
- iptErrMsgTxt.value = discordIptErrTxt;
- iptErrType = 'discord';
- } else {
- if(res.data.expires !== null) {
- // 不是永久邀请链接
- iptErrMsgTxt.value = discordIptNerverExpiresErrTxt;
- iptErrType = '';
- } else {
- if(iptErrMsgTxt.value) {
- iptErrMsgTxt.value = '';
- iptErrType = '';
- }
- if(params.showPop && res.data) {
- showDiscordInvitePop.value = true;
- setTimeout(() => {
- showDiscordInvitePop.value = false;
- }, 2000)
- }
- if(params.fromType == 'discord') {
- onIptSetErrorTxt();
- }
- }
- }
- cb && cb(res)
- })
- } else {
- iptErrMsgTxt.value = discordIptErrTxt;
- iptErrType = 'discord';
- }
- } else {
- if(params.actionType == 'discord_blur') {
- onIptSetErrorTxt({acitonType: 'discord_blur'});
- } else {
- // 设置空提示
- iptErrMsgTxt.value = discordIptEmptyErrTxt;
- iptErrType = 'discord';
- }
- }
- } else {
- cb && cb();
- }
- }
- const onIptDiscordDebounce = debounce(function() {
- setDiscordErrTxt({fromType: 'discord', showPop: true});
- }, 800)
- /**
- * 校验 discord邀请url
- */
- const checkInviteUrl = (inviteUrl) => {
- let flag = false;
- const INVITE_URL_PREFIX_1 = 'https://discord.gg/';
- const INVITE_URL_PREFIX_2 = 'https://discord.com/invite/';
- const INVITE_URL_PREFIX_3 = 'http://discord.gg/';
- const INVITE_URL_PREFIX_4 = 'http://discord.com/invite/';
- const INVITE_URL_PREFIX_5 = 'discord.gg/';
- const INVITE_URL_PREFIX_6 = 'discord.com/invite/';
- 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]
- if(inviteUrl) {
- if(arr.indexOf(inviteUrl) > -1) {
- flag = false;
- } else {
- let isPass = false;
- for(let i = 0; i < arr.length; i++) {
- let item = arr[i];
- if(inviteUrl.startsWith(item)) {
- isPass = true;
- break;
- }
- }
- flag = isPass;
- }
- }
- return flag;
- }
- /**获取discord 邀请信息 */
- const getDiscordInviteInfo = ({inviteUrl, getDuildId}, cb) => {
- if(!inviteUrl) return;
- let inviteCode = '';
- let arr = inviteUrl.split('/');
- if(arr.length > 0) {
- inviteCode = arr[arr.length - 1];
- }
- if(!getDuildId && discordInviteInfo.value.guildId && discordInviteInfo.value.inviteCode == inviteCode) {
- return;
- }
- getInviteGuildInfo({
- inviteCode
- }).then(res => {
- let resData = inviteGuildResHandler(res, {inviteCode, inviteUrl});
- if(resData.data.guildId) {
- cb && cb(resData);
- } else {
- //DISCORD 接口未获取到服务器信息 resdata
- Report.reportLog({
- pageSource: Report.pageSource.publisherDialog,
- businessType: Report.businessType.buttonClick,
- objectType: Report.objectType.getDiscordGuildNoData
- }, {
- resData: resData
- });
- getGuildInfoByOpenApi({inviteCode}, cb);
- }
- }).catch((err) => {
- //DISCORD 接口 catch
- Report.reportLog({
- pageSource: Report.pageSource.publisherDialog,
- businessType: Report.businessType.buttonClick,
- objectType: Report.objectType.getDiscordGuildCatch
- }, {
- err: err
- });
- let errMsg = err;
- if(typeof errMsg == 'object') {
- errMsg = JSON.stringify(err);
- }
- if(errMsg.indexOf('code 404') > -1) {
- discordInviteInfo.value = {};
- iptErrMsgTxt.value = discordIptErrTxt;
- } else {
- getGuildInfoByOpenApi({inviteCode}, cb);
- }
- });
- }
- const getGuildInfoByOpenApi = (params, cb) => {
- let { inviteCode } = params;
- getInviteGuildInfoByOpenApi({
- inviteCode
- }).then(res => {
- let resData = inviteGuildResHandler(res, {inviteCode, inviteUrl});
- if(resData.data.guildId) {
- cb && cb(resData);
- } else {
- //OPENAPI 接口未获取到服务器信息 resdata
- Report.reportLog({
- pageSource: Report.pageSource.publisherDialog,
- businessType: Report.businessType.buttonClick,
- objectType: Report.objectType.getDiscordGuildOpenApiNoData
- }, {
- resData: resData
- });
- }
- }).catch((err) => {
- // OPENAPI 接口 catch 限频
- Report.reportLog({
- pageSource: Report.pageSource.publisherDialog,
- businessType: Report.businessType.buttonClick,
- objectType: Report.objectType.getDiscordGuildOpenApiCatch
- }, {
- err: err
- });
- if(iptErrMsgTxt.value && iptErrType == 'discord') {
- iptErrMsgTxt.value = '';
- iptErrType = '';
- }
- });
- }
- const inviteGuildResHandler = (res, params) => {
- let {inviteCode, inviteUrl} = params;
- if(!res) {
- res = {};
- }
- let {name, icon, id} = res.guild || {};
- icon = icon && id ? `https://cdn.discordapp.com/icons/${id}/${icon}.png` : '';
- let resData = {
- inviteCode,
- data: {
- code: res.code,
- guildId: id,
- inviteUrl,
- inviteCode,
- expires: res.expires_at,
- name,
- icon,
- }
- }
- if(res.code == inviteCode) {
- discordInviteInfo.value = resData.data;
- } else {
- discordInviteInfo.value = {};
- iptErrMsgTxt.value = discordIptErrTxt;
- }
- return resData;
- };
- /**
- * 获取支付配置(paypalClientId)
- */
- const setPayConfig = () => {
- getPayConfig({
- params: {},
- }).then((res) => {
- if (res.code == 0) {
- payConfig.value = res.data;
- }
- });
- };
- /**
- * 获取配置
- */
- const setFrontConfig = () => {
- getFrontConfig({
- params: {},
- }).then((res) => {
- if (res.code == 0) {
- lotteryMaxHourDuration = res.data.lotteryMaxHourDuration;
- toolBoxPageData.postEditorLinkInputDescImage = res.data.postEditorLinkInputDescImage;
- toolBoxPageData.postEditorDefaultLinkTitle = res.data.postEditorDefaultLinkTitle;
- }
- });
- };
- const getUserName = (screenName) => {
- if(!screenName) return;
- getUser({
- params:{
- screenName
- }
- }).then(res => {
- if(res.code == 0) {
- userInfo.value.name = res.data.name || ''
- }
- console.log(userInfo.value, 'userinfo')
- });
- }
- /**
- * 默认获取上次选中的货币信息
- */
- const getLocalCurrencyInfoByCode = async () => {
- let storageUserInfo = await getChromeStorage('userInfo') || {};
- userInfo.value = storageUserInfo;
- getUserName(storageUserInfo.nickName);
- if(!currentCurrencyInfo.value.currencyCode) {
- getCurrencyInfo();
- }
- }
- const getCurrencyInfo = async (_params) => {
- let { loop = false} = _params || {};
- if (userInfo.value && userInfo.value.accessToken) {
- let {currencyCode = ''} = await getChromeStorage('selectCurrencyInfo') || {};
- if(currencyCode) {
- let currencyInfoRes = await getCurrencyByCode({currencyCode});
- if(currencyInfoRes.code == 0 && currencyInfoRes.data) {
- let currentCurrencyCode= currentCurrencyInfo.value.currencyCode;
- if(currentCurrencyCode && currentCurrencyCode == currencyInfoRes.data.currencyCode || !currentCurrencyCode) {
- currentCurrencyInfo.value = currencyInfoRes.data;
- tempCurrentCurrencyInfo.value = currencyInfoRes.data;
- if(!loop) {
- onIptSetErrorTxt();
- }
- }
- }
- }
- getChromeStorage('selectCurrencyList', (res) => {
- if (showCurrencySelect.value === false) {
- tempCurrentCurrencyList.value = res;
- }
- })
- }
- }
- const getCurrencyByCode = async (params) => {
- let res = await getCurrencyInfoByCode({
- params: {
- currencyCode: params.currencyCode
- }
- })
- return res || {};
- }
- const selectPublishMode = (params, index) => {
- if(params.type != selectModeInfo.type) {
- Report.reportLog({
- pageSource: Report.pageSource.publisherDialog,
- businessType: Report.businessType.pageView,
- }, {
- type: Report.getCurrentBizType(selectModeInfo.type)
- });
- }
- selectModeInfo.index = index;
- selectModeInfo.type = params.type;
- baseFormData.type = params.type;
- if(params.type == PlayType.treasure) {
- baseFormData.rewardType = RewardType.money;
- baseFormData.customizedReward = '';
- showGeneralLottery.value = false;
- } else {
- showGeneralLottery.value = true;
- }
- onIptSetErrorTxt();
- }
- const clickLeftTab = (params, index) => {
- publishType.value = params.type;
- Report.reportLog({
- pageSource: Report.pageSource.publisherDialog,
- businessType: Report.businessType.pageView,
- }, {
- type: params.type == 'REDPACKET' ? Report.bizType.Treasure : Report.bizType.ToolBox
- });
- }
- const onToolBoxPageChange = (params) => {
- toolBoxPageData.activePage = params.page;
- };
- const toolBoxPublishFinish = (params) => {
- toolBoxPageData.activePage = 'EDITOR';
- emits("postPublishFinish", { publishRes: params.publishRes });
- }
- // 截图相关
- const showDialog = () => {
- cropperDialog.value = true;
- }
- const hiddenDialog = () => {
- cropperDialog.value = false;
- cropperLoading.value = false;
- }
- const selectImage = (option) => {
- // 设置图片
- cropperOption.value.img = option.file
- // 选取比例
- if (option && option.type && option.type == 2) {
- cropperType.value = 'after';
- cropperOption.value.fixedNumber = [1, 1];
- } else {
- cropperType.value = 'before';
- cropperOption.value.fixedNumber = [16, 8.396];
- }
- nextTick(() => {
- showDialog()
- })
- }
- const confirmImage = () => {
- let contentType = 'image/png';
- cropperLoading.value = true;
- if (refCropper.value) {
- refCropper.value.getCropBlob(imgData => {
- uploadSignature({
- params: {
- bizType: 1,
- fileType: 1,
- contentType: contentType,
- fileSuffix: 'png',
- }
- }).then(res => {
- let { code, data } = res;
- if (code === 0) {
- let reader = new FileReader()
- reader.readAsArrayBuffer(imgData)
- reader.onload = function(e) {
- let execFile = e.target.result;
- uploadFile({
- url: data.url,
- data: new Blob([execFile]),
- headers: {
- 'Authorization': data.authorization,
- 'x-amz-date': data.date,
- 'Content-Type': contentType
- }
- }).then(res => {
- let { status } = res
- if (status == 200) {
- successImage(data)
- }
- }).finally(() => {
- cropperLoading.value = false;
- })
- }
- }
- })
- })
- }
- }
- const successImage = (data) => {
- hiddenDialog()
- // setPosterInfo
- customPosterInfo.value[cropperType.value] = data;
- }
- const confirmData = (data) => {
- close()
- customPosterData.value = customPosterInfo.value;
- }
- /**
- * 显示通用奖品名称编辑框
- */
- const addCustomizedRewardHandle = () => {
- showCurrencyPop.value = false;
- showCustomizedRewardEditPopup.value = true;
- }
- const closeRewardPopup = () => {
- showCustomizedRewardEditPopup.value = false;
- }
- const removeReward = () => {
- showCustomizedRewardEditPopup.value = false;
- resetFormIpt(false);
- onIptSetErrorTxt();
- }
- // 提交通用奖品
- const submitReward = (reward) => {
- if(baseFormData.customizedReward !== reward) {
- // 有修改时,重置之前已提交的数据
- resetFormIpt(false);
- }
- baseFormData.rewardType = RewardType.custom;
- baseFormData.customizedReward = reward;
- showCustomizedRewardEditPopup.value = false;
- currentCurrencyInfo.value = defaultCurrentCurrencyInfo;
- setLocalSelectCurrencyInfo(defaultCurrentCurrencyInfo);
- onIptSetErrorTxt();
- }
- const updateUSDeposit = async () => {
- if(showDepositMessageBox.value) {
- let currencyInfoRes = await getCurrencyByCode({currencyCode: currentCurrencyInfo.value.currencyCode});
- if(currencyInfoRes.code == 0 && currencyInfoRes.data) {
- currentCurrencyInfo.value = currencyInfoRes.data;
- let {balance} = currencyInfoRes.data;
- if(balance >= finalAmountData.value.orderAmountValue) {
- USDepositStatus.value = 'SUCCESS';
- }
- }
- }
- };
- const depositAchCancel = async () => {
- showDepositMessageBox.value = false;
- let currencyInfoRes = await getCurrencyByCode({currencyCode: currentCurrencyInfo.value.currencyCode});
- if(currencyInfoRes.code == 0 && currencyInfoRes.data) {
- currentCurrencyInfo.value = currencyInfoRes.data;
- let {balance} = currencyInfoRes.data;
- if(balance >= finalAmountData.value.orderAmountValue) {
- USDepositStatus.value = 'SUCCESS';
- }
- }
- }
- const depositAchConfirm = async () => {
- let currencyInfoRes = await getCurrencyByCode({currencyCode: currentCurrencyInfo.value.currencyCode});
- if(currencyInfoRes.code == 0 && currencyInfoRes.data) {
- showDepositMessageBox.value = false;
- currentCurrencyInfo.value = currencyInfoRes.data;
- let {balance} = currencyInfoRes.data;
- if(balance >= finalAmountData.value.orderAmountValue) {
- USDepositStatus.value = 'SUCCESS';
- payButtonDom.value && payButtonDom.value.balancePay();
- } else {
- message.info('Deposit failed, please try again later');
- }
- }
- }
- const onPageVisbile = () => {
- document.addEventListener('visibilitychange', function () {
- let isHidden = document.hidden;
- if (!isHidden) {
- updateUSDeposit();
- }
- });
- }
- onMounted(() => {
- setFrontConfig();
- setPayConfig();
- getLocalCurrencyInfoByCode();
- onPageVisbile();
- window.addEventListener('resize', function () {
- setDialogStyle(true);
- })
- // showNewImage
- getChromeStorage('custom_poster_guide', (info) => {
- if (!info) {
- customShowNewImage.value = true
- }
- })
- });
- </script>
- <style lang="scss">
- .font-color-1D9BF0 {
- color: #1D9BF0;
- }
- .margin-left-10 {
- margin-left: 10px;
- }
- </style>
- <style lang="scss" scoped>
- :deep() .ant-switch {
- background-color: #E9ECEE;
- height: 14px;
- line-height: 16px;
- min-width: 36px;
- }
- :deep() .ant-switch-checked {
- background-color: #AED8F5 !important;
- }
- :deep() .ant-switch::after {
- width: 20px;
- height: 20px;
- top: -4px;
- left: -1px;
- }
- :deep() .ant-switch-checked::after {
- background-color: #1D9BF0 !important;
- margin-left: 3px;
- left: 100% !important;
- }
- .overlay {
- position: fixed;
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- z-index: 1000;
- width: 100%;
- height: 100%;
- background-color: rgba(0, 0, 0, 0.5);
- overflow: auto;
- .content {
- height: 620px;
- background: #ffffff;
- border-radius: 20px;
- position: absolute;
- left: 50%;
- top: 50%;
- transform: translate(-50%, -50%);
- box-sizing: border-box;
- z-index: 2000;
- max-height: 825px;
- .pop-mask {
- width: 100%;
- height:100%;
- position: absolute;
- z-index:900;
- }
- .body {
- box-sizing: border-box;
- height: calc(100% - 48px);
- display: flex;
- position: relative;
- .body-content {
- display:flex;
- width:100%;
- }
- .currency-pop {
- position: absolute;
- width: 375px;
- height: 480px;
- top: 85px;
- left: 88px;
- z-index: 1000;
- box-shadow: 0px 4px 30px rgba(0, 0, 0, 0.3);
- background-color: #fff;
- border-radius: 20px;
- overflow-y: auto;
- }
- .currency-pop-select {
- position: absolute;
- width: 375px;
- max-height: 480px;
- top: 85px;
- left: 88px;
- z-index: 1000;
- box-shadow: 0px 4px 30px rgba(0, 0, 0, 0.3);
- background-color: #fff;
- border-radius: 20px;
- overflow-y: scroll;
- }
- .left,
- .right {
- height: 100%;
- }
- .left {
- width: 50px;
- display: flex;
- flex-direction: column;
- align-items: center;
- .tab-item {
- width: 100%;
- height: 55px;
- display: flex;
- align-items: center;
- justify-content: center;
- cursor: pointer;
- }
- .active-tab {
- background-color: #D2EAFC;
- }
- .bottom {
- .icon {
- display: block;
- margin-bottom: 26px;
- }
- }
- }
- .right {
- width: calc(100% - 50px);
- box-sizing: border-box;
- position: relative;
- border-left: 1px solid #ececec;
- .form-wrapper {
- padding: 18px 80px 18px 80px;
- height: calc(100% - 80px);
- overflow: auto;
- box-sizing: border-box;
- display: flex;
- .form-left-sheet {
- width: 500px;
- }
- .form-right-sheet {
- .custom-cover-btn {
- margin-top: 12px;
- display: flex;
- align-items: center;
- cursor: pointer;
- color: #494949;
- font-weight: 400;
- font-size: 12px;
- float: right;
- }
- }
- .base-form-wrapper {
- margin-right: 30px;
- width: 100%;
- .form-cell-content {
- .select-mode-ele {
- display: flex;
- position: relative;
- height: 120px;
- img {
- -webkit-user-drag: none;
- }
- .img:last-child {
- margin-right: 0px !important;
- }
- .img {
- width: 158px;
- height: 80px;
- border-radius: 5px;
- margin-right: 13px;
- cursor: pointer;
- }
- .img-tips {
- position: absolute;
- left: 0;
- bottom: -2px;
- }
- }
- .form-base {
- .form-cell {
- margin-top: 28px;
- .cell-title {
- color: #2F2F2F;
- font-weight: 500;
- font-size: 13px;
- display: flex;
- align-items: center;
- margin-bottom: 10px;
- .title-icon {
- width: 20px;
- margin-right: 4px;
- }
- }
- .flex {
- display: flex;
- align-items: center;
- }
- .cell-content {
- .count-input-wrapper {
- display: flex;
- align-items: center;
- .fans-unit-txt {
- margin-left: 10px;
- color: #7E7E7E;
- font-size: 12px;
- font-weight: 400;
- span {
- color: #C88726;
- }
- }
- }
- input {
- width: 178px;
- font-weight: 500;
- font-size: 14px;
- color: #000000;
- border: none;
- outline: none;
- box-sizing: border-box;
- }
- input::placeholder {
- color: #999999;
- }
- input:disabled {
- color: #999999;
- background-color: #fff;
- }
- .count-msg {
- font-weight: 400;
- font-size: 12px;
- color: #B3B3B3;
- margin-top: 12px;
- }
- }
- }
- .currency-select {
- cursor: pointer;
- background: #1D9BF0;
- padding: 0 10px;
- border-radius: 5px;
- color: #fff;
- width: max-content;
- max-width: 234px;
- display: flex;
- align-items: center;
- height: 38px;
- box-sizing: border-box;
- .icon {
- width: 20px;
- margin-right: 8px;
- }
- .text {
- white-space: nowrap;
- font-weight: 500;
- font-size: 14px;
- }
- .arrow {
- margin-left: 5px;
- }
- }
- .selected {
- background: #FFF !important;
- border: 1px solid #D9D9D9;
- .text {
- color: #000 !important;
- }
- }
- .automatically-input {
- border-top: 1px solid #D1D9DD;
- .input-wrapper {
- margin-right: 16px;
- box-sizing: border-box;
- input {
- padding-right: 4px !important;
- }
- .unit {
- font-weight: 700;
- font-size: 26px;
- opacity: 0.5;
- }
- }
- }
- }
- }
- }
- .currency-operation {
- position: relative;
- box-sizing: border-box;
- display: flex;
- align-items: center;
- margin-top: 8px;
- background: #F8F8F8;
- border-radius: 3px;
- width: 100%;
- height: 28px;
- padding-left: 10px;
- .balance,
- .amount {
- display: flex;
- align-items: center;
- }
- .amount {
- font-weight: 400;
- font-size: 12px;
- color: #A39F9F;
- img {
- margin-left: 6px;
- cursor: pointer;
- }
- }
- .top-up {
- font-weight: 500;
- font-size: 12px;
- color: #1D9BF0;
- cursor: pointer;
- margin-left: 4px;
- }
- }
- .form-label {
- margin-top: 14px;
- margin-bottom: 10px;
- font-weight: 500;
- font-size: 14px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- .icon-add-task {
- cursor: pointer;
- }
- }
- .form-require {
- box-sizing: border-box;
- border-radius: 15px;
- border: 1px solid #D1D9DD;
- .form-item {
- min-height: 54px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin: 0 16px;
- border-bottom: 1px solid #ececec;
- padding: 8px 0;
- box-sizing: border-box;
- .item-left {
- display: flex;
- }
- .label {
- min-width: 76px;
- display: flex;
- align-items: center;
- font-size: 15px;
- font-weight: 500;
- .icon {
- margin-right: 10px;
- }
- }
- .control {
- min-width: 258px;
- margin-left: 6px;
- box-sizing: border-box;
- position: relative;
- .discord-address {
- border: none;
- outline: none;
- color: #1D9BF0;
- font-weight: 500;
- font-size: 14px;
- width: 100%;
- height: 34px;
- padding-left: 15px;
- }
- .discord-address::placeholder {
- color: #c5c5c5;
- }
- .discord-invite-info {
- position: absolute;
- top: 40px;
- left: 0;
- box-shadow: 0px 4px 30px rgba(0, 0, 0, 0.3);
- background: #fff;
- border-radius: 16px;
- padding: 16px;
- box-sizing: border-box;
- display: flex;
- align-items: center;
- cursor: pointer;
- .icon {
- width: 40px;
- height: 40px;
- margin-right: 10px;
- border-radius: 50%;
- }
- .name {
- font-weight: 600;
- font-size: 16px;
- color: #101419;
- width: 193px;
- height: 20px;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- display: inline-block;
- }
- }
- }
- .icon-task-close {
- margin-left: 6px;
- cursor: pointer;
- }
- }
- .border-hide {
- border-bottom: none !important;
- }
- }
- }
- .usd-min-message {
- font-style: normal;
- font-weight: 400;
- font-size: 12px;
- line-height: 16px;
- letter-spacing: 0.3px;
- color: #C88726;
- margin-top: 8px;
- }
- .tips-wrapper {
- margin: 16px 0 0 12px !important;
- padding: 0px !important;
- .title,
- .row {
- font-weight: 400;
- font-size: 12px;
- color: #A39F9F;
- }
- .row {
- box-sizing: border-box;
- line-height: 16px;
- }
- }
- .submit-btn-wrapper {
- width: 100%;
- background: #fff;
- position: absolute;
- bottom: 18px;
- left: 0;
- box-sizing: border-box;
- padding: 16px 18px 0 18px;
- .submit-btn {
- width: 100%;
- height: 46px;
- text-align: center;
- background: #4a99e9;
- border-radius: 100px;
- color: #fff;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 16px;
- font-weight: 500;
- cursor: pointer;
- .icon-loading {
- width: 20px;
- height: 20px;
- margin-right: 3px;
- }
- }
- .disabled-submit {
- background-color: #D9D9D9;
- }
- }
- }
- .fill-right {
- width: 100% !important;
- border-bottom-left-radius: 16px;
- }
- }
- }
- }
- .icon-refresh-rotate {
- transform: rotate(360deg);
- transition-duration: 1s;
- }
- .payment {
- .balance {
- display: flex;
- margin-right: 20px;
- .icon {
- width: 40px;
- height: 40px;
- }
- .con {
- padding: 0 5px;
- .desc {
- color: rgba($color: #000000, $alpha: 0.5);
- font-size: 12px;
- margin-bottom: 4px;
- }
- .price {
- font-size: 14px;
- font-weight: bold;
- word-break: break-all;
- }
- }
- .refresh {
- width: 40px;
- cursor: pointer;
- margin-left: -5px;
- }
- }
- .btn-wrap {
- width: 100%;
- height: 80px;
- background-color: #fff;
- position: absolute;
- left: 0;
- bottom: 0;
- box-shadow: 0px -1px 0px #ececec;
- border-bottom-right-radius: 16px;
- padding: 12px 30px;
- box-sizing: border-box;
- display: flex;
- align-items: center;
- justify-content: flex-end;
- border-bottom-left-radius: 16px;
- z-index: 999;
- .custom-submit {
- width: 200px;
- height: 50px;
- background: #1D9BF0;
- border-radius: 50px;
- font-weight: 700;
- font-size: 18px;
- line-height: 50px;
- text-align: center;
- letter-spacing: 0.3px;
- color: #FFFFFF;
- cursor: pointer;
- }
- }
- }
- .dialog {
- position: absolute;
- z-index: 2002;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- width: 800px;
- height: calc(100% - 100px);
- border-radius: 20px;
- background-color: #ffffff;
- .corp-title {
- display: flex;
- height: 48px;
- align-items: center;
- .back {
- cursor: pointer;
- width: 24px;
- height: 24px;
- margin: 0 12px;
- }
- span {
- font-size: 16px;
- font-weight: 500;
- }
- }
- .corp-content {
- width: 472px;
- margin: auto;
- height: calc(100% - 130px);
- }
- .corp-footer {
- display: flex;
- align-items: center;
- justify-content: right;
- height: 80px;
- text-align: right;
- padding-right: 30px;
- .confirm {
- cursor: pointer;
- border: 0;
- width: 200px;
- height: 50px;
- color: #ffffff;
- font-size: 18px;
- font-weight: 700;
- border-radius: 25px;
- background: #1D9BF0;
- &.disable {
- background: #D9D9D9;
- img {
- width: 20px;
- margin-right: 10px;
- }
- }
- }
- }
- }
- .dialog-mask {
- position: absolute;
- z-index: 2001;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background-color: rgba(0, 0, 0, 0.5);
- }
- :deep() .vue-cropper {
- background-image: none;
- }
- :deep() .cropper-modal {
- background: rgba(0, 0, 0, .05);
- }
- </style>
|