Commit 9352a5db authored by chenqikuai's avatar chenqikuai

fix

parent ee01be77
......@@ -19,7 +19,7 @@
import Vue from 'vue'
export default Vue.extend({
props: {
speed: String,
speed: Number,
tps: Number,
txNumber: Number,
addressNumber: Number,
......@@ -29,11 +29,11 @@ export default Vue.extend({
return [
{
name: this.$t('lang.chainPerf.speed') as string,
value: '2s' + this.speed,
value: this.speed + 's',
},
{
name: this.$t('lang.chainPerf.tps') as string,
value: '13.3' + this.tps,
value: this.tps,
},
{
name: this.$t('lang.chainPerf.txNumber') as string,
......@@ -41,8 +41,7 @@ export default Vue.extend({
},
{
name: this.$t('lang.chainPerf.addressNumber') as string,
// value: '120391820' + this.addressNumber,
value: '23842',
value: this.addressNumber,
},
]
},
......
......@@ -7,11 +7,13 @@
}"
>
<img :src="yccIcon" alt="" class="yccIcon" />
<div class="text-white font-bold text-xl mt-1">0.004538 美元</div>
<div class="text-white font-bold text-xl mt-1">
{{ price }}{{ $t('lang.price.dollar') }}
</div>
<div
class="updown text-my-red font-bold text-xs flex items-center justify-center"
>
+9%
{{ quoteChange }}
</div>
<div class="font-bold text-xs text-white mt-4">
{{ $t('lang.price.realTimeQuotes') }}
......@@ -25,7 +27,7 @@
{{ $t('lang.price.marketValueInDollars') }}
</div>
<div class="text-footer-color font-bold">
1029381023
{{ marketValue }}
</div>
</div>
</div>
......@@ -35,6 +37,11 @@ import Vue from 'vue'
import bg from '@/assets/images/blockChainBrowser/home/beautiful-rect.png'
import yccIcon from '@/assets/images/blockChainBrowser/home/ycc-icon.png'
export default Vue.extend({
props: {
price: String,
quoteChange: String,
marketValue: Number,
},
data() {
return {
bg,
......
......@@ -15,7 +15,7 @@
import Vue from 'vue'
export default Vue.extend({
props: {
speed: String,
speed: Number,
tps: Number,
txNumber: Number,
addressNumber: Number,
......@@ -25,11 +25,11 @@ export default Vue.extend({
return [
{
name: this.$t('lang.chainPerf.speed') as string,
value: '2s' + this.speed,
value: this.speed + 's',
},
{
name: this.$t('lang.chainPerf.tps') as string,
value: '13.3' + this.tps,
value: this.tps,
},
{
name: this.$t('lang.chainPerf.txNumber') as string,
......@@ -37,8 +37,7 @@ export default Vue.extend({
},
{
name: this.$t('lang.chainPerf.addressNumber') as string,
// value: '120391820' + this.addressNumber,
value: '0asdf0980q9238409812304980932',
value: this.addressNumber,
},
]
},
......
......@@ -6,7 +6,12 @@
:marketValue="marketValue"
></chain-card-show-price>
<div>
<chain-card-show-perf :txNumber="totalTx"></chain-card-show-perf>
<chain-card-show-perf
:txNumber="totalTx"
:speed="speed"
:tps="tps"
:addressNumber="addressNumber"
></chain-card-show-perf>
<chain-tx-number-chart style="margin-top: 30px;"></chain-tx-number-chart>
</div>
</div>
......@@ -28,6 +33,9 @@ export default Vue.extend({
quoteChange: String,
price: String,
marketValue: Number,
speed: Number,
tps: Number,
addressNumber: Number,
},
})
</script>
......@@ -3,7 +3,7 @@ import { getLatestBlock } from "ycc-api/dist/cmjs/service/home/index";
import { iBlockMsg } from "ycc-api/dist/cmjs/service/home/types";
import { getRpc } from "ycc-api/src/service/Rpc";
import Base64 from "@/utils/_base64";
import { getTxList } from "@/service/api";
import { blockStatStatGets, getTxList } from "@/service/api";
export default Vue.extend({
data() {
return {
......@@ -14,15 +14,10 @@ export default Vue.extend({
quoteChange: "",
price: "",
marketValue: 0,
latestTxs: [
{
hash: "lkajskfdkasdf",
from: "laksjdflas",
to: "lakdjflkasdf",
time_block: 1643167975993,
amount: 30000000,
},
],
speed: 0,
tps: 0,
addressNumber: 0,
latestTxs: [],
};
},
mounted() {
......@@ -39,8 +34,24 @@ export default Vue.extend({
}));
}
});
this.getSpeed();
},
methods: {
getSpeed() {
blockStatStatGets(725000, this.latestHeight).then((res) => {
if (res.error === null) {
const fatherBlock = res.result[0];
const lastBlock = res.result[1];
const perTime =
(lastBlock.time - fatherBlock.time) / (this.latestHeight - 725000);
const perTxCount =
(lastBlock.tx_count - fatherBlock.tx_count) /
(lastBlock.time - fatherBlock.time);
this.tps = perTime;
this.tps = perTxCount;
}
});
},
setValue(v: string) {
this.value = v;
},
......@@ -111,6 +122,10 @@ export default Vue.extend({
},
},
computed: {
nodeNum(): number {
// 100 亿+30*725000 + 15*(当前高度-725000)
return 100 * 1e8 + 30 * 725000 + 15 * (this.latestHeight - 725000);
},
msgList(): any[] {
return [
{
......@@ -126,7 +141,7 @@ export default Vue.extend({
{
icon: require("@/assets/images/blockChainBrowser/home/circulateNumber.png"),
title: this.$t("lang.chainMsg.circulation"),
number: 102938,
number: this.nodeNum,
},
{
icon: require("@/assets/images/blockChainBrowser/home/pledgeQuantity.png"),
......
......@@ -110,3 +110,18 @@ export function getTxList(number: number, size: number) {
},
});
}
export function blockStatStatGets(startHeight: number, endHeight: number) {
return axios(expandApi, {
method: "post",
params: {
id: 1,
method: "BlockStat.StatGets",
params: [
{
height: [startHeight, endHeight],
},
],
},
});
}
......@@ -13,9 +13,20 @@
</div>
<m-num-of-on-chain-tx class="mx-4 mt-3.5"></m-num-of-on-chain-tx>
<div class="flex justify-between mx-4 mt-3.5">
<m-chain-price class="flex-shrink-0"></m-chain-price>
<m-chain-price
class="flex-shrink-0"
:marketValue="marketValue"
:price="price"
:quoteChange="quoteChange"
></m-chain-price>
<div style="width: 15px;"></div>
<m-chain-perf class="flex-grow"></m-chain-perf>
<m-chain-perf
class="flex-grow"
:speed="speed"
:addressNumber="addressNumber"
:tps="tps"
:txNumber="totalTx"
></m-chain-perf>
</div>
<m-latest-blocks
class="mx-4 mt-3.5 shadow-shadow1 rounded-twoPx overflow-hidden"
......
......@@ -28,6 +28,9 @@
:quoteChange="quoteChange"
:price="price"
:marketValue="marketValue"
:speed="speed"
:tps="tps"
:addressNumber="addressNumber"
/>
<div class="flex justify-between mt-14" style="margin-bottom: 60px;">
<latest-block :latestBlocks="latestBlocks"></latest-block>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment