From 12ae3f51dd40d0309931f0bdbe566a2137d622dc Mon Sep 17 00:00:00 2001
From: PC-20250623MANY\Administrator <344137771@qq.com>
Date: Wed, 27 Aug 2025 22:14:25 +0800
Subject: [PATCH] 1
---
src/page/markets/markets.vue | 55 ++++++++++++++++---------------------------------------
1 files changed, 16 insertions(+), 39 deletions(-)
diff --git a/src/page/markets/markets.vue b/src/page/markets/markets.vue
index d0d3f6a..f5e80ae 100644
--- a/src/page/markets/markets.vue
+++ b/src/page/markets/markets.vue
@@ -25,7 +25,7 @@
:key="item.pid"
@click="tab = item.pid"
>
- <span class="line-one">{{ item.abbreviation }}</span>
+ <span class="line-one">{{ item.name }}</span>
</div>
</div>
@@ -72,30 +72,11 @@
}
],
tabList: [],
- usList: [
- { abbreviation: "Dow Jones" },
- { abbreviation: "S&P 500" },
- { abbreviation: "NASDAQ" }
- ],
- hkList: [
- { abbreviation: "恒生指數" },
- { abbreviation: "恒生中國企業指數" },
- { abbreviation: "HSCEI Covered Call Index" }
- ],
- twList: [
- { abbreviation: "臺灣證券交易所發行量加權股價指數" },
- { abbreviation: "櫃買指數" },
- { abbreviation: "臺灣50指數" }
- ],
- inList: [
- { abbreviation: "Nifty 50 Index" },
- { abbreviation: "Nifty Bank Index" },
- { abbreviation: "Nifty Financial Services Index" }
- ],
tab: 1,
pageNum: 1,
pageSize: 10,
- kData: {}
+ kData: {},
+ times: null
};
},
components: {
@@ -106,8 +87,11 @@
},
watch: {
tab() {
- this.getIndicesAndKData();
+ this.init();
}
+ },
+ beforeDestroy() {
+ if (this.times) clearInterval(this.times);
},
computed: {
switchText() {
@@ -125,7 +109,6 @@
this.$store.commit("MARKET_CHANGE", this.actions[0]);
}
await this.getTabData();
- this.tab = this.tabList[0].pid;
},
mounted() {},
methods: {
@@ -133,7 +116,6 @@
async onSelect(e) {
this.$store.commit("MARKET_CHANGE", e);
await this.getTabData();
- this.tab = this.tabList[0].pid;
},
// 获取tab数据
async getTabData() {
@@ -141,17 +123,8 @@
let data = await api.getIndicesList({
stockType
});
-
- // 数据重构
- let list = [];
- if (stockType == "US") list = this.usList;
- else if (stockType == "HK") list = this.hkList;
- else if (stockType == "TW") list = this.twList;
- else if (stockType == "IN") list = this.inList;
- this.tabList = list.map((item, index) => {
- item = { ...item, ...data.data[index + 1] };
- return item;
- });
+ this.tabList = data.data;
+ this.tab = this.tabList[1].pid;
// console.log("dadadadadad", this.tabList);
},
@@ -164,9 +137,13 @@
this.kData = data.data;
// console.log("getIndicesAndKData", this.kData);
},
- // tab切换
- tabChange() {
+ // 初始化
+ init() {
+ if (this.times) clearInterval(this.times);
this.getIndicesAndKData();
+ this.times = setInterval(() => {
+ this.getIndicesAndKData();
+ }, 2000);
}
}
};
@@ -205,7 +182,7 @@
width: 32%;
height: 0.8em;
border-radius: 0.5em;
- padding: 0 .25em;
+ padding: 0 0.25em;
span {
font-size: 0.4em;
--
Gitblit v1.9.3