index.vue 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244
  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() {
  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. },
  434. showRedeem() {
  435. this.redeemStr = '';
  436. this.redeemLayer = true;
  437. this.$nextTick(() => {
  438. this.$refs.input.focus();
  439. })
  440. this.reportView(Report.pageSource.nftRedeemPage)
  441. this.reportPaymentBtnClick(Report.objectType.redeemButton)
  442. },
  443. textInput(e) {
  444. let len = 16
  445. let str = this.redeemStr.replace(/[^a-zA-Z0-9]/g, '')
  446. str = str.toUpperCase();
  447. str = str.slice(0, len);
  448. // set
  449. this.redeemStr = str;
  450. this.redeemNext = str !== '' && str.length === len;
  451. },
  452. textBlur(e) {
  453. let isiOS = !!window.navigator.userAgent.match(/\(i\[^;]+;( U;)? CPU.+Mac OS X/)
  454. if (isiOS) {
  455. setTimeout(() => {
  456. const scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0
  457. window.scrollTo(0, Math.max(scrollHeight - 1, 0))
  458. }, 100)
  459. }
  460. },
  461. textFocus(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. redeemPayment() {
  471. if (!this.redeemNext) return;
  472. let params = {
  473. redeemCode: this.redeemStr,
  474. nftProjectId: this.$route.query.nftProjectId,
  475. }
  476. this.redeemNext = false;
  477. postRequest(Api.redeemNft, {
  478. params
  479. }).then(res => {
  480. let { code, data } = res;
  481. if (code === 0) {
  482. this.redeemLayer = false;
  483. if (data.length > 0) {
  484. this.buyData = data[0];
  485. }
  486. // 购买成功
  487. this.step = 4;
  488. } else {
  489. this.payError(code)
  490. }
  491. }).finally(() => {
  492. this.redeemNext = true;
  493. })
  494. this.reportRedeemBtnClick()
  495. },
  496. getAddress() {
  497. postRequest(Api.getTokenRechargeAddress, {
  498. params: {
  499. tokenChain: this.salePlans.currencyInfo?.tokenChain
  500. }
  501. }).then(res => {
  502. let { code, data } = res;
  503. if (code === 0) {
  504. this.rechargeAddress = data.rechargeAddress
  505. this.maskUrlToLink()
  506. }
  507. })
  508. },
  509. maskUrlToLink() {
  510. // MetaMask Link
  511. let url;
  512. let price = Number(this.salePlans.price) > Number(this.currencyInfoData.balance) ? Number(this.salePlans.price) - Number(this.currencyInfoData.balance) : Number(this.salePlans.price)
  513. if (this.salePlans.currencyInfo?.contractAddress) {
  514. // 代币
  515. url = maskUrl({
  516. target_address: this.salePlans.currencyInfo.contractAddress,
  517. parameters: {
  518. address: this.rechargeAddress,
  519. uint256: `${price}e${this.salePlans.currencyInfo?.decimalLength || 18}`
  520. }
  521. }, false)
  522. } else {
  523. // 主币
  524. url = maskUrl({
  525. target_address: this.rechargeAddress,
  526. parameters: {
  527. value: `${price}e${this.salePlans.currencyInfo?.decimalLength || 18}`
  528. }
  529. })
  530. }
  531. this.maskUrlLink = url;
  532. },
  533. goNext() {
  534. this.$router.push({
  535. path: `/nft/${this.$route.query.nftProjectId}/${this.$route.query.account}/show`,
  536. })
  537. },
  538. pay() {
  539. if (this.payDisabled || Number(this.currencyInfoData.balance) < Number(this.salePlans.price)) return;
  540. this.payDisabled = true;
  541. postRequest(Api.payNftMysteryBoxWithBalance, {
  542. params: {
  543. nftProjectId: this.$route.query.nftProjectId,
  544. salePlanId: this.salePlans.salePlanId,
  545. }
  546. }).then(res => {
  547. let { code, data } = res;
  548. if (code == 0) {
  549. if (data && data.buyItems.length > 0) {
  550. this.buyData = data.buyItems[0];
  551. }
  552. // 购买成功
  553. this.step = 4;
  554. } else {
  555. this.payError(code)
  556. }
  557. }).finally(() => {
  558. this.payDisabled = false;
  559. })
  560. },
  561. payUSD() {
  562. if (Number(this.usdAmountData.rechargeAmountValue) <= 0) {
  563. this.pay()
  564. this.reportDepositCashPageClick(Report.objectType.purchaseNftButton)
  565. }
  566. },
  567. payToken() {
  568. if (Number(this.currencyInfoData.balance) >= Number(this.salePlans.price)) {
  569. this.pay()
  570. this.reportDepositTokenPageClick(Report.objectType.purchaseNftButton)
  571. }
  572. },
  573. payError(code) {
  574. let msg;
  575. switch (code.toString()) {
  576. case '5001':
  577. msg = 'nft project not exist'
  578. break;
  579. case '5002':
  580. msg = 'nft project not available'
  581. break
  582. case '5101':
  583. msg = 'nft sale plan not exist'
  584. break
  585. case '5102':
  586. msg = 'nft sold out'
  587. break
  588. case '5103':
  589. msg = 'Purchase limit reached'
  590. break
  591. case '5104':
  592. case '5105':
  593. case '5106':
  594. msg = 'Invalid redemption code'
  595. break;
  596. default:
  597. msg = 'Invalid redemption code, please try again'
  598. break;
  599. }
  600. // Dialog
  601. Dialog({
  602. message: msg,
  603. confirmButtonText: 'OK',
  604. confirmButtonColor: '#1D9BF0',
  605. });
  606. },
  607. deNetPay() {
  608. if (!this.salePlans) return;
  609. let where, pageSource;
  610. if (this.salePlans.currencyCode === 'USD') {
  611. where = Number(this.usdAmountData.rechargeAmountValue) > 0
  612. pageSource = Report.pageSource.nftDepositCashPage
  613. } else {
  614. where = Number(this.salePlans.price) > Number(this.currencyInfoData.balance)
  615. pageSource = Report.pageSource.nftDepositTokenPage
  616. }
  617. if (where) {
  618. // 余额不够
  619. this.step = 3;
  620. this.currencyInfoTimer();
  621. // Report
  622. this.reportView(pageSource);
  623. } else {
  624. // 余额足够
  625. this.step = 2;
  626. }
  627. this.reportPaymentBtnClick(Report.objectType.denetPayButton)
  628. },
  629. maskPay() {
  630. if (Number(this.salePlans.price) > Number(this.currencyInfoData.balance)) {
  631. this.step = 2;
  632. this.waitRefresh = true;
  633. this.currencyInfoTimer();
  634. Dialog({
  635. message: `Was the pament successful?`,
  636. showCancelButton: true,
  637. confirmButtonText: 'YES',
  638. confirmButtonColor: '#1D9BF0',
  639. cancelButtonText: 'NO',
  640. cancelButtonColor: '#1D9BF0',
  641. }).then(() => {
  642. this.checkWaitInfo()
  643. }).catch(() => {
  644. this.checkWaitInfo()
  645. });
  646. } else {
  647. this.step = 2;
  648. }
  649. this.reportPaymentBtnClick(Report.objectType.metamaskPayButton)
  650. },
  651. achPay(modifyStep = true, objectType = '') {
  652. if (Number(this.usdAmountData.rechargeAmountValue) > 0) {
  653. if (modifyStep) {
  654. this.step = 2;
  655. }
  656. this.waitRefresh = true;
  657. this.currencyInfoTimer();
  658. Dialog({
  659. message: `Was the pament successful?`,
  660. showCancelButton: true,
  661. confirmButtonText: 'YES',
  662. confirmButtonColor: '#1D9BF0',
  663. cancelButtonText: 'NO',
  664. cancelButtonColor: '#1D9BF0',
  665. }).then(() => {
  666. this.checkWaitInfo()
  667. }).catch(() => {
  668. this.checkWaitInfo()
  669. });
  670. this.$nextTick(() => {
  671. let win = window.open();
  672. win.opener = null;
  673. win.location.href = `${location.protocol}//${location.host}/payment_ach/${this.usdAmountData.rechargeAmountValue}`;
  674. this.achTimer = setInterval(() => {
  675. console.log('pay')
  676. if (win && win.closed) {
  677. console.log('done')
  678. clearInterval(this.achTimer);
  679. }
  680. }, 500);
  681. })
  682. } else {
  683. if (modifyStep) {
  684. this.step = 2;
  685. }
  686. }
  687. if (objectType !== '') {
  688. this.reportPaymentBtnClick(objectType)
  689. } else {
  690. this.reportDepositCashPageClick(Report.objectType.depositButtion)
  691. }
  692. },
  693. copyErCode() {
  694. this.reportDepositTokenPageClick(Report.objectType.copyButtion)
  695. },
  696. reportView(pageSource) {
  697. Report.log({
  698. pageSource,
  699. params: {
  700. eventData: {
  701. businessType: Report.businessType.pageView,
  702. },
  703. extParams: {
  704. userAgent: window.navigator.userAgent,
  705. }
  706. }
  707. })
  708. },
  709. reportPaymentBtnClick(objectType) {
  710. Report.log({
  711. pageSource: Report.pageSource.nftPaymentPage,
  712. params: {
  713. eventData: {
  714. objectType,
  715. businessType: Report.businessType.buttonClick,
  716. },
  717. extParams: {
  718. userAgent: window.navigator.userAgent,
  719. }
  720. }
  721. })
  722. },
  723. reportRedeemBtnClick() {
  724. Report.log({
  725. pageSource: Report.pageSource.nftRedeemPage,
  726. params: {
  727. eventData: {
  728. objectType: Report.objectType.redeemButton,
  729. businessType: Report.businessType.buttonClick,
  730. },
  731. extParams: {
  732. userAgent: window.navigator.userAgent,
  733. }
  734. }
  735. })
  736. },
  737. reportDepositCashPageClick(objectType) {
  738. Report.log({
  739. pageSource: Report.pageSource.nftDepositCashPage,
  740. params: {
  741. eventData: {
  742. objectType,
  743. businessType: Report.businessType.buttonClick,
  744. },
  745. extParams: {
  746. userAgent: window.navigator.userAgent,
  747. }
  748. }
  749. })
  750. },
  751. reportDepositTokenPageClick(objectType) {
  752. Report.log({
  753. pageSource: Report.pageSource.nftDepositTokenPage,
  754. params: {
  755. eventData: {
  756. objectType,
  757. businessType: Report.businessType.buttonClick,
  758. },
  759. extParams: {
  760. userAgent: window.navigator.userAgent,
  761. }
  762. }
  763. })
  764. },
  765. }
  766. }
  767. </script>
  768. <style lang="scss">
  769. html,
  770. body,
  771. #__nuxt,
  772. #__layout {
  773. width: 100%;
  774. height: 100%;
  775. padding: 0;
  776. margin: 0;
  777. overflow: hidden;
  778. }
  779. .payment {
  780. width: 100%;
  781. height: 100%;
  782. }
  783. .moneyInfo {
  784. display: flex;
  785. align-items: center;
  786. justify-content: center;
  787. flex-direction: column;
  788. height: 90px;
  789. border-bottom: solid 8px rgba($color: #f5f5f5, $alpha: .6);
  790. .tips {
  791. font-size: 12px;
  792. font-weight: 500;
  793. }
  794. .money {
  795. display: flex;
  796. align-items: center;
  797. justify-content: center;
  798. margin-top: 10px;
  799. .icon {
  800. overflow: hidden;
  801. width: 26px;
  802. height: 26px;
  803. border-radius: 50%;
  804. margin-right: 10px;
  805. vertical-align: middle;
  806. background-color: #f5f5f5;
  807. }
  808. .info {
  809. color: #000;
  810. font-size: 20px;
  811. font-weight: 700;
  812. &.usd {
  813. margin-top: -5px;
  814. }
  815. }
  816. }
  817. }
  818. .payList {
  819. overflow-y: auto;
  820. height: calc(100% - 90px);
  821. .detail {
  822. padding: 18px 16px;
  823. .title {
  824. color: #ADADAD;
  825. height: 26px;
  826. font-size: 12px;
  827. font-weight: 500;
  828. }
  829. .item {
  830. position: relative;
  831. display: flex;
  832. align-items: center;
  833. justify-content: center;
  834. font-weight: 500;
  835. font-size: 16px;
  836. height: 50px;
  837. margin-bottom: 14px;
  838. border-radius: 100px;
  839. border: 1px solid #ECECEC;
  840. &:last-child {
  841. margin-bottom: 0;
  842. }
  843. img {
  844. width: 24px;
  845. height: 24px;
  846. margin-right: 4px;
  847. }
  848. &.denet {
  849. flex-direction: column;
  850. img {
  851. margin-top: -6px;
  852. }
  853. }
  854. .wallet {
  855. width: 100%;
  856. overflow: hidden;
  857. color: #ADADAD;
  858. font-size: 11px;
  859. text-align: center;
  860. margin-top: -2px;
  861. }
  862. .maskLink {
  863. position: absolute;
  864. z-index: 10;
  865. width: 100%;
  866. height: 100%;
  867. }
  868. }
  869. }
  870. }
  871. .loading {
  872. position: absolute;
  873. z-index: 3;
  874. display: flex;
  875. align-items: center;
  876. justify-content: center;
  877. top: 0;
  878. left: 0;
  879. width: 100%;
  880. height: 100%;
  881. }
  882. .loadingBg {
  883. position: absolute;
  884. z-index: 2;
  885. top: 0;
  886. left: 0;
  887. width: 100%;
  888. height: 100%;
  889. background-color: rgba($color: #000, $alpha: .1);
  890. }
  891. .redeem {
  892. padding: 18px 16px 38px;
  893. .tips {
  894. height: 31px;
  895. font-size: 15px;
  896. font-weight: 500;
  897. }
  898. .footer {
  899. display: flex;
  900. justify-content: space-between;
  901. .input {
  902. display: flex;
  903. align-items: center;
  904. justify-content: center;
  905. width: calc(100% - 93px);
  906. height: 45px;
  907. border-radius: 5px;
  908. border: 1px solid #E0E0E0;
  909. input {
  910. width: 94%;
  911. border: 0;
  912. outline: 0;
  913. }
  914. }
  915. .enter {
  916. width: 83px;
  917. height: 45px;
  918. border: 0;
  919. color: #ffffff;
  920. font-size: 17px;
  921. font-weight: 500;
  922. border-radius: 5px;
  923. background: #1D9BF0;
  924. &.disabled {
  925. background: #DEDEDE;
  926. }
  927. }
  928. }
  929. }
  930. .payInfo {
  931. width: 100%;
  932. height: calc(100% - 88px);
  933. .picShow {
  934. padding: 54px 48px;
  935. .tip {
  936. height: 44px;
  937. font-size: 18px;
  938. font-weight: 600;
  939. text-align: center;
  940. }
  941. .pic {
  942. width: 280px;
  943. height: 280px;
  944. border-radius: 3px;
  945. margin-bottom: 20px;
  946. }
  947. .name {
  948. font-size: 18px;
  949. font-weight: 600;
  950. line-height: 21px;
  951. text-align: center;
  952. }
  953. }
  954. }
  955. .payBtn {
  956. padding: 0 16px 38px;
  957. .btn {
  958. width: 100%;
  959. height: 50px;
  960. color: #FFFFFF;
  961. font-size: 18px;
  962. font-weight: 700;
  963. border-radius: 50px;
  964. background: #1D9BF0;
  965. }
  966. }
  967. .balanceTop {
  968. display: flex;
  969. align-items: center;
  970. justify-content: center;
  971. flex-direction: column;
  972. height: calc(100% - 100px);
  973. background-color: #f5f5f5;
  974. .balance {
  975. width: 66px;
  976. height: 66px;
  977. margin-bottom: 6px;
  978. }
  979. .text {
  980. font-size: 15px;
  981. font-weight: 500;
  982. line-height: 18px;
  983. color: #9D9D9D;
  984. }
  985. .money {
  986. font-size: 22px;
  987. font-weight: 700;
  988. line-height: 26px;
  989. margin-top: 6px;
  990. .icon {
  991. width: 22px;
  992. height: 22px;
  993. margin-right: 6px;
  994. }
  995. .font {
  996. color: #000;
  997. }
  998. }
  999. }
  1000. .balanceInfo {
  1001. overflow-y: auto;
  1002. height: calc(100% - 100px);
  1003. background-color: #f5f5f5;
  1004. .top {
  1005. padding: 0 16px 17px 16px;
  1006. background-color: #ffffff;
  1007. .item {
  1008. display: flex;
  1009. align-items: center;
  1010. height: 54px;
  1011. border-bottom: solid 1px #F2F2F2;
  1012. &.title {
  1013. font-size: 16px;
  1014. font-weight: 600;
  1015. line-height: 19px;
  1016. img {
  1017. width: 26px;
  1018. height: 26px;
  1019. margin-right: 6px;
  1020. }
  1021. }
  1022. &.column {
  1023. color: rgba($color: #5E5E5E, $alpha: .7);
  1024. font-size: 14px;
  1025. font-weight: 400;
  1026. .l {
  1027. width: 70px;
  1028. }
  1029. .r {
  1030. img {
  1031. width: 21px;
  1032. height: 21px;
  1033. margin-right: 4px;
  1034. }
  1035. span {
  1036. color: rgba($color: #5E5E5E, $alpha: .7);
  1037. }
  1038. }
  1039. }
  1040. &.usd {
  1041. font-size: 14px;
  1042. font-weight: 500;
  1043. justify-content: space-between;
  1044. .fontPayment {
  1045. font-size: 18px;
  1046. font-weight: 600;
  1047. }
  1048. .font {
  1049. color: #9A9A9A;
  1050. font-size: 16px;
  1051. font-weight: 500;
  1052. }
  1053. .fontDeposit {
  1054. color: #1D9BF0;
  1055. font-size: 18px;
  1056. font-weight: 600;
  1057. }
  1058. }
  1059. }
  1060. .deposit {
  1061. display: flex;
  1062. align-items: center;
  1063. justify-content: center;
  1064. height: 54px;
  1065. color: #ffffff;
  1066. font-weight: 600;
  1067. font-size: 18px;
  1068. margin-top: 16px;
  1069. border-radius: 54px;
  1070. background: #1D9BF0;
  1071. }
  1072. .address {
  1073. color: rgba($color: #5E5E5E, $alpha: .7);
  1074. .title {
  1075. height: 42px;
  1076. font-size: 14px;
  1077. font-weight: 400;
  1078. line-height: 42px;
  1079. }
  1080. }
  1081. .notice {
  1082. display: flex;
  1083. justify-content: space-between;
  1084. padding: 10px;
  1085. margin-top: 12px;
  1086. border-radius: 8px;
  1087. background: #F9F6EE;
  1088. .icon {
  1089. width: 20px;
  1090. margin-right: 10px;
  1091. img {
  1092. width: 20px;
  1093. height: 20px;
  1094. }
  1095. }
  1096. .text {
  1097. flex: 1;
  1098. color: rgba($color: #5E5E5E, $alpha: .7);
  1099. font-size: 14px;
  1100. font-weight: 400;
  1101. line-height: 19px;
  1102. word-break: break-all;
  1103. strong {
  1104. color: #FF0000;
  1105. font-weight: bold;
  1106. }
  1107. }
  1108. }
  1109. }
  1110. .line {
  1111. height: 8px;
  1112. }
  1113. .balance {
  1114. display: flex;
  1115. align-items: center;
  1116. padding: 0 16px;
  1117. height: 54px;
  1118. background-color: #ffffff;
  1119. .icon {
  1120. width: 24px;
  1121. margin-right: 6px;
  1122. img {
  1123. width: 24px;
  1124. }
  1125. }
  1126. .text {
  1127. flex: 1;
  1128. font-size: 14px;
  1129. font-weight: 500;
  1130. line-height: 17px;
  1131. span {
  1132. color: #000;
  1133. margin-right: auto;
  1134. }
  1135. }
  1136. .refresh {
  1137. width: 24px;
  1138. height: 24px;
  1139. img {
  1140. width: 24px;
  1141. transform-origin: center center;
  1142. }
  1143. }
  1144. }
  1145. }
  1146. .balanceBot {
  1147. display: flex;
  1148. justify-content: space-between;
  1149. width: 100%;
  1150. padding: 17px 16px 38px;
  1151. border-top: solid 1px #ECECEC;
  1152. .l {
  1153. display: flex;
  1154. flex-direction: column;
  1155. justify-content: center;
  1156. }
  1157. .neet {
  1158. font-size: 12px;
  1159. font-weight: 500;
  1160. line-height: 14px;
  1161. }
  1162. .money {
  1163. height: 22px;
  1164. line-height: 22px;
  1165. font-size: 18px;
  1166. font-weight: 700;
  1167. margin-top: 4px;
  1168. .text {
  1169. color: #000;
  1170. margin-right: auto;
  1171. }
  1172. }
  1173. .btn {
  1174. display: flex;
  1175. align-items: center;
  1176. justify-content: center;
  1177. width: 140px;
  1178. height: 46px;
  1179. color: #ffffff;
  1180. font-size: 18px;
  1181. font-weight: 700;
  1182. line-height: 21px;
  1183. border-radius: 46px;
  1184. background: #1D9BF0;
  1185. &.disabled {
  1186. background: #D2D2D2;
  1187. }
  1188. }
  1189. }
  1190. .waitFont {
  1191. margin-top: 16px;
  1192. padding: 0 20px;
  1193. font-size: 14px;
  1194. font-weight: 500;
  1195. line-height: 17px;
  1196. text-align: center;
  1197. }
  1198. .waitBtn {
  1199. display: flex;
  1200. align-items: center;
  1201. justify-content: center;
  1202. width: 50px;
  1203. height: 50px;
  1204. margin: 50px auto 0;
  1205. border-radius: 50%;
  1206. background-color: #ffffff;
  1207. img {
  1208. width: 24px;
  1209. height: 24px;
  1210. }
  1211. }
  1212. .icon-refresh-rotate {
  1213. transform: rotate(360deg);
  1214. transition-duration: 1s;
  1215. }
  1216. </style>