123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500 |
- <template>
- <div class="overlay" v-if="visible">
- <div class="content"
- :style="{
- height: dialogHeight + 'px',
- width: showComType != 'preview' ? '600px' : 'auto'}">
- <div class="pop-mask"
- v-show="showCurrencyPop"
- @click.stop="showCurrencyPop = false"></div>
- <!-- 头部 -->
- <div class="head">
- <div class="left">
- <!-- 关闭按钮 -->
- <div class="close-btn" @click="close">
- <img class="icon-close"
- :src="require('../../assets/svg/icon-close.svg')"
- v-if="showComType == 'default'"/>
- <img class="icon-close"
- :src="require('../../assets/svg/icon-back.svg')"
- v-else/>
- </div>
- <!-- 标题 -->
- <div class="title">
- {{ currentComData[showComType]["title"] }}
- </div>
- </div>
- <div class="right">
- <!-- 更多按钮 -->
- <img :src="require('@/assets/svg/icon-more-l.svg')"
- class="more"
- @click="showMoreOption = true">
- <div class="area-option"
- v-if="showMoreOption"
- @click="showMoreOption = false">
- <div class="option">
- <div class="item" @click="goTransactionsList()">
- <img :src="require('@/assets/svg/icon-menu.svg')">
- <span>Transaction History</span>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- 内容 -->
- <div class="body">
- <img src="@/assets/gif/icon-guide-select.gif"
- class="icon-guide-select"
- v-if="!currentCurrencyInfo.currencyCode && showComType == 'default'">
- <!-- 充值组件 -->
- <top-up v-if="showComType == 'topUp'"
- :asyncIng="asyncIng"
- :currentCurrencyInfo="tempCurrentCurrencyInfo"
- @topUpDone="topUpDone"></top-up>
- <!-- 表单填写容器 -->
- <div class="body-content" v-if="showComType != 'topUp'">
- <!-- 货币列表 -->
- <div class="currency-pop" v-show="showCurrencyPop">
- <currency-list
- ref="currencyListDom"
- @selectCurrency="selectCurrency"
- @setCurrencyList="setCurrentCurrencyInfo"></currency-list>
- </div>
- <div class="left">
- <div class="gift-pack-wrapper">
- <img class="icon"
- :src="require('../../assets/svg/icon-gift-pack.svg')"/>
- </div>
- <div class="bottom">
- </div>
- </div>
- <div class="right">
- <div class="form-wrapper" v-if="showComType == 'default'">
- <img
- class="img-mode"
- :src="require('@/assets/svg/img-mode.svg')"
- />
- <!-- 金额、数量 -->
- <div class="form-base">
- <div class="item currency-select-wrapper">
- <div
- class="label currency-select"
- :class="{'selected': currentCurrencyInfo.currencyCode}"
- @click="selectCurrencyPopHandle"
- >
- <img v-if="currentCurrencyInfo.iconPath"
- class="icon"
- :src="currentCurrencyInfo.iconPath"
- />
- <div class="text">
- {{currentCurrencyInfo.currencyCode == 'USD' ? 'USD' : currentCurrencyInfo.tokenSymbol || 'Select a reward'}}
- </div>
- <img
- class="arrow"
- :src="currentCurrencyInfo.currencyCode ?
- require('../../assets/svg/icon-form-arrow-down.svg') : require('../../assets/svg/icon-form-white-arrow-down.svg')
- "
- />
- </div>
- <input
- v-model="baseFormData.amountValue"
- placeholder="0"
- autofocus
- @input="onAmountInput"
- @blur="onAmountBlur"
- />
- </div>
- <div class="item">
- <div class="label">
- <img
- class="icon"
- :src="
- require('../../assets/svg/icon-winners.svg')
- "
- />
- Winners
- </div>
- <input
- v-model="baseFormData.totalCount"
- placeholder="0"
- @input="onCountInput"
- @blur="onCountBlur"
- />
- </div>
- </div>
- <!-- 刷新按钮、充值 -->
- <div class="form-base-help" v-show="currentCurrencyInfo.currencyCode">
- <div class="currency-operation">
- <div class="balance">
- <img
- :src="
- require('../../assets/svg/icon-balance.svg')
- "
- />
- Balance
- </div>
- <div class="amount">
- {{currentCurrencyInfo.balance}}
- <img
- :class="{ 'icon-refresh-rotate': refreshRotate }"
- @click="updateCurrencyBanlce"
- :src="
- require('../../assets/svg/icon-form-refresh.svg')
- "
- />
- </div>
- <div v-if="currentCurrencyInfo.currencyCode != 'USD'" class="top-up" @click="goTopUp">Deposit</div>
- </div>
- <div class="msg">
- Recommend winners 100~10000
- </div>
- </div>
- <div class="form-label">Tasks</div>
- <!-- 转推、like、关注 -->
- <div class="form-require">
- <div
- class="form-item"
- v-for="(item, index) in formList"
- :key="index"
- >
- <div class="label">
- <img
- class="icon"
- :src="item.icon"
- />
- {{ item.label }}
- </div>
- <div
- class="control"
- v-if="item.nodeType == 'textarea'"
- >
- <follow-input
- :isAddSelf="!isBack"
- :atUserList="atUserList"
- @addUser="addFollowUser"
- @setUser="setFollowUser"
- @delUser="delFollowUser"
- ></follow-input>
- </div>
- <el-switch
- v-if="item.type == 2"
- v-model="item.checked"
- />
- <img
- v-if="item.type == 3"
- :src="
- require('../../assets/svg/icon-option-checked.svg')
- "
- />
- </div>
- </div>
- <!-- 机器人 -->
- <!-- <div class="anti-bot-wrapper">
- <div class="label">
- <img
- :src="
- require('../../assets/svg/icon-anti-bot.svg')
- "
- class="icon-bot"
- />
- Anti Bot
- <img
- :src="
- require('../../assets/svg/icon-beta.svg')
- "
- class="icon-beta"
- />
- <img
- :src="
- require('../../assets/svg/icon-question.svg')
- "
- class="icon-question"
- />
- </div>
- <el-switch v-model="openAntiBot" />
- </div> -->
- <!-- 提示 -->
- <ul class="tips-wrapper">
- <li class="row">
- 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">
- 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 class="submit-btn-wrapper">
- <div class="submit-btn"
- :class="{ 'disabled-submit': iptErrMsgTxt != '' && !depositGuide }"
- @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-card
- :currentCurrencyInfo="currentCurrencyInfo"
- :postData="publishRes"
- :baseFormData="baseFormData"
- :amountFontSize="previewFontSize"
- ></preview-card>
- </template>
- <!-- paypal支付按钮 -->
- <div v-show="showComType == 'preview'">
- <paypal-button
- :finalAmountData="finalAmountData"
- :payConfig="{
- paypalClientId,
- feeDesc: payConfig.feeDesc,
- paypalHtml,
- amount: baseFormData.amountValue,
- postId
- }"
- :currentCurrencyInfo="currentCurrencyInfo"
- @payPalFinsh="payPalFinsh"
- ></paypal-button>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- 提示 -->
- <message-box
- :dialogVisible="showMessageBox"
- :title="messageBoxData.title"
- :content="messageBoxData.content"
- @cancel="messageBoxCancel"
- @confirm="messageBoxConfirm"
- ></message-box>
- </div>
- </template>
- <script setup>
- import { ref, watch, reactive, defineProps, defineEmits, onMounted, nextTick } from "vue";
- import { postPublish, verifyPaypalResult, syncChainTokenRechargeRecord } from "@/http/publishApi";
- import { payCalcFee, getPayConfig } from "@/http/pay";
- import { getFrontConfig } from "@/http/account";
- import { throttle } from "@/uilts/help"
- import { ElMessage, ElLoading } from "element-plus";
- import "element-plus/es/components/message/style/css";
- import {create, all} from "mathjs";
- import previewCard from "./preview-card";
- import paypalButton from "./paypal-button";
- import followInput from "./follow-input";
- import messageBox from "./message-box.vue";
- import currencyList from "./currency-list.vue";
- import topUp from "./top-up.vue"
- const config = {
- number: 'BigNumber',
- }
- const math = create(all, config);
- let tempCurrentCurrencyInfo = ref({});
- let paypalClientId = ref("");
- let payConfig = ref({})
- let paypalHtml = ref("");
- let publishRes = reactive({});
- let currentComData = {
- default: {
- title: "Giveaway",
- },
- preview: {
- title: "Preview",
- },
- topUp: {
- title: "Deposit",
- },
- };
- let visible = ref(false);
- let showComType = ref("default"); // default(表单) preview(预览) topUp(充值)
- let openAntiBot = ref(false);
- let dialogHeight = ref(680);
- // 是否正在提交
- let submitIng = ref(false);
- // 艾特关注人列表
- let atUserList = ref([]);
- let iptErrMsgTxt = ref("Select a reward");
- // 是否返回
- let isBack = ref(false);
- // 展示消息提示
- let showMessageBox = ref(false);
- // 展示货币列表pop
- let showCurrencyPop = ref(false);
- let showMoreOption = ref(false);
- let currencyListDom = ref('');
- let refreshRotate = ref(false);
- let previewFontSize = ref(56);
- let postId = ref('');
- let asyncIng = ref(false);
- let depositGuide = ref(false);
- let messageBoxData = ref({
- title: "",
- content: "",
- });
- // 真实支付金额数据
- let finalAmountData = ref({
- currencyCode: '',
- feeAmountValue: 0,
- finalAmountValue: 0,
- requestAmountValue: 0,
- });
- // 表单数据
- let baseFormData = reactive({
- amountCurrencyCode: '',
- amountValue: "",
- totalCount: "",
- });
- // 当前选择的货币信息
- let currentCurrencyInfo = ref({
- currencyCode: "",
- currencyName: "",
- balance: "",
- currencyType: "",
- iconPath: "",
- minAmount: "",
- tokenChain: "",
- tokenSymbol: "",
- usdEstimateBalance: ""
- });
- let formList = reactive([
- {
- label: "Follow",
- icon: require("../../assets/svg/icon-follow.svg"),
- nodeType: "textarea",
- type: 1,
- text: [],
- checked: true,
- },
- {
- label: "Retweet",
- icon: require("../../assets/svg/icon-retweet.svg"),
- nodeType: "div",
- type: 3,
- checked: true,
- },
- {
- label: "Like Tweet",
- icon: require("../../assets/svg/icon-like.svg"),
- nodeType: "div",
- type: 2,
- checked: true,
- },
- ]);
- const props = defineProps({
- dialogVisible: {
- type: Boolean,
- default: false,
- },
- });
- watch(
- () => props.dialogVisible,
- (newVal) => {
- console.log("watch", newVal);
- visible.value = newVal;
- if (newVal) {
- setTimeout(() => {
- setDialogHeight();
- }, 300);
- }
- }
- );
- const emits = defineEmits(["close", "confirm", "payPalFinsh"]);
- const close = () => {
- if (showComType.value != "default") {
- showComType.value = "default";
- calcDomZoom();
- isBack.value = true;
- } else {
- initParams();
- emits("close", false);
- }
- };
- /**
- * 设置弹窗高度
- */
- const setDialogHeight = (resize = false) => {
- let clientHeight = window.innerHeight;
- let gapSafe = 40;
- if (dialogHeight.value > clientHeight - gapSafe) {
- dialogHeight.value = clientHeight - gapSafe;
- } else {
- if(resize) {
- dialogHeight.value = 680;
- }
- }
- };
- const selectCurrencyPopHandle = () => {
- showCurrencyPop.value = true;
- nextTick(() => {
- if(currencyListDom.value) {
- currencyListDom.value.getCurrencyInfoList && currencyListDom.value.getCurrencyInfoList();
- }
- })
- }
- /**
- * 获取实际支付金额
- */
- const getPayAmount = async (amountValue) => {
- let res = await payCalcFee({
- params: {
- amountValue,
- currencyCode: currentCurrencyInfo.value.currencyCode,
- payChannel: 'paypal',
- },
- });
- if (res.code == 0) {
- let { finalAmountValue, feeDesc } = res.data;
- payConfig.value.feeDesc = feeDesc;
- if (finalAmountValue > 0) {
- finalAmountData.value = res.data;
- }
- }
- return res.data;
- };
- const confirm = () => {
- if(depositGuide.value) { //余额不够去充值
- goTopUp();
- return;
- }
- if (submitIng.value || iptErrMsgTxt.value) {
- return;
- }
- let { totalCount = 0 } = baseFormData;
- if (!totalCount) {
- return;
- }
- submitRequest();
- };
- const selectCurrency = (params) => {
- tempCurrentCurrencyInfo.value = params;
- depositGuide.value = false;
- 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 {
- currentCurrencyInfo.value = params;
- showCurrencyPop.value = false;
- finalAmountData.value.currencyCode = currentCurrencyInfo.value.currencyCode;
- calcDomZoom();
- resetFormIpt();
- onIptSetErrorTxt();
- }
- };
- const calcDomZoom = () => {
- nextTick(() => {
- let maxWidth = 68;
- var textWidth = document.querySelector('.text').offsetWidth;
- if(textWidth > 68) {
- var scale = maxWidth / textWidth;
- document.querySelector('.text').style.zoom = scale;
- }
- })
- }
- const resetFormIpt = () => {
- baseFormData.amountValue = "";
- baseFormData.totalCount = "";
- }
- /**
- * 设置默认使用货币
- */
- const setCurrentCurrencyInfo = (params) => {
- let {list} = params;
- if(list && list.length && list[0].data && list[0].data.length) {
- // currentCurrencyInfo.value = list[0].data[0];
- // finalAmountData.value.currencyCode = currentCurrencyInfo.value.currencyCode;
- }
- }
- const messageBoxBlock = ({ title = "", content = "" }) => {
- showMessageBox.value = true;
- messageBoxData.value.title = title;
- messageBoxData.value.content = content;
- };
- /**
- * 确定
- */
- const messageBoxConfirm = () => {
- showMessageBox.value = false;
- showComType.value = "topUp";
- };
- /**
- * 取消
- */
- const messageBoxCancel = () => {
- currentCurrencyInfo.value = tempCurrentCurrencyInfo.value;
- showMessageBox.value = false;
- showCurrencyPop.value = false;
- calcDomZoom();
- resetFormIpt();
- onIptSetErrorTxt();
- };
- /**
- * 去充值
- */
- const goTopUp = () => {
- showComType.value = 'topUp';
- }
- /**
- * 充值done事件
- */
- const topUpDone = () => {
- currentCurrencyInfo.value = tempCurrentCurrencyInfo.value;
- asyncIng.value = true;
- depositGuide.value = false;
- asyncIng.value = false;
- showCurrencyPop.value = false;
- showComType.value = 'default';
- calcDomZoom();
- 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 = () => {
- if(!refreshRotate.value) {
- refreshRotate.value = true;
- setTimeout(() => {
- refreshRotate.value = false;
- }, 1000)
- }
- 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) => {
- syncChainTokenRechargeRecord({
- params: {
- currencyCode: currentCurrencyInfo.value.currencyCode
- }
- }).then(res => {
- cb && cb(res)
- })
- }
- /**
- * 提交表单请求
- */
- const submitRequest = async () => {
- let { amountValue = 0, totalCount = 0 } = baseFormData;
- baseFormData.amountCurrencyCode = currentCurrencyInfo.value.currencyCode;
- // 组装提交参数
- formList[0]["text"] = atUserList.value;
- let finishConditions = [];
- for (let i = 0; i < formList.length; i++) {
- let item = {};
- item.type = formList[i]["type"];
- if (item.type == 1 && formList[i]["text"]) {
- // follow 参数
- let relatedUsers = formList[i]["text"];
- item.relatedUsers = relatedUsers;
- finishConditions.push(item);
- } else if (formList[i]["checked"]) {
- finishConditions.push(item);
- }
- }
- let receiveConditions = openAntiBot.value ? "" : [];
- // 提交参数
- let formData = {
- amountCurrencyCode: baseFormData.amountCurrencyCode,
- amountValue,
- totalCount,
- finishConditions,
- receiveConditions,
- payAmountValue: amountValue
- };
- submitIng.value = true;
- // 法币支付需要计算费率
- if(formData.amountCurrencyCode == "USD") {
- let payAmountRes = await getPayAmount(amountValue);
- formData["payAmountValue"] = payAmountRes.finalAmountValue;
- }
- 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;
- showComType.value = "preview";
- previewFontSize.value = calcFontSize(baseFormData.amountValue, 238, 56);
- isBack.value = false;
- } else {
- console.log(res);
- }
- })
- .catch((err) => {
- console.log(err);
- });
- };
- 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();
- formList[0].text = [];
- atUserList.value = [];
- submitIng.value = false;
- isBack.value = false;
- showCurrencyPop.value = false;
- openAntiBot.value = false;
- tempCurrentCurrencyInfo.value = {};
- currentCurrencyInfo.value = {};
- };
- /**
- * 支付完成回调
- */
- const payPalFinsh = (params) => {
- let {payNetwork, payStatus} = params;
- // token 支付
- if(payNetwork == 'bsc') {
- payStatusHandle(payStatus);
- } else {
- // 法币支付
- let transaction = params.transaction;
- let loadingInstance = ElLoading.service({
- background: "rgba(0,0,0,.3)",
- });
- verifyPaypalResult({
- params: {
- paypalTransactionId: transaction.id,
- postId: publishRes.postId,
- paypalClientId: paypalClientId.value,
- },
- }).then((res) => {
- loadingInstance.close();
- if (res.code == 0) {
- if (res.data) {
- payStatusHandle(res.data.payStatus)
- }
- }
- })
- .catch(() => {
- loadingInstance.close();
- });
- }
- };
- const payStatusHandle = (payStatus) => {
- //支付状态 0:未支付,1:支付成功,2:支付失败,3:已关闭,4:已退款
- switch (payStatus) {
- case 1:
- emits("payPalFinsh", { publishRes });
- showComType.value = "default";
- initParams();
- break;
- case 2:
- // ElMessage({
- // message: "Pay Fail",
- // type: "warning",
- // });
- break;
- case 3:
- // ElMessage({
- // message: "Pay Exceptions",
- // type: "warning",
- // });
- break;
- case 4:
- // ElMessage({
- // message: "Pay Exceptions",
- // type: "warning",
- // });
- break;
- }
- }
- /**
- * follow组件触发新增关注人
- */
- const addFollowUser = (params) => {
- atUserList.value.push(params);
- };
- const setFollowUser = (params) => {
- atUserList.value[params.index]["name"] = params.name;
- };
- const delFollowUser = (params) => {
- atUserList.value.splice(params.index, 1);
- };
- const onAmountInput = () => {
- let val = baseFormData.amountValue;
- // val = val.replace(/[^\d^\.]+/g, "");
- val = val.replace(/^\D*(\d*(?:\.\d{0,18})?).*$/g, '$1');
- 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];
- }
- }
- baseFormData.amountValue = val;
- setInputErrorMsg({from: 'amount', type:'input'});
- return val;
- };
- const onCountInput = () => {
- let val = baseFormData.totalCount;
- if (val == 0) {
- val = "";
- }
- // val = val.replace(/[^\d]/g, "");
- val = val.replace(/^\D*(\d*(?:\.\d{0,18})?).*$/g, '$1');
- baseFormData.totalCount = val;
- setInputErrorMsg({from: 'count', type:'input'});
- return val;
- };
- /**
- * 金额输入失焦
- */
- const onAmountBlur = () => {
- setInputErrorMsg({from: 'amount', type:'blur'});
- };
- /**
- * count失焦,校验输入结果
- */
- const onCountBlur = () => {
- setInputErrorMsg({from: 'count', type:'blur'});
- };
- /**
- * 输入结果金额和数量 (金额/数量)是否小于最小货币单位
- */
- const calcIptValue = (cb) => {
- let amountValue = baseFormData.amountValue;
- let totalCount = baseFormData.totalCount;
- let flag = true;
- if (!amountValue || !totalCount) {
- return {
- flag
- };
- }
- // let num = amountValue, scale = 1;
- // if(amountValue.indexOf('.') > -1) {
- // num = amountValue.toString();
- // let obj = scaleNumber(num);
- // num = obj.val;
- // scale = obj.scale;
- // }
- // let minAmount = currentCurrencyInfo.value.minAmount;
- // // 输入的token数量或者法币金额,平均分到每个红包,是否小于最小单位
- // if (num / totalCount < minAmount * scale) {
- // flag = false;
- // }
- // return {
- // flag,
- // count: Math.floor((num / minAmount * scale)/ (scale * scale))
- // };
- // console.log('baseFormData',`${baseFormData.amountValue} / ${baseFormData.totalCount}`)
- 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}`)))
- }
- };
- /**
- * 设置输入提示语
- */
- const setInputErrorMsg = (params) => {
- // let amountValue = baseFormData.amountValue;
- // let num = amountValue, scale = 1;
- // if(amountValue.indexOf('.') > -1) {
- // num = amountValue.toString();
- // let obj = scaleNumber(num);
- // num = obj.val;
- // scale = obj.scale;
- // }
- onIptSetErrorTxt(params);
- };
- /**
- * 输入时 检测设置错误信息
- */
- const onIptSetErrorTxt = (params) => {
- depositGuide.value = false;
- if(!currentCurrencyInfo.value.currencyCode) {
- iptErrMsgTxt.value = "Select a reward"
- } else if (!baseFormData.amountValue || baseFormData.amountValue == '0') {
- iptErrMsgTxt.value = "Enter an amount";
- } else if (!baseFormData.totalCount || baseFormData.totalCount == '0') {
- iptErrMsgTxt.value = "Enter the number of winners";
- } else if(+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 {
- iptErrMsgTxt.value = "";
- }
- } else if(currentCurrencyInfo.value.currencyCode != 'USD') {
- depositGuide.value = true;
- iptErrMsgTxt.value = `Insufficient ${currentCurrencyInfo.value.tokenSymbol} balance, please deposit`;
- }
- }
- /**
- * 获取支付配置(paypalClientId)
- */
- const setPayConfig = () => {
- getPayConfig({
- params: {},
- }).then((res) => {
- if (res.code == 0) {
- payConfig.value = res.data;
- paypalClientId.value = res.data.paypalClientId;
- }
- });
- };
- /**
- * 获取配置
- */
- const setFrontConfig = () => {
- getFrontConfig({
- params: {},
- }).then((res) => {
- if (res.code == 0) {
- paypalHtml.value = res.data.paypalHtml;
- }
- });
- };
- const goTransactionsList = () => {
- window.open(`${chrome.runtime.getURL('/iframe/home.html#/transactions')}`)
- }
- onMounted(() => {
- setFrontConfig();
- setPayConfig();
- document.onkeydown = function (e) {
- var keyNum = window.event ? e.keyCode : e.which;
- let escKey = 27;
- if (keyNum == escKey) {
- if (visible.value) {
- // close();
- }
- }
- };
- window.onresize = throttle(function () {
- setDialogHeight(true)
- }, 300)
- });
- </script>
- <style lang="scss" scoped>
- .ql-container {
- height: 100px;
- }
- .overlay {
- position: fixed;
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- z-index: 1000;
- 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;
- .pop-mask {
- width: 100%;
- height:100%;
- position: absolute;
- z-index:900;
- }
- .head {
- border-bottom: 1px solid #ececec;
- height: 48px;
- box-sizing: border-box;
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 0 14px;
- .left {
- display: flex;
- align-items: center;
- .title {
- font-size: 16px;
- font-weight: 500;
- }
- .close-btn {
- display: flex;
- align-items: center;
- width: max-content;
- margin-right: 12px;
- cursor: pointer;
- }
- }
- .right {
- .more {
- cursor: pointer;
- }
- .area-option {
- width: 100%;
- height: 100%;
- position: absolute;
- top: 0;
- left: 0;
- z-index: 111;
- .option {
- position: absolute;
- top: 43px;
- right: 15px;
- background: #fff;
- filter: drop-shadow(0px 3px 20px rgba(0, 0, 0, 0.2));
- width: 240px;
- border-radius: 15px;
- overflow: hidden;
- .item {
- width: 100%;
- height: 50px;
- display: flex;
- align-items: center;
- cursor: pointer;
- border-top: 1px solid #E9E9E9;
- img {
- margin-left: 15px;
- width: 30px;
- height: 30px;
- margin-right: 6px;
- }
- span {
- font-weight: 500;
- font-size: 14px;
- }
- }
- .item:first-child {
- border-top: 0;
- }
- .item:hover {
- background: #F5F5F5;
- }
- }
- }
- }
- }
- .body {
- box-sizing: border-box;
- height: calc(100% - 48px);
- display: flex;
- position: relative;
- .icon-guide-select {
- width: 40px;
- position: absolute;
- top: 78px;
- left: 25px;
- z-index: 1000;
- }
- .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: scroll;
- }
- .left,
- .right {
- height: 100%;
- }
- .left {
- width: 50px;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- align-items: center;
- .gift-pack-wrapper {
- width: 100%;
- height: 55px;
- background: #f5f5f5;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .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: 0px 18px 18px 18px;
- height: calc(100% - 80px);
- overflow-y: scroll;
- overflow-x: hidden;
- box-sizing: border-box;
- .img-mode {
- margin-left: -18px;
- }
- .form-base-help {
- display: flex;
- justify-content: space-between;
- margin-top: 10px;
- .currency-operation:before{
- box-sizing: content-box;
- width: 0px;
- height: 0px;
- position: absolute;
- top: -16px;;
- left:46px;
- padding:0;
- border-bottom:8px solid #FFFFFF;
- border-top:8px solid transparent;
- border-left:8px solid transparent;
- border-right:8px solid transparent;
- display: block;
- content:'';
- z-index: 12;
- }
- .currency-operation:after{
- box-sizing: content-box;
- width: 0px;
- height: 0px;
- position: absolute;
- top: -18px;;
- left:45px;
- padding:0;
- border-bottom:9px solid #EAEAEA;
- border-top:9px solid transparent;
- border-left:9px solid transparent;
- border-right:9px solid transparent;
- display: block;
- content:'';
- z-index:10
- }
- .currency-operation {
- position: relative;
- height: 36px;
- border: 1px solid #EAEAEA;
- box-sizing: border-box;
- padding: 10px;
- display: flex;
- align-items: center;
- border-radius: 100px;
- .balance,
- .amount {
- display: flex;
- align-items: center;
- }
- .balance {
- font-weight: 400;
- font-size: 13px;
- img {
- width: 16px;
- height: 16px;
- margin-right: 3px;
- }
- }
- .amount {
- font-weight: 500;
- font-size: 13px;
- color: #4e4e4e;
- margin-left: 5px;
- img {
- margin-left: 5px;
- cursor: pointer;
- }
- }
- .top-up {
- font-weight: 500;
- font-size: 12px;
- color: #ff9839;
- cursor: pointer;
- margin-left: 8px;
- }
- .icon-refresh-rotate {
- transform: rotate(360deg);
- transition-duration: 1s;
- }
- }
- .msg {
- font-weight: 400;
- font-size: 12px;
- color: #acacac;
- }
- }
- .form-base {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-top: 14px;
- .item {
- width: 250px;
- height: 50px;
- box-sizing: border-box;
- border-radius: 14px;
- border: 1px solid #D1D9DD;
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 16px 14px;
- input {
- width: 102px;
- text-align: right;
- font-weight: 500;
- font-size: 18px;
- border: none;
- outline: none;
- box-sizing: border-box;
- }
- input::placeholder {
- color: #c5c5c5;
- }
- .label {
- font-weight: 500;
- font-size: 15px;
- display: flex;
- align-items: center;
- .icon {
- width: 20px;
- height: 20px;
- margin-right: 8px;
- }
- }
- }
- .item:first-child {
- margin-right: 14px
- }
- .currency-select-wrapper {
- padding: 0 !important;
- input {
- padding-right: 14px;
- }
- .currency-select {
- max-width: 136px;
- cursor: pointer;
- background: #1D9BF0;
- margin-left: 6px;
- padding: 6px 10px;
- border-radius: 12px;
- color: #fff;
- .text {
- white-space: nowrap;
- zoom: 0.85;
- }
- .arrow {
- margin-left: 5px;
- }
- }
- .selected {
- background: #F4F4F4 !important;
- color: #000 !important;
- }
- }
- }
- .form-label {
- margin-top: 14px;
- margin-bottom: 10px;
- font-weight: 500;
- font-size: 14px;
- }
- .form-require {
- box-sizing: border-box;
- border-radius: 15px;
- margin-top: 12px;
- border: 1px solid #D1D9DD;
- .form-item {
- min-height: 50px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin: 0 16px;
- border-bottom: 1px solid #ececec;
- .label {
- min-width: 88px;
- display: flex;
- align-items: center;
- font-size: 15px;
- font-weight: 500;
- .icon {
- margin-right: 10px;
- }
- }
- .control {
- width: 100%;
- min-height: 50px;
- margin-left: 18px;
- box-sizing: border-box;
- }
- }
- .form-item:last-child {
- border-bottom: none !important;
- }
- }
- }
- .anti-bot-wrapper {
- width: 100%;
- height: 50px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- box-sizing: border-box;
- border-radius: 15px;
- padding: 0 18px;
- margin-top: 14px;
- border: 1px solid #D1D9DD;
- .label {
- display: flex;
- align-items: center;
- font-size: 15px;
- font-weight: 500;
- .icon-bot {
- margin-right: 8px;
- }
- .icon-beta {
- margin-left: 5px;
- margin-right: 8px;
- }
- .icon-question {
- cursor: pointer;
- }
- }
- }
- .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;
- }
- .more {
- color: #1D9BF0;
- font-size: 13px;
- padding-left: 4px;
- cursor: pointer;
- }
- }
- .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;
- }
- }
- }
- }
- }
- }
- </style>
|