add.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790
  1. <template>
  2. <div class="center">
  3. <div class="title">Create NFTs</div>
  4. <div class="content">
  5. <div class="l">
  6. <div class="name">Preview</div>
  7. <template v-if="configList.length">
  8. <div class="show">
  9. <div class="card" :class="selectItem.modelName">
  10. <div class="logo">
  11. <img v-if="uploadItem && uploadItem.imagePath" :src="uploadItem.imagePath" alt="">
  12. </div>
  13. <div class="member">{{ projectName === '' ? 'xxxx' : projectName }}</div>
  14. <div class="number">{{ projectNo === '' ? '0000' : projectNo }}</div>
  15. </div>
  16. <img class="bg" :src="selectItem.mainImagePath" />
  17. </div>
  18. <div class="list">
  19. <div
  20. class="item"
  21. :class="{ on: item.modelName === selectItem.modelName }"
  22. @click="select(item, index)"
  23. v-for="(item, index) in configList"
  24. :key="index">
  25. <img :src="item.previewImagePath" alt="" />
  26. </div>
  27. </div>
  28. </template>
  29. <div class="wait" v-else>
  30. <img width="30" src="../../static/img/icon-loading-gray.png" alt="" />
  31. </div>
  32. </div>
  33. <div class="r">
  34. <div class="name">Card face</div>
  35. <div class="face">
  36. <input type="file" class="file" @change="uploadImg" accept="image/png,image/jpg,image/jpeg" />
  37. <div class="on" v-if="uploadItem && uploadItem.imagePath">
  38. <img src="../../static/img/icon-add-cover-on.svg" alt="" />
  39. <img class="img" :src="uploadItem.imagePath" alt="" />
  40. </div>
  41. <div class="off" v-else>
  42. <img src="../../static/img/icon-add-cover-off.svg" alt="" />
  43. </div>
  44. </div>
  45. <div class="desc">Recommended size 500*500 or more</div>
  46. <div class="name">Project Name</div>
  47. <div class="input"><input type="text" maxlength="30" v-model="projectName" placeholder="Your NFT Project Name" /></div>
  48. <div class="name">Project Description</div>
  49. <div class="input"><input type="text" maxlength="100" v-model="projectDesc" placeholder="Your NFT Project Description" /></div>
  50. <div class="name">Collection Size</div>
  51. <div class="input"><input type="text" v-model="projectSize" placeholder="0" /></div>
  52. <div class="showNo" v-if="showNoStr">No.{{ projectNo === '' ? '0000' : projectNo }}~{{projectSize}}</div>
  53. <div class="name">NFTs Price</div>
  54. <div class="price">
  55. <div class="currency" @click="showCurrencyDialog" v-if="currencyItem">
  56. <img class="head" :src="currencyItem.iconPath" alt="" />
  57. <div class="font">{{currencyItem.tokenSymbol}}</div>
  58. <img class="arrow" src="../../static/img/icon-add-arrow.svg" alt="" />
  59. </div>
  60. <div class="no-select" @click="showCurrencyDialog" v-else>
  61. <div class="font">Select a reward</div>
  62. <img class="arrow" src="../../static/img/icon-add-arrow-white.svg" alt="" />
  63. </div>
  64. <div class="input"><input type="number" v-model="projectPrice" @input="changePrice" placeholder="0" /></div>
  65. <!-- 货币列表 -->
  66. <div class="currency-pop" v-if="currencyDialog">
  67. <currency-list @selectCurrencyItem="selectCurrencyItem"></currency-list>
  68. </div>
  69. </div>
  70. <div class="explain">
  71. <ul>
  72. <li class="special">The NFT colection is minted on BNB Smart Chain (BEP20)</li>
  73. <li>NFT will be released in blind box mode</li>
  74. <li>Users need to pay service fees when transferring NFTs</li>
  75. </ul>
  76. </div>
  77. <div class="footer"></div>
  78. </div>
  79. </div>
  80. <div class="create">
  81. <button class="on" v-if="isNext" @click="next">Create</button>
  82. <button class="off" v-else>Create</button>
  83. </div>
  84. </div>
  85. <div class="feedBack" @click="feedback">
  86. <a href="mailto:service@cybertogether.net">
  87. <div class="mail">
  88. <img src="../../static/img/icon-feedback.svg" alt="" />
  89. </div>
  90. <div class="font">Feedback</div>
  91. </a>
  92. </div>
  93. <div class="loading" v-if="showLoading">
  94. <img src="../../static/img/icon-add-loading.svg" alt="" />
  95. </div>
  96. <div class="succ" v-if="showSuccess">
  97. <img class="icon" src="../../static/img/icon-notice-succ.svg" alt="" />
  98. <div class="notic">We have created your NFT collection</div>
  99. <button class="btn" @click="jumpList">Done</button>
  100. </div>
  101. <div class="succ-bg" v-if="showSuccess" @click="hideSuccess"></div>
  102. <div class="mask-bg" v-if="currencyDialog" @click="hideCurrencyDialog"></div>
  103. </template>
  104. <script lang="ts" setup>
  105. import { ref, onMounted, watchEffect } from 'vue';
  106. import Api from '../../static/http/api';
  107. import { postRequest } from '../../static/http';
  108. import { uploadFile } from '../../static/utils/upload'
  109. import { Report } from '../../static/report'
  110. import { businessType, pageSource, objectType } from '../../static/report/enum'
  111. import currencyList from '../../components/currency-list.vue';
  112. const isNext = ref(false);
  113. const showLoading = ref(false);
  114. const showSuccess = ref(false);
  115. const maxSize = ref(1000);
  116. const configList = ref([]);
  117. const selectItem = ref(null);
  118. const uploadItem = ref({});
  119. const currencyDialog = ref(false);
  120. const currencyItem = ref(null);
  121. const projectName = ref('');
  122. const projectDesc = ref('');
  123. const projectSize = ref('');
  124. const projectNo = ref('');
  125. const projectPrice = ref('');
  126. const showNoStr = ref(false);
  127. const buttonType = {
  128. feedback: 'feedback-button',
  129. create: 'create-button',
  130. }
  131. const getConfig = () => {
  132. postRequest(Api.createConfig).then(res => {
  133. let { code, data } = res;
  134. if ( code === 0 ) {
  135. configList.value = data.itemModels;
  136. maxSize.value = data.maxCollectionSize;
  137. selectItem.value = data.itemModels[0];
  138. }
  139. })
  140. }
  141. const next = () => {
  142. // show loading
  143. showLoading.value = true;
  144. // post
  145. postRequest(Api.userNftAdd, {
  146. params: {
  147. // 项目图标
  148. cardFaceImagePath: uploadItem.value && uploadItem.value.objectKey || '',
  149. // 发行数量
  150. nftCollectionSize: projectSize.value || '',
  151. // 选中的模版id
  152. nftItemImageModel: selectItem.value && selectItem.value.modelName || '',
  153. // 项目描述
  154. nftProjectDescription: projectDesc.value || '',
  155. // 项目名称
  156. nftProjectName: projectName.value || '',
  157. // 销售价格
  158. saleCurrencyAmount: projectPrice.value || '',
  159. // 销售的货币code
  160. saleCurrencyCode: currencyItem.value && currencyItem.value.currencyCode || '',
  161. }
  162. }).then(res => {
  163. if (res.code === 0) {
  164. showSuccess.value = true;
  165. }
  166. }).finally(() => {
  167. showLoading.value = false;
  168. })
  169. // Report
  170. Report({
  171. baseInfo: {
  172. pageSource: pageSource.creatorPage,
  173. },
  174. params: {
  175. eventData: {
  176. businessType: businessType.buttonClick,
  177. objectType: buttonType.create,
  178. }
  179. }
  180. })
  181. }
  182. const select = (item: any, index: number) => {
  183. selectItem.value = item;
  184. let objectType;
  185. switch(index) {
  186. case 0:
  187. objectType = `first-NFT-selection-button`;
  188. break;
  189. case 1:
  190. objectType = `second-NFT-selection-button`;
  191. break;
  192. case 2:
  193. objectType = `third-NFT-selection-button`;
  194. break;
  195. case 3:
  196. objectType = `forth-NFT-selection-button`;
  197. break;
  198. }
  199. // Report
  200. Report({
  201. baseInfo: {
  202. pageSource: pageSource.creatorPage,
  203. },
  204. params: {
  205. eventData: {
  206. businessType: businessType.buttonClick,
  207. objectType: objectType,
  208. }
  209. }
  210. })
  211. }
  212. const showCurrencyDialog = () => {
  213. currencyDialog.value = true;
  214. }
  215. const hideCurrencyDialog = () => {
  216. currencyDialog.value = false;
  217. }
  218. const selectCurrencyItem = (data: any) => {
  219. currencyItem.value = data;
  220. hideCurrencyDialog();
  221. }
  222. const uploadImg = (e: any) => {
  223. let file = e.target.files[0];
  224. // 清空file
  225. e.target.value = '';
  226. // upload
  227. uploadFile(file).then(res => {
  228. // @ts-ignore
  229. uploadItem.value = res;
  230. })
  231. }
  232. const hideSuccess = () => {
  233. showSuccess.value = false;
  234. }
  235. const jumpList = () => {
  236. location.href = `/nft/list`
  237. }
  238. const changePrice = (e: any) => {
  239. projectPrice.value = String(Math.abs(e.target.value))
  240. }
  241. const feedback = () => {
  242. // Report
  243. Report({
  244. baseInfo: {
  245. pageSource: pageSource.creatorPage,
  246. },
  247. params: {
  248. eventData: {
  249. businessType: businessType.buttonClick,
  250. objectType: buttonType.feedback,
  251. }
  252. }
  253. })
  254. }
  255. watchEffect(() => {
  256. // 数量
  257. let num = projectSize.value;
  258. num = num.replace(/\D/g, '');
  259. if (Number(num) > maxSize.value) {
  260. num = String(maxSize.value);
  261. }
  262. if (num) {
  263. projectSize.value = String(Number(num));
  264. } else {
  265. projectSize.value = '';
  266. }
  267. // 编号
  268. if (projectSize.value !== '') {
  269. projectNo.value = String(1).padStart(String(projectSize.value).length, '0')
  270. } else {
  271. projectNo.value = ''
  272. }
  273. showNoStr.value = projectNo.value != '';
  274. // 是否可以创建
  275. let ifUpload = uploadItem.value && uploadItem.value.objectKey || false;
  276. let ifName = projectName.value !== '';
  277. let ifDesc = projectDesc.value !== '';
  278. let ifSize = projectSize.value !== '' && Number(projectSize.value) > 0;
  279. let ifCurrency = currencyItem.value && currencyItem.value.currencyCode;
  280. let ifPrice = projectPrice.value && projectPrice.value !== '' && Number(projectPrice.value) > 0;
  281. isNext.value = ifUpload && ifName && ifDesc && ifSize && ifCurrency && ifPrice;
  282. })
  283. onMounted(() => {
  284. // config
  285. getConfig()
  286. // Report
  287. Report({
  288. baseInfo: {
  289. pageSource: pageSource.creatorPage,
  290. },
  291. params: {
  292. eventData: {
  293. businessType: businessType.pageView,
  294. }
  295. }
  296. })
  297. })
  298. </script>
  299. <style lang="less" scoped>
  300. .center {
  301. overflow-y: auto;
  302. padding: 0 50px;
  303. width: 1100px;
  304. margin: 10px auto 0;
  305. box-sizing: border-box;
  306. height: calc(100% - 10px);
  307. background-color: #fff;
  308. border-radius: 20px 20px 0 0;
  309. .title {
  310. padding: 22px 0;
  311. font-size: 20px;
  312. font-weight: 600;
  313. line-height: 24px;
  314. }
  315. .content {
  316. width: 100%;
  317. clear: both;
  318. display: flex;
  319. justify-content: space-between;
  320. .name {
  321. height: 24px;
  322. font-size: 12px;
  323. color: #939393;
  324. }
  325. .showNo {
  326. color: #939393;
  327. margin-top: -10px;
  328. margin-bottom: 24px;
  329. }
  330. .l {
  331. width: 400px;
  332. .wait {
  333. padding: 200px 0;
  334. text-align: center;
  335. img {
  336. opacity: .6;
  337. animation: rotate 1s infinite linear;
  338. }
  339. }
  340. .show {
  341. position: relative;
  342. overflow: hidden;
  343. width: 400px;
  344. height: 400px;
  345. border-radius: 10px;
  346. .card {
  347. position: absolute;
  348. left: 53px;
  349. top: 103px;
  350. width: 294px;
  351. height: 186px;
  352. .logo {
  353. position: absolute;
  354. top: 50%;
  355. left: 50%;
  356. transform: translate(-50%, -50%);
  357. width: 100px;
  358. height: 100px;
  359. border-radius: 50%;
  360. background-color: #fff;
  361. img {
  362. width: 100%;
  363. height: 100%;
  364. border-radius: 50%;
  365. object-fit: cover;
  366. }
  367. }
  368. .member {
  369. position: absolute;
  370. top: 11px;
  371. left: 11px;
  372. width: 228px;
  373. font-size: 12px;
  374. text-align: left;
  375. font-weight: 800;
  376. line-height: 13px;
  377. }
  378. .number {
  379. position: absolute;
  380. top: 11px;
  381. right: 10px;
  382. font-size: 12px;
  383. font-weight: 800;
  384. line-height: 13px;
  385. letter-spacing: 1px;
  386. }
  387. &.s1 {
  388. .member, .number {
  389. color: #ffffff;
  390. }
  391. }
  392. &.s2 {
  393. .member, .number {
  394. color: #4AC3E1;
  395. }
  396. }
  397. &.s3 {
  398. .member, .number {
  399. color: #606C94;
  400. }
  401. }
  402. &.s4 {
  403. .member, .number {
  404. color: #504215;
  405. }
  406. }
  407. }
  408. .bg {
  409. width: 100%;
  410. height: 100%;
  411. }
  412. }
  413. .list {
  414. margin-top: 20px;
  415. display: flex;
  416. .item {
  417. width: calc(100% / 4);
  418. cursor: pointer;
  419. overflow: hidden;
  420. margin-right: 13px;
  421. border-radius: 5px;
  422. img {
  423. width: 100%;
  424. border-radius: 5px;
  425. }
  426. &:last-child {
  427. margin: 0;
  428. }
  429. &.on {
  430. position: relative;
  431. &::before {
  432. position: absolute;
  433. display: block;
  434. top: 0;
  435. right: 0;
  436. content: '';
  437. width: 44px;
  438. height: 44px;
  439. background-size: 100%;
  440. background-image: url('../../static/img/icon-add-select.svg');
  441. }
  442. }
  443. }
  444. }
  445. }
  446. .r {
  447. width: 520px;
  448. .face {
  449. position: relative;
  450. width: 80px;
  451. margin-bottom: 10px;
  452. .file {
  453. position: absolute;
  454. z-index: 2;
  455. width: 100%;
  456. height: 100%;
  457. opacity: 0;
  458. cursor: pointer;
  459. }
  460. .off {
  461. display: flex;
  462. align-items: center;
  463. justify-content: center;
  464. cursor: pointer;
  465. width: 80px;
  466. height: 80px;
  467. border-radius: 100px;
  468. border: 1px dashed #D0D0D0;
  469. background: rgba(0, 0, 0, 0.02);
  470. }
  471. .on {
  472. position: relative;
  473. display: flex;
  474. align-items: center;
  475. justify-content: center;
  476. cursor: pointer;
  477. width: 80px;
  478. height: 80px;
  479. overflow: hidden;
  480. border-radius: 100px;
  481. background: #353535;
  482. .img {
  483. position: absolute;
  484. opacity: .4;
  485. width: 100%;
  486. height: 100%;
  487. border-radius: 100px;
  488. }
  489. }
  490. }
  491. .desc {
  492. color: #B4B4B4;
  493. font-size: 12px;
  494. font-weight: 400;
  495. line-height: 16px;
  496. margin-bottom: 22px;
  497. }
  498. .input {
  499. display: flex;
  500. align-items: center;
  501. justify-content: center;
  502. height: 41px;
  503. margin-bottom: 22px;
  504. border-radius: 5px;
  505. background: #FFFFFF;
  506. border: 1px solid #E0E0E0;
  507. input {
  508. border: 0;
  509. outline: none;
  510. padding: 3px 0;
  511. color: #777;
  512. font-size: 16px;
  513. font-weight: 500;
  514. letter-spacing: 0.3px;
  515. width: calc(100% - 24px);
  516. &::placeholder {
  517. color: rgba(0, 0, 0, .3);
  518. }
  519. }
  520. }
  521. .price {
  522. position: relative;
  523. display: flex;
  524. justify-content: space-between;
  525. .currency {
  526. display: flex;
  527. align-items: center;
  528. justify-content: center;
  529. flex-direction: row;
  530. cursor: pointer;
  531. height: 43px;
  532. padding: 0 14px;
  533. margin-right: 13px;
  534. border-radius: 25px;
  535. background: #F4F4F4;
  536. .head {
  537. overflow: hidden;
  538. width: 20px;
  539. height: 20px;
  540. margin-right: 8px;
  541. border-radius: 50%;
  542. background-color: #999;
  543. }
  544. .font {
  545. max-width: 250px;
  546. font-size: 15px;
  547. font-weight: 500;
  548. white-space: nowrap;
  549. overflow: hidden;
  550. text-overflow: ellipsis;
  551. }
  552. .arrow {
  553. margin-left: 8px
  554. }
  555. }
  556. .no-select {
  557. display: flex;
  558. align-items: center;
  559. justify-content: center;
  560. flex-direction: row;
  561. cursor: pointer;
  562. height: 43px;
  563. padding: 0 14px;
  564. margin-right: 13px;
  565. border-radius: 25px;
  566. background: #1d9bf0;
  567. .font {
  568. max-width: 250px;
  569. color: #fff;
  570. font-size: 15px;
  571. font-weight: 500;
  572. white-space: nowrap;
  573. overflow: hidden;
  574. text-overflow: ellipsis;
  575. }
  576. .arrow {
  577. margin-left: 8px
  578. }
  579. }
  580. .input {
  581. flex: 1;
  582. margin-bottom: 0;
  583. }
  584. .currency-pop {
  585. position: absolute;
  586. overflow: hidden;
  587. z-index: 3;
  588. left: 0;
  589. bottom: 50px;
  590. width: 375px;
  591. max-height: 420px;
  592. border-radius: 20px;
  593. background-color: #fff;
  594. box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.25);
  595. }
  596. }
  597. .explain {
  598. color: #B4B4B4;
  599. font-size: 12px;
  600. font-weight: 400;
  601. line-height: 18px;
  602. ul {
  603. padding: 0;
  604. margin-left: 14px;
  605. }
  606. .special {
  607. color: #E29015;
  608. }
  609. }
  610. .footer {
  611. height: 80px;
  612. }
  613. }
  614. }
  615. .create {
  616. position: fixed;
  617. left: 50%;
  618. bottom: 0;
  619. width: 1100px;
  620. text-align: right;
  621. padding: 15px 30px;
  622. transform: translateX(-50%);
  623. box-sizing: border-box;
  624. background-color: #fff;
  625. border-top: solid 1px #ECECEC;
  626. .on {
  627. border: 0;
  628. height: 50px;
  629. color: #FFFFFF;
  630. cursor: pointer;
  631. padding: 0 50px;
  632. font-size: 18px;
  633. font-weight: 700;
  634. letter-spacing: 0.3px;
  635. border-radius: 25px;
  636. background: #1D9BF0;
  637. }
  638. .off {
  639. border: 0;
  640. height: 50px;
  641. color: #FFFFFF;
  642. cursor: pointer;
  643. padding: 0 50px;
  644. font-size: 18px;
  645. font-weight: 700;
  646. letter-spacing: 0.3px;
  647. border-radius: 25px;
  648. background: #E4E4E4;
  649. }
  650. }
  651. }
  652. .feedBack {
  653. position: absolute;
  654. right: 44px;
  655. bottom: 88px;
  656. cursor: pointer;
  657. font-size: 12px;
  658. text-align: center;
  659. a:link, a:visited {
  660. color: #A8A8A8;
  661. text-decoration: none;
  662. }
  663. .mail {
  664. display: flex;
  665. align-items: center;
  666. justify-content: center;
  667. margin: auto;
  668. width: 50px;
  669. height: 50px;
  670. margin-bottom: 10px;
  671. border-radius: 50%;
  672. background-color: #fff;
  673. }
  674. .font {
  675. opacity: 0.7;
  676. color: #A8A8A8;
  677. letter-spacing: 0.3px;
  678. }
  679. }
  680. .loading {
  681. display: flex;
  682. align-items: center;
  683. justify-content: center;
  684. position: absolute;
  685. top: 0;
  686. left: 0;
  687. z-index: 2;
  688. width: 100%;
  689. height: 100%;
  690. background: rgba(255, 255, 255, .8);
  691. img {
  692. width: 100px;
  693. animation: rotate 1s linear infinite;
  694. }
  695. }
  696. @keyframes rotate {
  697. 0% {
  698. transform: rotate(0);
  699. }
  700. 100% {
  701. transform: rotate(360deg);
  702. }
  703. }
  704. .succ {
  705. position: absolute;
  706. z-index: 2;
  707. top: 50%;
  708. left: 50%;
  709. width: 500px;
  710. height: 400px;
  711. border-radius: 20px;
  712. background-color: #fff;
  713. transform: translate(-50%, -50%);
  714. .icon {
  715. display: block;
  716. width: 120px;
  717. height: 120px;
  718. margin: 78px auto 27px auto;
  719. }
  720. .notic {
  721. font-size: 20px;
  722. font-weight: 700;
  723. text-align: center;
  724. line-height: 24px;
  725. }
  726. .btn {
  727. display: block;
  728. border: 0;
  729. cursor: pointer;
  730. width: 440px;
  731. height: 50px;
  732. color: #fff;
  733. font-size: 18px;
  734. font-weight: 700;
  735. margin: 70px auto 0;
  736. border-radius: 50px;
  737. background: #1D9BF0;
  738. }
  739. }
  740. .succ-bg {
  741. position: absolute;
  742. top: 0;
  743. left: 0;
  744. width: 100%;
  745. height: 100%;
  746. background: rgba(0, 0, 0, .8);
  747. }
  748. .mask-bg {
  749. position: absolute;
  750. top: 0;
  751. left: 0;
  752. z-index: 2;
  753. width: 100%;
  754. height: 100%;
  755. }
  756. </style>