浏览代码

fix(云机分辨率): 横屏方案同步客户端。横屏时也是使用竖屏分辨率,在触控时进行转换。

zengzhixiang 2 年之前
父节点
当前提交
5b9aa7fcbb
共有 4 个文件被更改,包括 114 次插入100 次删除
  1. 15 12
      static/screenAndroid/WXdraw.js
  2. 49 43
      static/screenAndroid/WXtrialInterface.html
  3. 11 11
      static/screenIos/WXdraw.js
  4. 39 34
      static/screenIos/WXtrialInterface.html

+ 15 - 12
static/screenAndroid/WXdraw.js

@@ -77,9 +77,12 @@ function doConnectDirectives() {
     }
   };
   wsss.onmessage = function (res) {
-    console.log('res', res);
     var result = typeof res.data === 'string' ? JSON.parse(res.data) : res.data;
-    console.log('result.type', result.type);
+    console.log(
+      '🚀 ~ file: WXdraw.js ~ line 78 ~ doConnectDirectives ~ result',
+      result,
+    );
+
     if (result.type === 'cutting') {
       if (result.data.status === 0) {
         $.toast('复制成功', 'text');
@@ -194,14 +197,14 @@ function doConnectDirectives() {
       // console.log(result);
       const data = window.phoneSizeList.find(function (v) {
         return (
-          v.width === result.data.width &&
-          v.height === result.data.height &&
+          v.width === result.data[resolving ? 'width' : 'height'] &&
+          v.height === result.data[resolving ? 'height' : 'width'] &&
           v.pid === result.data.pid
         );
       });
       window.currentPhoneSize = data || {
-        width: result.data.width,
-        height: result.data.height,
+        width: result.data[resolving ? 'width' : 'height'],
+        height: result.data[resolving ? 'height' : 'width'],
         pid: result.data.pid,
       };
       return;
@@ -272,14 +275,14 @@ var draw_graph = function (graphType, obj) {
               return (
                 resolving
                   ? x * (window.currentPhoneSize.width / vowidth)
-                  : y * (window.currentPhoneSize.width / voheight)
+                  : y * (window.currentPhoneSize.height / voheight)
               ).toFixed(2);
             })(),
             y: (function () {
               return (
                 resolving
                   ? y * (window.currentPhoneSize.height / voheight)
-                  : (vowidth - x) * (window.currentPhoneSize.height / vowidth)
+                  : (vowidth - x) * (window.currentPhoneSize.width / vowidth)
               ).toFixed(2);
             })(),
           },
@@ -309,14 +312,14 @@ var draw_graph = function (graphType, obj) {
               return (
                 resolving
                   ? x * (window.currentPhoneSize.width / vowidth)
-                  : y * (window.currentPhoneSize.width / voheight)
+                  : y * (window.currentPhoneSize.height / voheight)
               ).toFixed(2);
             })(),
             y: (function () {
               return (
                 resolving
                   ? y * (window.currentPhoneSize.height / voheight)
-                  : (vowidth - x) * (window.currentPhoneSize.height / vowidth)
+                  : (vowidth - x) * (window.currentPhoneSize.width / vowidth)
               ).toFixed(2);
             })(),
           },
@@ -352,14 +355,14 @@ var draw_graph = function (graphType, obj) {
               return (
                 resolving
                   ? x * (window.currentPhoneSize.width / vowidth)
-                  : y * (window.currentPhoneSize.width / voheight)
+                  : y * (window.currentPhoneSize.height / voheight)
               ).toFixed(2);
             })(),
             y: (function () {
               return (
                 resolving
                   ? y * (window.currentPhoneSize.height / voheight)
-                  : (vowidth - x) * (window.currentPhoneSize.height / vowidth)
+                  : (vowidth - x) * (window.currentPhoneSize.width / vowidth)
               ).toFixed(2);
             })(),
           },

+ 49 - 43
static/screenAndroid/WXtrialInterface.html

@@ -764,16 +764,16 @@
               //横屏处理
               resolving = 0;
             }
-            window.phoneSizeList = window.phoneSizeListBack.map(function (
-              item,
-            ) {
-              return resolving
-                ? item
-                : Object.assign({}, item, {
-                    width: item.height,
-                    height: item.width,
-                  });
-            });
+            // window.phoneSizeList = window.phoneSizeListBack.map(function (
+            //   item,
+            // ) {
+            //   return resolving
+            //     ? item
+            //     : Object.assign({}, item, {
+            //         width: item.height,
+            //         height: item.width,
+            //       });
+            // });
 
             // wsss.send(
             //   JSON.stringify({
@@ -781,13 +781,13 @@
             //   }),
             // );
             // 横竖屏变更时获取分辨率要延迟,不然会获取到变更前的分辨率
-            setTimeout(function () {
-              wsss.send(
-                JSON.stringify({
-                  type: 'getPhoneSize',
-                }),
-              );
-            }, 500);
+            // setTimeout(function () {
+            //   wsss.send(
+            //     JSON.stringify({
+            //       type: 'getPhoneSize',
+            //     }),
+            //   );
+            // }, 500);
           }
           if (input[23] == 0x0b) {
             //多端登录处理, 数据从索引24开始取, input 是接收到的原始数据
@@ -1422,6 +1422,19 @@
           getAD();
         });
       }
+      // 观看广告次数上报
+      function reportFrequency() {
+        $.ajax({
+          url: baseUrl + '/api/resoures/v1/trial/reportFrequency/' + userCardId,
+          headers: {
+            Authorization: token,
+          },
+          type: 'post',
+          contentType: 'application/json',
+          dataType: 'json',
+          success: function (res) {},
+        });
+      }
       //广告信息
       // function adInit() {
       //   sourceType = parameters['sourceType'];
@@ -1522,19 +1535,6 @@
           success: function (res) {},
         });
       }
-      // 观看广告次数上报
-      function reportFrequency() {
-        $.ajax({
-          url: baseUrl + '/api/resoures/v1/trial/reportFrequency/' + userCardId,
-          headers: {
-            Authorization: token,
-          },
-          type: 'post',
-          contentType: 'application/json',
-          dataType: 'json',
-          success: function (res) {},
-        });
-      }
       //关闭广告
       $('.time-close-wrap')[0].addEventListener('click', () => {
         if (videoTime == 0) {
@@ -1658,6 +1658,11 @@
         const templatePhoneSizeItem = doT.template(
           $('#template-phone-size-item').html().replace(/&/g, '&'),
         );
+        // console.log({
+        //   list: window.phoneSizeList,
+        //   active: window.activePhoneSize,
+        //   resolving,
+        // });
         const phoneSizeListItemsHtml = templatePhoneSizeItem({
           list: window.phoneSizeList,
           active: window.activePhoneSize,
@@ -1681,11 +1686,12 @@
       window.phoneSizeList = [];
       // 当前生效的分辨率
       window.currentPhoneSize = {
+        // id: 1,
         width: 720,
         height: 1280,
       };
       // 选中的分辨率
-      window.activePhoneSize = window.currentPhoneSize;
+      // window.activePhoneSize = window.currentPhoneSize;
 
       function getPhoneSizeList() {
         return $.ajax({
@@ -1704,8 +1710,8 @@
             return {
               id: v.id,
               dpi: v.dpi,
-              width: v.width || v.abscissa,
-              height: v.height || v.ordinate || v.high,
+              width: v.width,
+              height: v.high,
             };
           });
         });
@@ -1713,16 +1719,18 @@
 
       getPhoneSizeList().then(function (phoneSizeList) {
         window.phoneSizeList = phoneSizeList;
-        window.phoneSizeListBack = phoneSizeList; // 备份下数据,用户横竖切换时。
+        // window.phoneSizeListBack = phoneSizeList; // 备份下数据,用户横竖切换时。
         const currentPhoneSize = window.phoneSizeList.find(function (v) {
           return (
-            v.width === window.currentPhoneSize.width &&
-            v.height === window.currentPhoneSize.height &&
+            v.width ===
+              window.currentPhoneSize[resolving ? 'width' : 'height'] &&
+            v.height ===
+              window.currentPhoneSize[resolving ? 'height' : 'width'] &&
             v.dpi === window.currentPhoneSize.dpi
           );
         });
         window.currentPhoneSize = currentPhoneSize || window.currentPhoneSize;
-        return updatePhoneSizeListHtml();
+        // return updatePhoneSizeListHtml();
       });
 
       // const phoneSizeListSwiper = new Swiper('#phone-size-list-swiper', {
@@ -1732,12 +1740,10 @@
       //   centeredSlides: true,
       // });
       function setPhoneSize(config) {
-        config = resolving
-          ? config
-          : Object.assign({}, config, {
-              width: config.height,
-              height: config.width,
-            });
+        // config = Object.assign({}, config, {
+        //   width: config.width,
+        //   height: config.height,
+        // });
         // 修改云机分辨率
         wsss.send(
           JSON.stringify({

+ 11 - 11
static/screenIos/WXdraw.js

@@ -203,17 +203,17 @@ function doConnectDirectives() {
       return;
     }
     if (result.type === 'getPhoneSize') {
-      console.log(result);
+      // console.log(result);
       const data = window.phoneSizeList.find(function (v) {
         return (
-          v.width === result.data.width &&
-          v.height === result.data.height &&
+          v.width === result.data[resolving ? 'width' : 'height'] &&
+          v.height === result.data[resolving ? 'height' : 'width'] &&
           v.pid === result.data.pid
         );
       });
       window.currentPhoneSize = data || {
-        width: result.data.width,
-        height: result.data.height,
+        width: result.data[resolving ? 'width' : 'height'],
+        height: result.data[resolving ? 'height' : 'width'],
         pid: result.data.pid,
       };
       return;
@@ -292,14 +292,14 @@ var draw_graph = function (graphType) {
               return (
                 resolving
                   ? x * (window.currentPhoneSize.width / vowidth)
-                  : y * (window.currentPhoneSize.width / voheight)
+                  : y * (window.currentPhoneSize.height / voheight)
               ).toFixed(2);
             })(),
             y: (function () {
               return (
                 resolving
                   ? y * (window.currentPhoneSize.height / voheight)
-                  : (vowidth - x) * (window.currentPhoneSize.height / vowidth)
+                  : (vowidth - x) * (window.currentPhoneSize.width / vowidth)
               ).toFixed(2);
             })(),
           },
@@ -329,14 +329,14 @@ var draw_graph = function (graphType) {
               return (
                 resolving
                   ? x * (window.currentPhoneSize.width / vowidth)
-                  : y * (window.currentPhoneSize.width / voheight)
+                  : y * (window.currentPhoneSize.height / voheight)
               ).toFixed(2);
             })(),
             y: (function () {
               return (
                 resolving
                   ? y * (window.currentPhoneSize.height / voheight)
-                  : (vowidth - x) * (window.currentPhoneSize.height / vowidth)
+                  : (vowidth - x) * (window.currentPhoneSize.width / vowidth)
               ).toFixed(2);
             })(),
           },
@@ -419,14 +419,14 @@ var draw_graph = function (graphType) {
               return (
                 resolving
                   ? x * (window.currentPhoneSize.width / vowidth)
-                  : y * (window.currentPhoneSize.width / voheight)
+                  : y * (window.currentPhoneSize.height / voheight)
               ).toFixed(2);
             })(),
             y: (function () {
               return (
                 resolving
                   ? y * (window.currentPhoneSize.height / voheight)
-                  : (vowidth - x) * (window.currentPhoneSize.height / vowidth)
+                  : (vowidth - x) * (window.currentPhoneSize.width / vowidth)
               ).toFixed(2);
             })(),
           },

+ 39 - 34
static/screenIos/WXtrialInterface.html

@@ -1082,16 +1082,16 @@
                 resolving = 0;
                 // $('#playCanvas').removeClass('vertical').addClass('horizontal');
               }
-              window.phoneSizeList = window.phoneSizeListBack.map(function (
-                item,
-              ) {
-                return resolving
-                  ? item
-                  : Object.assign({}, item, {
-                      width: item.height,
-                      height: item.width,
-                    });
-              });
+              // window.phoneSizeList = window.phoneSizeListBack.map(function (
+              //   item,
+              // ) {
+              //   return resolving
+              //     ? item
+              //     : Object.assign({}, item, {
+              //         width: item.height,
+              //         height: item.width,
+              //       });
+              // });
 
               // wsss.send(
               //   JSON.stringify({
@@ -1099,13 +1099,13 @@
               //   }),
               // );
               // 横竖屏变更时获取分辨率要延迟,不然会获取到变更前的分辨率
-              setTimeout(function () {
-                wsss.send(
-                  JSON.stringify({
-                    type: 'getPhoneSize',
-                  }),
-                );
-              }, 500);
+              // setTimeout(function () {
+              //   wsss.send(
+              //     JSON.stringify({
+              //       type: 'getPhoneSize',
+              //     }),
+              //   );
+              // }, 1000);
             }
             if (input[23] == 0x0b) {
               console.log('多端登陆');
@@ -1460,6 +1460,11 @@
         const templatePhoneSizeItem = doT.template(
           $('#template-phone-size-item').html().replace(/&/g, '&'),
         );
+        // console.log({
+        //   list: window.phoneSizeList,
+        //   active: window.activePhoneSize,
+        //   resolving,
+        // });
         const phoneSizeListItemsHtml = templatePhoneSizeItem({
           list: window.phoneSizeList,
           active: window.activePhoneSize,
@@ -1489,7 +1494,7 @@
         height: 1280,
       };
       // 选中的分辨率
-      window.activePhoneSize = window.currentPhoneSize;
+      // window.activePhoneSize = window.currentPhoneSize;
 
       function getPhoneSizeList() {
         return $.ajax({
@@ -1508,8 +1513,8 @@
             return {
               id: v.id,
               dpi: v.dpi,
-              width: v.width || v.abscissa,
-              height: v.height || v.ordinate || v.high,
+              width: v.width,
+              height: v.high,
             };
           });
         });
@@ -1517,16 +1522,18 @@
 
       getPhoneSizeList().then(function (phoneSizeList) {
         window.phoneSizeList = phoneSizeList;
-        window.phoneSizeListBack = phoneSizeList; // 备份下数据,用户横竖切换时。
+        // window.phoneSizeListBack = phoneSizeList; // 备份下数据,用户横竖切换时。
         const currentPhoneSize = window.phoneSizeList.find(function (v) {
           return (
-            v.width === window.currentPhoneSize.width &&
-            v.height === window.currentPhoneSize.height &&
+            v.width ===
+              window.currentPhoneSize[resolving ? 'width' : 'height'] &&
+            v.height ===
+              window.currentPhoneSize[resolving ? 'height' : 'width'] &&
             v.dpi === window.currentPhoneSize.dpi
           );
         });
         window.currentPhoneSize = currentPhoneSize || window.currentPhoneSize;
-        return updatePhoneSizeListHtml();
+        // return updatePhoneSizeListHtml();
       });
 
       // const phoneSizeListSwiper = new Swiper('#phone-size-list-swiper', {
@@ -1536,12 +1543,10 @@
       //   centeredSlides: true,
       // });
       function setPhoneSize(config) {
-        config = resolving
-          ? config
-          : Object.assign({}, config, {
-              width: config.height,
-              height: config.width,
-            });
+        // config = Object.assign({}, config, {
+        //   width: config.width,
+        //   height: config.height,
+        // });
         // 修改云机分辨率
         wsss.send(
           JSON.stringify({
@@ -1598,10 +1603,10 @@
       // });
       $('#phone-size-list').on('click', '.phone-size-item', function (e) {
         const data = $(e.currentTarget).data();
-        console.log(
-          '🚀 ~ file: WXtrialInterface.html ~ line 1494 ~ data',
-          data,
-        );
+        // console.log(
+        //   '🚀 ~ file: WXtrialInterface.html ~ line 1494 ~ data',
+        //   data,
+        // );
         window.activePhoneSize = data;
         updatePhoneSizeListHtml();
         // setPhoneSize(data.width, data.height);