Browse Source

feat(云机分辨率): 解开屏蔽

zengzhixiang 2 years ago
parent
commit
d0e133044c
2 changed files with 66 additions and 35 deletions
  1. 39 21
      static/screenAndroid/WXtrialInterface.html
  2. 27 14
      static/screenIos/WXtrialInterface.html

+ 39 - 21
static/screenAndroid/WXtrialInterface.html

@@ -63,7 +63,7 @@
       {{~}}
     </template>
     <template id="template-shear">
-      {{? it.length}}
+      {{? it.length }}
       <div class="title">
         剪贴板
         <div class="btn-clear">清空</div>
@@ -129,11 +129,11 @@
           <div class="menu-btn PictureQuality avit" data-id="3">标清</div>
           <div class="menu-btn PictureQuality" data-id="2">极速</div>
         </div>
-        <!-- <div class="">
+        <div class="open-set-phone-size-dialog-btn-wrap">
           <div class="menu-btn" id="open-set-phone-size-dialog-btn">
             <span>分辨率</span>
           </div>
-        </div> -->
+        </div>
         <div class="operation">
           <div class="upload" id="showsuss" data-text="uploads">
             <img src="../static/img/wx/shangchuan_icon.png" />
@@ -1702,6 +1702,10 @@
           systemBuriedPoint('激活码-强制关闭-继续观看');
         }
       });
+      window.onbeforeunload = function () {
+        wsss.close();
+        ws.close();
+      };
       // 埋点
       function systemBuriedPoint(pointName) {
         $.ajax({
@@ -1733,10 +1737,7 @@
           });
         }
       }
-      window.onbeforeunload = function () {
-        ws.close();
-        wsss.close();
-      };
+
       function updatePhoneSizeListHtml() {
         const templatePhoneSizeItem = doT.template(
           $('#template-phone-size-item').html().replace(/&amp;/g, '&'),
@@ -1753,7 +1754,9 @@
         });
         $('#phone-size-list').html(phoneSizeListItemsHtml);
       }
-      $('#open-set-phone-size-dialog-btn').on('click', function (e) {
+
+      $('#open-set-phone-size-dialog-btn').on('click', async function (e) {
+        !window.phoneSizeList.length && (await getPhoneSizeList());
         window.activePhoneSize = window.currentPhoneSize;
         updatePhoneSizeListHtml();
         $('#set-phone-size-dialog').addClass('show');
@@ -1771,8 +1774,8 @@
       // 选中的分辨率
       // window.activePhoneSize = window.currentPhoneSize;
 
-      function getPhoneSizeList() {
-        return $.ajax({
+      async function getPhoneSizeList() {
+        const response = await $.ajax({
           url:
             baseUrl + '/api/resources/v5/machine/resolution/getResolvingPower',
           headers: {
@@ -1783,18 +1786,29 @@
           data: {
             userCardId,
           },
-        }).then(function (response) {
-          return response.data.map(function (v) {
-            return {
-              id: v.id,
-              dpi: v.dpi,
-              width: v.width,
-              height: v.high,
-            };
-          });
         });
-      }
 
+        const phoneSizeList = response.data.map(function (v) {
+          return {
+            id: v.id,
+            dpi: v.dpi,
+            width: v.width,
+            height: v.high,
+          };
+        });
+        window.phoneSizeList = phoneSizeList;
+
+        // 关联上当前云机分辨率
+        const currentPhoneSize = phoneSizeList.find(function (v) {
+          return (
+            window.currentPhoneSize &&
+            v.width === window.currentPhoneSize.width &&
+            v.height === window.currentPhoneSize.height &&
+            v.dpi === window.currentPhoneSize.dpi
+          );
+        });
+        window.currentPhoneSize = currentPhoneSize || window.currentPhoneSize;
+      }
       /*
       getPhoneSizeList().then(function (phoneSizeList) {
         window.phoneSizeList = phoneSizeList;
@@ -1812,7 +1826,6 @@
         // return updatePhoneSizeListHtml();
       });
       */
-
       // const phoneSizeListSwiper = new Swiper('#phone-size-list-swiper', {
       //   direction: 'vertical',
       //   slidesPerView: 'auto',
@@ -1845,6 +1858,7 @@
             },
           }),
         );
+        // XXX: 去除了,改为中台发送
         // 通知其他在线端
         // wsss.send(
         //   JSON.stringify({
@@ -1870,6 +1884,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,
+        // );
         window.activePhoneSize = data;
         updatePhoneSizeListHtml();
         // setPhoneSize(data.width, data.height);

+ 27 - 14
static/screenIos/WXtrialInterface.html

@@ -108,11 +108,11 @@
           <div class="menu-btn PictureQuality avit" data-id="3">标清</div>
           <div class="menu-btn PictureQuality" data-id="2">极速</div>
         </div>
-        <!-- <div class="open-set-phone-size-dialog-btn-wrap">
+        <div class="open-set-phone-size-dialog-btn-wrap">
           <div class="menu-btn" id="open-set-phone-size-dialog-btn">
             <span>分辨率</span>
           </div>
-        </div> -->
+        </div>
         <div class="operation">
           <div class="upload" id="showsuss" data-text="uploads">
             <img src="../static/img/wx/shangchuan_icon.png" />
@@ -1554,7 +1554,8 @@
         $('#phone-size-list').html(phoneSizeListItemsHtml);
       }
 
-      $('#open-set-phone-size-dialog-btn').on('click', function (e) {
+      $('#open-set-phone-size-dialog-btn').on('click', async function (e) {
+        !window.phoneSizeList.length && (await getPhoneSizeList());
         window.activePhoneSize = window.currentPhoneSize;
         updatePhoneSizeListHtml();
         $('#set-phone-size-dialog').addClass('show');
@@ -1572,8 +1573,8 @@
       // 选中的分辨率
       // window.activePhoneSize = window.currentPhoneSize;
 
-      function getPhoneSizeList() {
-        return $.ajax({
+      async function getPhoneSizeList() {
+        const response = await $.ajax({
           url:
             baseUrl + '/api/resources/v5/machine/resolution/getResolvingPower',
           headers: {
@@ -1584,16 +1585,28 @@
           data: {
             userCardId,
           },
-        }).then(function (response) {
-          return response.data.map(function (v) {
-            return {
-              id: v.id,
-              dpi: v.dpi,
-              width: v.width,
-              height: v.high,
-            };
-          });
         });
+
+        const phoneSizeList = response.data.map(function (v) {
+          return {
+            id: v.id,
+            dpi: v.dpi,
+            width: v.width,
+            height: v.high,
+          };
+        });
+        window.phoneSizeList = phoneSizeList;
+
+        // 关联上当前云机分辨率
+        const currentPhoneSize = phoneSizeList.find(function (v) {
+          return (
+            window.currentPhoneSize &&
+            v.width === window.currentPhoneSize.width &&
+            v.height === window.currentPhoneSize.height &&
+            v.dpi === window.currentPhoneSize.dpi
+          );
+        });
+        window.currentPhoneSize = currentPhoneSize || window.currentPhoneSize;
       }
       /*
       getPhoneSizeList().then(function (phoneSizeList) {