index.vue 44 KB

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