This commit is contained in:
2026-01-14 14:48:14 +08:00
parent 7862d37545
commit 801a973801
8 changed files with 36 additions and 12 deletions

View File

@@ -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 === '') {