123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868 |
- <template>
- <div class="center">
- <div class="title">Create NFTs</div>
- <div class="content">
- <div class="l">
- <div class="name">Preview</div>
- <template v-if="configList.length">
- <div class="show">
- <div class="card" :class="selectItem.modelName">
- <div class="logo">
- <img v-if="tempUrl" :src="tempUrl" alt="">
- </div>
- <div class="member">{{ projectName === '' ? 'xxxx' : projectName }}</div>
- <div class="number">{{ projectNo === '' ? '0000' : projectNo }}</div>
- </div>
- <img class="bg" :src="selectItem.mainImagePath" />
- </div>
- <div class="list">
- <div
- class="item"
- :class="{ on: item.modelName === selectItem.modelName }"
- @click="select(item, index)"
- v-for="(item, index) in configList"
- :key="index">
- <img :src="item.previewImagePath" alt="" />
- </div>
- </div>
- </template>
- <div class="wait" v-else>
- <img width="30" src="../../static/img/icon-loading-gray.png" alt="" />
- </div>
- </div>
- <div class="r">
- <div class="name">Card face</div>
- <div class="face">
- <input type="file" class="file" @change="uploadImg" accept="image/png,image/jpg,image/jpeg" />
- <div class="on" v-if="tempUrl">
- <img src="../../static/img/icon-add-cover-on.svg" alt="" />
- <img class="img" :src="tempUrl" alt="" />
- </div>
- <div class="off" v-else>
- <img src="../../static/img/icon-add-cover-off.svg" alt="" />
- </div>
- </div>
- <div class="desc">Recommended size 500*500 or more</div>
- <div class="name">Project Name</div>
- <div class="input"><input type="text" maxlength="30" v-model="projectName" placeholder="Your NFT Project Name" /></div>
- <div class="name">Project Description</div>
- <div class="textarea"><textarea placeholder="Your NFT Project Description" maxlength="250" v-model="projectDesc"></textarea></div>
- <div class="name">Collection Size</div>
- <div class="input"><input type="text" v-model="projectSize" placeholder="0" /></div>
- <div class="showNo" v-if="showNoStr">No.{{ projectNo === '' ? '0000' : projectNo }}~{{projectSize}}</div>
- <div class="name">NFTs Price</div>
- <div class="price">
- <div class="currency" @click="showCurrencyDialog" v-if="currencyItem">
- <img class="head" :src="currencyItem.iconPath" alt="" />
- <div class="font">{{currencyItem.tokenSymbol}}</div>
- <img class="arrow" src="../../static/img/icon-add-arrow.svg" alt="" />
- </div>
- <div class="no-select" @click="showCurrencyDialog" v-else>
- <div class="font">Select a reward</div>
- <img class="arrow" src="../../static/img/icon-add-arrow-white.svg" alt="" />
- </div>
- <div class="input">
- <div class="tips" v-if="showMinPrice">the price of each NFT must be above $0.1 USD</div>
- <input type="number" v-model="projectPrice" @input="changePrice" placeholder="0" />
- </div>
- <!-- 货币列表 -->
- <div class="currency-pop" v-if="currencyDialog">
- <currency-list @selectCurrencyItem="selectCurrencyItem"></currency-list>
- </div>
- </div>
- <div class="explain">
- <ul>
- <li class="special">The NFT colection is minted on BNB Smart Chain (BEP20)</li>
- <li>NFT will be released in blind box mode</li>
- <li>Users need to pay service fees when transferring NFTs</li>
- </ul>
- </div>
- <div class="footer"></div>
- </div>
- </div>
- <div class="create">
- <button class="on" v-if="isNext" @click="next">Create</button>
- <button class="off" v-else>Create</button>
- </div>
- </div>
- <div class="feedBack" @click="feedback">
- <a href="mailto:service@cybertogether.net">
- <div class="mail">
- <img src="../../static/img/icon-feedback.svg" alt="" />
- </div>
- <div class="font">Feedback</div>
- </a>
- </div>
- <div class="loading" v-if="showLoading">
- <img src="../../static/img/icon-add-loading.svg" alt="" />
- </div>
- <div class="succ" v-if="showSuccess">
- <img class="icon" src="../../static/img/icon-notice-succ.svg" alt="" />
- <div class="notic">We have created your NFT collection</div>
- <button class="btn" @click="jumpList">Done</button>
- </div>
- <div class="succ-bg" v-if="showSuccess"></div>
- <div class="mask-bg" v-if="currencyDialog" @click="hideCurrencyDialog"></div>
- </template>
- <script lang="ts" setup>
- import { ref, onMounted, watchEffect } from 'vue';
- import Api from '../../static/http/api';
- import { postRequest } from '../../static/http';
- import { uploadFile } from '../../static/utils/upload'
- import { Report } from '../../static/report'
- import { debounce } from '../../static/utils'
- import { businessType, pageSource, objectType } from '../../static/report/enum'
- import currencyList from '../../components/currency-list.vue';
- const isNext = ref(false);
- const showLoading = ref(false);
- const showSuccess = ref(false);
- const maxSize = ref(100000);
- const minUsdAmount = ref(0)
- const configList = ref([]);
- const selectItem = ref(null);
- const uploadItem = ref({});
- const currencyDialog = ref(false);
- const currencyItem = ref(null);
- const projectName = ref('');
- const projectDesc = ref('');
- const projectSize = ref('');
- const projectNo = ref('');
- const projectPrice = ref('');
- const showNoStr = ref(false);
- const showMinPrice = ref(false);
- const tempFile = ref('');
- const tempUrl = ref('');
- const buttonType = {
- feedback: 'feedback-button',
- create: 'create-button',
- }
- const getConfig = () => {
- postRequest(Api.createConfig).then(res => {
- let { code, data } = res;
- if ( code === 0 ) {
- configList.value = data.itemModels;
- maxSize.value = data.maxCollectionSize;
- selectItem.value = data.itemModels[0];
- minUsdAmount.value = data.sellMinUsdAmount;
- // 预加载图片
- if (data.itemModels) {
- data.itemModels.forEach(item => {
- let img = new Image()
- img.src = item.previewImagePath;
- })
- }
- }
- })
- }
- const next = () => {
- // show loading
- showLoading.value = true;
- uploadFile(tempFile.value).then(res => {
- // @ts-ignore
- uploadItem.value = res;
- // post
- postRequest(Api.userNftAdd, {
- params: {
- // 项目图标
- cardFaceImagePath: uploadItem.value && uploadItem.value.objectKey || '',
- // 发行数量
- nftCollectionSize: projectSize.value || '',
- // 选中的模版id
- nftItemImageModel: selectItem.value && selectItem.value.modelName || '',
- // 项目描述
- nftProjectDescription: projectDesc.value.trim() || '',
- // 项目名称
- nftProjectName: projectName.value.trim() || '',
- // 销售价格
- saleCurrencyAmount: projectPrice.value || '',
- // 销售的货币code
- saleCurrencyCode: currencyItem.value && currencyItem.value.currencyCode || '',
- }
- }).then(res => {
- if (res.code === 0) {
- showSuccess.value = true;
- }
- }).finally(() => {
- showLoading.value = false;
- })
- // Report
- Report({
- baseInfo: {
- pageSource: pageSource.creatorPage,
- },
- params: {
- eventData: {
- businessType: businessType.buttonClick,
- objectType: buttonType.create,
- }
- }
- })
- }).catch(() => {
- showLoading.value = false;
- })
- }
- const select = (item: any, index: number) => {
- selectItem.value = item;
- let objectType;
- switch(index) {
- case 0:
- objectType = `first-NFT-selection-button`;
- break;
- case 1:
- objectType = `second-NFT-selection-button`;
- break;
- case 2:
- objectType = `third-NFT-selection-button`;
- break;
- case 3:
- objectType = `forth-NFT-selection-button`;
- break;
- }
- // Report
- Report({
- baseInfo: {
- pageSource: pageSource.creatorPage,
- },
- params: {
- eventData: {
- businessType: businessType.buttonClick,
- objectType: objectType,
- }
- }
- })
- }
- const showCurrencyDialog = () => {
- currencyDialog.value = true;
- }
- const hideCurrencyDialog = () => {
- currencyDialog.value = false;
- }
- const selectCurrencyItem = (data: any) => {
- currencyItem.value = data;
- hideCurrencyDialog();
- }
- const uploadImg = (e: any) => {
- let file = e.target.files[0];
- // 清空file
- e.target.value = '';
- // 预览
- tempFile.value = file;
- tempUrl.value = URL.createObjectURL(file);
- }
- const hideSuccess = () => {
- showSuccess.value = false;
- }
- const jumpList = () => {
- location.href = `/nft/list`
- }
- const changePrice = debounce((e: any) => {
- projectPrice.value = String(Math.abs(e.target.value))
- }, 500)
- const feedback = () => {
- // Report
- Report({
- baseInfo: {
- pageSource: pageSource.creatorPage,
- },
- params: {
- eventData: {
- businessType: businessType.buttonClick,
- objectType: buttonType.feedback,
- }
- }
- })
- }
- let timer = ref(0);
- watchEffect(() => {
- let emojiReg = /[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F]|[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF]|[0-9|*|#]\uFE0F\u20E3|[0-9|#]\u20E3|[\u203C-\u3299]\uFE0F\u200D|[\u203C-\u3299]\uFE0F|[\u2122-\u2B55]|\u303D|[\A9|\AE]\u3030|\uA9|\uAE|\u3030/gi;
- // 数量
- let num = projectSize.value;
- num = num.replace(/\D/g, '');
- if (Number(num) > maxSize.value) {
- num = String(maxSize.value);
- }
- if (num) {
- projectSize.value = String(Number(num));
- } else {
- projectSize.value = '';
- }
-
- // 编号
- if (projectSize.value !== '') {
- projectNo.value = String(1).padStart(String(projectSize.value).length, '0')
- } else {
- projectNo.value = ''
- }
- showNoStr.value = projectNo.value != '';
- // 是否可以创建
- let ifUpload = tempUrl.value != '' || false;
- let ifName = projectName.value !== '';
- let ifDesc = projectDesc.value !== '';
- let ifSize = projectSize.value !== '' && Number(projectSize.value) > 0;
- let ifCurrency = currencyItem.value && currencyItem.value.currencyCode;
- let ifPrice = projectPrice.value && projectPrice.value !== '' && Number(projectPrice.value) > 0;
- // setTimeout
- clearTimeout(timer.value);
- timer.value = setTimeout(() => {
- projectName.value = projectName.value.replace(emojiReg, '');
- // 最低金额
- if (ifCurrency && ifPrice) {
- let usdPrice = currencyItem.value && currencyItem.value.usdPrice;
- if (Number(usdPrice) * Number(projectPrice.value) < Number(minUsdAmount.value)) {
- showMinPrice.value = true;
- } else {
- showMinPrice.value = false;
- }
- }
- // show next
- isNext.value = ifUpload && ifName && ifDesc && ifSize && ifCurrency && ifPrice && !showMinPrice.value;
- }, 400)
- })
- onMounted(() => {
- // config
- getConfig()
- // Report
- Report({
- baseInfo: {
- pageSource: pageSource.creatorPage,
- },
- params: {
- eventData: {
- businessType: businessType.pageView,
- }
- }
- })
- })
- </script>
- <style lang="less" scoped>
- .center {
- overflow-y: auto;
- padding: 0 50px;
- width: 1100px;
- margin: 10px auto 0;
- box-sizing: border-box;
- height: calc(100% - 10px);
- background-color: #fff;
- border-radius: 20px 20px 0 0;
- &::-webkit-scrollbar {
- width: 0 !important;
- }
- .title {
- padding: 22px 0;
- font-size: 20px;
- font-weight: 600;
- line-height: 24px;
- }
- .content {
- width: 100%;
- clear: both;
- display: flex;
- justify-content: space-between;
- .name {
- height: 24px;
- font-size: 12px;
- color: #939393;
- }
- .showNo {
- color: #939393;
- font-size: 12px;
- margin-top: -10px;
- margin-bottom: 24px;
- }
- .l {
- width: 400px;
- .wait {
- padding: 200px 0;
- text-align: center;
- img {
- opacity: .6;
- animation: rotate 1s infinite linear;
- }
- }
- .show {
- position: relative;
- overflow: hidden;
- width: 400px;
- height: 400px;
- border-radius: 10px;
- .card {
- position: absolute;
- left: 53px;
- top: 103px;
- width: 294px;
- height: 186px;
- .logo {
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- width: 100px;
- height: 100px;
- border-radius: 50%;
- background-color: #fff;
- img {
- width: 100%;
- height: 100%;
- border-radius: 50%;
- object-fit: cover;
- }
- }
- .member {
- position: absolute;
- top: 11px;
- left: 11px;
- width: 228px;
- font-size: 12px;
- text-align: left;
- font-weight: 800;
- line-height: 13px;
- }
- .number {
- position: absolute;
- top: 11px;
- right: 10px;
- font-size: 12px;
- font-weight: 800;
- line-height: 13px;
- letter-spacing: 1px;
- }
- &.s1 {
- .member, .number {
- color: #ffffff;
- }
- }
- &.s2 {
- .member, .number {
- color: #4AC3E1;
- }
- }
- &.s3 {
- .member, .number {
- color: #606C94;
- }
- }
- &.s4 {
- .member, .number {
- color: #504215;
- }
- }
- }
- .bg {
- width: 100%;
- height: 100%;
- }
- }
- .list {
- margin-top: 20px;
- display: flex;
- .item {
- width: calc(100% / 4);
- cursor: pointer;
- overflow: hidden;
- margin-right: 13px;
- border-radius: 5px;
- img {
- width: 100%;
- border-radius: 5px;
- }
- &:last-child {
- margin: 0;
- }
- &.on {
- position: relative;
- &::before {
- position: absolute;
- display: block;
- top: 0;
- right: 0;
- content: '';
- width: 44px;
- height: 44px;
- background-size: 100%;
- background-image: url('../../static/img/icon-add-select.svg');
- }
- }
- }
- }
- }
- .r {
- width: 520px;
- .face {
- position: relative;
- width: 80px;
- margin-bottom: 10px;
- .file {
- position: absolute;
- z-index: 2;
- width: 100%;
- height: 100%;
- opacity: 0;
- cursor: pointer;
- }
- .off {
- display: flex;
- align-items: center;
- justify-content: center;
- cursor: pointer;
- width: 80px;
- height: 80px;
- border-radius: 100px;
- border: 1px dashed #D0D0D0;
- background: rgba(0, 0, 0, 0.02);
- }
- .on {
- position: relative;
- display: flex;
- align-items: center;
- justify-content: center;
- cursor: pointer;
- width: 80px;
- height: 80px;
- overflow: hidden;
- border-radius: 100px;
- background: #353535;
- .img {
- position: absolute;
- opacity: .4;
- width: 100%;
- height: 100%;
- border-radius: 100px;
- }
- }
- }
- .desc {
- color: #B4B4B4;
- font-size: 12px;
- font-weight: 400;
- line-height: 16px;
- margin-bottom: 22px;
- }
- .input {
- position: relative;
- display: flex;
- align-items: center;
- justify-content: center;
- height: 41px;
- margin-bottom: 22px;
- border-radius: 5px;
- background: #FFFFFF;
- border: 1px solid #E0E0E0;
- input {
- border: 0;
- outline: none;
- padding: 3px 0;
- color: #777;
- font-size: 16px;
- font-weight: 500;
- letter-spacing: 0.3px;
- width: calc(100% - 24px);
- &::placeholder {
- color: rgba(0, 0, 0, .3);
- }
- }
- .tips {
- position: absolute;
- left: 0;
- top: -22px;
- font-size: 12px;
- color: #E29015;
- }
- }
- .textarea {
- display: flex;
- align-items: center;
- justify-content: center;
- height: 72px;
- margin-bottom: 22px;
- border-radius: 5px;
- background: #FFFFFF;
- border: 1px solid #E0E0E0;
- textarea {
- resize: none;
- border: 0;
- height: 52px;
- outline: none;
- color: #777;
- font-size: 16px;
- font-weight: 500;
- letter-spacing: 0.3px;
- width: calc(100% - 24px);
- font-family: "Segoe UI", Helvetica, Arial, sans-serif;
- &::placeholder {
- color: rgba(0, 0, 0, .3);
- }
- }
- }
- .price {
- position: relative;
- display: flex;
- justify-content: space-between;
- .currency {
- display: flex;
- align-items: center;
- justify-content: center;
- flex-direction: row;
- cursor: pointer;
- height: 43px;
- padding: 0 14px;
- margin-right: 13px;
- border-radius: 25px;
- background: #F4F4F4;
- .head {
- overflow: hidden;
- width: 20px;
- height: 20px;
- margin-right: 8px;
- border-radius: 50%;
- background-color: #999;
- }
- .font {
- max-width: 250px;
- font-size: 15px;
- font-weight: 500;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- .arrow {
- margin-left: 8px
- }
- }
- .no-select {
- display: flex;
- align-items: center;
- justify-content: center;
- flex-direction: row;
- cursor: pointer;
- height: 43px;
- padding: 0 14px;
- margin-right: 13px;
- border-radius: 25px;
- background: #1d9bf0;
- .font {
- max-width: 250px;
- color: #fff;
- font-size: 15px;
- font-weight: 500;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- .arrow {
- margin-left: 8px
- }
- }
- .input {
- flex: 1;
- margin-bottom: 0;
- }
- .currency-pop {
- position: absolute;
- overflow: hidden;
- z-index: 3;
- left: 0;
- bottom: 50px;
- width: 375px;
- max-height: 420px;
- border-radius: 20px;
- background-color: #fff;
- box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.25);
- }
- }
- .explain {
- color: #B4B4B4;
- font-size: 12px;
- font-weight: 400;
- line-height: 18px;
- ul {
- padding: 0;
- margin-left: 14px;
- }
- .special {
- color: #E29015;
- }
- }
- .footer {
- height: 80px;
- }
- }
- }
- .create {
- position: fixed;
- left: 50%;
- bottom: 0;
- width: 1100px;
- text-align: right;
- padding: 15px 30px;
- transform: translateX(-50%);
- box-sizing: border-box;
- background-color: #fff;
- border-top: solid 1px #ECECEC;
- .on {
- border: 0;
- height: 50px;
- color: #FFFFFF;
- cursor: pointer;
- padding: 0 50px;
- font-size: 18px;
- font-weight: 700;
- letter-spacing: 0.3px;
- border-radius: 25px;
- background: #1D9BF0;
- }
- .off {
- border: 0;
- height: 50px;
- color: #FFFFFF;
- cursor: pointer;
- padding: 0 50px;
- font-size: 18px;
- font-weight: 700;
- letter-spacing: 0.3px;
- border-radius: 25px;
- background: #E4E4E4;
- }
- }
- }
- .feedBack {
- position: absolute;
- right: 44px;
- bottom: 88px;
- cursor: pointer;
- font-size: 12px;
- text-align: center;
- a:link, a:visited {
- color: #A8A8A8;
- text-decoration: none;
- }
- .mail {
- display: flex;
- align-items: center;
- justify-content: center;
- margin: auto;
- width: 50px;
- height: 50px;
- margin-bottom: 10px;
- border-radius: 50%;
- background-color: #fff;
- }
- .font {
- opacity: 0.7;
- color: #A8A8A8;
- letter-spacing: 0.3px;
- }
- }
- .loading {
- display: flex;
- align-items: center;
- justify-content: center;
- position: absolute;
- top: 0;
- left: 0;
- z-index: 2;
- width: 100%;
- height: 100%;
- background: rgba(255, 255, 255, .8);
- img {
- width: 100px;
- animation: rotate 1s linear infinite;
- }
- }
- @keyframes rotate {
- 0% {
- transform: rotate(0);
- }
- 100% {
- transform: rotate(360deg);
- }
- }
- .succ {
- position: absolute;
- z-index: 2;
- top: 50%;
- left: 50%;
- width: 500px;
- height: 400px;
- border-radius: 20px;
- background-color: #fff;
- transform: translate(-50%, -50%);
- .icon {
- display: block;
- width: 120px;
- height: 120px;
- margin: 78px auto 27px auto;
- }
- .notic {
- font-size: 20px;
- font-weight: 700;
- text-align: center;
- line-height: 24px;
- }
- .btn {
- display: block;
- border: 0;
- cursor: pointer;
- width: 440px;
- height: 50px;
- color: #fff;
- font-size: 18px;
- font-weight: 700;
- margin: 70px auto 0;
- border-radius: 50px;
- background: #1D9BF0;
- }
- }
- .succ-bg {
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background: rgba(0, 0, 0, .8);
- }
- .mask-bg {
- position: absolute;
- top: 0;
- left: 0;
- z-index: 2;
- width: 100%;
- height: 100%;
- }
- </style>
|