index.vue 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295
  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="{ disabled: (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 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. {{salePlans.price}} {{ salePlans.currencyInfo.tokenSymbol }}
  172. </FontZoom>
  173. </div>
  174. </div>
  175. <div>
  176. <div
  177. class="btn"
  178. :class="{ disabled: (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. <FontZoom width="190" :unColor="true">
  224. {{ Number(usdAmountData.rechargeAmountValue) > 0 ? usdAmountData.rechargeAmountValue : usdAmountData.orderAmountValue }} {{ salePlans.currencyInfo.tokenSymbol }}
  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 = this.usdAmountData.rechargeAmountValue;
  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.usdAmountData.rechargeAmountValue) > 0) 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 pageSource;
  623. if (this.salePlans.currencyCode === 'USD') {
  624. pageSource = Report.pageSource.nftDepositCashPage
  625. } else {
  626. pageSource = Report.pageSource.nftDepositTokenPage
  627. }
  628. if (Number(this.usdAmountData.rechargeAmountValue) > 0) {
  629. // 余额不够
  630. this.step = 3;
  631. this.currencyInfoTimer();
  632. // Report
  633. this.reportView(pageSource);
  634. } else {
  635. // 余额足够
  636. this.step = 2;
  637. this.reportView(Report.pageSource.nftBalancePage);
  638. }
  639. this.reportPaymentBtnClick(Report.objectType.denetPayButton)
  640. },
  641. maskPay() {
  642. if (Number(this.usdAmountData.rechargeAmountValue) > 0) {
  643. this.step = 2;
  644. this.waitRefresh = true;
  645. this.currencyInfoTimer();
  646. Dialog({
  647. message: `Was the pament successful?`,
  648. showCancelButton: true,
  649. confirmButtonText: 'YES',
  650. confirmButtonColor: '#1D9BF0',
  651. cancelButtonText: 'NO',
  652. cancelButtonColor: '#1D9BF0',
  653. }).then(() => {
  654. this.checkWaitInfo(false)
  655. }).catch(() => {
  656. this.checkWaitInfo(false)
  657. });
  658. this.reportView(Report.pageSource.nftPaymentBalancePage);
  659. } else {
  660. this.step = 2;
  661. this.reportView(Report.pageSource.nftBalancePage);
  662. }
  663. this.reportPaymentBtnClick(Report.objectType.metamaskPayButton)
  664. },
  665. achPay(modifyStep = true, objectType = '') {
  666. if (Number(this.usdAmountData.rechargeAmountValue) > 0) {
  667. if (modifyStep) {
  668. this.step = 2;
  669. this.reportView(Report.pageSource.nftPaymentBalancePage);
  670. }
  671. this.waitRefresh = true;
  672. this.currencyInfoTimer();
  673. Dialog({
  674. message: `Was the pament successful?`,
  675. showCancelButton: true,
  676. confirmButtonText: 'YES',
  677. confirmButtonColor: '#1D9BF0',
  678. cancelButtonText: 'NO',
  679. cancelButtonColor: '#1D9BF0',
  680. }).then(() => {
  681. this.checkWaitInfo(false)
  682. }).catch(() => {
  683. this.checkWaitInfo(false)
  684. });
  685. this.$nextTick(() => {
  686. let win = window.open();
  687. win.opener = null;
  688. win.location.href = `${location.protocol}//${location.host}/payment_ach/${this.usdAmountData.rechargeAmountValue}`;
  689. this.achTimer = setInterval(() => {
  690. console.log('pay')
  691. if (win && win.closed) {
  692. console.log('done')
  693. clearInterval(this.achTimer);
  694. }
  695. }, 500);
  696. })
  697. } else {
  698. if (modifyStep) {
  699. this.step = 2;
  700. this.reportView(Report.pageSource.nftBalancePage);
  701. }
  702. }
  703. if (objectType !== '') {
  704. this.reportPaymentBtnClick(objectType)
  705. } else {
  706. this.reportDepositCashPageClick(Report.objectType.depositButtion)
  707. }
  708. },
  709. copyErCode() {
  710. this.reportDepositTokenPageClick(Report.objectType.copyButtion)
  711. },
  712. reportView(pageSource) {
  713. Report.log({
  714. pageSource,
  715. params: {
  716. eventData: {
  717. businessType: Report.businessType.pageView,
  718. },
  719. extParams: {
  720. userAgent: window.navigator.userAgent,
  721. }
  722. }
  723. })
  724. },
  725. reportPaymentBtnClick(objectType) {
  726. Report.log({
  727. pageSource: Report.pageSource.nftPaymentPage,
  728. params: {
  729. eventData: {
  730. objectType,
  731. businessType: Report.businessType.buttonClick,
  732. },
  733. extParams: {
  734. userAgent: window.navigator.userAgent,
  735. }
  736. }
  737. })
  738. },
  739. reportRedeemBtnClick() {
  740. Report.log({
  741. pageSource: Report.pageSource.nftRedeemPage,
  742. params: {
  743. eventData: {
  744. objectType: Report.objectType.redeemButton,
  745. businessType: Report.businessType.buttonClick,
  746. },
  747. extParams: {
  748. userAgent: window.navigator.userAgent,
  749. }
  750. }
  751. })
  752. },
  753. reportDepositCashPageClick(objectType) {
  754. Report.log({
  755. pageSource: Report.pageSource.nftDepositCashPage,
  756. params: {
  757. eventData: {
  758. objectType,
  759. businessType: Report.businessType.buttonClick,
  760. },
  761. extParams: {
  762. userAgent: window.navigator.userAgent,
  763. }
  764. }
  765. })
  766. },
  767. reportDepositTokenPageClick(objectType) {
  768. Report.log({
  769. pageSource: Report.pageSource.nftDepositTokenPage,
  770. params: {
  771. eventData: {
  772. objectType,
  773. businessType: Report.businessType.buttonClick,
  774. },
  775. extParams: {
  776. userAgent: window.navigator.userAgent,
  777. }
  778. }
  779. })
  780. },
  781. reportBalanceRefresh() {
  782. let pageSource = this.waitRefresh ? Report.pageSource.nftPaymentBalancePage : Report.pageSource.nftBalancePage;
  783. Report.log({
  784. pageSource: pageSource,
  785. params: {
  786. eventData: {
  787. objectType: Report.objectType.refreshBalanceButton,
  788. businessType: Report.businessType.buttonClick,
  789. },
  790. extParams: {
  791. userAgent: window.navigator.userAgent,
  792. }
  793. }
  794. })
  795. },
  796. reportBalanceBuy() {
  797. let pageSource = this.waitRefresh ? Report.pageSource.nftPaymentBalancePage : Report.pageSource.nftBalancePage;
  798. Report.log({
  799. pageSource: pageSource,
  800. params: {
  801. eventData: {
  802. objectType: Report.objectType.purchaseNftButton,
  803. businessType: Report.businessType.buttonClick,
  804. },
  805. extParams: {
  806. userAgent: window.navigator.userAgent,
  807. }
  808. }
  809. })
  810. },
  811. }
  812. }
  813. </script>
  814. <style lang="scss">
  815. html,
  816. body,
  817. #__nuxt,
  818. #__layout {
  819. width: 100%;
  820. height: 100%;
  821. padding: 0;
  822. margin: 0;
  823. overflow: hidden;
  824. }
  825. .payment {
  826. width: 100%;
  827. height: 100%;
  828. }
  829. .moneyInfo {
  830. display: flex;
  831. align-items: center;
  832. justify-content: center;
  833. flex-direction: column;
  834. height: 90px;
  835. border-bottom: solid 8px rgba($color: #f5f5f5, $alpha: .6);
  836. .tips {
  837. font-size: 12px;
  838. font-weight: 500;
  839. }
  840. .money {
  841. display: flex;
  842. align-items: center;
  843. justify-content: center;
  844. margin-top: 10px;
  845. color: #000;
  846. font-size: 20px;
  847. font-weight: 700;
  848. .icon {
  849. overflow: hidden;
  850. width: 26px;
  851. height: 26px;
  852. border-radius: 50%;
  853. margin-right: 10px;
  854. vertical-align: middle;
  855. background-color: #f5f5f5;
  856. }
  857. .info {
  858. &.usd {
  859. margin-top: -5px;
  860. }
  861. }
  862. }
  863. }
  864. .payList {
  865. overflow-y: auto;
  866. height: calc(100% - 90px);
  867. .detail {
  868. padding: 18px 16px;
  869. .title {
  870. color: #ADADAD;
  871. height: 26px;
  872. font-size: 12px;
  873. font-weight: 500;
  874. }
  875. .item {
  876. position: relative;
  877. display: flex;
  878. align-items: center;
  879. justify-content: center;
  880. font-weight: 500;
  881. font-size: 16px;
  882. height: 50px;
  883. margin-bottom: 14px;
  884. border-radius: 100px;
  885. border: 1px solid #ECECEC;
  886. &:last-child {
  887. margin-bottom: 0;
  888. }
  889. img {
  890. width: 24px;
  891. height: 24px;
  892. margin-right: 4px;
  893. }
  894. &.denet {
  895. flex-direction: column;
  896. img {
  897. margin-top: -6px;
  898. }
  899. }
  900. .wallet {
  901. width: 100%;
  902. overflow: hidden;
  903. color: #ADADAD;
  904. font-size: 11px;
  905. text-align: center;
  906. margin-top: -2px;
  907. }
  908. .maskLink {
  909. position: absolute;
  910. z-index: 10;
  911. width: 100%;
  912. height: 100%;
  913. }
  914. }
  915. }
  916. }
  917. .loading {
  918. position: absolute;
  919. z-index: 3;
  920. display: flex;
  921. align-items: center;
  922. justify-content: center;
  923. top: 0;
  924. left: 0;
  925. width: 100%;
  926. height: 100%;
  927. }
  928. .loadingBg {
  929. position: absolute;
  930. z-index: 2;
  931. top: 0;
  932. left: 0;
  933. width: 100%;
  934. height: 100%;
  935. background-color: rgba($color: #000, $alpha: .1);
  936. }
  937. .redeem {
  938. padding: 18px 16px 38px;
  939. .tips {
  940. height: 31px;
  941. font-size: 15px;
  942. font-weight: 500;
  943. }
  944. .footer {
  945. display: flex;
  946. justify-content: space-between;
  947. .input {
  948. display: flex;
  949. align-items: center;
  950. justify-content: center;
  951. width: calc(100% - 93px);
  952. height: 45px;
  953. border-radius: 5px;
  954. border: 1px solid #E0E0E0;
  955. input {
  956. width: 94%;
  957. border: 0;
  958. outline: 0;
  959. }
  960. }
  961. .enter {
  962. width: 83px;
  963. height: 45px;
  964. border: 0;
  965. padding: 0;
  966. color: #ffffff;
  967. font-size: 17px;
  968. font-weight: 500;
  969. border-radius: 5px;
  970. background: #1D9BF0;
  971. &.disabled {
  972. background: #DEDEDE;
  973. }
  974. }
  975. }
  976. }
  977. .payInfo {
  978. width: 100%;
  979. height: calc(100% - 88px);
  980. .picShow {
  981. padding: 54px 48px;
  982. .tip {
  983. height: 44px;
  984. font-size: 18px;
  985. font-weight: 600;
  986. text-align: center;
  987. }
  988. .pic {
  989. display: block;
  990. margin: auto;
  991. width: 280px;
  992. height: 280px;
  993. border-radius: 3px;
  994. margin-bottom: 20px;
  995. }
  996. .name {
  997. font-size: 18px;
  998. font-weight: 600;
  999. line-height: 21px;
  1000. text-align: center;
  1001. }
  1002. }
  1003. }
  1004. .payBtn {
  1005. padding: 0 16px 38px;
  1006. .btn {
  1007. width: 100%;
  1008. height: 50px;
  1009. color: #FFFFFF;
  1010. font-size: 18px;
  1011. font-weight: 700;
  1012. border-radius: 50px;
  1013. background: #1D9BF0;
  1014. }
  1015. }
  1016. .balanceTop {
  1017. display: flex;
  1018. align-items: center;
  1019. justify-content: center;
  1020. flex-direction: column;
  1021. height: calc(100% - 100px);
  1022. background-color: #f5f5f5;
  1023. .balance {
  1024. width: 66px;
  1025. height: 66px;
  1026. margin-bottom: 6px;
  1027. }
  1028. .text {
  1029. font-size: 15px;
  1030. font-weight: 500;
  1031. line-height: 18px;
  1032. color: #9D9D9D;
  1033. }
  1034. .money {
  1035. font-size: 22px;
  1036. font-weight: 700;
  1037. line-height: 26px;
  1038. margin-top: 6px;
  1039. .icon {
  1040. width: 22px;
  1041. height: 22px;
  1042. margin-right: 6px;
  1043. }
  1044. .font {
  1045. color: #000;
  1046. }
  1047. }
  1048. }
  1049. .balanceInfo {
  1050. overflow-y: auto;
  1051. height: calc(100% - 100px);
  1052. background-color: #f5f5f5;
  1053. .top {
  1054. padding: 0 16px 17px 16px;
  1055. background-color: #ffffff;
  1056. .item {
  1057. display: flex;
  1058. align-items: center;
  1059. height: 54px;
  1060. border-bottom: solid 1px #F2F2F2;
  1061. &.title {
  1062. font-size: 16px;
  1063. font-weight: 600;
  1064. line-height: 19px;
  1065. img {
  1066. width: 26px;
  1067. height: 26px;
  1068. margin-right: 6px;
  1069. }
  1070. }
  1071. &.column {
  1072. color: rgba($color: #5E5E5E, $alpha: .7);
  1073. font-size: 14px;
  1074. font-weight: 400;
  1075. .l {
  1076. width: 70px;
  1077. }
  1078. .r {
  1079. img {
  1080. width: 21px;
  1081. height: 21px;
  1082. margin-right: 4px;
  1083. }
  1084. span {
  1085. color: rgba($color: #5E5E5E, $alpha: .7);
  1086. }
  1087. }
  1088. }
  1089. &.usd {
  1090. font-size: 14px;
  1091. font-weight: 500;
  1092. justify-content: space-between;
  1093. .fontPayment {
  1094. font-size: 18px;
  1095. font-weight: 600;
  1096. }
  1097. .font {
  1098. color: #9A9A9A;
  1099. font-size: 16px;
  1100. font-weight: 500;
  1101. }
  1102. .fontDeposit {
  1103. color: #1D9BF0;
  1104. font-size: 18px;
  1105. font-weight: 600;
  1106. }
  1107. }
  1108. }
  1109. .deposit {
  1110. display: flex;
  1111. align-items: center;
  1112. justify-content: center;
  1113. height: 54px;
  1114. color: #ffffff;
  1115. font-weight: 600;
  1116. font-size: 18px;
  1117. margin-top: 16px;
  1118. border-radius: 54px;
  1119. background: #1D9BF0;
  1120. }
  1121. .address {
  1122. color: rgba($color: #5E5E5E, $alpha: .7);
  1123. .title {
  1124. height: 42px;
  1125. font-size: 14px;
  1126. font-weight: 400;
  1127. line-height: 42px;
  1128. }
  1129. }
  1130. .notice {
  1131. display: flex;
  1132. justify-content: space-between;
  1133. padding: 10px;
  1134. margin-top: 12px;
  1135. border-radius: 8px;
  1136. background: #F9F6EE;
  1137. .icon {
  1138. width: 20px;
  1139. margin-right: 10px;
  1140. img {
  1141. width: 20px;
  1142. height: 20px;
  1143. }
  1144. }
  1145. .text {
  1146. flex: 1;
  1147. color: rgba($color: #5E5E5E, $alpha: .7);
  1148. font-size: 14px;
  1149. font-weight: 400;
  1150. line-height: 19px;
  1151. word-break: break-all;
  1152. strong {
  1153. color: #FF0000;
  1154. font-weight: bold;
  1155. }
  1156. }
  1157. }
  1158. }
  1159. .line {
  1160. height: 8px;
  1161. }
  1162. .balance {
  1163. display: flex;
  1164. align-items: center;
  1165. padding: 0 16px;
  1166. height: 54px;
  1167. background-color: #ffffff;
  1168. .icon {
  1169. width: 24px;
  1170. margin-right: 6px;
  1171. img {
  1172. width: 24px;
  1173. }
  1174. }
  1175. .text {
  1176. flex: 1;
  1177. font-size: 14px;
  1178. font-weight: 500;
  1179. line-height: 17px;
  1180. span {
  1181. color: #000;
  1182. margin-right: auto;
  1183. }
  1184. }
  1185. .refresh {
  1186. width: 24px;
  1187. height: 24px;
  1188. img {
  1189. width: 24px;
  1190. transform-origin: center center;
  1191. }
  1192. }
  1193. }
  1194. }
  1195. .balanceBot {
  1196. display: flex;
  1197. justify-content: space-between;
  1198. width: 100%;
  1199. padding: 17px 16px 38px;
  1200. border-top: solid 1px #ECECEC;
  1201. .l {
  1202. display: flex;
  1203. flex-direction: column;
  1204. justify-content: center;
  1205. }
  1206. .neet {
  1207. font-size: 12px;
  1208. font-weight: 500;
  1209. line-height: 14px;
  1210. }
  1211. .money {
  1212. height: 22px;
  1213. line-height: 22px;
  1214. font-size: 18px;
  1215. font-weight: 700;
  1216. margin-top: 4px;
  1217. .text {
  1218. margin-right: auto;
  1219. }
  1220. }
  1221. .btn {
  1222. display: flex;
  1223. align-items: center;
  1224. justify-content: center;
  1225. width: 110px;
  1226. height: 46px;
  1227. color: #ffffff;
  1228. font-size: 18px;
  1229. font-weight: 700;
  1230. line-height: 21px;
  1231. border-radius: 46px;
  1232. background: #1D9BF0;
  1233. &.disabled {
  1234. background: #D2D2D2;
  1235. }
  1236. }
  1237. }
  1238. .waitFont {
  1239. margin-top: 16px;
  1240. padding: 0 20px;
  1241. font-size: 14px;
  1242. font-weight: 500;
  1243. line-height: 17px;
  1244. text-align: center;
  1245. }
  1246. .waitBtn {
  1247. display: flex;
  1248. align-items: center;
  1249. justify-content: center;
  1250. width: 50px;
  1251. height: 50px;
  1252. margin: 50px auto 0;
  1253. border-radius: 50%;
  1254. background-color: #ffffff;
  1255. img {
  1256. width: 24px;
  1257. height: 24px;
  1258. }
  1259. }
  1260. .icon-refresh-rotate {
  1261. transform: rotate(360deg);
  1262. transition-duration: 1s;
  1263. }
  1264. </style>