| | |
| | | |
| | | <div class="resoult_list"> |
| | | <el-table |
| | | height="100%" |
| | | :data="tableData" |
| | | style="width: 100%" |
| | | height="100%" |
| | | size="small" |
| | | empty-text="No Data" |
| | | @row-click="Choice" |
| | |
| | | this.opt.stockType = this.activeName; // 赋值类型 |
| | | this.apiInterface = api.getStockByType; // 赋值接口 |
| | | this.init(); // 获取记录列表 |
| | | this.initWebSocket(); // 连接ws实时监控变动 |
| | | // this.initWebSocket(); // 连接ws实时监控变动 |
| | | }, |
| | | watch: { |
| | | activeName: { |
| | | handler(val) { |
| | | // 根据当前股票类型连接对应的ws |
| | | if (val == "US") |
| | | this.initWebSocket("wss://ws.isusstock.com/websocket-server"); |
| | | else this.initWebSocket("wss://ws.acapl.net/websocket-server"); |
| | | }, |
| | | immediate: true, |
| | | deep: true, |
| | | }, |
| | | }, |
| | | computed: { |
| | | }, |
| | | props: { |
| | | }, |
| | | components: {}, |
| | | mounted() {}, |
| | | beforeDestroy() { |
| | | if (this.Trade) { |
| | | this.Trade.close(); |
| | | console.log("WebSocket disconnected"); |
| | | } |
| | | }, |
| | | methods: { |
| | | handleClick() { |
| | |
| | | this.$emit("choice", val.code); |
| | | }, |
| | | // 连接ws实时监控变动 |
| | | initWebSocket() { |
| | | initWebSocket(url) { |
| | | console.log("initWebSocket"); |
| | | if (this.Trade) { |
| | | this.Trade.close(); |
| | | } |
| | | this.Trade = new WhrWebSocket({ |
| | | path: `wss://ws.kuspitai.com/websocket-server `, |
| | | path: url, |
| | | onmessage: this.getTradeMessage, |
| | | }); |
| | | |