From 66a33e936d39ec4db7fdffed5d646e044ccc43e9 Mon Sep 17 00:00:00 2001
From: lxf <1371462558@qq.com>
Date: Fri, 18 Apr 2025 10:44:39 +0800
Subject: [PATCH] feat

---
 src/page/deliveryContract/hold.vue |   42 ++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/src/page/deliveryContract/hold.vue b/src/page/deliveryContract/hold.vue
index b519aa3..e14a74a 100644
--- a/src/page/deliveryContract/hold.vue
+++ b/src/page/deliveryContract/hold.vue
@@ -35,7 +35,9 @@
                 <div>
                     <div class="text-grey text-right">{{ $t('现价') }}</div>
                     <div class="mt-20 text-right" :class="item.close_price > item.open_price ? 'text-green' : 'text-red'">
-                        {{ item.close_price }}</div>
+                        <!-- {{ item.close_price }} -->
+						{{newprice}}
+						</div>
                 </div>
             </div>
             <div class="flex pt-40 pb-40">
@@ -75,20 +77,26 @@
             $t('您目前没有持仓') }}</div>
         <van-popup v-model="show">
             <popup-delivery :showBtns="true" :price="price" :detailData="detailData" :key="detailData.order_no"
-                @close="onClose" />
+                @close="onClose" :symbol="symbol" />
         </van-popup>
     </div>
 </template>
 
 <script>
 import PopupDelivery from '@/components/popup-delivery'
+import { WS_URL } from '@/config'
 import { Popup } from 'vant';
 import { _futrueOrderDetail } from "@/API/trade.api";
 export default {
     name: "deliveryHoldList",
     data() {
         return {
+			sockets: {
+			    quotes: null, // 行情
+			    deep: null /// 深度
+			},
             show: false,
+			newprice:"",
             iconShow: false,
             detailData: {},
         }
@@ -104,12 +112,42 @@
                 return []
             }
         },
+		symbol: {
+		    type: String,
+		    default: ''
+		},
         price: {
             type: [Number, String],
             default: '0.00'
         },
     },
+	deactivated(){
+		  this.closeSocket()
+	},
+	mounted (){
+		  this.fetchDeepData()
+	},
     methods: {
+		closeSocket() {
+				  this.sockets.deep.close()
+		    // this.sockets.quotes && this.sockets.quotes.close()
+		    // this.sockets.deep && this.sockets.deep.close()
+		    this.sockets.quotes = null
+		    this.sockets.deep = null
+		},
+		fetchDeepData() {
+		   
+		        this.startDeepSocket() // socket
+		},
+		startDeepSocket() {
+		    this.sockets.deep = new WebSocket(`${WS_URL}/3/${this.symbol}`)
+		    this.sockets.deep.onmessage = (evt) => {
+		        const { data } = evt
+		        const { code, data: _data } = JSON.parse(data)
+					// console.log(_data.bids[0].price);
+					this.newprice = _data.asks[0].price
+		    }
+		},
         clearTimeout() {
             clearTimeout(this.timeout)
             this.timeout = null

--
Gitblit v1.9.3