currency-detail.vue 11 KB

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