Browse Source

新增初始化默认股票符号的方法以优化数据请求逻辑

master
TorsenLi 6 days ago
parent
commit
2364af09b4
  1. 21
      src/views/exchangeStock/index.vue

21
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();
},

Loading…
Cancel
Save