diff --git a/components/kline/kline.vue b/components/kline/kline.vue index 1b6bd74..a3cea48 100644 --- a/components/kline/kline.vue +++ b/components/kline/kline.vue @@ -117,15 +117,15 @@ }, methods: { setSymbol(symbol){ - console.log(symbol) + //console.log(symbol) this.chartSymbol=symbol }, setWidth(width) { - console.log("可用窗口宽度:", width) + //console.log("可用窗口宽度:", width) this.chartWidth = width }, setHeight(height) { - console.log("可用窗口高度:", height) + //console.log("可用窗口高度:", height) this.chartHeight = 300 }, changindex_activeCycle(index_activeCycle){ @@ -147,12 +147,12 @@ chartConfig.height = this.chartHeight chartConfig.time_frames=[] // 初始化 TradingView - console.log(window.TradingView.version()) + //console.log(window.TradingView.version()) widgetObj = new widget(chartConfig) - console.log(11111,widgetObj) + //console.log(11111,widgetObj) widgetObj._options.interval=5 widgetObj.onChartReady(() => { // 这是k线图 展示的 7日均线和30日均线。 diff --git a/components/kline/tradingView/datafeed.js b/components/kline/tradingView/datafeed.js index 4f4059e..8291d8e 100644 --- a/components/kline/tradingView/datafeed.js +++ b/components/kline/tradingView/datafeed.js @@ -48,15 +48,11 @@ FeedBase.prototype.resolveSymbol = function(symbolName, onResolve, onError) { "has_intraday": true, "seconds_multipliers":['1', '5', '15', '30', '60', '1D', '1W','1M'], "intraday_multipliers": ['1', '5', '15', '30', '60', '1D', '1W','1M'], - "supports_search": false, - "supports_group_request": false, - "supported_resolutions": ['1', '5', '15', '30', '60', '1D', '1W','1M'], // 时间 - - "has_seconds":false, + "has_seconds":true, "supports_marks": true, "supports_timescale_marks": true, "supported_time": true, - "has_weekly_and_monthly": false, + "has_weekly_and_monthly": true, "has_no_volume": true, "regular_session": "24x7", @@ -74,7 +70,7 @@ FeedBase.prototype.resolveSymbol = function(symbolName, onResolve, onError) { const resolutionFormat = (resolution, name, to) => { let req = `market.${name}.kline.${resolution}min`; let minutes = resolution; - console.log(resolution) + //console.log(resolution) if (resolution.includes('D')) { if (resolution.length < 2) resolution = '1' + resolution; req = `market.${name}.kline.${parseInt(resolution)}day`; @@ -99,7 +95,8 @@ const resolutionFormat = (resolution, name, to) => { if (resolution.includes('M') || resolution.includes('W')) { // 周线月线控制条数,时间超出火币规定范围, ws报错 from = to - 50 * minutes * 500; } - } + } + return { minutes, req, @@ -109,12 +106,11 @@ const resolutionFormat = (resolution, name, to) => { }; FeedBase.prototype.getBars = function(symbolInfo, resolution, periodParams, onHistoryCallback, onErrorCallback) { - console.log("获取历史数据",periodParams) + //console.log("获取历史数据",periodParams) // 切换产品周期 或者 切换产品 会执行这个函数 - let reso = resolutionFormat(resolution, symbolInfo.name, periodParams.to) - // if (resolution.includes('M') || resolution.includes('W')|| resolution.includes('D')) { // 周线月线控制条数,时间超出火币规定范围, ws报错 - // reso = resolutionFormat(resolution, symbolInfo.name, periodParams.to) - // } + let reso = resolutionFormat(resolution, symbolInfo.name, periodParams.to > detafeed_historyTime ? periodParams + .to : + detafeed_historyTime) // 是历史数据 var history = true @@ -166,7 +162,7 @@ FeedBase.prototype.getBars = function(symbolInfo, resolution, periodParams, onHi datas.push(i) } } else { - console.log('进来') + //console.log('进来') meta = { noData: 'no_data', nextTime: detafeed_historyTime diff --git a/components/kline/tradingView/websocket.js b/components/kline/tradingView/websocket.js index 42bdd77..c6b3187 100644 --- a/components/kline/tradingView/websocket.js +++ b/components/kline/tradingView/websocket.js @@ -30,8 +30,8 @@ var socket = { // 如果不是订阅历史产品 那么肯定就是切换周期咯 或者切换产品咯 // 那么就订阅一下 这次产品的或者周期的 实时数据 if (!history) { - console.log('订阅新的' + realTimeDatas) - console.log(111111,realTimeDatas) + //console.log('订阅新的' + realTimeDatas) + //console.log(111111,realTimeDatas) this.sendWsRequest({ event: 'un_sub', type: 'kline', @@ -65,12 +65,12 @@ var socket = { } }, error(err) { - console.log(err, 'depth-socket::error') + //console.log(err, 'depth-socket::error') }, close() { // 如果websocket关闭的话,就从新打开一下。 this.initWs() - console.log('depth-socket::close') + //console.log('depth-socket::close') }, message(resp) { resp=JSON.parse(resp.data) @@ -126,7 +126,7 @@ var socket = { } if (i >= checkTimes) { clearInterval(this.intervalObj) - console.log('send post_data_str timeout.') + //console.log('send post_data_str timeout.') } }, 500) }, @@ -139,13 +139,13 @@ var socket = { this.socket.send(JSON.stringify(options)) break case 2: - console.log('ws关闭状态') + //console.log('ws关闭状态') break case 3: this.initWs() break default: - console.log('ws未知错误') + //console.log('ws未知错误') } } } diff --git a/pages/markets/kLine.vue b/pages/markets/kLine.vue index fc59748..ce8c435 100644 --- a/pages/markets/kLine.vue +++ b/pages/markets/kLine.vue @@ -129,7 +129,7 @@ }, onLoad() { //this.kdata = this.splitData(ktest.JSON); - // console.log(this.kdata, 1111) + // //console.log(this.kdata, 1111) //延时计算窗口 @@ -182,7 +182,7 @@ uni.navigateTo({ url, fail(err) { - console.log(err) + //console.log(err) } }) }, @@ -242,12 +242,12 @@ "symbol": this.symbol.symbol }); bboList.then(res => { - // console.log(9999999, res) + // //console.log(9999999, res) this.bboList = res this.statisticsSum(); }) .catch(e => { - // console.log(e) + // //console.log(e) uni.showToast({ title: e, icon: 'none', @@ -264,7 +264,7 @@ }) .catch(e => { - // console.log(e) + // //console.log(e) uni.showToast({ title: e, icon: 'none', diff --git a/utils/websocket.js b/utils/websocket.js index fe8157c..50c5aea 100644 --- a/utils/websocket.js +++ b/utils/websocket.js @@ -39,7 +39,7 @@ class WebSocketClass { this.ws = uni.connectSocket({ url: this.wsUrl, success(data) { - console.log('websocket连接成功'); + //console.log('websocket连接成功'); that.initEventHandle(); }, @@ -58,13 +58,13 @@ class WebSocketClass { // #ifdef H5 this.ws.onopen = (event) => { - console.log('WebSocket连接打开'); + //console.log('WebSocket连接打开'); }; // #endif // #ifdef APP-PLUS this.ws.onOpen(res => { - console.log('WebSocket连接打开'); + //console.log('WebSocket连接打开'); }); // #endif @@ -151,10 +151,10 @@ class WebSocketClass { this.ws && this.ws.send({ data: JSON.stringify(msg), success() { - console.log('消息发送成功',msg); + //console.log('消息发送成功',msg); }, fail(err) { - console.log('关闭失败', err) + //console.log('关闭失败', err) } }); // #endif @@ -177,10 +177,10 @@ class WebSocketClass { // #ifdef APP-PLUS this.ws.close({ success(res) { - console.log('关闭成功', res) + //console.log('关闭成功', res) }, fail(err) { - console.log('关闭失败', err) + //console.log('关闭失败', err) } }); // #endif @@ -189,7 +189,7 @@ class WebSocketClass { } writeToScreen(massage) { - console.log(massage); + //console.log(massage); } subLatest() { @@ -278,7 +278,7 @@ class WebSocketClass { } publicSend(event, type, channel, date) { - console.log(this.id) + //console.log(this.id) var data = { event: event, type: type,