<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>
|