This commit is contained in:
2026-01-14 15:06:59 +08:00
parent 07bc8373cc
commit 5e41d219d8
8 changed files with 48 additions and 16 deletions

View File

@@ -484,6 +484,9 @@
})
},
mounted() {
console.log('🚀 trade组件已挂载');
console.log('🔌 WebSocket状态:', this.$socket ? '已连接' : '未连接');
console.log('📱 channels对象:', this.$socket ? this.$socket.channels : 'N/A');
this._getMarkList();
this.symbol = this.$route.query.symbol
},
@@ -499,7 +502,9 @@
async _getDepth(){
let symbol = this.currentMarket.symbol;
let mergeDepth = this.chooseMergeDepth;
console.log('📊 初始化获取深度数据:', symbol, mergeDepth);
let res = await tradeApi.getDepth(symbol,mergeDepth)
console.log('📊 API返回的深度数据:', res.data);
this.depthsData = res.data
this.processDepthData()
},
@@ -665,9 +670,14 @@
// },
marketChange(currentMarket) {
this.currentMarket = currentMarket;
console.log("marketChange", currentMarket);
console.log("📍 marketChange", currentMarket);
this.switchMarketListDropdown = false;
this.timeStp = new Date().getTime();
// 先取消之前的订阅
this.unsubscribeDepths();
this.unsubscribeTrades();
//依赖marketId
this._getUserAccount(this.currentMarket.symbol);
this._serverGetTurnoverOrderList();
@@ -676,9 +686,11 @@
this.subscribeEntrust();
this.subscribeTurnover();
// 先获取初始数据
this._getDepth()
this._getTrades()
// 订阅实时更新
this.subscribeDepths();
this.subscribeTrades();
@@ -1029,37 +1041,57 @@
let symbol = this.currentMarket.symbol.toLowerCase();
let mergeDepth = this.chooseMergeDepth;
console.log('📊 订阅深度数据:', symbol, mergeDepth);
this.$socket.subscribe(`market.${symbol}.depth.${mergeDepth}`, 'market-depth');
this.$socket.on('market-depth', (data) => {
console.log('📊 收到深度数据原始:', data);
// 处理双层 JSON 字符串
try {
let parsedData = null;
if(data.result) {
console.log('📊 数据格式: data.result');
let result = JSON.parse(data.result);
if(result.tick) {
this.depthsData = JSON.parse(result.tick);
parsedData = JSON.parse(result.tick);
}
} else if(data.tick) {
this.depthsData = typeof data.tick === 'string' ? JSON.parse(data.tick) : data.tick;
console.log('📊 数据格式: data.tick');
parsedData = typeof data.tick === 'string' ? JSON.parse(data.tick) : data.tick;
} else if(data.body) {
console.log('📊 数据格式: data.body');
let body = typeof data.body === 'string' ? JSON.parse(data.body) : data.body;
parsedData = body;
}
if(this.depthsData && kline && kline.contentWindow) {
kline.contentWindow.set_current_depth(this.depthsData);
}
if(this.depthsData) {
if(parsedData) {
console.log('📊 解析后的深度数据:', parsedData);
this.depthsData = parsedData;
// 更新K线
let klineIframe = kline || document.getElementById('kline-win');
if(this.depthsData && klineIframe && klineIframe.contentWindow) {
klineIframe.contentWindow.set_current_depth(this.depthsData);
}
this.processDepthData()
} else {
console.warn('📊 无法解析深度数据,原始数据:', data);
}
} catch(e) {
console.error('解析深度数据失败:', e, data);
console.error('📊 解析深度数据失败:', e, data);
}
})
},
processDepthData(){
console.log('📊 处理深度数据开始:', this.depthsData);
if(!this.depthsData || !this.depthsData.asks || !this.depthsData.bids) {
console.warn('深度数据为空或格式错误', this.depthsData);
console.warn('📊 深度数据为空或格式错误', this.depthsData);
return;
}
let {asks, bids} = this.depthsData;
console.log('📊 asks数量:', asks.length, 'bids数量:', bids.length);
let {priceScale, buyFeeRate, sellFeeRate,numScale} = this.currentMarket;
if(this.currentBuyItem.price === '' && bids.length > 0 && this.currentBuyItem.canBuyAmount === '') {
let {buyAmount} = this.userAccount;

View File

@@ -11,4 +11,4 @@
// hm.src = "https://hm.baidu.com/hm.js?b4837d50cf55e64e8da2130f1ae8e997";
// var s = document.getElementsByTagName("script")[0];
// s.parentNode.insertBefore(hm, s);
// })();</script><script type=text/javascript src=/static/js/manifest.1dd99496d8b507517792.js></script><script type=text/javascript src=/static/js/vendor.0d306d721fa4eca4e4ea.js></script><script type=text/javascript src=/static/js/app.6040d417623130efbb8e.js></script></body></html>
// })();</script><script type=text/javascript src=/static/js/manifest.d71f8eb56057e01ab9a8.js></script><script type=text/javascript src=/static/js/vendor.0d306d721fa4eca4e4ea.js></script><script type=text/javascript src=/static/js/app.6040d417623130efbb8e.js></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,2 +1,2 @@
!function(e){function a(c){if(d[c])return d[c].exports;var f=d[c]={i:c,l:!1,exports:{}};return e[c].call(f.exports,f,f.exports,a),f.l=!0,f.exports}var c=window.webpackJsonp;window.webpackJsonp=function(d,n,t){for(var r,b,o,i=0,u=[];i<d.length;i++)b=d[i],f[b]&&u.push(f[b][0]),f[b]=0;for(r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);for(c&&c(d,n,t);u.length;)u.shift()();if(t)for(i=0;i<t.length;i++)o=a(a.s=t[i]);return o};var d={},f={47:0};a.e=function(e){function c(){r.onerror=r.onload=null,clearTimeout(b);var a=f[e];0!==a&&(a&&a[1](new Error("Loading chunk "+e+" failed.")),f[e]=void 0)}var d=f[e];if(0===d)return new Promise(function(e){e()});if(d)return d[2];var n=new Promise(function(a,c){d=f[e]=[a,c]});d[2]=n;var t=document.getElementsByTagName("head")[0],r=document.createElement("script");r.type="text/javascript",r.charset="utf-8",r.async=!0,r.timeout=12e4,a.nc&&r.setAttribute("nonce",a.nc),r.src=a.p+"static/js/"+e+"."+{0:"6b306e70df4dffaf4dde",1:"ea56ad8dd5d68646daea",2:"d02e8da5d2425b3abe7d",3:"a5034031b218bfc8bf0a",4:"3a31def876d81528641e",5:"55f644ae3ea937093622",6:"85bee17e4902de4a9ccb",7:"5e31923ed89c99462386",8:"f617d318c2411b8250c5",9:"b13f0fdfb63845b2d2bd",10:"f6c60b6ef2360efb6f65",11:"7fc6d7a8ab554ce7d245",12:"8a3fd93a31ff1371e24b",13:"0673978e6ad4850d8a84",14:"042424dc880c07768e98",15:"d76249aadd6b40861af5",16:"adcd4f2408712cd6a225",17:"4ea30b10b41ea8ed0559",18:"b525d8c4c4e577832858",19:"ecf7fc15747348e05cdf",20:"3b851313b2a2c069bc98",21:"9fe1339f00fb17f535d5",22:"1770c47fc7536c9419bd",23:"60f7228bbb61307ede00",24:"daedc0a1563d469065e5",25:"b804466da864228a9b9d",26:"76fd6880edc5d6c9c6ac",27:"4313571b2a29dcc5bf64",28:"67ecdd0e59b01bd57432",29:"73df6ec04ad07c2c1371",30:"382e2781642a999f6768",31:"109c0da4e83f95d5480c",32:"0535b59baba4bd20b0ed",33:"eac8ad88455c881ef1be",34:"90f8fdf654acc1f0d734",35:"cbc7d1a54e49e8197ce9",36:"1d355294209e499b22ab",37:"20d9b16a4be4b6910e5e",38:"3d367bea534f9080b660",39:"d784630316fde96155e0",40:"87ac8499cd30afa85a73",41:"20ee0cf8bc14eea4bbfc",42:"b8c35f2ecaf791363f3b",43:"38bcbf137ef960a51727",44:"1844d416059cdd4f80ad",45:"0d306d721fa4eca4e4ea",46:"6040d417623130efbb8e"}[e]+".js";var b=setTimeout(c,12e4);return r.onerror=r.onload=c,t.appendChild(r),n},a.m=e,a.c=d,a.i=function(e){return e},a.d=function(e,c,d){a.o(e,c)||Object.defineProperty(e,c,{configurable:!1,enumerable:!0,get:d})},a.n=function(e){var c=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(c,"a",c),c},a.o=function(e,a){return Object.prototype.hasOwnProperty.call(e,a)},a.p="/",a.oe=function(e){throw e}}([]);
//# sourceMappingURL=manifest.1dd99496d8b507517792.js.map
!function(e){function c(a){if(d[a])return d[a].exports;var f=d[a]={i:a,l:!1,exports:{}};return e[a].call(f.exports,f,f.exports,c),f.l=!0,f.exports}var a=window.webpackJsonp;window.webpackJsonp=function(d,n,t){for(var r,b,o,i=0,u=[];i<d.length;i++)b=d[i],f[b]&&u.push(f[b][0]),f[b]=0;for(r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);for(a&&a(d,n,t);u.length;)u.shift()();if(t)for(i=0;i<t.length;i++)o=c(c.s=t[i]);return o};var d={},f={47:0};c.e=function(e){function a(){r.onerror=r.onload=null,clearTimeout(b);var c=f[e];0!==c&&(c&&c[1](new Error("Loading chunk "+e+" failed.")),f[e]=void 0)}var d=f[e];if(0===d)return new Promise(function(e){e()});if(d)return d[2];var n=new Promise(function(c,a){d=f[e]=[c,a]});d[2]=n;var t=document.getElementsByTagName("head")[0],r=document.createElement("script");r.type="text/javascript",r.charset="utf-8",r.async=!0,r.timeout=12e4,c.nc&&r.setAttribute("nonce",c.nc),r.src=c.p+"static/js/"+e+"."+{0:"6b306e70df4dffaf4dde",1:"ea56ad8dd5d68646daea",2:"d02e8da5d2425b3abe7d",3:"a5034031b218bfc8bf0a",4:"3a31def876d81528641e",5:"55f644ae3ea937093622",6:"85bee17e4902de4a9ccb",7:"5e31923ed89c99462386",8:"f617d318c2411b8250c5",9:"b13f0fdfb63845b2d2bd",10:"f6c60b6ef2360efb6f65",11:"7fc6d7a8ab554ce7d245",12:"8a3fd93a31ff1371e24b",13:"c21ec0b8f60c9a2ba729",14:"042424dc880c07768e98",15:"d76249aadd6b40861af5",16:"adcd4f2408712cd6a225",17:"4ea30b10b41ea8ed0559",18:"b525d8c4c4e577832858",19:"ecf7fc15747348e05cdf",20:"3b851313b2a2c069bc98",21:"9fe1339f00fb17f535d5",22:"1770c47fc7536c9419bd",23:"60f7228bbb61307ede00",24:"daedc0a1563d469065e5",25:"b804466da864228a9b9d",26:"76fd6880edc5d6c9c6ac",27:"4313571b2a29dcc5bf64",28:"67ecdd0e59b01bd57432",29:"73df6ec04ad07c2c1371",30:"382e2781642a999f6768",31:"109c0da4e83f95d5480c",32:"0535b59baba4bd20b0ed",33:"eac8ad88455c881ef1be",34:"90f8fdf654acc1f0d734",35:"cbc7d1a54e49e8197ce9",36:"1d355294209e499b22ab",37:"20d9b16a4be4b6910e5e",38:"3d367bea534f9080b660",39:"d784630316fde96155e0",40:"87ac8499cd30afa85a73",41:"20ee0cf8bc14eea4bbfc",42:"b8c35f2ecaf791363f3b",43:"38bcbf137ef960a51727",44:"1844d416059cdd4f80ad",45:"0d306d721fa4eca4e4ea",46:"6040d417623130efbb8e"}[e]+".js";var b=setTimeout(a,12e4);return r.onerror=r.onload=a,t.appendChild(r),n},c.m=e,c.c=d,c.i=function(e){return e},c.d=function(e,a,d){c.o(e,a)||Object.defineProperty(e,a,{configurable:!1,enumerable:!0,get:d})},c.n=function(e){var a=e&&e.__esModule?function(){return e.default}:function(){return e};return c.d(a,"a",a),a},c.o=function(e,c){return Object.prototype.hasOwnProperty.call(e,c)},c.p="/",c.oe=function(e){throw e}}([]);
//# sourceMappingURL=manifest.d71f8eb56057e01ab9a8.js.map