| | |
| | | </div> |
| | | </van-list> |
| | | </template> |
| | | |
| | | <div v-if="type === 'position'"> |
| | | <PerpetualPositionList |
| | | :list-data="orderHold" |
| | | ></PerpetualPositionList> |
| | | </div> |
| | | </van-tab> |
| | | </van-tabs> |
| | | </div> |
| | |
| | | import assetsHead from "@/components/assets-head"; |
| | | import PerpetualEntrustList from "@/components/perpetual-entrust-list/index.vue"; |
| | | import PerpetualHistoryPosition from "@/components/perpetual-history-position/index.vue"; |
| | | import PerpetualPositionList from "@/components/perpetual-position-list/index.vue"; |
| | | import { _orderListCur, _orderListHold } from "@/API/trade.api"; |
| | | import { _getCoins } from "@/API/home.api"; |
| | | import { List, Tab, Tabs, DropdownMenu, DropdownItem } from "vant"; |
| | |
| | | data() { |
| | | return { |
| | | type: "orders", |
| | | orderHold: [], // 永续持有仓位 |
| | | dataList: { |
| | | orders: [], |
| | | hisorders: [], |
| | |
| | | title: this.$t("历史委托"), |
| | | type: "hisorders", |
| | | }, |
| | | { |
| | | title: this.$t("当前持仓"), |
| | | type: "position", |
| | | }, |
| | | ], |
| | | 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) => { |
| | | this.orderHold = data; |
| | | }); |
| | | return; |
| | | } |
| | | const _api = this.type === "orders" ? _orderListCur : _orderListHold; |
| | | const type = this.type; |
| | | symbol = ""; |
| | |
| | | components: { |
| | | PerpetualEntrustList, |
| | | PerpetualHistoryPosition, |
| | | PerpetualPositionList, |
| | | assetsHead, |
| | | [DropdownMenu.name]: DropdownMenu, |
| | | [DropdownItem.name]: DropdownItem, |