currency-detail.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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. <template v-if="showSendBtn">
  37. <div class="btn send-btn" @click="showSendGiveawayDialog(currencyInfo)">
  38. <img :src="require('@/assets/svg/icon-send-giveaway.svg')" />
  39. Send Giveaway
  40. </div>
  41. <div class="btn-wrapper">
  42. <div class="button" @click="clickDeposit">Deposit</div>
  43. <div class="button" @click="clickWithdraw">Withdrawal</div>
  44. </div>
  45. </template>
  46. <template v-else>
  47. <div class="btn deposit-btn" @click="clickDeposit">Deposit</div>
  48. <div class="btn withdrawal-btn" @click="clickWithdraw">Withdrawal</div>
  49. </template>
  50. </div>
  51. <template v-if="showCurrencySelect">
  52. <div class="selectDiv">
  53. <currency-select
  54. ref="currencySelectDom"
  55. :list="currenciesData"
  56. @selectCurrency="selectCurrency">
  57. </currency-select>
  58. </div>
  59. <div class="selectBg" @click="showCurrencySelect = false"></div>
  60. </template>
  61. </div>
  62. </template>
  63. <script setup>
  64. import { ref, onMounted, inject, reactive } from "vue";
  65. import router from "@/router/popup.js";
  66. import Report from "@/log-center/log";
  67. import { getStorage } from "@/uilts/help";
  68. import { getCurrencyInfoBySymbol } from "@/http/publishApi";
  69. import {setChromeStorage} from "@/uilts/chromeExtension"
  70. import VHead from '@/view/popup/components/head.vue'
  71. import currencySelect from "@/view/components/currency-select.vue";
  72. import { getBit } from "@/uilts/help";
  73. let currenciesData = ref([]);
  74. let currencyInfo = ref({
  75. totalBalance: '',
  76. tokenSymbol: ''
  77. });
  78. let showCurrencySelect = ref(false);
  79. let currencyOpertionType = '';
  80. let showSendBtn = ref(true);
  81. const selectCurrency = (params) => {
  82. showCurrencySelect.value = false;
  83. if(currencyOpertionType == 'WITHDRAW') {
  84. withdrawHandle(params);
  85. } else if(currencyOpertionType == 'DEPOSIT') {
  86. depositHandle(params);
  87. } else if(currencyOpertionType == 'SEND') {
  88. showSendGiveawayDialog(params);
  89. }
  90. }
  91. let withdraw_info = inject('withdraw_info')
  92. // 点击提现
  93. const clickWithdraw = () => {
  94. Report.reportLog({
  95. pageSource: Report.pageSource.denetHomePage,
  96. businessType: Report.businessType.buttonClick,
  97. objectType: Report.objectType.withdrawButton
  98. });
  99. if(currenciesData.value.length > 1) {
  100. showCurrencySelect.value = true;
  101. currencyOpertionType = "WITHDRAW";
  102. } else if(currenciesData.value.length == 1){
  103. withdrawHandle(currenciesData.value[0]);
  104. }
  105. }
  106. const withdrawHandle = (_params) => {
  107. withdraw_info.chainInfo = _params.chainInfo;
  108. withdraw_info.source = 'home'
  109. withdraw_info.balance = _params.balance
  110. withdraw_info.token_symbol = _params.tokenSymbol || ''
  111. withdraw_info.currency_name = _params.currencyName || ''
  112. withdraw_info.token_chain = _params.tokenChain || ''
  113. withdraw_info.currency_code = _params.currencyCode
  114. withdraw_info.icon_token = _params.iconPath || ''
  115. withdraw_info.icon_net = require('@/assets/svg/icon-BNB.svg')
  116. if (_params.currencyCode == 'USD') {
  117. withdraw_info.currency_code = _params.currencyCode
  118. withdraw_info.paypal.amount_value = _params.balance
  119. router.push('/withdraw/paypal')
  120. } else {
  121. console.log(withdraw_info.chainInfo.iconPath)
  122. router.push('/withdraw/info')
  123. }
  124. }
  125. let top_up_info = inject('top_up_info');
  126. const clickDeposit = () => {
  127. Report.reportLog({
  128. pageSource: Report.pageSource.denetHomePage,
  129. businessType: Report.businessType.buttonClick,
  130. objectType: Report.objectType.topupButton
  131. });
  132. if(currenciesData.value.length > 1) {
  133. showCurrencySelect.value = true;
  134. currencyOpertionType = "DEPOSIT";
  135. } else if(currenciesData.value.length == 1){
  136. let currencyInfo = currenciesData.value[0];
  137. if(currencyInfo.currencyCode == 'USD') {
  138. // 法币充值
  139. } else {
  140. depositHandle(currencyInfo);
  141. }
  142. }
  143. }
  144. const depositHandle = (_params) => {
  145. top_up_info.token = _params.currencyName || ''
  146. top_up_info.token_chain = _params.tokenChain
  147. top_up_info.token_symbol = _params.tokenSymbol || ''
  148. top_up_info.currency_code = _params.currencyCode
  149. top_up_info.icon_token = _params.iconPath || ''
  150. top_up_info.icon_net = require('@/assets/svg/icon-BNB.svg')
  151. top_up_info.chainInfo = {
  152. ..._params.chainInfo
  153. };
  154. router.push('/top-up/info');
  155. };
  156. const onRefresh = () => {
  157. getCurrencyInfoBySymbol({
  158. params: {
  159. symbol: currencyInfo.value.tokenSymbol
  160. }
  161. }).then(res => {
  162. if(res.code == 0) {
  163. if(res.data && res.data.currencyCategories && res.data.currencyCategories.length) {
  164. let data = res.data.currencyCategories[0].data;
  165. if(data.length) {
  166. let {totalBalance = '', totalUsdEstimateBalance = ''} = data[0] || {};
  167. currencyInfo.value.totalBalance = totalBalance;
  168. currencyInfo.value.totalUsdEstimateBalance = totalUsdEstimateBalance;
  169. }
  170. }
  171. }
  172. })
  173. };
  174. const showSendGiveawayDialog = (params = {}) => {
  175. if(currenciesData.value.length > 1 && currencyOpertionType != 'SEND') {
  176. showCurrencySelect.value = true;
  177. currencyOpertionType = "SEND";
  178. } else {
  179. console.log(params,'params')
  180. setLocalSelectCurrencyInfo(params)
  181. setTimeout(() => {
  182. chrome.runtime.sendMessage({
  183. actionType: "POPUP_SHOW_DENET_PUBLISH_DIALOG",
  184. data: { }
  185. }, () => { });
  186. }, 600)
  187. currencyOpertionType = '';
  188. }
  189. };
  190. const setLocalSelectCurrencyInfo = (params = {}) => {
  191. setChromeStorage({ selectCurrencyInfo : JSON.stringify(params)})
  192. }
  193. onMounted(() => {
  194. let {params = '{}'} = router.currentRoute.value.query;
  195. let {currencies = [], totalBalance = 0, totalUsdEstimateBalance = 0} = JSON.parse(params);
  196. currenciesData.value = currencies;
  197. if(currencies.length) {
  198. currencyInfo.value = {
  199. ...currencies[0],
  200. totalBalance,
  201. totalUsdEstimateBalance
  202. };
  203. console.log(currencyInfo.value )
  204. }
  205. if(window.location.pathname.indexOf('/home.html') > -1) {
  206. showSendBtn.value = false;
  207. } else {
  208. showSendBtn.value = true;
  209. }
  210. })
  211. </script>
  212. <style lang='scss' scoped>
  213. .currency-detail-page {
  214. width: 100%;
  215. height: 100%;
  216. position: relative;
  217. .top {
  218. height: calc(100% - 212px);
  219. display: flex;
  220. flex-direction: column;
  221. align-items: center;
  222. justify-content: center;
  223. .icon-currency {
  224. width: 100px;
  225. margin-bottom: 30px;
  226. }
  227. .amount {
  228. font-weight: 700;
  229. font-size: 28px;
  230. text-align: center;
  231. display: flex;
  232. align-items: center;
  233. justify-content: center;
  234. flex-direction: column;
  235. width: 100%;
  236. .balance {
  237. padding: 0 18px;
  238. box-sizing: border-box;
  239. width: 100%;
  240. word-break: break-word;
  241. display: flex;
  242. align-items: center;
  243. justify-content: center;
  244. .symbol{
  245. word-break: break-all;
  246. }
  247. }
  248. .direction-column {
  249. flex-direction: column;
  250. }
  251. .final {
  252. margin-top: 9px;
  253. font-weight: 500;
  254. font-size: 22px;
  255. color: #a2a2a2;
  256. text-align: center;
  257. }
  258. }
  259. }
  260. .bottom {
  261. height: 162px;
  262. padding: 0 20px;
  263. box-sizing: border-box;
  264. .btn {
  265. width: 100%;
  266. height: 57px;
  267. display: flex;
  268. align-items: center;
  269. justify-content: center;
  270. font-weight: 500;
  271. font-size: 17px;
  272. border-radius: 100px;
  273. cursor: pointer;
  274. }
  275. .deposit-btn {
  276. margin-bottom: 18px;
  277. background: #1d9bf0;
  278. color: #fff;
  279. }
  280. .withdrawal-btn {
  281. background: rgba(244, 244, 244, 0.01);
  282. border: 1px solid #d7e8f4;
  283. box-sizing: border-box;
  284. color: #1d9bf0;
  285. }
  286. .send-btn {
  287. font-weight: 700;
  288. font-size: 18px;
  289. margin-bottom: 18px;
  290. background: #1d9bf0;
  291. color: #fff;
  292. img {
  293. width: 19px;
  294. height: 19px;
  295. margin-right: 8px;
  296. }
  297. }
  298. .btn-wrapper {
  299. width: 100%;
  300. display: flex;
  301. align-items: center;
  302. justify-content: space-between;
  303. .button {
  304. width: 163px;
  305. height: 50px;
  306. border: 1px solid #d7e8f4;
  307. display: flex;
  308. align-items: center;
  309. justify-content: center;
  310. font-weight: 600;
  311. font-size: 16px;
  312. border-radius: 100px;
  313. box-sizing: border-box;
  314. color: #1D9BF0;
  315. cursor: pointer;
  316. }
  317. }
  318. }
  319. .selectDiv {
  320. position: absolute;
  321. z-index: 1000;
  322. width: 100%;
  323. max-height: 480px;
  324. padding-bottom: 30px;
  325. left: 0;
  326. bottom: 0;
  327. background-color: #fff;
  328. border-radius: 20px 20px 0 0;
  329. overflow-y: auto;
  330. }
  331. .selectBg {
  332. position: absolute;
  333. z-index: 999;
  334. top: 0;
  335. left: 0;
  336. width: 100%;
  337. height: 100%;
  338. background: rgba($color: #000000, $alpha: 0.6);
  339. }
  340. }
  341. </style>