|
|
|
@ -67,7 +67,8 @@ |
|
|
|
<div style="width: 200px;"> |
|
|
|
<div class="name fn-14 px-3" style="display: inline-block;">{{ $t("contract.g3") }}</div> |
|
|
|
<div class="num fn-20 increace" style="display: inline-block;"> |
|
|
|
{{ newPriceObj.price }} |
|
|
|
<!-- {{ newPriceObj.price }} --> |
|
|
|
{{ price1 }} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="w-14/24 text-right"> |
|
|
|
@ -134,6 +135,8 @@ export default { |
|
|
|
buyList: [], |
|
|
|
tradeList: [], |
|
|
|
newPriceObj: {}, |
|
|
|
price1:0, |
|
|
|
intervalId:'' |
|
|
|
}; |
|
|
|
}, |
|
|
|
props: { |
|
|
|
@ -193,15 +196,28 @@ export default { |
|
|
|
this.getMarketInfo(); |
|
|
|
this.linkSocket(); |
|
|
|
} |
|
|
|
bus.$on('collapse', msg => { |
|
|
|
this.newPriceObj.price =this.symbol=='BTC'? (msg.close).toFixed(1):(msg.close).toFixed(3); |
|
|
|
this.$emit("input", this.newPriceObj); |
|
|
|
}); |
|
|
|
// bus.$on('collapse', msg => { |
|
|
|
// this.newPriceObj.price =this.symbol=='BTC'? (msg.close).toFixed(1):(msg.close).toFixed(3); |
|
|
|
// this.$emit("input", this.newPriceObj); |
|
|
|
// }); |
|
|
|
this.startWatchingPrice() |
|
|
|
}, |
|
|
|
beforeDestroy() { |
|
|
|
this.stopWatchingPrice(); // 组件销毁时停止监听 |
|
|
|
}, |
|
|
|
// 获取盘口 |
|
|
|
methods: { |
|
|
|
parseTime: date.parseTime, |
|
|
|
omitTo: math.omitTo, |
|
|
|
startWatchingPrice(){ |
|
|
|
this.intervalId = setInterval(() => { |
|
|
|
let newPrice = localStorage.getItem('price'); |
|
|
|
this.price1 = newPrice; |
|
|
|
}, 100); // 每秒检查一次 |
|
|
|
}, |
|
|
|
stopWatchingPrice() { |
|
|
|
clearInterval(this.intervalId); // 清除定时器 |
|
|
|
}, |
|
|
|
getMarketInfo() { |
|
|
|
let data = { |
|
|
|
symbol: this.symbol |
|
|
|
@ -264,6 +280,9 @@ export default { |
|
|
|
this.tradeList.pop(); |
|
|
|
// this.newPriceObj = data; |
|
|
|
// this.$emit("input", this.newPriceObj); |
|
|
|
this.newPriceObj = data; |
|
|
|
localStorage.setItem("price",this.newPriceObj.price) |
|
|
|
this.$emit("input", this.newPriceObj); |
|
|
|
} else if (type == "ping" ||cmd == "ping") { |
|
|
|
this.ws.send({ |
|
|
|
cmd: "pong" |
|
|
|
|