index.vue 44 KB

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