1
PC-20250623MANY\Administrator
2025-09-23 01d33e0271209b14ed364ccdb5d6ed0270a906af
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
<template>
  <div class="home flex-between-start page-w page-content">
    <div class="left">
      <div class="top">
        <home-ltl @choice="choice"></home-ltl>
        <home-ltr :obj="singDetails"></home-ltr>
      </div>
      <home-lb class="bottom" @choice="choice"></home-lb>
    </div>
    <div class="right">
      <HomeRight :obj="singDetails" :positionSn.sync="positionSn"></HomeRight>
    </div>
  </div>
</template>
 
<script>
import * as api from "@/axios/api";
import HomeLtl from "./components/HomeLtl.vue";
import HomeLtr from "./components/HomeLtr.vue";
import HomeLb from "./components/HomeLb.vue";
import HomeRight from "./components/HomeRight.vue";
export default {
  name: "HomeView",
  components: { HomeRight, HomeLtl, HomeLtr, HomeLb },
  data() {
    return {
      cId: null, // 选中的股票id
      positionSn: null, // 已购买股票的参数
      timer: null, // 定时器
      singDetails: {}, // 股票详情
    };
  },
  watch: {
    cId: {
      handler(val) {
        // console.log("val", val);
 
        this.getSingDetails(val);
        if (this.timer) clearInterval(this.timer);
        this.timer = setInterval(() => {
          this.getSingDetails(val);
        }, 2000);
      },
    },
  },
  beforeDestroy() {
    if (this.timer) clearInterval(this.timer);
  },
  created() {},
  methods: {
    choice(val, positionSn = null) {
      this.cId = val;
      this.positionSn = positionSn;
    },
 
    async getSingDetails(code) {
      let opts = {
        code,
      };
      await api.getSingleStock(opts).then((res) => {
        if (res.status === 0) {
          const obj = {
            pid: res.data.stock.code,
            type: res.data.stock.type,
          };
          window.localStorage.setItem("kLine", JSON.stringify(obj));
 
          this.singDetails = res.data.stock;
        }
      });
    },
  },
};
</script>
 
<style lang="scss" scoped>
.home {
  .left {
    flex: 1;
    width: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
 
    .top,
    .bottom {
      flex: 1;
      height: 0;
    }
    .top {
      display: flex;
    }
    .bottom {
      display: flex;
      flex-direction: column;
      border-top: 1px solid #ebeef5;
      box-sizing: border-box;
    }
  }
  .right {
    height: 100%;
    width: 360px;
    border-left: 1px solid #ebeef5;
  }
}
</style>