소스 검색

2023-10-16

cmy 1 년 전
부모
커밋
ab48b0bffe
2개의 변경된 파일82개의 추가작업 그리고 38개의 파일을 삭제
  1. 0 2
      api/game.js
  2. 82 36
      pages/index/entertainment.vue

+ 0 - 2
api/game.js

@@ -11,7 +11,6 @@ export function test(data) {
 
 // 互娱  游戏列表
 export  function getGameList(data) {
-	console.log("”");
 	return request({
 		url: `/api/game`,
 		method: 'get',
@@ -21,7 +20,6 @@ export  function getGameList(data) {
 
 // 互娱 获取当前游戏历史记录
 export function getGame(data,id) {
-	console.log(id);
 	return request({
 		url: `/api/game/room/${id}`,
 		method: 'get',

+ 82 - 36
pages/index/entertainment.vue

@@ -199,7 +199,7 @@
 					page: 1,
 					limit: 10,
 				},
-				userWallet: 0
+				userWallet: 0,
 			};
 		},
 		onLoad() {
@@ -250,7 +250,6 @@
 							that.time.S = Math.floor(timenum / 1000 % 60)
 							that.time.M = Math.floor(timenum / 1000 / 60 % 60);
 							if (that.time.H == 0 && that.time.M == 0 && that.time.S == 0) {
-								console.log('进入');
 								clearInterval(that.time.t);
 								setTimeout(() => {
 									test();
@@ -307,8 +306,7 @@
 					limit: 10,
 					id: this.history.base.id
 				}).then((res) => {
-					this.betList.list
-					console.log(res);
+					this.betList.list = res.data.bet_log;
 				})
 			},
 			// 获取游戏K线信息
@@ -316,18 +314,21 @@
 				const that = this;
 				gameKline({
 					page: 1,
-					limit: 30
+					limit: 60
 				}, that.history.base.id).then((res) => {
-					console.log(res, 'res');
 					let list = res.data.list.reverse();
 					// x轴记录
 					let xarr = [];
 					// 打点数据
 					let linearr = [];
 					for (let i = 0; i < list.length; i++) {
-						const ll = list[i]
-						xarr.push(ll.ts)
-						linearr.push([+ll.o, +ll.c, +ll.l, +ll.h])
+						const ll = list[i];
+						const time = new Date(+ll.ts);
+						const addar = [+(+ll.o).toFixed(5), +(+ll.c).toFixed(5), +(+ll.l).toFixed(5), +(+ll.h)
+							.toFixed(5)
+						];
+						xarr.push(`${time.getHours()}:${time.getMinutes()}`)
+						linearr.push(addar)
 					}
 					that.$nextTick(() => {
 						that.initKline({
@@ -367,20 +368,28 @@
 					for (var j = 0; j < dayCount; j++) {
 						sum += data.linearr[i - j][1];
 					}
-					result.push(+(sum / dayCount).toFixed(3));
+					result.push(+(sum / dayCount).toFixed(5));
 				}
 				return result;
 			},
 
 			async initKline(data) {
 				const that = this;
-				const chart = await this.$refs.chart.init(echarts);
 				try {
+					const chart = await this.$refs.chart.init(echarts);
 					const upColor = '#00da3c';
 					const downColor = '#ec0000';
 					chart.setOption(
 						(this.option = {
 							animation: false,
+							legend: {
+								top: 10,
+								left: 10,
+								data: ['MA5', 'MA10', 'MA20'],
+								textStyle: {
+									color: '#999999'
+								}
+							},
 							tooltip: {
 								trigger: 'axis',
 								axisPointer: {
@@ -396,22 +405,26 @@
 									const obj = {
 										top: 10
 									};
-									obj[['left', 'right'][+(pos[0] < size.viewSize[0] / 2)]] = 30;
+									obj[['left', 'right'][+(pos[0] < size.viewSize[0] / 2)]] = 40;
 
-									console.log(obj, 'obj');
 									return obj;
 								}
 							},
+							dataZoom: [{
+								type: 'inside',
+								xAxisIndex: 0,
+								start: 50,
+								end: 100
+							}],
 							grid: [{
-								left: 0,
-								right: 0,
-								height: '80%',
-								top: 30
+								left: 10,
+								right: 55,
+								bottom: 20,
+								top: 45
 							}],
 							xAxis: [{
 								type: 'category',
 								data: data.xarr,
-								boundaryGap: false,
 								axisLine: {
 									onZero: false
 								},
@@ -426,32 +439,65 @@
 							}],
 							yAxis: [{
 								scale: true,
-								splitNumber: 2,
+								splitNumber: 4,
+								position: 'right',
 								axisTick: {
 									show: false
 								},
-								splitLine:{
-									lineStyle:{
-										color:['#FFF']
+								splitLine: {
+									show: false,
+									lineStyle: {
+										color: '#e3e3e3'
 									}
 								},
 								axisLabel: {
-									inside: true,
+									inside: false,
 									formatter: '{value}\n',
-									color:"#FFFFFF"
+									color: '#999999'
 								}
-							} ],
+							}],
 							series: [{
-								name: that.history.base.token + '-USDT',
-								type: 'candlestick',
-								data: data.linearr,
-								itemStyle: {
-									color: upColor,
-									color0: downColor,
-									borderColor: undefined,
-									borderColor0: undefined
-								}
-							}]
+									name: that.history.base.token + '-USDT',
+									type: 'candlestick',
+									data: data.linearr,
+									itemStyle: {
+										color: upColor,
+										color0: downColor,
+										borderColor: undefined,
+										borderColor0: undefined
+									}
+								},
+								{
+									name: "MA5",
+									smooth: true,
+									type: 'line',
+									data: that.calculateMA(5, data),
+									showSymbol: false,
+									lineStyle: {
+										width: 1
+									}
+								},
+								{
+									name: "MA10",
+									smooth: true,
+									type: 'line',
+									data: that.calculateMA(10, data),
+									showSymbol: false,
+									lineStyle: {
+										width: 1
+									}
+								},
+								{
+									name: "MA20",
+									smooth: true,
+									type: 'line',
+									data: that.calculateMA(20, data),
+									showSymbol: false,
+									lineStyle: {
+										width: 1
+									}
+								},
+							]
 						}),
 						true
 					)
@@ -506,7 +552,7 @@
 		}
 
 		.top {
-			height: 500rpx;
+			height: 530rpx;
 			width: 100%;
 		}
 	}