huangxiaojing 4 年 前
コミット
81ae850ef6
共有3 個のファイルを変更した215 個の追加903 個の削除を含む
  1. 86 230
      screenAndroid/WXdraw.js
  2. 127 659
      screenAndroid/WXtrialInterface.html
  3. 2 14
      screenAndroid/helper.js

+ 86 - 230
screenAndroid/WXdraw.js

@@ -1,110 +1,40 @@
-//画布
-var canvas;
-var context;
 //蒙版
-var canvas_bak = document.getElementById("box");;
-var context_bak;
+var canvas_bak = document.getElementById("box");
 
-var canvasWidth = 720;
-var canvasHeight = 1280;
+var winHeight = window.screen.height - window.innerHeight;
+var vowidth = window.screen.width;
+var topwinHeightDraw = window.screen.height - window.innerHeight + 30; // 计算title top 头部
+var numse = window.screen.height;
 
-var canvasTop;
-var canvasLeft;
-var winHeight = window.screen.height - window.innerHeight
-var vowidth = window.screen.width
-var topwinHeightDraw = window.screen.height - window.innerHeight + 30; //计算title top 头部
-var numse = window.screen.height //-winHeight
-
-//计算title top 头部
+// 计算title top 头部
 if (numse <= 70) {
-
 	var voheight = window.screen.height - winHeight - 34 - 20
 } else {
-	console.log("numse>>>", numse)
 	var voheight = window.screen.height - topwinHeightDraw - 20
 }
 
-//console.log("画笔大小>>>",window.innerHeight)
-//画笔大小
-var size = 1;
-var color = '#000000';
-var resolving
-//alert(winHeight)
-var url = window.location.href;
-url = url.split('/')
-
-var query = window.location.search.substring(1);
-// debugger
-// query = "clientType=3&username=WqXTc1593762177&userCardId=377"
-// debugger
-var vars = query.split("&");
-var data = {}
-var clientType = vars.find(e => {
-	return e.startsWith('clientType')
-}) || ''
-var cardIp = vars.find(e => {
-	return e.startsWith('cardIp')
-}) || ''
-var port = vars.find(e => {
-	return e.startsWith('port')
-}) || ''
-
-var sn = vars.find(e => {
-	return e.startsWith('sn')
-}) || ''
-var username = vars.find(e => {
-	return e.startsWith('username')
-}) || ''
-var userCardId = vars.find(e => {
-	return e.startsWith('userCardId')
-}) || ''
-var ip = vars.find(e => {
-	return e.startsWith('ip')
-}) || ''
+// 画笔大小
+var resolving;
 
-var data = {}
-data.clientType = clientType.substring(11, clientType.length)
+var url = window.location.href;
+url = url.split('/');
 
-data.cardIp = cardIp.substring(7, cardIp.length)
+var parameters = GetRequest();
+var form = {};
 
-data.port = port.substring(5, port.length)
+form.clientType = parameters["clientType"];
+form.cardIp = parameters["cardIp"];
+form.port = parameters["port"];
+form.sn = parameters["sn"];
+form.username = parameters["username"];
+form.userCardId = parameters["userCardId"];
+form.ip = parameters["ip"];
 
-data.sn = sn.substring(3, sn.length)
-data.username = username.substring(9, username.length)
-data.userCardId = userCardId.substring(11, userCardId.length)
-data.ip = ip.substring(3, ip.length)
-// var urlss=url[2]
-// urlss = "14.215.128.96"
-urlss = '192.168.31.20'
-// urlss = 'test.androidscloud.com'
-// debugger
-// var cUrl = ''
-// cUrl = "ws://192.168.11.66:9101";
-// var cUrl="wss://www.ted2018.com:9101"
-// var cUrl = "ws://192.168.198.21:9101"
-var cUrl = "ws://192.168.198.82:9100/card?cardIp=" + data.ip;
-// if (data.clientType == 3) {
-// 	cUrl = "wss://" + urlss + "/authControlWebSocket?" + "clientType=" + data.clientType + "&username=" + data.username +
-// 		"&userCardId=" + data.userCardId
-// } else if (data.clientType == 2) {
-// 	// cUrl = "wss://" + urlss + "/shareWebSocket?" + "clientType=" + data.clientType + "&username=" + data.username +
-// 	// 	"&userCardId=" + data.userCardId + "&ip=" + data.ip
-// 	cUrl = "wss://test.androidscloud.com/videoWebSocket?clientType=1&cardIp=14.215.128.96&port=2005&sn=RK3930C2301900005";
-// } else {
-// 	cUrl = "wss://" + urlss + "/controlWebSocket?" + "clientType=" + data.clientType + "&cardIp=" + data.cardIp + "&port=" +
-// 		data.port + "&sn=" + data.sn
-// }
-console.log(cUrl, 'curl')
-// var cUrl = Number(data.clientType) === 3? "ws://"+urlss+"/authControlWebSocket?"+"clientType="+data.clientType+"&username="+data.username+"&userCardId="+data.userCardId : "ws://"+urlss+"/controlWebSocket?"+"clientType="+data.clientType+"&cardIp="+data.cardIp+"&port="+data.port+"&sn="+data.sn
+var cUrl = "ws://192.168.199.243/card?cardIp=" + form.ip;
 var wsss = new WebSocket(cUrl);
-console.log('wsssss==============', wsss)
 wsss.binaryType = 'arraybuffer';
-////
-// wsss = new WebSocket(
-// 	"ws://14.215.128.96/authControlWebSocket?clientType=3&username=WqXTc1593762177&userCardId=377");
 
-wsss.onopen = function() {
-	console.log("onopen==============");
+wsss.onopen = function () {
 	var pings = {
 		"event": "getScreenStatus"
 	}
@@ -115,32 +45,21 @@ wsss.onopen = function() {
 		},
 		"event": "bitRate"
 	}
-	// wsss.send(JSON.stringify(bitRate));
-	wsss.send(ExexuteMove(JSON.stringify(bitRate),data.sn)) 
+	wsss.send(ExexuteMove(JSON.stringify(bitRate), form.sn))
 };
-// wsss.onmessage = function(event) {
-// 	// console.log("onMessage==============", event);
-// 	// var resets = JSON.parse(event.data)
-// 	// var resets = event.data;
-// 	// resets.errorMsg && alert(resets.errorMsg)
-// 	// resolving = resets.data.orientation
-// 	// if (resolving == 1) {} else {}
-// 	// console.log('>>>resolvingresolvingresolving', resolving)
 
-// };
-wsss.onclose = function(event) {
+wsss.onclose = function (event) {
 	console.log("onclose==============");
 };
-wsss.onerror = function(event) {
+wsss.onerror = function (event) {
 	console.log("onerror==============");
 };
-$('#box').on("click", function() {
-
+$('#box').on("click", function () {
 	draw_graph('pencil', this)
 })
 //剪切板
-$(".upload").on("click", function() {
-	let texts = $(this).attr("data-text")
+$(".upload").on("click", function () {
+	var texts = $(this).attr("data-text")
 	if (texts == "uploads") {
 		$(".mainbox").css({
 			"display": "block"
@@ -148,94 +67,56 @@ $(".upload").on("click", function() {
 		$(".sbox").css({
 			"display": "none"
 		})
-	} else if (texts == "Signout") {
-		//		alert()
-
 	}
 })
 
 //home 控制home
-$(".botmat1img").on("click", function() {
-	let codes = $(this).attr("data-text")
-	console.log(codes)
+$(".botmat1img").on("click", function () {
+	var codes = $(this).attr("data-text")
 	if (codes == "home") {
-		// var bitRate = {
-		// 	"data": {
-		// 		"keyCode": 3
-		// 	},
-		// 	"event": "keyCode"
-		// }
-		// console.log("打印主页json", JSON.stringify(bitRate))
-		wsss.send(ExexuteKeyBoard(3),data.sn);
-		// console.log("打印主页json", wsss)
+		wsss.send(ExexuteKeyBoard(3), form.sn);
 	} else if (codes == "return") {
-		// var bitRate = {
-		// 	"data": {
-		// 		"keyCode": "4"
-		// 	},
-		// 	"event": "keyCode"
-		// }
-		// wsss.send(JSON.stringify(bitRate));
-		wsss.send(ExexuteKeyBoard(4),data.sn);
+		wsss.send(ExexuteKeyBoard(4), form.sn);
 	} else if (codes == "gengduo") {
-		// var bitRate = {
-		// 	"data": {
-		// 		"keyCode": "187"
-		// 	},
-		// 	"event": "keyCode"
-		// }
-		// wsss.send(JSON.stringify(bitRate));
-		wsss.send(ExexuteKeyBoard(187),data.sn);
+		wsss.send(ExexuteKeyBoard(187), form.sn);
 	}
 
 })
 //高清控制
-$(".PictureQuality").on("click", function() {
+$(".PictureQuality").on("click", function () {
 	$(this).addClass("avit").siblings().removeClass('avit')
-	let id = $(this).attr("data-id")
+	var id = $(this).attr("data-id")
 	var bitRate = {
 		"data": {
 			"bitRate": id
 		},
 		"event": "bitRate"
 	}
-	wsss.send(ExexuteMove(JSON.stringify(bitRate),data.sn)) 
-	console.log(id)
+	wsss.send(ExexuteMove(JSON.stringify(bitRate), form.sn))
 })
 
 //画图形
-var draw_graph = function(graphType, obj) {
-	console.log('111》》》', graphType)
+var draw_graph = function (graphType, obj) {
 	//把蒙版放于画板上面
-	//$("#canvas_bak").css("z-index",1);
 	$("#container").css("z-index", 30);
 	$("#dedit").css("z-index", 20);
-	//先画在蒙版上 再复制到画布上
-
-	chooseImg(obj);
 	var canDraw = false;
-
-	var startX;
-	var startY;
-
 	//鼠标按下获取 开始xy开始画图
-	var touchstart = function(e) {
+	var touchstart = function (e) {
 		$('.control-right-img').attr({
 			"data-id": "2"
 		})
 		$(".leftmains").css({
 			"right": "-4rem"
 		})
-		//		.toFixed(2)
 		var touchfor = e.originalEvent.targetTouches; //for 的手指数组
-		var touch = e.originalEvent.targetTouches[0];
-		var thochlethng = e.originalEvent.targetTouches.length
+
 		//是否横屏
 		if (resolving == 0) {
-			let ping
-			for (let i = 0; i < touchfor.length; i++) {
-				let cawidthXs = touchfor[i].pageY * (1280 / voheight)
-				let caheightYs = 720 - touchfor[i].pageX * (720 / vowidth)
+			var ping;
+			for (var i = 0; i < touchfor.length; i++) {
+				var cawidthXs = touchfor[i].pageY * (1280 / voheight)
+				var caheightYs = 720 - touchfor[i].pageX * (720 / vowidth)
 				ping = {
 					"data": {
 						"action": 0,
@@ -247,14 +128,12 @@ var draw_graph = function(graphType, obj) {
 					"event": "0"
 				}
 			}
-			// wsss.send(JSON.stringify(ping));
-			wsss.send(ExexuteMove(JSON.stringify(ping),data.sn)) 
-			console.log("鼠标按下>>>", ping)
+			wsss.send(ExexuteMove(JSON.stringify(ping), form.sn))
 		} else {
-			let ping
-			for (let i = 0; i < touchfor.length; i++) {
-				let cawidthXs = touchfor[i].pageX * (720 / vowidth)
-				let caheightYs = touchfor[i].pageY * (1280 / voheight)
+			var ping;
+			for (var i = 0; i < touchfor.length; i++) {
+				var cawidthXs = touchfor[i].pageX * (720 / vowidth)
+				var caheightYs = touchfor[i].pageY * (1280 / voheight)
 				ping = {
 					"data": {
 						"action": 0,
@@ -267,27 +146,20 @@ var draw_graph = function(graphType, obj) {
 				}
 
 			}
-			// wsss.send(JSON.stringify(ping));
-			wsss.send(ExexuteMove(JSON.stringify(ping),data.sn)) 
-			console.log("鼠标按下>>>", ping)
+			wsss.send(ExexuteMove(JSON.stringify(ping), form.sn));
 		}
-
 		canDraw = true;
-
 	};
 
 	//鼠标离开 把蒙版canvas的图片生成到canvas中
-	var touchend = function(e) {
+	var touchend = function (e) {
 		var touchfor = e.originalEvent.changedTouches; //for 的手指数组
-		var touch = e.originalEvent.changedTouches[0];
-		var thochlethng = e.originalEvent.changedTouches.length
-		//	 alert(thochlethng)
 		//是否横屏 morePortionUp
 		if (resolving == 0) {
-			let ping
-			for (let i = 0; i < touchfor.length; i++) {
-				let cawidthXs = touchfor[i].pageY * (1280 / voheight)
-				let caheightYs = 720 - touchfor[i].pageX * (720 / vowidth)
+			var ping;
+			for (var i = 0; i < touchfor.length; i++) {
+				var cawidthXs = touchfor[i].pageY * (1280 / voheight);
+				var caheightYs = 720 - touchfor[i].pageX * (720 / vowidth);
 				ping = {
 					"data": {
 						"action": 1,
@@ -299,15 +171,12 @@ var draw_graph = function(graphType, obj) {
 					"event": "1"
 				}
 			}
-
-			// wsss.send(JSON.stringify(ping));
-			wsss.send(ExexuteMove(JSON.stringify(ping),data.sn)) 
-
+			wsss.send(ExexuteMove(JSON.stringify(ping), form.sn));
 		} else {
-			let ping
-			for (let i = 0; i < touchfor.length; i++) {
-				let cawidthXs = touchfor[i].pageX * (720 / vowidth)
-				let caheightYs = touchfor[i].pageY * (1280 / voheight)
+			var ping;
+			for (var i = 0; i < touchfor.length; i++) {
+				var cawidthXs = touchfor[i].pageX * (720 / vowidth);
+				var caheightYs = touchfor[i].pageY * (1280 / voheight);
 				ping = {
 					"data": {
 						"action": 1,
@@ -319,35 +188,26 @@ var draw_graph = function(graphType, obj) {
 					"event": "1"
 				}
 			}
-
-			// wsss.send(JSON.stringify(ping));
-			wsss.send(ExexuteMove(JSON.stringify(ping),data.sn)) 
+			wsss.send(ExexuteMove(JSON.stringify(ping), form.sn))
 		}
-
 		canDraw = false;
-
 	};
 
 	//清空层 云手机超出屏幕的开关
-	var clearContext = function(type) {
+	var clearContext = function () {
 		canDraw = false;
 	}
 
 	// 鼠标移动
-	var touchmove = function(e) {
-
+	var touchmove = function (e) {
 		e = e || window.event;
 		var touchfor = e.originalEvent.targetTouches; //for 的手指数组
-		var touch = e.originalEvent.targetTouches[0];
-		var thochlethng = e.originalEvent.targetTouches.length
-		let ping
+		var ping;
 		//是否横屏  morePortionMove
 		if (resolving == 0) {
-			let obj = []
-			for (let i = 0; i < touchfor.length; i++) {
-				let cawidthXs = touchfor[i].pageY * (1280 / voheight)
-				let caheightYs = 720 - touchfor[i].pageX * (720 / vowidth)
-
+			for (var i = 0; i < touchfor.length; i++) {
+				var cawidthXs = touchfor[i].pageY * (1280 / voheight)
+				var caheightYs = 720 - touchfor[i].pageX * (720 / vowidth)
 				ping = {
 					"data": {
 						"action": 2,
@@ -360,14 +220,12 @@ var draw_graph = function(graphType, obj) {
 				}
 
 			}
-
-			// wsss.send(JSON.stringify(ping));
-			wsss.send(ExexuteMove(JSON.stringify(ping),data.sn)) 
+			wsss.send(ExexuteMove(JSON.stringify(ping), form.sn))
 		} else {
-			let ping
-			for (let i = 0; i < touchfor.length; i++) {
-				let cawidthXs = touchfor[i].pageX * (720 / vowidth)
-				let caheightYs = touchfor[i].pageY * (1280 / voheight)
+			var ping;
+			for (var i = 0; i < touchfor.length; i++) {
+				var cawidthXs = touchfor[i].pageX * (720 / vowidth);
+				var caheightYs = touchfor[i].pageY * (1280 / voheight);
 				ping = {
 					"data": {
 						"action": 2,
@@ -378,27 +236,15 @@ var draw_graph = function(graphType, obj) {
 					},
 					"event": "2"
 				}
-
 			}
-
-			// wsss.send(JSON.stringify(ping));
-			wsss.send(ExexuteMove(JSON.stringify(ping),data.sn)) 
-		}
-
-
-
-		//				var ping = {"data":{"action":2,"count":1,"pointerId":0,"x":cawidthX.toFixed(2),"y":caheightY.toFixed(2)},"event":"2"}	    
-
-
-
+			wsss.send(ExexuteMove(JSON.stringify(ping), form.sn));
+		};
 	};
 
 	//鼠标离开区域以外 除了涂鸦 都清空
-	var mouseout = function() {
-
+	var mouseout = function () {
 		if (graphType != 'handwriting') {
 			clearContext();
-
 		}
 	}
 
@@ -409,7 +255,17 @@ var draw_graph = function(graphType, obj) {
 	$(canvas_bak).bind('mouseout', mouseout);
 }
 
-//选择功能按钮 修改样式
-function chooseImg(obj) {
-
+// 获取url中"?"符后的字串
+function GetRequest() {
+	var url = location.search;
+	var obj = new Object();
+	if (url.indexOf("?") != -1) {
+		var str = url.substr(1);
+		strs = str.split("&");
+		for (var i = 0; i < strs.length; i++) {
+			obj[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
+		}
+	}
+	return obj;
 }
+

File diff suppressed because it is too large
+ 127 - 659
screenAndroid/WXtrialInterface.html


+ 2 - 14
screenAndroid/helper.js

@@ -54,16 +54,12 @@ function makeFrame(sn, dataType, jsonCmd) {
 	var bccBuffer = outPut.slice(1, frameLen - 3 + 1);//忽略协议头和协议尾
 	outPut[index++] = calBcc(bccBuffer);
 	outPut[index++] = 0x16;
-	// console.log("打印数组:%s", PrintArry(outPut));
-	console.log("数组长度:%d", outPut.length);
-	//return PrintArry(outPut);
 	return outPut;
 }
 //触发键盘事件, code表示键盘值
 function ExexuteKeyDown(code) {
 	var jsonObj = { "data": { "keyCode": code, "event": "keyDown" } };
 	var json = JSON.stringify(jsonObj);
-	console.log("json==================", json);
 	var sn = "RK3923C1201900139";
 	return makeFrame(sn, 0, json);
 }
@@ -71,7 +67,6 @@ function ExexuteKeyDown(code) {
 function ExexuteMouseDown(x, y) {
 	var jsonObj = { "data": { "action": 0, "count": 1, "pointerId": 0, "x": x, "y": y }, "event": "0" };
 	var json = JSON.stringify(jsonObj);
-	console.log("json==================", json);
 	var sn = "RK3923C1201900139";
 	return makeFrame(sn, 0, json);
 }
@@ -99,9 +94,6 @@ function ExexuteMouseUp(x, y) {
 }
 //触发滑动事件
 function ExexuteMove(data, sn) {
-	// var jsonObj = {"data":{"action":1, "count":1, "pointerId":0,"x":x, "y":y}, "event":"1"};
-	// var json = JSON.stringify(jsonObj);
-	// var sn = "RK3923C1201900139";
 	return makeFrame(sn, 0, data);
 }
 function makeFrameExtend(sn, dataType, body) {
@@ -114,14 +106,14 @@ function makeFrameExtend(sn, dataType, body) {
 	outPut[index++] = (dataLen & 0x00ff0000) >> 16;
 	outPut[index++] = (dataLen & 0x0000ff00) >> 8;
 	outPut[index++] = dataLen & 0x000000ff;
-	outPut[index++] = 0;//类型为client
+	outPut[index++] = 0; // 类型为client
 
 	//sn号赋值,string转ascii
 	for (i = 0; i < sn.length; i++) {
 		outPut[index++] = sn[i].charCodeAt();
 	}
 
-	outPut[index++] = dataType;//指定数据类型为json
+	outPut[index++] = dataType; // 指定数据类型为json
 	//json string转ascii
 	for (i = 0; i < body.length; i++) {
 		outPut[index++] = body[i];
@@ -130,9 +122,6 @@ function makeFrameExtend(sn, dataType, body) {
 	var bccBuffer = outPut.slice(1, frameLen - 3 + 1);//忽略协议头和协议尾
 	outPut[index++] = calBcc(bccBuffer);
 	outPut[index++] = 0x16;
-	var str = PrintArry(outPut);
-	//console.log("打印数组:%s", PrintArry(outPut));
-	//return PrintArry(outPut);
 	return outPut;
 }
 
@@ -180,7 +169,6 @@ function RequestIFrame() {
 	return makeFrameExtend(sn, 6, outPut);
 }
 
-
  //示例:
  //var sn = "RK3923C1201900139";
  //var json = "{\"data\":{\"keyCode\":24},\"type\":\"keyDown\"}";