1
PC-20250623MANY\Administrator
2025-07-22 3003b7486ddeffd169f2b2f564fc0ff8c2c58bb3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<template>
  <div
    class="index_component"
    :class="dataObj.chg > 0 ? 'bg-green' : 'bg-red'"
    @click="toLine"
  >
    <div class="item_title">
      <span class="line-one">{{ dataObj.name }}</span>
    </div>
    <div class="item_price">{{ dataObj.last }}</div>
    <div class="item_index flex-between">
      <span>{{ dataObj.chg }}</span>
      <span>{{ dataObj.chgPct }}%</span>
    </div>
    <div style="width:100%;flex:1">
      <Echart :ids="ids" :colorType="dataObj.chg / 1" :data="klist"></Echart>
    </div>
  </div>
</template>
 
<script>
import Echart from "@/page/home/components/echart.vue";
export default {
  name: "IndexComponent",
  props: {
    ids: {
      type: String,
      required: true
    },
    dataObj: {
      type: Object,
      default: () => {}
    }
  },
  computed: {
    klist() {
      if (!this.dataObj.kData || this.dataObj.kData.length == 0) return [];
      return this.dataObj.kData.map(item => {
        return item.c;
      });
    }
  },
  components: {
    Echart
  },
  methods: {
    // 跳转到指数图
    toLine() {
      // 点击进入详情
      const obj = {
        pid: this.dataObj.id || "",
        type: this.dataObj.stockType || ""
      };
      window.localStorage.setItem("kLine", JSON.stringify(obj));
 
      this.$router.push({
        path: "/kLineIndex",
        query: {
          // if_us: 1,
          code: this.dataObj.id,
          type: this.dataObj.stockType
        }
      });
    }
  }
};
</script>
 
<style lang="less" scoped>
@red: #ee0a24;
 
.bg-red {
  background-color: rgba(red, 0.1);
  color: @red;
}
 
.bg-green {
  background-color: #f3fbf9;
  color: green;
}
 
.index_component {
  width: 100%;
  height: 100%;
  border-radius: 0.1em;
  padding: 0.25em 0;
  display: flex;
  flex-direction: column;
 
  .item_title {
    padding: 0 0.5em;
    font-size: 0.35em;
    color: #333;
    font-weight: 500;
 
    span {
      width: 100%;
      display: inline-block;
    }
  }
 
  .item_price {
    padding: 0.4em 0.5em;
    font-size: 0.4em;
  }
 
  .item_index {
    padding: 0 0.5em;
    font-size: 0.3em;
    margin-bottom: 0.2em;
  }
}
</style>