currency-detail.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <div class="currency-detail-page">
  3. <v-head :title="currencyInfo.currencyName"
  4. :show_more="false"
  5. :show_refresh="true"
  6. :show_list="true"
  7. @on-refresh="onRefresh" />
  8. <div class="top">
  9. <img
  10. class="icon-currency"
  11. :src="currencyInfo.iconPath"/>
  12. <div class="amount">
  13. {{currencyInfo.balance}} {{currencyInfo.currencyName}}
  14. <div class="final">${{currencyInfo.usdEstimateBalance}}</div>
  15. </div>
  16. </div>
  17. <div class="bottom">
  18. <div class="btn deposit-btn"
  19. v-if="currencyInfo.currencyCode != 'USD'"
  20. @click="clickDeposit">Deposit</div>
  21. <div class="btn withdrawal-btn" @click="clickWithdraw">Withdrawal</div>
  22. </div>
  23. <template v-if="showCurrencySelect">
  24. <div class="selectDiv">
  25. <currency-select
  26. ref="currencySelectDom"
  27. :list="currenciesData"
  28. @selectCurrency="selectCurrency">
  29. </currency-select>
  30. </div>
  31. <div class="selectBg"></div>
  32. </template>
  33. </div>
  34. </template>
  35. <script setup>
  36. import { ref, onMounted, inject, reactive } from "vue";
  37. import router from "@/router/popup.js";
  38. import Report from "@/log-center/log";
  39. import { getStorage } from "@/uilts/help";
  40. import { syncChainTokenRechargeRecord } from "@/http/publishApi";
  41. import VHead from '@/view/popup/components/head.vue'
  42. import currencySelect from "@/view/components/currency-select.vue";
  43. let currenciesData = ref([]);
  44. let currencyInfo = ref({});
  45. let showCurrencySelect = ref(false);
  46. const selectCurrency = (params) => {
  47. showCurrencySelect.value = false;
  48. currencyInfo.value = {
  49. ...params,
  50. totalBalance: currencyInfo.value.totalBalance,
  51. totalUsdEstimateBalance: currencyInfo.value.totalUsdEstimateBalance
  52. }
  53. console.log(currencyInfo.value)
  54. }
  55. // 点击提现
  56. const clickWithdraw = () => {
  57. Report.reportLog({
  58. pageSource: Report.pageSource.denetHomePage,
  59. businessType: Report.businessType.buttonClick,
  60. objectType: Report.objectType.withdrawButton
  61. });
  62. withdrawHandle(currencyInfo.value);
  63. }
  64. let withdraw_info = inject('withdraw_info')
  65. const withdrawHandle = (_params) => {
  66. withdraw_info.chainInfo = _params.chainInfo;
  67. if (_params.currencyCode == 'USD') {
  68. withdraw_info.currency_code = _params.currencyCode
  69. router.push('/withdraw/paypal')
  70. } else {
  71. withdraw_info.source = 'home'
  72. withdraw_info.balance = _params.balance
  73. withdraw_info.token_symbol = _params.tokenSymbol || ''
  74. withdraw_info.currency_name = _params.currencyName || ''
  75. withdraw_info.token_chain = _params.tokenChain || 'BNB Chain'
  76. withdraw_info.currency_code = _params.currencyCode
  77. withdraw_info.icon_token = _params.iconPath || ''
  78. withdraw_info.icon_net = require('@/assets/svg/icon-BNB.svg')
  79. console.log(withdraw_info.chainInfo.iconPath)
  80. router.push('/withdraw/info')
  81. }
  82. }
  83. const clickDeposit = () => {
  84. Report.reportLog({
  85. pageSource: Report.pageSource.denetHomePage,
  86. businessType: Report.businessType.buttonClick,
  87. objectType: Report.objectType.topupButton
  88. });
  89. depositHandle(currencyInfo.value);
  90. }
  91. let top_up_info = inject('top_up_info');
  92. const depositHandle = (_params) => {
  93. top_up_info.token = _params.currencyName || ''
  94. top_up_info.token_chain = _params.tokenChain
  95. top_up_info.token_symbol = _params.tokenSymbol || ''
  96. top_up_info.currency_code = _params.currencyCode
  97. top_up_info.icon_token = _params.iconPath || ''
  98. top_up_info.icon_net = require('@/assets/svg/icon-BNB.svg')
  99. top_up_info.chainInfo = {
  100. ..._params.chainInfo
  101. };
  102. router.push('/top-up/info');
  103. };
  104. const onRefresh = () => {
  105. // 刷新余额接口
  106. asyncTokenRechRecord(currencyInfo.value, (res) => {
  107. if(res.code == 0 && res.data && res.data.length) {
  108. let currencyData = res.data[0];
  109. if(currencyData.currencyCode == currencyInfo.value.currencyCode) {
  110. currencyInfo.value.balance = currencyData.balance;
  111. currencyInfo.value.usdEstimateBalance = currencyData.usdEstimateBalance;
  112. }
  113. }
  114. })
  115. };
  116. const asyncTokenRechRecord = (_params, cb) => {
  117. syncChainTokenRechargeRecord({
  118. params: {
  119. currencyCode: _params.currencyCode
  120. }
  121. }).then(res => {
  122. cb && cb(res)
  123. })
  124. }
  125. onMounted(() => {
  126. let {params = '{}'} = router.currentRoute.value.query;
  127. let {currencies = [], totalBalance = 0, totalUsdEstimateBalance = 0} = JSON.parse(params);
  128. currenciesData.value = currencies;
  129. if(currencies.length) {
  130. currencyInfo.value = {
  131. ...currencies[0],
  132. totalBalance,
  133. totalUsdEstimateBalance
  134. };
  135. }
  136. if(currenciesData.value.length > 1) {
  137. showCurrencySelect.value = true;
  138. }
  139. })
  140. </script>
  141. <style lang='scss' scoped>
  142. .currency-detail-page {
  143. width: 100%;
  144. height: 100%;
  145. position: relative;
  146. .top {
  147. height: calc(100% - 212px);
  148. display: flex;
  149. flex-direction: column;
  150. align-items: center;
  151. justify-content: center;
  152. .icon-currency {
  153. width: 100px;
  154. margin-bottom: 30px;
  155. }
  156. .amount {
  157. font-weight: 700;
  158. font-size: 28px;
  159. .final {
  160. margin-top: 9px;
  161. font-weight: 500;
  162. font-size: 22px;
  163. color: #a2a2a2;
  164. text-align: center;
  165. }
  166. }
  167. }
  168. .bottom {
  169. height: 162px;
  170. padding: 0 20px;
  171. box-sizing: border-box;
  172. .btn {
  173. width: 100%;
  174. height: 57px;
  175. display: flex;
  176. align-items: center;
  177. justify-content: center;
  178. font-weight: 500;
  179. font-size: 17px;
  180. border-radius: 100px;
  181. cursor: pointer;
  182. }
  183. .deposit-btn {
  184. margin-bottom: 18px;
  185. background: #1d9bf0;
  186. color: #fff;
  187. }
  188. .withdrawal-btn {
  189. background: rgba(244, 244, 244, 0.01);
  190. border: 1px solid #d7e8f4;
  191. box-sizing: border-box;
  192. color: #1d9bf0;
  193. }
  194. }
  195. .selectDiv {
  196. position: absolute;
  197. z-index: 1000;
  198. width: 100%;
  199. max-height: 480px;
  200. padding-bottom: 30px;
  201. left: 0;
  202. bottom: 0;
  203. background-color: #fff;
  204. border-radius: 20px 20px 0 0;
  205. overflow-y: auto;
  206. }
  207. .selectBg {
  208. position: absolute;
  209. z-index: 999;
  210. top: 0;
  211. left: 0;
  212. width: 100%;
  213. height: 100%;
  214. background: rgba($color: #000000, $alpha: 0.6);
  215. }
  216. }
  217. </style>