index.vue 43 KB

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