diff --git a/src/components/trade/trade.vue b/src/components/trade/trade.vue
index feeecff..76a79e7 100644
--- a/src/components/trade/trade.vue
+++ b/src/components/trade/trade.vue
@@ -403,7 +403,12 @@
turnoverTbData: [], //成交记录
entrustTbData: [], //委托定单
//深度数据
- depthsData: {},
+ depthsData: {
+ asks: [],
+ bids: [],
+ price: 0,
+ cnyPrice: 0
+ },
domWidth: 0,
asksDepth: 0,
@@ -1027,14 +1032,33 @@
this.$socket.subscribe(`market.${symbol}.depth.${mergeDepth}`, 'market-depth');
this.$socket.on('market-depth', (data) => {
- this.depthsData = data.tick;
- if(kline && kline.contentWindow) {
- kline.contentWindow.set_current_depth(this.depthsData);
+ // 处理双层 JSON 字符串
+ try {
+ if(data.result) {
+ let result = JSON.parse(data.result);
+ if(result.tick) {
+ this.depthsData = JSON.parse(result.tick);
+ }
+ } else if(data.tick) {
+ this.depthsData = typeof data.tick === 'string' ? JSON.parse(data.tick) : data.tick;
+ }
+
+ if(this.depthsData && kline && kline.contentWindow) {
+ kline.contentWindow.set_current_depth(this.depthsData);
+ }
+ if(this.depthsData) {
+ this.processDepthData()
+ }
+ } catch(e) {
+ console.error('解析深度数据失败:', e, data);
}
- this.processDepthData()
})
},
processDepthData(){
+ if(!this.depthsData || !this.depthsData.asks || !this.depthsData.bids) {
+ console.warn('深度数据为空或格式错误', this.depthsData);
+ return;
+ }
let {asks, bids} = this.depthsData;
let {priceScale, buyFeeRate, sellFeeRate,numScale} = this.currentMarket;
if(this.currentBuyItem.price === '' && bids.length > 0 && this.currentBuyItem.canBuyAmount === '') {
diff --git a/web/index.html b/web/index.html
index f3771c5..7b88928 100644
--- a/web/index.html
+++ b/web/index.html
@@ -11,4 +11,4 @@
// hm.src = "https://hm.baidu.com/hm.js?b4837d50cf55e64e8da2130f1ae8e997";
// var s = document.getElementsByTagName("script")[0];
// s.parentNode.insertBefore(hm, s);
-// })();