From 584860d11b454774b60c71b63d221b5481c0f3bd Mon Sep 17 00:00:00 2001
From: 李 <344137771@qq.com>
Date: Wed, 29 Apr 2026 14:21:48 +0800
Subject: [PATCH] 更新为3.29

---
 src/page/markets/markets.vue |   86 ++++++++++++++++++------------------------
 1 files changed, 37 insertions(+), 49 deletions(-)

diff --git a/src/page/markets/markets.vue b/src/page/markets/markets.vue
index 38ed571..b4abbc4 100644
--- a/src/page/markets/markets.vue
+++ b/src/page/markets/markets.vue
@@ -1,13 +1,7 @@
 <template>
   <div class="markets">
     <tab-head :rightShow="false">
-      <van-popover
-        v-model="switchShow"
-        trigger="click"
-        :actions="actions"
-        @select="onSelect"
-        placement="bottom-end"
-      >
+      <van-popover v-model="switchShow" trigger="click" :actions="actions" @select="onSelect" placement="bottom-end">
         <template #reference>
           <div class="switch flex-center">
             <van-icon name="exchange" size=".45em" />
@@ -18,20 +12,14 @@
     </tab-head>
 
     <div class="tabs flex-between">
-      <div
-        class="tab_item flex-center"
-        :class="{ active: item.pid == tab }"
-        v-for="item in tabList"
-        :key="item.pid"
-        @click="tab = item.pid"
-      >
-        <span>{{ item.abbreviation }}</span>
+      <div class="tab_item flex-center" :class="{ active: item.pid == tab }" v-for="item in tabList" :key="item.pid"
+        @click="tab = item.pid">
+        <span class="line-one">{{ item.name }}</span>
       </div>
     </div>
 
     <div class="markets_echart">
       <index-component :ids="'markets'" :dataObj="kData"></index-component>
-      <!-- <van-skeleton title :row="3" /> -->
     </div>
 
     <stock-list :propOption="propOption"></stock-list>
@@ -54,29 +42,30 @@
         {
           text: this.$t("美国"),
           value: "US",
-          name: "美国"
+          name: this.$t("美国")
         },
-        {
-          text: this.$t("墨西哥"),
-          value: "MEX",
-          name: "墨西哥"
-        }
+        // {
+        //   text: this.$t("日本"),
+        //   value: "JP",
+        //   name: this.$t("日本")
+        // },
+        // {
+        //   text: this.$t("hk1"),
+        //   value: "HK",
+        //   name: this.$t("hk1")
+        // },
+        // {
+        //   text: this.$t("tw"),
+        //   value: "TW",
+        //   name: this.$t("tw")
+        // },
       ],
       tabList: [],
-      usList: [
-        { abbreviation: "Dow Jones" },
-        { abbreviation: "S&P 500" },
-        { abbreviation: "NASDAQ" }
-      ],
-      mxList: [
-        { abbreviation: "IPC" },
-        { abbreviation: "INMEX" },
-        { abbreviation: "NASDAQ" }
-      ],
       tab: 1,
       pageNum: 1,
       pageSize: 10,
-      kData: {}
+      kData: {},
+      times: null
     };
   },
   components: {
@@ -87,8 +76,11 @@
   },
   watch: {
     tab() {
-      this.getIndicesAndKData();
+      this.init();
     }
+  },
+  beforeDestroy() {
+    if (this.times) clearInterval(this.times);
   },
   computed: {
     switchText() {
@@ -106,15 +98,13 @@
       this.$store.commit("MARKET_CHANGE", this.actions[0]);
     }
     await this.getTabData();
-    this.tab = this.tabList[0].pid;
   },
-  mounted() {},
+  mounted() { },
   methods: {
     // 选择
     async onSelect(e) {
       this.$store.commit("MARKET_CHANGE", e);
       await this.getTabData();
-      this.tab = this.tabList[0].pid;
     },
     // 获取tab数据
     async getTabData() {
@@ -122,15 +112,8 @@
       let data = await api.getIndicesList({
         stockType
       });
-
-      // 数据重构
-      let list = [];
-      if (stockType == "US") list = this.usList;
-      if (stockType == "MEX") list = this.mxList;
-      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);
     },
@@ -143,9 +126,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);
     }
   }
 };
@@ -153,7 +140,7 @@
 
 <style lang="less" scoped>
 @red: #ee0a24;
-@green: #c4d600;
+@green: #00f0ff;
 @white: #fff;
 @black: #000;
 @green2: #f0f0f0;
@@ -184,6 +171,7 @@
       width: 32%;
       height: 0.8em;
       border-radius: 0.5em;
+      padding: 0 0.25em;
 
       span {
         font-size: 0.4em;

--
Gitblit v1.9.3