index.vue 43 KB

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