index.vue 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291
  1. <template>
  2. <div class="payment">
  3. <!-- 选择支付方式 -->
  4. <template v-if="step === 1">
  5. <div class="moneyInfo">
  6. <div class="tips">You Neet to Pay</div>
  7. <div class="money" v-if="salePlans">
  8. <FontZoom width="320">
  9. <template v-if="salePlans && salePlans.currencyCode && salePlans.currencyCode !== 'USD'">
  10. <img class="icon" :src="salePlans.currencyInfo.iconPath" /><span class="info"> {{ salePlans.price }} {{ salePlans.currencyInfo.tokenSymbol }} (${{salePlans.usdPrice}})</span>
  11. </template>
  12. <template v-else>
  13. <span class="info usd">${{salePlans.usdPrice}}</span>
  14. </template>
  15. </FontZoom>
  16. </div>
  17. </div>
  18. <div class="payList">
  19. <div class="detail" v-if="salePlans && salePlans.currencyCode && salePlans.currencyCode !== 'USD'">
  20. <div class="title">Crypto Wallet</div>
  21. <div class="item denet" @click="deNetPay">
  22. <div>
  23. <img src="../../static/payment/icon_wallet.png" />
  24. <span>DeNet Pay</span>
  25. </div>
  26. <div class="wallet">
  27. <FontZoom width="300" :unColor="true">
  28. Balance:{{currencyInfoData.balance}} {{currencyInfoData.tokenSymbol}}
  29. </FontZoom>
  30. </div>
  31. </div>
  32. <div class="item" @click="maskPay">
  33. <a class="maskLink" :href="maskUrlLink" v-if="Number(currencyInfoData.balance) < Number(salePlans.price)"></a>
  34. <img src="../../static/payment/icon_meta_mask.png" />
  35. <span>MetaMask</span>
  36. </div>
  37. </div>
  38. <div class="detail" v-if="salePlans && salePlans.currencyCode && salePlans.currencyCode === 'USD'">
  39. <div class="title">Credit/Debit Card</div>
  40. <div class="item denet" @click="deNetPay">
  41. <div>
  42. <img src="../../static/payment/icon_wallet.png" />
  43. <span>DeNet Pay</span>
  44. </div>
  45. <div class="wallet">
  46. Balance:{{currencyInfoData.balance}} {{currencyInfoData.tokenSymbol}}
  47. </div>
  48. </div>
  49. <div class="item" @click="achPay(true, Report.objectType.mastercardPayButton)">
  50. <img src="../../static/payment/icon_master_card.png" />
  51. <span>MasterCard</span>
  52. </div>
  53. <div class="item" @click="achPay(true, Report.objectType.visaPayButton)">
  54. <img src="../../static/payment/icon_visa.png" />
  55. <span>VISA</span>
  56. </div>
  57. </div>
  58. <div class="detail">
  59. <div class="title">Redemption Code</div>
  60. <div class="item" @click="showRedeem">
  61. <img src="../../static/payment/icon_enter_code.png" />
  62. <span>Enter Code</span>
  63. </div>
  64. </div>
  65. </div>
  66. </template>
  67. <!-- 余额足够 -->
  68. <template v-else-if="step === 2">
  69. <div class="balanceTop">
  70. <img class="balance" src="../../static/img/icon_balance.svg" />
  71. <div class="text">Balance</div>
  72. <div class="money">
  73. <FontZoom width="300">
  74. <img class="icon" :src="currencyInfoData.iconPath" /> <span class="font">{{currencyInfoData.balance}} {{currencyInfoData.tokenSymbol}}</span>
  75. </FontZoom>
  76. </div>
  77. <template v-if="waitRefresh">
  78. <div class="waitFont">It may take some time to credit the funds into your account.</div>
  79. <div
  80. @click="checkWaitInfo"
  81. class="waitBtn">
  82. <img :class="{ 'icon-refresh-rotate': refreshRotate }" src="../../static/img/icon_refresh.svg" />
  83. </div>
  84. </template>
  85. </div>
  86. <div class="balanceBot">
  87. <div class="l">
  88. <div class="neet">You Neet to Pay</div>
  89. <div class="money">
  90. <FontZoom width="190">
  91. <span class="text">{{salePlans.price}} {{ salePlans.currencyInfo.tokenSymbol }}</span>
  92. </FontZoom>
  93. </div>
  94. </div>
  95. <div>
  96. <div
  97. class="btn"
  98. :class="{ disabled: (Number(currencyInfoData.balance) < Number(salePlans.price)) || payDisabled }"
  99. @click="pay">
  100. Pay Now
  101. </div>
  102. </div>
  103. </div>
  104. </template>
  105. <!-- 余额不足 -->
  106. <template v-else-if="step === 3">
  107. <template v-if="salePlans && salePlans.currencyCode && salePlans.currencyCode !== 'USD'">
  108. <div class="balanceInfo">
  109. <div class="top">
  110. <div class="item title">
  111. <img src="../../static/img/icon_deposit.png" />
  112. <span>Deposit to Buy</span>
  113. </div>
  114. <div class="item column">
  115. <div class="l">Deposit</div>
  116. <div class="r">
  117. <FontZoom width="260">
  118. <img :src="currencyInfoData.iconPath" />
  119. <span>{{ salePlans.price - currencyInfoData.balance}} {{currencyInfoData.tokenSymbol}}</span>
  120. </FontZoom>
  121. </div>
  122. </div>
  123. <div class="item column">
  124. <div class="l">Network</div>
  125. <div class="r">
  126. <FontZoom width="260">
  127. <img :src="currencyInfoData.chainInfo.iconPath" />
  128. <span>{{ currencyInfoData.chainInfo.chainName }}</span>
  129. </FontZoom>
  130. </div>
  131. </div>
  132. <div class="address">
  133. <div class="title">Address</div>
  134. <QrCode :tokenChain="currencyInfoData.tokenChain" :rechargeAddress="rechargeAddress" @copy="copyErCode"></QrCode>
  135. </div>
  136. <div class="notice">
  137. <div class="icon"><img src="../../static/img/icon_warning.svg" /></div>
  138. <div class="text">Make sure you also selected <Br/><strong>{{ currencyInfoData.chainInfo.chainName }}</strong> <br/>as the Network on the platform where you are withdrawing funds for this deposiit. Otherwise, you'll lose your assets.</div>
  139. </div>
  140. </div>
  141. <div class="line"></div>
  142. <div class="balance">
  143. <div class="icon">
  144. <img src="../../static/img/icon_balance_blue.svg" />
  145. </div>
  146. <div class="text">
  147. <FontZoom width="260">
  148. <span>Balance: {{ currencyInfoData.balance }} {{ currencyInfoData.tokenSymbol }}</span>
  149. </FontZoom>
  150. </div>
  151. <div
  152. class="refresh"
  153. @click="checkCurrencyInfo">
  154. <img :class="{ 'icon-refresh-rotate': refreshRotate }" src="../../static/img/icon_refresh.svg" />
  155. </div>
  156. </div>
  157. </div>
  158. <div class="balanceBot">
  159. <div class="l">
  160. <div class="neet">You Neet to Pay</div>
  161. <div class="money">
  162. <FontZoom width="190">
  163. <span class="text">{{salePlans.price}} {{ salePlans.currencyInfo.tokenSymbol }}</span>
  164. </FontZoom>
  165. </div>
  166. </div>
  167. <div>
  168. <div
  169. class="btn"
  170. :class="{ disabled: (Number(currencyInfoData.balance) < Number(salePlans.price)) || payDisabled }"
  171. @click="payToken">
  172. Pay Now
  173. </div>
  174. </div>
  175. </div>
  176. </template>
  177. <template v-if="salePlans && salePlans.currencyCode && salePlans.currencyCode === 'USD'">
  178. <div class="balanceInfo">
  179. <div class="top">
  180. <div class="item usd">
  181. <div class="l">Payment amount</div>
  182. <div class="r fontPayment">${{ usdAmountData.orderAmountValue }}</div>
  183. </div>
  184. <div class="item usd">
  185. <div class="l">Balance</div>
  186. <div class="r font">${{ usdAmountData.balance }}</div>
  187. </div>
  188. <div class="item usd" v-if="Number(usdAmountData.rechargeAmountValue) > 0">
  189. <div class="l">{{ usdAmountData.feeDesc }}</div>
  190. <div class="r font">${{ usdAmountData.feeAmountValue }}</div>
  191. </div>
  192. <div class="item usd" v-if="Number(usdAmountData.rechargeAmountValue) > 0">
  193. <div class="l">Deposit Amount</div>
  194. <div class="r fontDeposit">${{ usdAmountData.rechargeAmountValue }}</div>
  195. </div>
  196. <div class="deposit" @click="achPay(false, '')">Deposit</div>
  197. </div>
  198. <div class="line"></div>
  199. <div class="balance">
  200. <div class="icon">
  201. <img src="../../static/img/icon_balance_blue.svg" />
  202. </div>
  203. <div class="text">Balance: ${{currencyInfoData.balance}}</div>
  204. <div
  205. class="refresh"
  206. @click="checkUsdCurrencyInfo">
  207. <img :class="{ 'icon-refresh-rotate': refreshRotate }" src="../../static/img/icon_refresh.svg" />
  208. </div>
  209. </div>
  210. </div>
  211. <div class="balanceBot">
  212. <div class="l">
  213. <div class="neet">You Neet to Pay</div>
  214. <div class="money">
  215. <FontZoom width="190">
  216. <span class="text">{{ Number(usdAmountData.rechargeAmountValue) > 0 ? usdAmountData.rechargeAmountValue : usdAmountData.orderAmountValue }} {{ salePlans.currencyInfo.tokenSymbol }}</span>
  217. </FontZoom>
  218. </div>
  219. </div>
  220. <div>
  221. <div
  222. class="btn"
  223. :class="{ disabled: (Number(usdAmountData.rechargeAmountValue) > 0) || payDisabled }"
  224. @click="payUSD">
  225. Pay Now
  226. </div>
  227. </div>
  228. </div>
  229. </template>
  230. </template>
  231. <!-- 成功支付 -->
  232. <template v-else-if="step === 4">
  233. <div class="payInfo">
  234. <div class="picShow" v-if="buyData">
  235. <div class="tip">Wow, NFT in the Mystery box is</div>
  236. <img class="pic" :src="buyData.imagePath" />
  237. <div class="name">{{buyData.nftItemName}}</div>
  238. </div>
  239. </div>
  240. <div class="payBtn">
  241. <button class="btn" @click="goNext">Done</button>
  242. </div>
  243. </template>
  244. <!-- loading -->
  245. <div class="loading" v-if="loading">
  246. <van-loading color="#1D9BF0"></van-loading>
  247. </div>
  248. <div class="loadingBg" v-if="loading"></div>
  249. <!-- redeem -->
  250. <van-popup
  251. round
  252. v-model="redeemLayer"
  253. position="bottom">
  254. <div class="redeem">
  255. <div class="tips">Enter Redemption Code</div>
  256. <div class="footer">
  257. <div class="input">
  258. <input
  259. type="text"
  260. ref="input"
  261. v-model="redeemStr"
  262. @input="textInput"
  263. @blur="textBlur"
  264. @focus="textFocus"
  265. @keydown.enter="redeemPayment" />
  266. </div>
  267. <button
  268. class="enter"
  269. :class="{ disabled: !redeemNext }"
  270. @click="redeemPayment">
  271. Redeem
  272. </button>
  273. </div>
  274. </div>
  275. </van-popup>
  276. </div>
  277. </template>
  278. <script>
  279. import FontZoom from '../../components/FontZoom.vue';
  280. import QrCode from '../../components/qrcode.vue';
  281. import { postRequest } from '../../http/index';
  282. import { maskUrl } from '../../utils/help';
  283. import { Dialog, Toast } from 'vant';
  284. import Api from '../../http/api';
  285. import Report from '../../log-center/log';
  286. export default {
  287. name: 'payment',
  288. data() {
  289. return {
  290. step: 1, // 1: 支付方式列表 2: 余额支付 3: 充值支付 4: 支付完成
  291. loading: true,
  292. salePlans: null,
  293. rechargeAddress: '',
  294. redeemStr: '',
  295. redeemNext: false,
  296. redeemLayer: false,
  297. buyData: {},
  298. payDisabled: false,
  299. waitRefresh: false,
  300. refreshRotate: false,
  301. currencyInfoData: {},
  302. currencyTimer: 0,
  303. achTimer: 0,
  304. maskUrlLink: ``,
  305. usdAmountData: {},
  306. Report: Report,
  307. }
  308. },
  309. head() {
  310. return {
  311. title: 'Buy NFT Mystery Box',
  312. }
  313. },
  314. components: {
  315. QrCode,
  316. FontZoom,
  317. },
  318. mounted() {
  319. this.saleInfo()
  320. this.reportView(Report.pageSource.nftPaymentPage)
  321. },
  322. beforeDestroy() {
  323. clearTimeout(this.currencyTimer);
  324. },
  325. methods : {
  326. saleInfo () {
  327. postRequest(Api.getNftMysteryBoxSaleInfo, {
  328. params: {
  329. nftProjectId: this.$route.query.nftProjectId
  330. }
  331. }).then(res => {
  332. let { code, data } = res;
  333. if (code === 0) {
  334. this.salePlans = data.salePlans[0];
  335. this.getCurrencyInfoByCode();
  336. // 获取充值地址
  337. if (this.rechargeAddress === '') {
  338. this.getAddress()
  339. }
  340. }
  341. }).finally(() => {
  342. this.loading = false;
  343. })
  344. },
  345. getCurrencyInfoByCode() {
  346. postRequest(Api.getCurrencyInfoByCode, {
  347. params: {
  348. currencyCode: this.salePlans.currencyCode
  349. }
  350. }).then(res => {
  351. let { code, data } = res;
  352. if (code === 0) {
  353. this.currencyInfoData = data;
  354. }
  355. })
  356. // 计算金额
  357. if (this.salePlans.currencyCode === 'USD') {
  358. // this.salePlans.price
  359. postRequest(Api.calcRechargePayAmount, {
  360. params: {
  361. currencyCode: this.salePlans.currencyCode,
  362. orderAmountValue: this.salePlans.price,
  363. payChannel: 'ach'
  364. }
  365. }).then(res => {
  366. let { code, data } = res;
  367. if (code === 0) {
  368. this.usdAmountData = data;
  369. }
  370. })
  371. }
  372. },
  373. getTokenRechargeRecord() {
  374. postRequest(Api.syncChainTokenRechargeRecord, {
  375. params: {
  376. currencyCode: this.salePlans.currencyCode
  377. }
  378. }).then(res => {
  379. let { code, data } = res;
  380. if (code === 0) {
  381. if (data.length > 0) {
  382. let currencyInfo = data[0];
  383. if (currencyInfo.currencyCode == this.currencyInfoData.currencyCode) {
  384. this.currencyInfoData.balance = currencyInfo.balance;
  385. }
  386. } else {
  387. this.currencyInfoData.balance = 0
  388. }
  389. }
  390. })
  391. },
  392. currencyInfoTimer() {
  393. clearTimeout(this.currencyTimer);
  394. this.currencyTimer = setTimeout(() => {
  395. this.currencyInfoTimer()
  396. this.getCurrencyInfoByCode()
  397. }, 10000);
  398. },
  399. checkUsdCurrencyInfo() {
  400. if (!this.refreshRotate) {
  401. this.refreshRotate = true;
  402. this.getCurrencyInfoByCode()
  403. setTimeout(() => {
  404. this.refreshRotate = false;
  405. }, 1000)
  406. // report
  407. this.reportDepositCashPageClick(Report.objectType.refreshBalanceButton)
  408. }
  409. },
  410. checkCurrencyInfo() {
  411. if (!this.refreshRotate) {
  412. this.refreshRotate = true;
  413. this.getTokenRechargeRecord()
  414. setTimeout(() => {
  415. this.refreshRotate = false;
  416. }, 1000)
  417. // report
  418. this.reportDepositTokenPageClick(Report.objectType.refreshBalanceButton)
  419. }
  420. },
  421. checkWaitInfo(isReport = true) {
  422. if (!this.refreshRotate) {
  423. this.refreshRotate = true;
  424. if (this.salePlans.currencyCode === 'USD') {
  425. this.getCurrencyInfoByCode()
  426. } else {
  427. this.getTokenRechargeRecord()
  428. }
  429. setTimeout(() => {
  430. this.refreshRotate = false;
  431. }, 1000)
  432. }
  433. if (isReport) {
  434. this.reportBalanceRefresh()
  435. }
  436. },
  437. showRedeem() {
  438. this.redeemStr = '';
  439. this.redeemNext = false;
  440. this.redeemLayer = true;
  441. this.$nextTick(() => {
  442. this.$refs.input.focus();
  443. })
  444. this.reportView(Report.pageSource.nftRedeemPage)
  445. this.reportPaymentBtnClick(Report.objectType.redeemButton)
  446. },
  447. textInput(e) {
  448. let len = 16
  449. let str = this.redeemStr.replace(/[^a-zA-Z0-9]/g, '')
  450. str = str.toUpperCase();
  451. str = str.slice(0, len);
  452. // set
  453. this.redeemStr = str;
  454. this.redeemNext = str !== '' && str.length === len;
  455. },
  456. textBlur(e) {
  457. let isiOS = !!window.navigator.userAgent.match(/\(i\[^;]+;( U;)? CPU.+Mac OS X/)
  458. if (isiOS) {
  459. setTimeout(() => {
  460. const scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0
  461. window.scrollTo(0, Math.max(scrollHeight - 1, 0))
  462. }, 100)
  463. }
  464. },
  465. textFocus(e) {
  466. let isiOS = !!window.navigator.userAgent.match(/\(i\[^;]+;( U;)? CPU.+Mac OS X/)
  467. if (isiOS) {
  468. setTimeout(() => {
  469. const scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0
  470. window.scrollTo(0, Math.max(scrollHeight - 1, 0))
  471. }, 100)
  472. }
  473. },
  474. redeemPayment() {
  475. if (!this.redeemNext) return;
  476. let params = {
  477. redeemCode: this.redeemStr,
  478. nftProjectId: this.$route.query.nftProjectId,
  479. }
  480. this.redeemNext = false;
  481. postRequest(Api.redeemNft, {
  482. params
  483. }).then(res => {
  484. let { code, data } = res;
  485. if (code === 0) {
  486. this.redeemLayer = false;
  487. if (data.length > 0) {
  488. this.buyData = data[0];
  489. }
  490. // 购买成功
  491. this.step = 4;
  492. } else {
  493. this.payError(code)
  494. }
  495. }).finally(() => {
  496. this.redeemNext = true;
  497. })
  498. this.reportRedeemBtnClick()
  499. },
  500. getAddress() {
  501. postRequest(Api.getTokenRechargeAddress, {
  502. params: {
  503. tokenChain: this.salePlans.currencyInfo?.tokenChain
  504. }
  505. }).then(res => {
  506. let { code, data } = res;
  507. if (code === 0) {
  508. this.rechargeAddress = data.rechargeAddress
  509. this.maskUrlToLink()
  510. }
  511. })
  512. },
  513. maskUrlToLink() {
  514. // MetaMask Link
  515. let url;
  516. let price = Number(this.salePlans.price) > Number(this.currencyInfoData.balance) ? Number(this.salePlans.price) - Number(this.currencyInfoData.balance) : Number(this.salePlans.price)
  517. if (this.salePlans.currencyInfo?.contractAddress) {
  518. // 代币
  519. url = maskUrl({
  520. target_address: this.salePlans.currencyInfo.contractAddress,
  521. parameters: {
  522. address: this.rechargeAddress,
  523. uint256: `${price}e${this.salePlans.currencyInfo?.decimalLength || 18}`
  524. }
  525. }, false)
  526. } else {
  527. // 主币
  528. url = maskUrl({
  529. target_address: this.rechargeAddress,
  530. parameters: {
  531. value: `${price}e${this.salePlans.currencyInfo?.decimalLength || 18}`
  532. }
  533. })
  534. }
  535. this.maskUrlLink = url;
  536. },
  537. goNext() {
  538. this.$router.push({
  539. path: `/nft/${this.$route.query.nftProjectId}/${this.$route.query.account}/show`,
  540. })
  541. },
  542. pay(isReport = true) {
  543. if (this.payDisabled || Number(this.currencyInfoData.balance) < Number(this.salePlans.price)) return;
  544. this.payDisabled = true;
  545. postRequest(Api.payNftMysteryBoxWithBalance, {
  546. params: {
  547. nftProjectId: this.$route.query.nftProjectId,
  548. salePlanId: this.salePlans.salePlanId,
  549. }
  550. }).then(res => {
  551. let { code, data } = res;
  552. if (code == 0) {
  553. if (data && data.buyItems.length > 0) {
  554. this.buyData = data.buyItems[0];
  555. }
  556. // 购买成功
  557. this.step = 4;
  558. } else {
  559. this.payError(code)
  560. }
  561. }).finally(() => {
  562. this.payDisabled = false;
  563. })
  564. // report
  565. if (isReport) {
  566. this.reportBalanceBuy()
  567. }
  568. },
  569. payUSD() {
  570. if (Number(this.usdAmountData.rechargeAmountValue) <= 0) {
  571. this.pay(false)
  572. this.reportDepositCashPageClick(Report.objectType.purchaseNftButton)
  573. }
  574. },
  575. payToken() {
  576. if (Number(this.currencyInfoData.balance) >= Number(this.salePlans.price)) {
  577. this.pay(false)
  578. this.reportDepositTokenPageClick(Report.objectType.purchaseNftButton)
  579. }
  580. },
  581. payError(code) {
  582. let msg;
  583. switch (code.toString()) {
  584. case '5001':
  585. msg = 'nft project not exist'
  586. break;
  587. case '5002':
  588. msg = 'nft project not available'
  589. break
  590. case '5101':
  591. msg = 'nft sale plan not exist'
  592. break
  593. case '5102':
  594. msg = 'nft sold out'
  595. break
  596. case '5103':
  597. msg = 'Purchase limit reached'
  598. break
  599. case '5104':
  600. case '5105':
  601. case '5106':
  602. msg = 'Invalid redemption code'
  603. break;
  604. default:
  605. msg = 'Invalid redemption code, please try again'
  606. break;
  607. }
  608. // Dialog
  609. Dialog({
  610. message: msg,
  611. confirmButtonText: 'OK',
  612. confirmButtonColor: '#1D9BF0',
  613. });
  614. },
  615. deNetPay() {
  616. if (!this.salePlans) return;
  617. let where, pageSource;
  618. if (this.salePlans.currencyCode === 'USD') {
  619. where = Number(this.usdAmountData.rechargeAmountValue) > 0
  620. pageSource = Report.pageSource.nftDepositCashPage
  621. } else {
  622. where = Number(this.salePlans.price) > Number(this.currencyInfoData.balance)
  623. pageSource = Report.pageSource.nftDepositTokenPage
  624. }
  625. if (where) {
  626. // 余额不够
  627. this.step = 3;
  628. this.currencyInfoTimer();
  629. // Report
  630. this.reportView(pageSource);
  631. } else {
  632. // 余额足够
  633. this.step = 2;
  634. this.reportView(Report.pageSource.nftBalancePage);
  635. }
  636. this.reportPaymentBtnClick(Report.objectType.denetPayButton)
  637. },
  638. maskPay() {
  639. if (Number(this.salePlans.price) > Number(this.currencyInfoData.balance)) {
  640. this.step = 2;
  641. this.waitRefresh = true;
  642. this.currencyInfoTimer();
  643. Dialog({
  644. message: `Was the pament successful?`,
  645. showCancelButton: true,
  646. confirmButtonText: 'YES',
  647. confirmButtonColor: '#1D9BF0',
  648. cancelButtonText: 'NO',
  649. cancelButtonColor: '#1D9BF0',
  650. }).then(() => {
  651. this.checkWaitInfo(false)
  652. }).catch(() => {
  653. this.checkWaitInfo(false)
  654. });
  655. this.reportView(Report.pageSource.nftPaymentBalancePage);
  656. } else {
  657. this.step = 2;
  658. this.reportView(Report.pageSource.nftBalancePage);
  659. }
  660. this.reportPaymentBtnClick(Report.objectType.metamaskPayButton)
  661. },
  662. achPay(modifyStep = true, objectType = '') {
  663. if (Number(this.usdAmountData.rechargeAmountValue) > 0) {
  664. if (modifyStep) {
  665. this.step = 2;
  666. this.reportView(Report.pageSource.nftPaymentBalancePage);
  667. }
  668. this.waitRefresh = true;
  669. this.currencyInfoTimer();
  670. Dialog({
  671. message: `Was the pament successful?`,
  672. showCancelButton: true,
  673. confirmButtonText: 'YES',
  674. confirmButtonColor: '#1D9BF0',
  675. cancelButtonText: 'NO',
  676. cancelButtonColor: '#1D9BF0',
  677. }).then(() => {
  678. this.checkWaitInfo(false)
  679. }).catch(() => {
  680. this.checkWaitInfo(false)
  681. });
  682. this.$nextTick(() => {
  683. let win = window.open();
  684. win.opener = null;
  685. win.location.href = `${location.protocol}//${location.host}/payment_ach/${this.usdAmountData.rechargeAmountValue}`;
  686. this.achTimer = setInterval(() => {
  687. console.log('pay')
  688. if (win && win.closed) {
  689. console.log('done')
  690. clearInterval(this.achTimer);
  691. }
  692. }, 500);
  693. })
  694. } else {
  695. if (modifyStep) {
  696. this.step = 2;
  697. this.reportView(Report.pageSource.nftBalancePage);
  698. }
  699. }
  700. if (objectType !== '') {
  701. this.reportPaymentBtnClick(objectType)
  702. } else {
  703. this.reportDepositCashPageClick(Report.objectType.depositButtion)
  704. }
  705. },
  706. copyErCode() {
  707. this.reportDepositTokenPageClick(Report.objectType.copyButtion)
  708. },
  709. reportView(pageSource) {
  710. Report.log({
  711. pageSource,
  712. params: {
  713. eventData: {
  714. businessType: Report.businessType.pageView,
  715. },
  716. extParams: {
  717. userAgent: window.navigator.userAgent,
  718. }
  719. }
  720. })
  721. },
  722. reportPaymentBtnClick(objectType) {
  723. Report.log({
  724. pageSource: Report.pageSource.nftPaymentPage,
  725. params: {
  726. eventData: {
  727. objectType,
  728. businessType: Report.businessType.buttonClick,
  729. },
  730. extParams: {
  731. userAgent: window.navigator.userAgent,
  732. }
  733. }
  734. })
  735. },
  736. reportRedeemBtnClick() {
  737. Report.log({
  738. pageSource: Report.pageSource.nftRedeemPage,
  739. params: {
  740. eventData: {
  741. objectType: Report.objectType.redeemButton,
  742. businessType: Report.businessType.buttonClick,
  743. },
  744. extParams: {
  745. userAgent: window.navigator.userAgent,
  746. }
  747. }
  748. })
  749. },
  750. reportDepositCashPageClick(objectType) {
  751. Report.log({
  752. pageSource: Report.pageSource.nftDepositCashPage,
  753. params: {
  754. eventData: {
  755. objectType,
  756. businessType: Report.businessType.buttonClick,
  757. },
  758. extParams: {
  759. userAgent: window.navigator.userAgent,
  760. }
  761. }
  762. })
  763. },
  764. reportDepositTokenPageClick(objectType) {
  765. Report.log({
  766. pageSource: Report.pageSource.nftDepositTokenPage,
  767. params: {
  768. eventData: {
  769. objectType,
  770. businessType: Report.businessType.buttonClick,
  771. },
  772. extParams: {
  773. userAgent: window.navigator.userAgent,
  774. }
  775. }
  776. })
  777. },
  778. reportBalanceRefresh() {
  779. let pageSource = this.waitRefresh ? Report.pageSource.nftPaymentBalancePage : Report.pageSource.nftBalancePage;
  780. Report.log({
  781. pageSource: pageSource,
  782. params: {
  783. eventData: {
  784. objectType: Report.objectType.refreshBalanceButton,
  785. businessType: Report.businessType.buttonClick,
  786. },
  787. extParams: {
  788. userAgent: window.navigator.userAgent,
  789. }
  790. }
  791. })
  792. },
  793. reportBalanceBuy() {
  794. let pageSource = this.waitRefresh ? Report.pageSource.nftPaymentBalancePage : Report.pageSource.nftBalancePage;
  795. Report.log({
  796. pageSource: pageSource,
  797. params: {
  798. eventData: {
  799. objectType: Report.objectType.purchaseNftButton,
  800. businessType: Report.businessType.buttonClick,
  801. },
  802. extParams: {
  803. userAgent: window.navigator.userAgent,
  804. }
  805. }
  806. })
  807. },
  808. }
  809. }
  810. </script>
  811. <style lang="scss">
  812. html,
  813. body,
  814. #__nuxt,
  815. #__layout {
  816. width: 100%;
  817. height: 100%;
  818. padding: 0;
  819. margin: 0;
  820. overflow: hidden;
  821. }
  822. .payment {
  823. width: 100%;
  824. height: 100%;
  825. }
  826. .moneyInfo {
  827. display: flex;
  828. align-items: center;
  829. justify-content: center;
  830. flex-direction: column;
  831. height: 90px;
  832. border-bottom: solid 8px rgba($color: #f5f5f5, $alpha: .6);
  833. .tips {
  834. font-size: 12px;
  835. font-weight: 500;
  836. }
  837. .money {
  838. display: flex;
  839. align-items: center;
  840. justify-content: center;
  841. margin-top: 10px;
  842. .icon {
  843. overflow: hidden;
  844. width: 26px;
  845. height: 26px;
  846. border-radius: 50%;
  847. margin-right: 10px;
  848. vertical-align: middle;
  849. background-color: #f5f5f5;
  850. }
  851. .info {
  852. color: #000;
  853. font-size: 20px;
  854. font-weight: 700;
  855. &.usd {
  856. margin-top: -5px;
  857. }
  858. }
  859. }
  860. }
  861. .payList {
  862. overflow-y: auto;
  863. height: calc(100% - 90px);
  864. .detail {
  865. padding: 18px 16px;
  866. .title {
  867. color: #ADADAD;
  868. height: 26px;
  869. font-size: 12px;
  870. font-weight: 500;
  871. }
  872. .item {
  873. position: relative;
  874. display: flex;
  875. align-items: center;
  876. justify-content: center;
  877. font-weight: 500;
  878. font-size: 16px;
  879. height: 50px;
  880. margin-bottom: 14px;
  881. border-radius: 100px;
  882. border: 1px solid #ECECEC;
  883. &:last-child {
  884. margin-bottom: 0;
  885. }
  886. img {
  887. width: 24px;
  888. height: 24px;
  889. margin-right: 4px;
  890. }
  891. &.denet {
  892. flex-direction: column;
  893. img {
  894. margin-top: -6px;
  895. }
  896. }
  897. .wallet {
  898. width: 100%;
  899. overflow: hidden;
  900. color: #ADADAD;
  901. font-size: 11px;
  902. text-align: center;
  903. margin-top: -2px;
  904. }
  905. .maskLink {
  906. position: absolute;
  907. z-index: 10;
  908. width: 100%;
  909. height: 100%;
  910. }
  911. }
  912. }
  913. }
  914. .loading {
  915. position: absolute;
  916. z-index: 3;
  917. display: flex;
  918. align-items: center;
  919. justify-content: center;
  920. top: 0;
  921. left: 0;
  922. width: 100%;
  923. height: 100%;
  924. }
  925. .loadingBg {
  926. position: absolute;
  927. z-index: 2;
  928. top: 0;
  929. left: 0;
  930. width: 100%;
  931. height: 100%;
  932. background-color: rgba($color: #000, $alpha: .1);
  933. }
  934. .redeem {
  935. padding: 18px 16px 38px;
  936. .tips {
  937. height: 31px;
  938. font-size: 15px;
  939. font-weight: 500;
  940. }
  941. .footer {
  942. display: flex;
  943. justify-content: space-between;
  944. .input {
  945. display: flex;
  946. align-items: center;
  947. justify-content: center;
  948. width: calc(100% - 93px);
  949. height: 45px;
  950. border-radius: 5px;
  951. border: 1px solid #E0E0E0;
  952. input {
  953. width: 94%;
  954. border: 0;
  955. outline: 0;
  956. }
  957. }
  958. .enter {
  959. width: 83px;
  960. height: 45px;
  961. border: 0;
  962. padding: 0;
  963. color: #ffffff;
  964. font-size: 17px;
  965. font-weight: 500;
  966. border-radius: 5px;
  967. background: #1D9BF0;
  968. &.disabled {
  969. background: #DEDEDE;
  970. }
  971. }
  972. }
  973. }
  974. .payInfo {
  975. width: 100%;
  976. height: calc(100% - 88px);
  977. .picShow {
  978. padding: 54px 48px;
  979. .tip {
  980. height: 44px;
  981. font-size: 18px;
  982. font-weight: 600;
  983. text-align: center;
  984. }
  985. .pic {
  986. width: 280px;
  987. height: 280px;
  988. border-radius: 3px;
  989. margin-bottom: 20px;
  990. }
  991. .name {
  992. font-size: 18px;
  993. font-weight: 600;
  994. line-height: 21px;
  995. text-align: center;
  996. }
  997. }
  998. }
  999. .payBtn {
  1000. padding: 0 16px 38px;
  1001. .btn {
  1002. width: 100%;
  1003. height: 50px;
  1004. color: #FFFFFF;
  1005. font-size: 18px;
  1006. font-weight: 700;
  1007. border-radius: 50px;
  1008. background: #1D9BF0;
  1009. }
  1010. }
  1011. .balanceTop {
  1012. display: flex;
  1013. align-items: center;
  1014. justify-content: center;
  1015. flex-direction: column;
  1016. height: calc(100% - 100px);
  1017. background-color: #f5f5f5;
  1018. .balance {
  1019. width: 66px;
  1020. height: 66px;
  1021. margin-bottom: 6px;
  1022. }
  1023. .text {
  1024. font-size: 15px;
  1025. font-weight: 500;
  1026. line-height: 18px;
  1027. color: #9D9D9D;
  1028. }
  1029. .money {
  1030. font-size: 22px;
  1031. font-weight: 700;
  1032. line-height: 26px;
  1033. margin-top: 6px;
  1034. .icon {
  1035. width: 22px;
  1036. height: 22px;
  1037. margin-right: 6px;
  1038. }
  1039. .font {
  1040. color: #000;
  1041. }
  1042. }
  1043. }
  1044. .balanceInfo {
  1045. overflow-y: auto;
  1046. height: calc(100% - 100px);
  1047. background-color: #f5f5f5;
  1048. .top {
  1049. padding: 0 16px 17px 16px;
  1050. background-color: #ffffff;
  1051. .item {
  1052. display: flex;
  1053. align-items: center;
  1054. height: 54px;
  1055. border-bottom: solid 1px #F2F2F2;
  1056. &.title {
  1057. font-size: 16px;
  1058. font-weight: 600;
  1059. line-height: 19px;
  1060. img {
  1061. width: 26px;
  1062. height: 26px;
  1063. margin-right: 6px;
  1064. }
  1065. }
  1066. &.column {
  1067. color: rgba($color: #5E5E5E, $alpha: .7);
  1068. font-size: 14px;
  1069. font-weight: 400;
  1070. .l {
  1071. width: 70px;
  1072. }
  1073. .r {
  1074. img {
  1075. width: 21px;
  1076. height: 21px;
  1077. margin-right: 4px;
  1078. }
  1079. span {
  1080. color: rgba($color: #5E5E5E, $alpha: .7);
  1081. }
  1082. }
  1083. }
  1084. &.usd {
  1085. font-size: 14px;
  1086. font-weight: 500;
  1087. justify-content: space-between;
  1088. .fontPayment {
  1089. font-size: 18px;
  1090. font-weight: 600;
  1091. }
  1092. .font {
  1093. color: #9A9A9A;
  1094. font-size: 16px;
  1095. font-weight: 500;
  1096. }
  1097. .fontDeposit {
  1098. color: #1D9BF0;
  1099. font-size: 18px;
  1100. font-weight: 600;
  1101. }
  1102. }
  1103. }
  1104. .deposit {
  1105. display: flex;
  1106. align-items: center;
  1107. justify-content: center;
  1108. height: 54px;
  1109. color: #ffffff;
  1110. font-weight: 600;
  1111. font-size: 18px;
  1112. margin-top: 16px;
  1113. border-radius: 54px;
  1114. background: #1D9BF0;
  1115. }
  1116. .address {
  1117. color: rgba($color: #5E5E5E, $alpha: .7);
  1118. .title {
  1119. height: 42px;
  1120. font-size: 14px;
  1121. font-weight: 400;
  1122. line-height: 42px;
  1123. }
  1124. }
  1125. .notice {
  1126. display: flex;
  1127. justify-content: space-between;
  1128. padding: 10px;
  1129. margin-top: 12px;
  1130. border-radius: 8px;
  1131. background: #F9F6EE;
  1132. .icon {
  1133. width: 20px;
  1134. margin-right: 10px;
  1135. img {
  1136. width: 20px;
  1137. height: 20px;
  1138. }
  1139. }
  1140. .text {
  1141. flex: 1;
  1142. color: rgba($color: #5E5E5E, $alpha: .7);
  1143. font-size: 14px;
  1144. font-weight: 400;
  1145. line-height: 19px;
  1146. word-break: break-all;
  1147. strong {
  1148. color: #FF0000;
  1149. font-weight: bold;
  1150. }
  1151. }
  1152. }
  1153. }
  1154. .line {
  1155. height: 8px;
  1156. }
  1157. .balance {
  1158. display: flex;
  1159. align-items: center;
  1160. padding: 0 16px;
  1161. height: 54px;
  1162. background-color: #ffffff;
  1163. .icon {
  1164. width: 24px;
  1165. margin-right: 6px;
  1166. img {
  1167. width: 24px;
  1168. }
  1169. }
  1170. .text {
  1171. flex: 1;
  1172. font-size: 14px;
  1173. font-weight: 500;
  1174. line-height: 17px;
  1175. span {
  1176. color: #000;
  1177. margin-right: auto;
  1178. }
  1179. }
  1180. .refresh {
  1181. width: 24px;
  1182. height: 24px;
  1183. img {
  1184. width: 24px;
  1185. transform-origin: center center;
  1186. }
  1187. }
  1188. }
  1189. }
  1190. .balanceBot {
  1191. display: flex;
  1192. justify-content: space-between;
  1193. width: 100%;
  1194. padding: 17px 16px 38px;
  1195. border-top: solid 1px #ECECEC;
  1196. .l {
  1197. display: flex;
  1198. flex-direction: column;
  1199. justify-content: center;
  1200. }
  1201. .neet {
  1202. font-size: 12px;
  1203. font-weight: 500;
  1204. line-height: 14px;
  1205. }
  1206. .money {
  1207. height: 22px;
  1208. line-height: 22px;
  1209. font-size: 18px;
  1210. font-weight: 700;
  1211. margin-top: 4px;
  1212. .text {
  1213. color: #000;
  1214. margin-right: auto;
  1215. }
  1216. }
  1217. .btn {
  1218. display: flex;
  1219. align-items: center;
  1220. justify-content: center;
  1221. width: 140px;
  1222. height: 46px;
  1223. color: #ffffff;
  1224. font-size: 18px;
  1225. font-weight: 700;
  1226. line-height: 21px;
  1227. border-radius: 46px;
  1228. background: #1D9BF0;
  1229. &.disabled {
  1230. background: #D2D2D2;
  1231. }
  1232. }
  1233. }
  1234. .waitFont {
  1235. margin-top: 16px;
  1236. padding: 0 20px;
  1237. font-size: 14px;
  1238. font-weight: 500;
  1239. line-height: 17px;
  1240. text-align: center;
  1241. }
  1242. .waitBtn {
  1243. display: flex;
  1244. align-items: center;
  1245. justify-content: center;
  1246. width: 50px;
  1247. height: 50px;
  1248. margin: 50px auto 0;
  1249. border-radius: 50%;
  1250. background-color: #ffffff;
  1251. img {
  1252. width: 24px;
  1253. height: 24px;
  1254. }
  1255. }
  1256. .icon-refresh-rotate {
  1257. transform: rotate(360deg);
  1258. transition-duration: 1s;
  1259. }
  1260. </style>