improve display of currency

This commit is contained in:
liangping 2022-02-16 19:06:20 +08:00
parent 6bd333a41c
commit cb1159ddf3

View File

@ -105,12 +105,12 @@
</div> </div>
<div class="d-flex flex-column"> <div class="d-flex flex-column">
<span class="text-right">{{ formatToken(token) }}</span> <span class="text-right">{{ formatToken(token) }}</span>
<small class="text-right">{{ currency }}{{ token.currency }}</small> <small class="text-right">{{ currency }}{{ formatNumber(token.currency) }}</small>
</div> </div>
</div> </div>
<!--/ tokens --> <!--/ tokens -->
<div class="text-right border-top pt-1"> <div class="text-right border-top pt-1">
<h2>Total: {{ currency }}{{ assetTable.currency }}</h2> <h2>Total: {{ currency }}{{ formatNumber(assetTable.currency) }}</h2>
</div> </div>
</b-col> </b-col>
</b-row> </b-row>
@ -369,7 +369,7 @@ import VueQr from 'vue-qr'
import chainAPI from '@/libs/fetch' import chainAPI from '@/libs/fetch'
import { import {
formatToken, formatTokenAmount, formatTokenDenom, getStakingValidatorOperator, percent, tokenFormatter, toDay, formatToken, formatTokenAmount, formatTokenDenom, getStakingValidatorOperator, percent, tokenFormatter, toDay,
toDuration, abbrMessage, abbrAddress, getUserCurrency, getUserCurrencySign, toDuration, abbrMessage, abbrAddress, getUserCurrency, getUserCurrencySign, numberWithCommas,
} from '@/libs/utils' } from '@/libs/utils'
import { sha256 } from '@cosmjs/crypto' import { sha256 } from '@cosmjs/crypto'
import { toHex } from '@cosmjs/encoding' import { toHex } from '@cosmjs/encoding'
@ -612,6 +612,9 @@ export default {
}) })
}, },
methods: { methods: {
formatNumber(v) {
return numberWithCommas(v)
},
pageload(v) { pageload(v) {
this.$http.getTxsBySender(this.address, v).then(res => { this.$http.getTxsBySender(this.address, v).then(res => {
this.transactions = res this.transactions = res
@ -624,14 +627,14 @@ export default {
formatDenom(v) { formatDenom(v) {
return formatTokenDenom(this.denoms[v] ? this.denoms[v] : v) return formatTokenDenom(this.denoms[v] ? this.denoms[v] : v)
}, },
formatAmount(v, dec = 2, denom = 'uatom') { formatAmount(v, dec = 2, denom = 'uatom', format = true) {
return formatTokenAmount(v, dec, denom) return formatTokenAmount(v, dec, denom, format)
}, },
formatToken(v) { formatToken(v) {
return tokenFormatter(v, this.denoms) return tokenFormatter(v, this.denoms)
}, },
formatCurrency(amount, denom) { formatCurrency(amount, denom) {
const qty = this.formatAmount(amount, 2, denom) const qty = this.formatAmount(amount, 2, denom, false)
const d2 = this.formatDenom(denom) const d2 = this.formatDenom(denom)
const userCurrency = getUserCurrency() const userCurrency = getUserCurrency()
const quote = this.$store.state.chains.quotes[d2] const quote = this.$store.state.chains.quotes[d2]