currency-detail.vue 7.8 KB

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