|
@@ -32,8 +32,8 @@ form.ip = parameters["ip"];
|
|
|
form.domainName = parameters["domainName"];
|
|
|
var isWSS = true;
|
|
|
var cUrl = isWSS ? "wss://" + form.domainName + "?cardIp=" + form.ip + "&token=" + cardToken : "ws://" + form.domainName + "?cardIp=" + form.ip + "&token=" + cardToken;
|
|
|
-var videoWidth = 720
|
|
|
-var videoHeight = 1280
|
|
|
+var videoWidth = parameters['mealType'] === "STARPRO" || parameters['mealType'] === "STAR" ? 1080 : 720
|
|
|
+var videoHeight = parameters['mealType'] === "STARPRO" || parameters['mealType'] === "STAR" ? 1920 : 1280
|
|
|
|
|
|
var wsss, errorTime = 0;
|
|
|
var first = true;
|
|
@@ -75,25 +75,20 @@ function doConnect() {
|
|
|
}
|
|
|
}
|
|
|
wsss.send(JSON.stringify(screenPic));
|
|
|
- // 获取分辨率
|
|
|
- var phoneSize = {
|
|
|
- "type": "getPhoneSize"
|
|
|
- }
|
|
|
- wsss.send(JSON.stringify(phoneSize));
|
|
|
};
|
|
|
wsss.onerror = function (evt) {
|
|
|
wsss.close();
|
|
|
throttle(doConnect, 100);
|
|
|
if (errorTime > 1000) {
|
|
|
- if(navigator.userAgent.toLowerCase().includes('toutiaomicroapp')){
|
|
|
- tt.miniProgram.switchTab({
|
|
|
- url: '/pages/home/home'
|
|
|
- })
|
|
|
- }else{
|
|
|
- wx.miniProgram.switchTab({
|
|
|
- url: '/pages/home/home'
|
|
|
- })
|
|
|
- }
|
|
|
+ if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
|
|
|
+ tt.miniProgram.switchTab({
|
|
|
+ url: '/pages/home/home'
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ wx.miniProgram.switchTab({
|
|
|
+ url: '/pages/home/home'
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
wsss.onmessage = function (res) {
|
|
@@ -106,13 +101,6 @@ function doConnect() {
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
- if (result.type === 'getPhoneSize') {
|
|
|
- if (result.data.status === 0) {
|
|
|
- videoWidth = result.data.width
|
|
|
- videoHeight = result.data.height
|
|
|
- }
|
|
|
- return
|
|
|
- }
|
|
|
var unit8Arr = new Uint8Array(result);
|
|
|
if (unit8Arr[0] == 0x68 && unit8Arr[1] == 0x09 && first) {
|
|
|
first = false;
|
|
@@ -163,7 +151,6 @@ $(".PictureQuality").on("click", function () {
|
|
|
}
|
|
|
wsss.send(JSON.stringify(bitRate))
|
|
|
})
|
|
|
-var ongoingTouches = [];
|
|
|
//画图形
|
|
|
var draw_graph = function (graphType, obj) {
|
|
|
//把蒙版放于画板上面
|
|
@@ -171,6 +158,7 @@ var draw_graph = function (graphType, obj) {
|
|
|
$("#dedit").css("z-index", 20);
|
|
|
var canDraw = false;
|
|
|
//鼠标按下获取 开始xy开始画图
|
|
|
+ var ongoingTouches = [];
|
|
|
var touchstart = function (e) {
|
|
|
$('.control-right-img').attr({
|
|
|
"data-id": "2"
|
|
@@ -178,33 +166,46 @@ var draw_graph = function (graphType, obj) {
|
|
|
$(".leftmains").css({
|
|
|
"right": "-4rem"
|
|
|
})
|
|
|
- var touchfor = e.originalEvent.changedTouches[0]; //for 的手指数组
|
|
|
- ongoingTouches.push(touchfor);
|
|
|
- var acrossWidthX = touchfor.pageY * (videoHeight / voheight);
|
|
|
- var acrossHeightY = videoWidth - touchfor.pageX * (videoWidth / vowidth);
|
|
|
- var verticalWidthX = touchfor.pageX * (videoWidth / vowidth);
|
|
|
- var verticalHeightY = touchfor.pageY * (videoHeight / voheight);
|
|
|
+ var touchfor = e.originalEvent.changedTouches; //for 的手指数组
|
|
|
//是否横屏
|
|
|
- var ping = resolving == 0 ?
|
|
|
- { "data": { "action": 0, "count": ongoingTouches.length, "id": touchfor.identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
|
|
|
- { "data": { "action": 0, "count": ongoingTouches.length, "id": touchfor.identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2) }, "type": "event" };
|
|
|
- wsss.send(JSON.stringify(ping));
|
|
|
+ for (var i = 0; i < touchfor.length; i++) {
|
|
|
+ var acrossWidthX = touchfor[i].pageY * (videoHeight / voheight);
|
|
|
+ var acrossHeightY = videoWidth - touchfor[i].pageX * (videoWidth / vowidth);
|
|
|
+ var verticalWidthX = touchfor[i].pageX * (videoWidth / vowidth);
|
|
|
+ var verticalHeightY = touchfor[i].pageY * (videoHeight / voheight);
|
|
|
+ var idx = ongoingTouches.findIndex(function (ele) {
|
|
|
+ return ele.identifier === touchfor[i].identifier
|
|
|
+ })
|
|
|
+ if (idx < 0) {
|
|
|
+ ongoingTouches.push(touchfor[i]);
|
|
|
+ }
|
|
|
+ var ping = resolving == 0 ?
|
|
|
+ { "data": { "action": 0, "count": ongoingTouches.length, "pointerId": touchfor[i].identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
|
|
|
+ { "data": { "action": 0, "count": ongoingTouches.length, "pointerId": touchfor[i].identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2) }, "type": "event" };
|
|
|
+ wsss.send(JSON.stringify(ping));
|
|
|
+ }
|
|
|
canDraw = true;
|
|
|
};
|
|
|
|
|
|
//鼠标离开 把蒙版canvas的图片生成到canvas中
|
|
|
var touchend = function (e) {
|
|
|
- var touchfor = e.originalEvent.changedTouches[0]; //for 的手指数组
|
|
|
- var acrossWidthX = touchfor.pageY * (videoHeight / voheight);
|
|
|
- var acrossHeightY = videoWidth - touchfor.pageX * (videoWidth / vowidth);
|
|
|
- var verticalWidthX = touchfor.pageX * (videoWidth / vowidth);
|
|
|
- var verticalHeightY = touchfor.pageY * (videoHeight / voheight);
|
|
|
+ var touchfor = e.originalEvent.changedTouches; //for 的手指数组
|
|
|
//是否横屏
|
|
|
- var ping = resolving == 0 ?
|
|
|
- { "data": { "action": 1, "count": ongoingTouches.length, "id": touchfor.identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
|
|
|
- { "data": { "action": 1, "count": ongoingTouches.length, "id": touchfor.identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2) }, "type": "event" };
|
|
|
- wsss.send(JSON.stringify(ping));
|
|
|
- ongoingTouches.splice(touchfor.identifier, 1);
|
|
|
+ for (var i = 0; i < touchfor.length; i++) {
|
|
|
+ var acrossWidthX = touchfor[i].pageY * (videoHeight / voheight);
|
|
|
+ var acrossHeightY = videoWidth - touchfor[i].pageX * (videoWidth / vowidth);
|
|
|
+ var verticalWidthX = touchfor[i].pageX * (videoWidth / vowidth);
|
|
|
+ var verticalHeightY = touchfor[i].pageY * (videoHeight / voheight);
|
|
|
+ var ping = resolving == 0 ?
|
|
|
+ { "data": { "action": 1, "count": ongoingTouches.length, "pointerId": touchfor[i].identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
|
|
|
+ { "data": { "action": 1, "count": ongoingTouches.length, "pointerId": touchfor[i].identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2) }, "type": "event" };
|
|
|
+ wsss.send(JSON.stringify(ping));
|
|
|
+ ongoingTouches.forEach(function (item, index) {
|
|
|
+ if (item.identifier === touchfor[i].identifier) {
|
|
|
+ ongoingTouches.splice(index, 1)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
canDraw = false;
|
|
|
};
|
|
|
|
|
@@ -215,16 +216,17 @@ var draw_graph = function (graphType, obj) {
|
|
|
|
|
|
// 鼠标移动
|
|
|
var touchmove = function (e) {
|
|
|
- e = e || window.event;
|
|
|
- var touchfor = e.originalEvent.changedTouches[0]; //for 的手指数组
|
|
|
- var acrossWidthX = touchfor.pageY * (videoHeight / voheight);
|
|
|
- var acrossHeightY = videoWidth - touchfor.pageX * (videoWidth / vowidth);
|
|
|
- var verticalWidthX = touchfor.pageX * (videoWidth / vowidth);
|
|
|
- var verticalHeightY = touchfor.pageY * (videoHeight / voheight);
|
|
|
- var ping = resolving == 0 ?
|
|
|
- { "data": { "action": 2, "count": ongoingTouches.length, "id": touchfor.identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
|
|
|
- { "data": { "action": 2, "count": ongoingTouches.length, "id": touchfor.identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2) }, "type": "event" };
|
|
|
- wsss.send(JSON.stringify(ping));
|
|
|
+ var touchfor = e.originalEvent.targetTouches; //for 的手指数组
|
|
|
+ for (var i = 0; i < touchfor.length; i++) {
|
|
|
+ var acrossWidthX = touchfor[i].pageY * (videoHeight / voheight);
|
|
|
+ var acrossHeightY = videoWidth - touchfor[i].pageX * (videoWidth / vowidth);
|
|
|
+ var verticalWidthX = touchfor[i].pageX * (videoWidth / vowidth);
|
|
|
+ var verticalHeightY = touchfor[i].pageY * (videoHeight / voheight);
|
|
|
+ var ping = resolving == 0 ?
|
|
|
+ { "data": { "action": 2, "count": touchfor.length, "pointerId": touchfor[i].identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
|
|
|
+ { "data": { "action": 2, "count": touchfor.length, "pointerId": touchfor[i].identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2) }, "type": "event" };
|
|
|
+ wsss.send(JSON.stringify(ping));
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
//鼠标离开区域以外 除了涂鸦 都清空
|