| | |
| | | loading: false, |
| | | finished: false, |
| | | page: 1, |
| | | pollTimer: null, |
| | | }; |
| | | }, |
| | | mounted() { |
| | | this.getCoins(); |
| | | // this.symbol = this.$route.query.symbol; |
| | | }, |
| | | watch: { |
| | | type(newVal) { |
| | | if (newVal === "position") { |
| | | this.startPolling(); |
| | | } else { |
| | | this.stopPolling(); |
| | | } |
| | | }, |
| | | }, |
| | | beforeDestroy() { |
| | | this.stopPolling(); |
| | | }, |
| | | methods: { |
| | | getCoins() { |
| | |
| | | onClickLeft() { |
| | | this.$router.go(-1); |
| | | }, |
| | | startPolling() { |
| | | if (this.pollTimer) return; |
| | | this.pollTimer = setInterval(() => { |
| | | this.fetchList(); // 你的轮询方法 |
| | | }, 1500); // 3秒轮询一次,可根据需要调整 |
| | | }, |
| | | stopPolling() { |
| | | if (this.pollTimer) { |
| | | clearInterval(this.pollTimer); |
| | | this.pollTimer = null; |
| | | } |
| | | }, |
| | | async fetchList(symbol) { |
| | | if (this.type === "position") { |
| | | _orderListHold().then((data) => { |