代码推送

This commit is contained in:
2026-01-16 10:32:27 +08:00
parent 8da877de40
commit 408e40b206
570 changed files with 172605 additions and 1 deletions

View File

@@ -0,0 +1,366 @@
import * as echarts from "echarts";
import { getOpenInterest } from "../../api/pages"
import { chartsWidth, emptyData, handelLineType, handelZoom, handelWatermark, handelSwitchs, fetchBtcPrice, fetchEthPrice, handelSmaData, getDateArray } from "../../util/processingData"
export default {
data() {
return {
openInterestLoading: false,
option: {
tooltip: {
trigger: "axis",
//解决tooltip显示不全问题1
confine: true,
},
legend: {
right: "100",
//处理legengd过长
// formatter: function (name) {
// return echarts.format.truncateText(name, 100, '14px Microsoft Yahei', '…');
// },
tooltip: {
show: true
}
},
xAxis: {
// type: "time",
boundaryGap: false,
// axisLabel: {
// formatter: `{yyyy}-{MM}-{dd}`,
// },
data: []
},
yAxis: [
{
type: "value",
// boundaryGap: [0, "100%"],
axisLabel: {
formatter: function (e) {
let value;
if (e > 100000000) {
value = `${e / 100000000}E`;
} else if (e > 1000000) {//百万
value = `${e / 1000000}M`;
} else if (e >= 10000) {//万
value = `${e / 10000}W`;
} else if (e < -1000000) {//百万
value = `${e / 1000000}M`;
} else if (e < -10000) {//万
value = `${e / 10000}W`;
}
else {
value = e;
}
return value;
},
},
min: "dataMin",
max: "dataMax",
},
{
type: "value",
// boundaryGap: [0, "100%"],
show: true,
min: "dataMin",
max: "dataMax",
position: "right",
axisLabel: {
formatter: function (e) {
let value;
if (e > 100000000) {
value = `${e / 100000000}E`;
} else if (e > 1000000) {//百万
value = `${e / 1000000}M`;
} else if (e >= 10000) {//万
value = `${e / 10000}W`;
} else if (e < -1000000) {//百万
value = `${e / 1000000}M`;
} else if (e < -10000) {//万
value = `${e / 10000}W`;
}
else {
value = e;
}
return value;
},
},
},
{
type: "value",
// boundaryGap: [0, "100%"],
min: "dataMin",
max: "dataMax",
show: false,
},
{
type: "value",
// boundaryGap: [0, "100%"],
min: "dataMin",
max: "dataMax",
show: false,
},
{
type: "value",
// boundaryGap: [0, "100%"],
min: "dataMin",
max: "dataMax",
show: false,
},
],
dataZoom: [
{
type: "inside",
start: 0,
end: 100,
},
{
start: 0,
end: 100,
},
],
series: [
{
name: "number of open interest",
type: "line",
smooth: false,
symbol: "circle",
showSymbol: false,
symbolSize: 5,
// areaStyle: {},
itemStyle: {
color: "#f7864c",
borderColor: "rgba(221,220,107,0.1)",
borderWidth: 12,
},
yAxisIndex: 0,
lineStyle: {
//线条样式
color: "#f7864c",
width: "1",
},
data: [],
},
// {
// name: "Price[BTC]",
// type: "line",
// smooth: false,
// symbol: "circle",
// symbolSize: 5,
// showSymbol: false,
// // areaStyle: {},
// itemStyle: {
// color: "#888888",
// borderColor: "rgba(221,220,107,0.1)",
// borderWidth: 12,
// },
// lineStyle: {
// //线条样式
// color: "#888888",
// width: "1",
// },
// yAxisIndex: 1,
// data: [],
// },
// {
// name: "Price [ETH]",
// type: "line",
// smooth: false, //线条是否圆滑
// symbol: "circle",
// symbolSize: 5,
// showSymbol: false,
// itemStyle: {
// color: "#627eea",
// borderColor: "rgba(221,220,107,0.1)",
// borderWidth: 12,
// },
// lineStyle: {
// //线条样式
// color: "#627eea",
// width: "1",
// },
// yAxisIndex: 4,
// data: [],
// },
],
},
switch3: "",
oldY: null,
btcFlag: null,
ethFlag: null,
fatherSmaData: [],
start: "",
end: "",
params: {
start: "",
end: "",
sma: "",
symbol: "BTCUSDT"
},
zoomStart: 0,
zoomEnd: 0,
tableLoading: false,
totalPage: 0,
currentPage4: 1,
tableData: [],
symbolList: [{
value: "BTCUSDT",
label: "BTCUSDT"
},
{
value: "ETHUSDT",
label: "ETHUSDT"
}],
value: ""
}
},
mounted() {
this.handelTime()
this.fetchMpenInterest(this.params)
//禁用时间框
// this.$addStorageEvent(1, "timeShow", true);
this.switch3 = handelSwitchs(this.option, this.switch3)
this.oldY = this.option.yAxis
this.ethFlag = JSON.parse(localStorage.getItem("ethFlag"));
this.btcFlag = JSON.parse(localStorage.getItem("btcFlag"));
this.$addStorageEvent(1, "zoomStart", this.zoomStart);
this.$addStorageEvent(1, "zoomEnd", this.zoomEnd);
window.addEventListener("setItem", () => {
this.ethFlag = JSON.parse(localStorage.getItem("ethFlag"));
this.btcFlag = JSON.parse(localStorage.getItem("btcFlag"));
this.zoomStart = localStorage.getItem("zoomStart")
this.zoomEnd = localStorage.getItem("zoomEnd")
})
},
methods: {
//初始化图表
inCharts() {
if (this.myChart == null) {
this.myChart = echarts.init(document.getElementById("openInterestBox"));
}
this.option = handelZoom(this.myChart, this.option, this, this.zoomStart, this.zoomEnd)
this.myChart.setOption(this.option);
chartsWidth("openInterestBox", this);
window.addEventListener("resize", () => {
if (this.myChart) this.myChart.resize();
});
},
async fetchMpenInterest(params) {
this.openInterestLoading = true
const { data } = await getOpenInterest(params)
let openInterestData = data.data
//空数据处理
let noData = emptyData(data.data, this.option.series, this.inCharts, this)
if (noData) {
this.openInterestLoading = false
return
}
this.start = openInterestData[0].date.split("T")[0]
this.end = openInterestData[openInterestData.length - 1].date.split("T")[0]
// //添加水印
this.option = handelWatermark(this.option)
// // //根据渲染的数据时间渲染对应的价格线和移动平均线
// this.$nextTick(() => {
// //渲染ETH
// if (this.ethFlag) {
// this.$addStorageEvent(1, "ethFlag", JSON.stringify(this.ethFlag));
// this.handelSonEthPrice("ETH", this.ethFlag)
// }
// //渲染BTC价格
// if (this.btcFlag) {
// this.$addStorageEvent(1, "btcFlag", JSON.stringify(this.btcFlag));
// this.handelSonBtcPrice("BTC", this.btcFlag)
// }
// })
let ValueList = []
this.option.xAxis.data = []
openInterestData.forEach(item => {
this.option.xAxis.data.push(`${item.date.split(`T`)[0]} ${item.date.split(`T`)[1].split(`.`)[0]}`)
ValueList.push(Number(item.value.toFixed(2)))
})
this.option.series[0].data = ValueList
console.log(this.option);
this.inCharts()
this.openInterestLoading = false
},
//接收Home传的时间handelParmesTime
handelSonTime(start, end) {
this.params.start = start;
this.params.end = end;
if (!this.params.start) {
this.handelTime()
}
this.fetchMpenInterest(this.params)
},
//点击对数/线性按钮切换
handelLineSwitch() {
this.option = handelLineType(this.option, this.oldY)
this.switch3 = handelSwitchs(this.option, this.switch3)
this.myChart.setOption(this.option);
},
//父级点击BTC价格按钮
handelSonBtcPrice(radius, flag) {
this.btcFlag = flag
fetchBtcPrice("BTC", this.option.series[1], this.start, this.end, this.inCharts, this, this.btcFlag)
},
//父级点击ETH价格按钮
handelSonEthPrice(radius, flag) {
this.ethFlag = flag
fetchEthPrice("ETH", this.option.series[2], this.start, this.end, this.inCharts, this, this.ethFlag)
},
//父级选择Sma
handelSonSma(smaDataList) {
this.params.sma = smaDataList
this.fetchMpenInterest(this.params)
this.$addStorageEvent(1, "sma", smaDataList);
},
//下拉选择框
handelChang() {
this.fetchMpenInterest(this.params)
},
handelTime() {
let start = new Date();
start.setMonth(start.getMonth() - 1);//当前时间减去一个月
// 提取年、月和日
const year = start.getFullYear();
const month = String(start.getMonth() + 1).padStart(2, '0');
const day = String(start.getDate()).padStart(2, '0');
const formattedDate = `${year}-${month}-${day}`;
this.params.start = formattedDate
}
}
}

View File

@@ -0,0 +1,63 @@
<template>
<div v-loading="openInterestLoading">
<!-- 选择symbol -->
<!-- <el-row>
<el-col :span="2.5">
<el-button @click="handelLineSwitch"
style="margin-left:100px;height:35px;border-radius:6px;"
>{{ $t(`home.switch`)
}}<span class="according"> {{ $t(switch3) }}</span></el-button
>
</el-col>
<el-col :span="3" class="timeBoxS">
<el-select
class="symbol"
v-model="params.symbol"
@change="handelChang"
filterable
:placeholder="$t(`arh.pleaseTrade`)"
>
<el-option
v-for="item in symbolList"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</el-col>
</el-row> -->
<el-row>
<el-col :span="24">
<div
id="openInterestBox"
style="width: 100%; min-height: 700px"
></div>
</el-col>
</el-row>
</div>
</template>
<script>
import IndexJs from "../openInterest/index";
export default {
mixins: [IndexJs],
};
</script>
<style scoped>
.timeBoxS{
/* outline: 1px solid red; */
padding: 10px 10px;
margin-bottom: 10px;
}
::v-deep .el-row--flex{
height: 550px;
}
</style>