Explorar el Código

Merge branch 'hotfix/云集分辨率-修复坐标偏移' of Software/android-cloud-H5 into develop

zengzhixiang hace 2 años
padre
commit
6d7ff9cecf

+ 1 - 0
pages/login.vue

@@ -47,6 +47,7 @@
 
 <script>
 export default {
+  auth: 'guest',
   name: 'LoginPage',
   data() {
     return {

+ 43 - 39
pages/phone/_id.vue

@@ -5,48 +5,52 @@
 </template>
 
 <script>
-// import qs from 'qs';
+import qs from 'qs';
+const isNew = false;
 export default {
   name: 'DiskPage',
   middleware: [
-    // async ({ base, route, $axios, $auth, redirect, $userAgent }) => {
-    //   const res = await $axios.$get(
-    //     '/resources/v5/client/disk/info/userCard/single',
-    //     {
-    //       params: {
-    //         userCardId: route.params.id,
-    //       },
-    //     },
-    //   );
-    //   const {
-    //     userCardId,
-    //     userName,
-    //     room,
-    //     buyVipType,
-    //     sourceType,
-    //     authPhone,
-    //     validTime,
-    //   } = res.data;
-    //   const token = $auth.strategy.token.get();
-    //   const url = `${location.origin}${base}${
-    //     $userAgent.isIos ? 'screenIos' : 'screenAndroid'
-    //   }/WXtrialInterface.html${qs.stringify(
-    //     {
-    //       userCardId,
-    //       username: userName,
-    //       token,
-    //       rm: room,
-    //       mealType: buyVipType,
-    //       sourceType,
-    //       authPhone,
-    //       validTime,
-    //     },
-    //     {
-    //       addQueryPrefix: true,
-    //     },
-    //   )}`;
-    //   redirect(url);
-    // },
+    async ({ base, route, $axios, $auth, redirect, $userAgent }) => {
+      if (isNew) {
+        return;
+      }
+      const res = await $axios.$get(
+        '/resources/v5/client/disk/info/userCard/single',
+        {
+          params: {
+            userCardId: route.params.id,
+          },
+        },
+      );
+      const {
+        userCardId,
+        userName,
+        room,
+        buyVipType,
+        sourceType,
+        authPhone,
+        validTime,
+      } = res.data;
+      const token = $auth.strategy.token.get();
+      const url = `${location.origin}${base}${
+        $userAgent.isIos ? 'screenIos' : 'screenAndroid'
+      }/WXtrialInterface.html${qs.stringify(
+        {
+          userCardId,
+          username: userName,
+          token,
+          rm: room,
+          mealType: buyVipType,
+          sourceType,
+          authPhone,
+          validTime,
+        },
+        {
+          addQueryPrefix: true,
+        },
+      )}`;
+      redirect(url);
+    },
   ],
   data() {
     return {

+ 90 - 112
static/screenAndroid/WXdraw.js

@@ -125,6 +125,7 @@ function doConnectDirectives() {
           window.currentPhoneSize = {
             width: result.data.width,
             height: result.data.height,
+            pid: result.data.pid,
           };
           return;
         }
@@ -165,11 +166,16 @@ function doConnectDirectives() {
     if (result.type === 'getPhoneSize') {
       // console.log(result);
       const data = window.phoneSizeList.find(function (v) {
-        return v.width === result.data.width && v.height === result.data.height;
+        return (
+          v.width === result.data.width &&
+          v.height === result.data.height &&
+          v.pid === result.data.pid
+        );
       });
       window.currentPhoneSize = data || {
         width: result.data.width,
         height: result.data.height,
+        pid: result.data.pid,
       };
       return;
     }
@@ -219,58 +225,46 @@ var draw_graph = function (graphType, obj) {
   $('#dedit').css('z-index', 20);
   var canDraw = false;
   //鼠标按下获取 开始xy开始画图
-  var ongoingTouches = [];
+  // var ongoingTouches = [];
   var touchstart = function (e) {
     if (!isControl) {
       return;
     }
     $('.control-right-img').attr({
-      'data-id': '2',
+      'data-id': '1',
     });
     $('.leftmains').css({
       right: '-4rem',
     });
-    var touchfor = e.originalEvent.changedTouches; //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 * (window.currentPhoneSize.width / vowidth);
-      var verticalHeightY =
-        touchfor[i].pageY * (window.currentPhoneSize.height / 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',
-        //     }
-        //   :
-        {
+    const action = 0;
+    Array.from(e.originalEvent.changedTouches).forEach(function (item, index) {
+      const x = item.clientX - item.target.getBoundingClientRect().x;
+      const y = item.clientY - item.target.getBoundingClientRect().y;
+      return wsss.send(
+        JSON.stringify({
+          type: 'event',
           data: {
-            action: 0,
-            count: ongoingTouches.length,
-            pointerId: touchfor[i].identifier,
-            x: verticalWidthX.toFixed(2),
-            y: verticalHeightY.toFixed(2),
+            action,
+            count: e.originalEvent.touches.length,
+            pointerId: item.identifier,
+            x: (function () {
+              return (
+                resolving
+                  ? x * (window.currentPhoneSize.width / vowidth)
+                  : y * (window.currentPhoneSize.width / voheight)
+              ).toFixed(2);
+            })(),
+            y: (function () {
+              return (
+                resolving
+                  ? y * (window.currentPhoneSize.height / voheight)
+                  : (vowidth - x) * (window.currentPhoneSize.height / vowidth)
+              ).toFixed(2);
+            })(),
           },
-          type: 'event',
-        };
-      wsss.send(JSON.stringify(ping));
-    }
+        }),
+      );
+    });
     canDraw = true;
   };
 
@@ -279,46 +273,35 @@ var draw_graph = function (graphType, obj) {
     if (!isControl) {
       return;
     }
-    var touchfor = e.originalEvent.changedTouches; //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 * (window.currentPhoneSize.width / vowidth);
-      var verticalHeightY =
-        touchfor[i].pageY * (window.currentPhoneSize.height / 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',
-        //     }
-        //   :
-        {
+    const action = 1;
+    Array.from(e.originalEvent.changedTouches).forEach(function (item, index) {
+      const x = item.clientX - item.target.getBoundingClientRect().x;
+      const y = item.clientY - item.target.getBoundingClientRect().y;
+      return wsss.send(
+        JSON.stringify({
+          type: 'event',
           data: {
-            action: 1,
-            count: ongoingTouches.length,
-            pointerId: touchfor[i].identifier,
-            x: verticalWidthX.toFixed(2),
-            y: verticalHeightY.toFixed(2),
+            action,
+            count: e.originalEvent.touches.length,
+            pointerId: item.identifier,
+            x: (function () {
+              return (
+                resolving
+                  ? x * (window.currentPhoneSize.width / vowidth)
+                  : y * (window.currentPhoneSize.width / voheight)
+              ).toFixed(2);
+            })(),
+            y: (function () {
+              return (
+                resolving
+                  ? y * (window.currentPhoneSize.height / voheight)
+                  : (vowidth - x) * (window.currentPhoneSize.height / vowidth)
+              ).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;
   };
 
@@ -332,40 +315,35 @@ var draw_graph = function (graphType, obj) {
     if (!isControl) {
       return;
     }
-    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 * (window.currentPhoneSize.width / vowidth);
-      var verticalHeightY =
-        touchfor[i].pageY * (window.currentPhoneSize.height / 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',
-        //     }
-        //   :
-        {
+    const action = 2;
+    Array.from(e.originalEvent.changedTouches).forEach(function (item, index) {
+      const x = item.clientX - item.target.getBoundingClientRect().x;
+      const y = item.clientY - item.target.getBoundingClientRect().y;
+      return wsss.send(
+        JSON.stringify({
+          type: 'event',
           data: {
-            action: 2,
-            count: touchfor.length,
-            pointerId: touchfor[i].identifier,
-            x: verticalWidthX.toFixed(2),
-            y: verticalHeightY.toFixed(2),
+            action,
+            count: e.originalEvent.touches.length,
+            pointerId: item.identifier,
+            x: (function () {
+              return (
+                resolving
+                  ? x * (window.currentPhoneSize.width / vowidth)
+                  : y * (window.currentPhoneSize.width / voheight)
+              ).toFixed(2);
+            })(),
+            y: (function () {
+              return (
+                resolving
+                  ? y * (window.currentPhoneSize.height / voheight)
+                  : (vowidth - x) * (window.currentPhoneSize.height / vowidth)
+              ).toFixed(2);
+            })(),
           },
-          type: 'event',
-        };
-      wsss.send(JSON.stringify(ping));
-    }
+        }),
+      );
+    });
   };
 
   //鼠标离开区域以外 除了涂鸦 都清空

+ 5 - 0
static/screenAndroid/WXtrialInterface.html

@@ -764,6 +764,11 @@
               //横屏处理
               resolving = 0;
             }
+            wsss.send(
+              JSON.stringify({
+                type: 'getPhoneSize',
+              }),
+            );
           }
           if (input[23] == 0x0b) {
             //多端登录处理, 数据从索引24开始取, input 是接收到的原始数据

+ 182 - 82
static/screenIos/WXdraw.js

@@ -141,6 +141,7 @@ function doConnectDirectives() {
           id: result.data.id,
           width: result.data.width,
           height: result.data.height,
+          pid: result.data.pid,
         };
         return;
       }
@@ -179,11 +180,16 @@ function doConnectDirectives() {
     if (result.type === 'getPhoneSize') {
       // console.log(result);
       const data = window.phoneSizeList.find(function (v) {
-        return v.width === result.data.width && v.height === result.data.height;
+        return (
+          v.width === result.data.width &&
+          v.height === result.data.height &&
+          v.pid === result.data.pid
+        );
       });
       window.currentPhoneSize = data || {
         width: result.data.width,
         height: result.data.height,
+        pid: result.data.pid,
       };
       return;
     }
@@ -239,49 +245,48 @@ var draw_graph = function (graphType) {
   $('#dedit').css('z-index', 20);
   // 先画在蒙版上 再复制到画布上
   //鼠标按下获取 开始xy开始画图
-  var ongoingTouches = [];
+  // var ongoingTouches = [];
   var touchstart = function (e) {
+    console.log('🚀 ~ file: WXdraw.js ~ line 244 ~ touchstart ~ e', e);
     if (!isControl) {
       return;
     }
     $('.control-right-img').attr({
-      'data-id': '2',
+      'data-id': '1',
     });
     $('.leftmains').css({
       right: '-4rem',
     });
-    var touchfor = e.originalEvent.changedTouches; //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 * (window.currentPhoneSize.width / vowidth);
-      var verticalHeightY =
-        touchfor[i].pageY * (window.currentPhoneSize.height / 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" } :
-        {
+    const action = 0;
+    Array.from(e.originalEvent.changedTouches).forEach(function (item, index) {
+      const x = item.clientX - item.target.getBoundingClientRect().x;
+      const y = item.clientY - item.target.getBoundingClientRect().y;
+      return wsss.send(
+        JSON.stringify({
+          type: 'event',
           data: {
-            action: 0,
-            count: ongoingTouches.length,
-            pointerId: touchfor[i].identifier,
-            x: verticalWidthX.toFixed(2),
-            y: verticalHeightY.toFixed(2),
+            action,
+            count: e.originalEvent.touches.length,
+            pointerId: item.identifier,
+            x: (function () {
+              return (
+                resolving
+                  ? x * (window.currentPhoneSize.width / vowidth)
+                  : y * (window.currentPhoneSize.width / voheight)
+              ).toFixed(2);
+            })(),
+            y: (function () {
+              return (
+                resolving
+                  ? y * (window.currentPhoneSize.height / voheight)
+                  : (vowidth - x) * (window.currentPhoneSize.height / vowidth)
+              ).toFixed(2);
+            })(),
           },
-          type: 'event',
-        };
-      wsss.send(JSON.stringify(ping));
-    }
+        }),
+      );
+    });
     canDraw = true;
   };
 
@@ -290,36 +295,82 @@ var draw_graph = function (graphType) {
     if (!isControl) {
       return;
     }
-    var touchfor = e.originalEvent.changedTouches; //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 * (window.currentPhoneSize.width / vowidth);
-      var verticalHeightY =
-        touchfor[i].pageY * (window.currentPhoneSize.height / 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" } :
-        {
+    const action = 1;
+    Array.from(e.originalEvent.changedTouches).forEach(function (item, index) {
+      const x = item.clientX - item.target.getBoundingClientRect().x;
+      const y = item.clientY - item.target.getBoundingClientRect().y;
+      return wsss.send(
+        JSON.stringify({
+          type: 'event',
           data: {
-            action: 1,
-            count: ongoingTouches.length,
-            pointerId: touchfor[i].identifier,
-            x: verticalWidthX.toFixed(2),
-            y: verticalHeightY.toFixed(2),
+            action,
+            count: e.originalEvent.touches.length,
+            pointerId: item.identifier,
+            x: (function () {
+              return (
+                resolving
+                  ? x * (window.currentPhoneSize.width / vowidth)
+                  : y * (window.currentPhoneSize.width / voheight)
+              ).toFixed(2);
+            })(),
+            y: (function () {
+              return (
+                resolving
+                  ? y * (window.currentPhoneSize.height / voheight)
+                  : (vowidth - x) * (window.currentPhoneSize.height / vowidth)
+              ).toFixed(2);
+            })(),
           },
-          type: 'event',
-        };
-      wsss.send(JSON.stringify(ping));
-      ongoingTouches.forEach(function (item, index) {
-        if (item.identifier === touchfor[i].identifier) {
-          ongoingTouches.splice(index, 1);
-        }
-      });
-    }
+        }),
+      );
+    });
+    // var touchfor = e.originalEvent.changedTouches; //for 的手指数组
+    // //是否横屏
+    // for (var i = 0; i < touchfor.length; i++) {
+    //   // var acrossWidthX = touchfor[i].pageY * (videoHeight / voheight);
+    //   // var acrossHeightY =
+    //   //   videoWidth - touchfor[i].pageX * (videoWidth / vowidth);
+    //   // if (resolving) {
+    //   //   var verticalWidthX =
+    //   //     touchfor[i].pageX * (window.currentPhoneSize.width / vowidth);
+    //   //   var verticalHeightY =
+    //   //     touchfor[i].pageY * (window.currentPhoneSize.height / voheight);
+    //   // } else {
+    //   //   var verticalWidthX =
+    //   //     touchfor[i].pageX * (window.currentPhoneSize.width / vowidth);
+    //   //   var verticalHeightY =
+    //   //     touchfor[i].pageY * (window.currentPhoneSize.height / 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: (() =>
+    //           (resolving
+    //             ? touchfor[i].pageX * (window.currentPhoneSize.width / vowidth)
+    //             : touchfor[i].pageY * (window.currentPhoneSize.width / voheight)
+    //           ).toFixed(2))(),
+    //         y: (() =>
+    //           (resolving
+    //             ? touchfor[i].pageY *
+    //               (window.currentPhoneSize.height / voheight)
+    //             : (vowidth - touchfor[i].pageX) *
+    //               (window.currentPhoneSize.height / vowidth)
+    //           ).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;
   };
 
@@ -333,30 +384,79 @@ var draw_graph = function (graphType) {
     if (!isControl) {
       return;
     }
-    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 * (window.currentPhoneSize.width / vowidth);
-      var verticalHeightY =
-        touchfor[i].pageY * (window.currentPhoneSize.height / 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" } :
-        {
+    const action = 2;
+    Array.from(e.originalEvent.changedTouches).forEach(function (item, index) {
+      const x = item.clientX - item.target.getBoundingClientRect().x;
+      const y = item.clientY - item.target.getBoundingClientRect().y;
+      return wsss.send(
+        JSON.stringify({
+          type: 'event',
           data: {
-            action: 2,
-            count: touchfor.length,
-            pointerId: touchfor[i].identifier,
-            x: verticalWidthX.toFixed(2),
-            y: verticalHeightY.toFixed(2),
+            action,
+            count: e.originalEvent.touches.length,
+            pointerId: item.identifier,
+            x: (function () {
+              return (
+                resolving
+                  ? x * (window.currentPhoneSize.width / vowidth)
+                  : y * (window.currentPhoneSize.width / voheight)
+              ).toFixed(2);
+            })(),
+            y: (function () {
+              return (
+                resolving
+                  ? y * (window.currentPhoneSize.height / voheight)
+                  : (vowidth - x) * (window.currentPhoneSize.height / vowidth)
+              ).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);
+
+    //   // let verticalWidthX = 0;
+    //   // let verticalHeightY = 0;
+    //   // if (resolving) {
+    //   //   verticalWidthX =
+    //   //     touchfor[i].pageX * (window.currentPhoneSize.width / vowidth);
+    //   //   verticalHeightY =
+    //   //     touchfor[i].pageY * (window.currentPhoneSize.height / voheight);
+    //   // } else {
+    //   //   verticalWidthX =
+    //   //     touchfor[i].pageX * (window.currentPhoneSize.width / vowidth);
+    //   //   verticalHeightY =
+    //   //     touchfor[i].pageY * (window.currentPhoneSize.height / 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: (() =>
+    //           (resolving
+    //             ? touchfor[i].pageX * (window.currentPhoneSize.width / vowidth)
+    //             : touchfor[i].pageY * (window.currentPhoneSize.width / voheight)
+    //           ).toFixed(2))(),
+    //         y: (() =>
+    //           (resolving
+    //             ? touchfor[i].pageY *
+    //               (window.currentPhoneSize.height / voheight)
+    //             : (vowidth - touchfor[i].pageX) *
+    //               (window.currentPhoneSize.height / vowidth)
+    //           ).toFixed(2))(),
+    //       },
+    //       type: 'event',
+    //     };
+    //   wsss.send(JSON.stringify(ping));
+    // }
   };
 
   //鼠标离开区域以外 除了涂鸦 都清空

+ 5 - 0
static/screenIos/WXtrialInterface.html

@@ -1072,6 +1072,11 @@
                 resolving = 0;
                 // $('#playCanvas').removeClass('vertical').addClass('horizontal');
               }
+              wsss.send(
+                JSON.stringify({
+                  type: 'getPhoneSize',
+                }),
+              );
             }
             if (input[23] == 0x0b) {
               console.log('多端登陆');