diff --git a/src/views/exchangeStock/index.vue b/src/views/exchangeStock/index.vue index 1a1c269..fcb62b9 100644 --- a/src/views/exchangeStock/index.vue +++ b/src/views/exchangeStock/index.vue @@ -391,6 +391,17 @@ }, methods: { + initDefaultSymbol(marketList) { + if (this.symbol || !marketList || !marketList.length) return; + const firstGroup = marketList[0]; + const first = firstGroup && firstGroup.marketInfoList && firstGroup.marketInfoList[0]; + if (!first) return; + this.symbol = first.symbol; + this.findMarketBySymbol(); + if (this.ws && this.ws.socket && this.ws.socket.readyState === WebSocket.OPEN) { + this.addSub(); + } + }, ispopover1(item){ this.symbol=item; }, @@ -643,9 +654,9 @@ this.marketList = data; - if (!this.symbol) { // 默认symbol 重新请求数据 - this.symbol = _.nth(data).marketInfoList[0].symbol; - } else { // 找出该symbol对应的记录并更新页面 + if (!this.symbol) { + this.initDefaultSymbol(data); + } else { this.findMarketBySymbol(); } @@ -698,9 +709,7 @@ Market.getstockMarketList().then(data => { this.marketList = data; - // if (!this.symbol) { // 默认symbol 重新请求数据 - // this.symbol = _.nth(data).marketInfoList[0].symbol; - // } + this.initDefaultSymbol(data); }).catch(err => {}); // this.update(); },