diff --git a/src/views/contract/handicap.vue b/src/views/contract/handicap.vue index 3302791..3f2e563 100644 --- a/src/views/contract/handicap.vue +++ b/src/views/contract/handicap.vue @@ -198,6 +198,7 @@ export default { bus.$on('collapse', msg => { this.newPriceObj.price =this.symbol=='BTC'? (msg.close).toFixed(1):(msg.close).toFixed(3); this.$emit("input", this.newPriceObj); + localStorage.setItem("price",this.newPriceObj.price) }); }, // 获取盘口 @@ -214,6 +215,7 @@ export default { this.tradeList = res.swapTradeList; this.newPriceObj = this.tradeList[0]; this.$emit("input", this.newPriceObj); + localStorage.setItem("price",this.newPriceObj.price) }); }, // 计算深度 diff --git a/src/views/contract/index.vue b/src/views/contract/index.vue index d644077..d15c6a2 100644 --- a/src/views/contract/index.vue +++ b/src/views/contract/index.vue @@ -20,7 +20,8 @@ decreace2: activeContract.increase < 0, increase: activeContract.increase >= 0 }"> - {{ activeContract.price }} + + {{price1}} - {{ item.price }} + + {{item.symbol == activeSymbol ? price1 : item.price}}
{{ item.increaseStr }} @@ -244,7 +246,9 @@ export default { symbolDetail:{}, currentIcon: '', filterCoin: "", - contractListFilter: [] + contractListFilter: [], + price1:0, + intervalId:'' }; }, computed: { @@ -314,8 +318,7 @@ export default { if(item.symbol==this.activeContract.symbol) item.realtimePrice=this.activeContract.price }) }); - - + this.startWatchingPrice(); }, //三秒更新一次数据 mounted: function () { @@ -324,6 +327,12 @@ export default { }, 2000) }, methods: { + startWatchingPrice(){ + this.intervalId = setInterval(() => { + let newPrice = localStorage.getItem('price'); + this.price1 = newPrice; + }, 10); // 每秒检查一次 + }, ispopover1(item){ this.activeSymbol=item; // this.$refs.popover.showPopper = false;