Commit a9627295 authored by wenglk's avatar wenglk

地址转小写

parent bdbe3b53
...@@ -3,19 +3,19 @@ ...@@ -3,19 +3,19 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import * as echarts from 'echarts/core' import * as echarts from "echarts/core";
import { LineSeriesOption, LineChart } from 'echarts/charts' import { LineSeriesOption, LineChart } from "echarts/charts";
import { TooltipComponent, GridComponent } from 'echarts/components' import { TooltipComponent, GridComponent } from "echarts/components";
import { CanvasRenderer } from 'echarts/renderers' import { CanvasRenderer } from "echarts/renderers";
import { getAccountRecords } from '@/service/api' import { getAccountRecords } from "@/service/api";
import moment from 'moment' import moment from "moment";
type ECOption = echarts.ComposeOption<LineSeriesOption> type ECOption = echarts.ComposeOption<LineSeriesOption>;
echarts.use([TooltipComponent, GridComponent, LineChart, CanvasRenderer]) echarts.use([TooltipComponent, GridComponent, LineChart, CanvasRenderer]);
import chartsMixin from '@/mixin/componentsMixin/charts' import chartsMixin from "@/mixin/componentsMixin/charts";
import VueTypedMixins from 'vue-typed-mixins' import VueTypedMixins from "vue-typed-mixins";
import { nFormatter } from '@/utils/common' import { nFormatter } from "@/utils/common";
export default VueTypedMixins(chartsMixin).extend({ export default VueTypedMixins(chartsMixin).extend({
props: { props: {
...@@ -26,43 +26,45 @@ export default VueTypedMixins(chartsMixin).extend({ ...@@ -26,43 +26,45 @@ export default VueTypedMixins(chartsMixin).extend({
return { return {
xData: [], xData: [],
seriesData: [], seriesData: [],
} };
}, },
methods: { methods: {
generate() { generate() {
switch (this.scale) { switch (this.scale) {
case 'D1': case "D1":
return this.generateD1() return this.generateD1();
case 'W1': case "W1":
return this.generateW1() return this.generateW1();
case 'M1': case "M1":
return this.generateM1() return this.generateM1();
case 'M6': case "M6":
return this.generateM6() return this.generateM6();
case 'Y1': case "Y1":
return this.generateY1() return this.generateY1();
} }
}, },
draw() { draw() {
const times = this.generate() const times = this.generate();
times && times &&
getAccountRecords( getAccountRecords(
this.$route.query.address as string, (this.$route.query.address as string).toLowerCase(),
times, times,
'ycc', "ycc"
).then((ret) => { ).then((ret) => {
if (ret.error == null) { if (ret.error == null) {
this.xData = ret.result this.xData = ret.result;
const myChart = echarts.init(this.$refs.charts as HTMLElement) const myChart = echarts.init(
this.$refs.charts as HTMLElement
);
myChart.setOption({ myChart.setOption({
tooltip: { tooltip: {
trigger: 'axis', trigger: "axis",
}, },
xAxis: { xAxis: {
type: 'category', type: "category",
axisLabel: { axisLabel: {
textStyle: { textStyle: {
color: '#7c88ad', color: "#7c88ad",
}, },
}, },
axisTick: { axisTick: {
...@@ -70,18 +72,20 @@ export default VueTypedMixins(chartsMixin).extend({ ...@@ -70,18 +72,20 @@ export default VueTypedMixins(chartsMixin).extend({
}, },
data: times data: times
?.map((i) => { ?.map((i) => {
return moment.unix(i).format('YYYY.MM.DD') return moment
.unix(i)
.format("YYYY.MM.DD");
}) })
.reverse(), .reverse(),
}, },
yAxis: { yAxis: {
type: 'value', type: "value",
axisLabel: { axisLabel: {
formatter: (item: number) => { formatter: (item: number) => {
return nFormatter(item) return nFormatter(item);
}, },
textStyle: { textStyle: {
color: '#7c88ad', color: "#7c88ad",
}, },
}, },
}, },
...@@ -89,31 +93,40 @@ export default VueTypedMixins(chartsMixin).extend({ ...@@ -89,31 +93,40 @@ export default VueTypedMixins(chartsMixin).extend({
{ {
data: this.xData data: this.xData
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
.map((i: any) => (i && i[0] && i[0].balance) || 0) .map(
(i: any) =>
(i && i[0] && i[0].balance) || 0
)
.map((i) => i / 1e8) .map((i) => i / 1e8)
.reverse(), .reverse(),
type: 'line', type: "line",
areaStyle: { areaStyle: {
normal: { normal: {
// 颜色渐变函数 前四个参数分别表示四个位置依次为左、下、右、上 // 颜色渐变函数 前四个参数分别表示四个位置依次为左、下、右、上
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ color: new echarts.graphic.LinearGradient(
0,
0,
0,
1,
[
{ {
offset: 0, offset: 0,
color: '#2545CB', // 0% 处的颜色 color: "#2545CB", // 0% 处的颜色
}, },
{ {
offset: 0.6, offset: 0.6,
color: '#9FAEE9', // 40% 处的颜色 color: "#9FAEE9", // 40% 处的颜色
}, },
{ {
offset: 1, offset: 1,
color: 'white', // 100% 处的颜色 color: "white", // 100% 处的颜色
}, },
]), //背景渐变色 ]
), //背景渐变色
lineStyle: { lineStyle: {
// 系列级个性化折线样式 // 系列级个性化折线样式
type: 'solid', type: "solid",
color: '#2545CB', //折线的颜色 color: "#2545CB", //折线的颜色
}, },
}, },
}, },
...@@ -123,23 +136,23 @@ export default VueTypedMixins(chartsMixin).extend({ ...@@ -123,23 +136,23 @@ export default VueTypedMixins(chartsMixin).extend({
}, },
], ],
grid: this.grid, grid: this.grid,
} as ECOption) } as ECOption);
} }
}) });
}, },
}, },
mounted() { mounted() {
this.draw() this.draw();
}, },
watch: { watch: {
'$route.query.address'() { "$route.query.address"() {
this.draw() this.draw();
}, },
scale() { scale() {
this.draw() this.draw();
}, },
}, },
}) });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.charts { .charts {
......
This diff is collapsed.
...@@ -15,7 +15,9 @@ export default Vue.extend({ ...@@ -15,7 +15,9 @@ export default Vue.extend({
"$route.query.address"() { "$route.query.address"() {
this.getAddrOverview(); this.getAddrOverview();
this.init(); this.init();
getAddressTxCount(this.$route.query.address as string).then((ret) => { getAddressTxCount(
(this.$route.query.address as string).toLowerCase()
).then((ret) => {
if (ret.error === null) { if (ret.error === null) {
this.txCount = ret.result; this.txCount = ret.result;
} }
...@@ -25,7 +27,9 @@ export default Vue.extend({ ...@@ -25,7 +27,9 @@ export default Vue.extend({
mounted() { mounted() {
this.getAddrOverview(); this.getAddrOverview();
this.init(); this.init();
getAddressTxCount(this.$route.query.address as string).then((ret) => { getAddressTxCount(
(this.$route.query.address as string).toLowerCase()
).then((ret) => {
if (ret.error === null) { if (ret.error === null) {
this.txCount = ret.result; this.txCount = ret.result;
} }
...@@ -55,7 +59,9 @@ export default Vue.extend({ ...@@ -55,7 +59,9 @@ export default Vue.extend({
}, },
methods: { methods: {
getAddrOverview() { getAddrOverview() {
Rpc.getAddrOverview(this.$route.query.address as string).then((res) => { Rpc.getAddrOverview(
(this.$route.query.address as string).toLowerCase()
).then((res) => {
if (res.error === null) { if (res.error === null) {
const balance = res.result.balance; const balance = res.result.balance;
const receiver = res.result.reciver; const receiver = res.result.reciver;
...@@ -76,7 +82,7 @@ export default Vue.extend({ ...@@ -76,7 +82,7 @@ export default Vue.extend({
init() { init() {
QRCode.toCanvas( QRCode.toCanvas(
document.getElementById("qrcode"), document.getElementById("qrcode"),
this.$route.query.address as string, (this.$route.query.address as string).toLowerCase(),
{ {
color: { color: {
dark: "#1F3470", dark: "#1F3470",
...@@ -85,7 +91,7 @@ export default Vue.extend({ ...@@ -85,7 +91,7 @@ export default Vue.extend({
width: 130, width: 130,
margin: 0, margin: 0,
}, },
function (error) { function(error) {
if (error) console.error(error); if (error) console.error(error);
} }
); );
......
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