From dce10d37ad35efe8ed1d39d6e5fcf7e4904381df Mon Sep 17 00:00:00 2001
From: 李凌 <344137771@qq.com>
Date: Fri, 12 Jun 2026 13:19:53 +0800
Subject: [PATCH] 1

---
 src/views/cryptos/PerpetualContract/index.vue |   81 +++++++++++++++++++---------------------
 1 files changed, 39 insertions(+), 42 deletions(-)

diff --git a/src/views/cryptos/PerpetualContract/index.vue b/src/views/cryptos/PerpetualContract/index.vue
index b5867b0..9b5855e 100644
--- a/src/views/cryptos/PerpetualContract/index.vue
+++ b/src/views/cryptos/PerpetualContract/index.vue
@@ -94,7 +94,7 @@
           <!-- 委托/持仓-->
           <PerpetualOrder class="pl-8 pr-8" :key="keyIndex + 'b'" :symbol="symbol" :order-cur="orderCur"
             :order-hold="orderHold" :topIndex="selectIndex" :futrue-hold="futrueHold" :futrue-histroy="futrueHistroy"
-            @tab="onTab" @recall="onRecall">
+            :perpetual-histroy="perpetualHistroy" :symbol-type="type" @tab="onTab" @recall="onRecall">
           </PerpetualOrder>
         </div>
       </div>
@@ -180,7 +180,8 @@
           <!-- 委托/持仓-->
           <PerpetualOrder class="pl-8 pr-8" :key="keyIndex + 'd'" :symbol="symbol" :order-cur="orderCur"
             :order-hold="orderHold" :price="price" :topIndex="selectIndex" :futrue-hold="futrueHold"
-            :futrue-histroy="futrueHistroy" @tab="onTab" @recall="onRecall">
+            :futrue-histroy="futrueHistroy" :perpetual-histroy="perpetualHistroy" :symbol-type="type" @tab="onTab"
+            @recall="onRecall">
           </PerpetualOrder>
         </div>
       </div>
@@ -243,8 +244,6 @@
 import { useUserStore } from "@/store/user";
 const userStore = useUserStore();
 const quotesStore = useQuotesStore()
-let timer = null  // 底部持仓等的公用定时器
-let timer1 = null
 
 var showLength = 7
 export default {
@@ -294,6 +293,8 @@
       initTimer: null,
       keyIndex: 0,
       timeout: null,
+      timer: null, // 底部持仓等的公用定时器
+      timer1: null,
       balance: 0,
       symbol: '',
       price: '',
@@ -304,6 +305,7 @@
       bids: initArr, // 买单
       orderCur: [], // 当前委托
       orderHold: [], // 持有仓位
+      perpetualHistroy: [], // 永续历史
       futrueHold: [], // 交割持仓
       futrueHistroy: [], // 交割历史
       sockets: {
@@ -355,22 +357,16 @@
     }
   },
   async created() {
+
     if (this.$route.query.type) {
       this.type = this.$route.query.type
     }
-    this.symbol = this.$route.params.symbol
-    
     await this.SET_COIN_LIST(this.type)
-    // _getBalance().then(data => { // 获取用户余额
-    //   this.$store.commit('user/SET_USERINFO', { balance: data.money })
-    //   // const { money } = data
-    //   // this.balance = money
-    // })
     if (this.userInfo.token) {
       this.getBalance()
       this.timerMoeny = setInterval(() => {
         this.getBalance()
-      }, 5000)
+      }, 3000)
     }
   },
   methods: {
@@ -426,6 +422,7 @@
         symbolType: 'cryptos'
       }
       contractOrder(obj).then(data => {
+
         this.orderHold = data
       })
       this[this.curTab](this.symbol)
@@ -443,16 +440,16 @@
       if (this.selectIndex / 1 === 1) {
         this.curTab = 'fetchOrderListHold'
         this.animated2 = true
-        timer1 = setTimeout(() => {
+        this.timer1 = setTimeout(() => {
           this.animated2 = false
-          clearTimeout(timer1)
-        }, 5000)
+          clearTimeout(this.timer1)
+        }, 1000)
       } else {
         this.animated1 = true
-        timer1 = setTimeout(() => {
+        this.timer1 = setTimeout(() => {
           this.animated1 = false
-          clearTimeout(timer1)
-        }, 5000)
+          clearTimeout(this.timer1)
+        }, 1000)
       }
       this[this.curTab](this.symbol)
     },
@@ -569,7 +566,7 @@
           }).catch(err => {
             this.initFunTimer1 = setTimeout(() => {
               initFun()
-            }, 5000);
+            }, 1000);
           })
         }
         initFun()
@@ -585,7 +582,7 @@
           }).catch(err => {
             this.initFunTimer2 = setTimeout(() => {
               initFun()
-            }, 5000);
+            }, 1000);
           })
         }
         this.initFunTimer2 = setTimeout(() => {
@@ -610,24 +607,20 @@
           this.orderCur = data
         })
         this.clearTimer()
-        timer = setInterval(() => {
+        this.timer = setInterval(() => {
           _contractApplyOrderList({
             symbol,
             type: 'orders',
             page_no: 1
           }).then(data => {
-            // if (typeof timer === 'string') {
-            //   timer = null
-            //   return
-            // }
             this.orderCur = data
           })
-        }, 5000)
+        }, 1000)
       }
     },
     fetchOrderListHold(symbol) { // 当前持仓
       let obj = {
-        symbol: this.symbol,
+        symbol: symbol,
         type: 'orders',
         page_no: 1,
         symbolType: 'cryptos'
@@ -637,16 +630,12 @@
           // this.orderHold = data
           this.orderHold = data.sort(this.sortData);
         })
-        timer = setInterval(() => {
+        this.timer = setInterval(() => {
           contractOrder(obj).then(data => {
-            // if (typeof timer === 'string') {
-            //   timer = null
-            //   return
-            // }
             // this.orderHold = data
             this.orderHold = data.sort(this.sortData);
           })
-        }, 5000)
+        }, 1000)
       }
     },
     fetchFutrueHoldList(symbol) { // 交割持仓
@@ -655,16 +644,12 @@
           // this.futrueHold = data
           this.futrueHold = data.sort(this.sortData);
         })
-        timer = setInterval(() => {
+        this.timer = setInterval(() => {
           _futrueOrderList(symbol, 'orders', 1, 'cryptos').then(data => {
-            // if (typeof timer === 'string') {
-            //   timer = null
-            //   return
-            // }
             // this.futrueHold = data
             this.futrueHold = data.sort(this.sortData);
           })
-        }, 5000)
+        }, 1000)
       }
     },
     fetchFutrueHistory(symbol) { // 交割历史持仓
@@ -672,6 +657,18 @@
         this.futrueHistroy = data
         // this.clearTimeout()
       })
+    },
+    fetchPerpetualHistory(symbol) { // 永续历史仓位
+      if (this.userInfo.token) {
+        contractOrder({
+          symbol,
+          type: 'hisorders',
+          page_no: 1,
+          symbolType: this.type || 'cryptos'
+        }).then(data => {
+          this.perpetualHistroy = data || []
+        })
+      }
     },
     init(symbol) { // 初始化页面
       this.symbol = symbol
@@ -711,12 +708,12 @@
         clearTimeout(this.initFunTimer2)
         this.initFunTimer2 = null
       }
-      clearInterval(timer)
+      clearInterval(this.timer)
       // if (isNeed) {
-      //   timer = ''
+      //   this.timer = ''
       //   return
       // }
-      timer = null
+      this.timer = null
     },
     changeCurrentType(type) {
       this.currentType = type

--
Gitblit v1.9.3