Преглед изворни кода

feat(分辨率调整): 上报分辨率使用id

zengzhixiang пре 2 година
родитељ
комит
a2f2670df5

+ 1 - 0
pages/index.vue

@@ -3,6 +3,7 @@
     <div>
       <div>
         <v-btn to="/inspire" nuxt>inspire</v-btn>
+        <v-btn to="/phone" nuxt>phoneList</v-btn>
       </div>
     </div>
     <div class="">{{ FILE_PREFIX }}</div>

+ 102 - 0
pages/phone/_id.vue

@@ -0,0 +1,102 @@
+<template>
+  <div class="disk"></div>
+</template>
+
+<script>
+import qs from 'qs';
+export default {
+  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,
+        },
+      )}`;
+      // console.log(url);
+      redirect(url);
+      // window.open(url, '_self');
+    },
+  ],
+  data() {
+    return {
+      // diskInfo: null,
+    };
+  },
+  async fetch() {
+    // await this.getDiskInfo(this.$route.params.id);
+    // this.openDisk();
+  },
+  methods: {
+    // async getDiskInfo(userCardId) {
+    //   const res = await this.$axios.$get(
+    //     '/resources/v5/client/disk/info/userCard/single',
+    //     {
+    //       params: {
+    //         userCardId,
+    //       },
+    //     },
+    //   );
+    //   this.diskInfo = res.data;
+    // },
+    // openDisk() {
+    //   const {
+    //     userCardId,
+    //     userName,
+    //     room,
+    //     buyVipType,
+    //     sourceType,
+    //     authPhone,
+    //     validTime,
+    //   } = this.diskInfo;
+    //   const token = this.$auth.strategy.token.get();
+    //   const url = `/screenIos/WXtrialInterface.html${qs.stringify(
+    //     {
+    //       userCardId,
+    //       username: userName,
+    //       token,
+    //       rm: room,
+    //       mealType: buyVipType,
+    //       sourceType,
+    //       authPhone,
+    //       validTime,
+    //     },
+    //     {
+    //       addQueryPrefix: true,
+    //     },
+    //   )}`;
+    //   window.open(url);
+    // },
+  },
+};
+</script>

+ 37 - 0
pages/phone/index.vue

@@ -0,0 +1,37 @@
+<template>
+  <div class="">
+    <div class="disk-list">
+      <div v-for="item in diskList" :key="item.id" class="disk-item">
+        <v-btn
+          :to="{
+            name: 'phone-id',
+            params: {
+              id: item.id,
+            },
+          }"
+          >{{ item.diskName }}</v-btn
+        >
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+export default {
+  data() {
+    return {
+      diskList: [],
+    };
+  },
+  async fetch() {
+    await this.getDiskList();
+  },
+  methods: {
+    async getDiskList() {
+      const res = await this.$axios.$get('/resources/v5/client/disk/info');
+      this.diskList = res.data.diskInfo;
+    },
+  },
+};
+</script>
+

+ 1 - 0
plugins/auth.js

@@ -1,5 +1,6 @@
 export default async function ({ $auth, query, error }) {
   if (query.token) {
+    console.log("🚀 ~ file: auth.js ~ line 3 ~ query.token", query.token)
     // 请求携带了token
     try {
       await $auth.setUserToken(query.token);

+ 1 - 0
plugins/axios.js

@@ -8,6 +8,7 @@ export default function ({ $axios, $auth, redirect }) {
     return config;
   });
   $axios.onResponse(async (response) => {
+    console.log("🚀 ~ file: axios.js ~ line 11 ~ $axios.onResponse ~ response", response)
     if (Object.prototype.toString.call(response.data) === '[object Object]') {
       if ([6013, 6014].includes(response.data.status)) {
         // await $auth.logout();

+ 5 - 2
static/screenAndroid/WXdraw.js

@@ -163,8 +163,11 @@ function doConnectDirectives() {
       return;
     }
     if (result.type === 'getPhoneSize') {
-      console.log(result);
-      window.currentPhoneSize = {
+      // console.log(result);
+      const data = window.phoneSizeList.find(function (v) {
+        return v.width === result.data.width && v.height === result.data.height;
+      });
+      window.currentPhoneSize = data || {
         width: result.data.width,
         height: result.data.height,
       };

+ 7 - 0
static/screenAndroid/WXtrialInterface.html

@@ -52,6 +52,7 @@
         class="phone-size-item {{? value.width === it.active.width && value.height === it.active.height }}active{{?}}"
         data-width="{{= value.width }}"
         data-height="{{= value.height }}"
+        data-id="{{= value.id }}""
       >
         <span>{{= value.width }}x{{= value.height }}</span>
       </div>
@@ -1639,6 +1640,10 @@
 
       getPhoneSizeList().then(function (phoneSizeList) {
         window.phoneSizeList = phoneSizeList;
+        const currentPhoneSize = window.phoneSizeList.find(function (v) {
+          return v.width ===  window.currentPhoneSize.width && v.height ===  window.currentPhoneSize.height;
+        });
+        window.currentPhoneSize = currentPhoneSize ||  window.currentPhoneSize
         return updatePhoneSizeListHtml();
       });
 
@@ -1662,6 +1667,7 @@
             userCardId: window.userCardId,
             width: config.width,
             height: config.height,
+            resolvingPowerId: config.id,
           },
         });
         wsss.send(
@@ -1678,6 +1684,7 @@
             type: 'forwardMsg',
             data: {
               code: 'phoneSizeChange',
+              id: config.id,
               width: config.width,
               height: config.height,
               desc: '分辨率修改', // 可选

+ 16 - 12
static/screenIos/WXdraw.js

@@ -136,8 +136,9 @@ function doConnectDirectives() {
         return;
       }
       if (result.data.code === 'phoneSizeChange') {
-        console.log(result.data);
+        // console.log(result.data);
         window.currentPhoneSize = {
+          id: result.data.id,
           width: result.data.width,
           height: result.data.height,
         };
@@ -176,8 +177,11 @@ function doConnectDirectives() {
       return;
     }
     if (result.type === 'getPhoneSize') {
-      console.log(result);
-      window.currentPhoneSize = {
+      // console.log(result);
+      const data = window.phoneSizeList.find(function (v) {
+        return v.width === result.data.width && v.height === result.data.height;
+      });
+      window.currentPhoneSize = data || {
         width: result.data.width,
         height: result.data.height,
       };
@@ -249,9 +253,9 @@ var draw_graph = function (graphType) {
     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 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) {
@@ -286,9 +290,9 @@ var draw_graph = function (graphType) {
     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 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 =
@@ -326,9 +330,9 @@ var draw_graph = function (graphType) {
     }
     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 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 =

+ 19 - 12
static/screenIos/WXtrialInterface.html

@@ -55,6 +55,7 @@
         class="phone-size-item {{? value.width === it.active.width && value.height === it.active.height }}active{{?}}"
         data-width="{{= value.width }}"
         data-height="{{= value.height }}"
+        data-id="{{= value.id }}""
       >
         <span>{{= value.width }}x{{= value.height }}</span>
       </div>
@@ -1389,6 +1390,7 @@
       window.phoneSizeList = [];
       // 当前生效的分辨率
       window.currentPhoneSize = {
+        // id: 1,
         width: 720,
         height: 1280,
       };
@@ -1397,36 +1399,35 @@
 
       function getPhoneSizeList() {
         return $.ajax({
-          url: baseUrl + '/api/public/config/switch/getValue/toJSONObject',
+          url:
+            baseUrl + '/api/resources/v5/machine/resolution/getResolvingPower',
           headers: {
             Authorization: token,
           },
           type: 'get',
           dataType: 'json',
           data: {
-            configKey: 'cloud_phone_resolving_power',
+            userCardId,
+            // configKey: 'cloud_phone_resolving_power',
           },
         }).then(function (response) {
           return response.data.map(function (v) {
             return {
+              id: v.id,
+              dpi: v.dpi,
               width: v.width || v.abscissa,
-              height: v.height || v.ordinate,
+              height: v.height || v.ordinate || v.high,
             };
           });
-          // [
-          //   // { width: 320, height: 240 },
-          //   // { width: 640, height: 480 },
-          //   { width: 375, height: 812 },
-          //   { width: 720, height: 1280 },
-
-          //   // { width: 1280, height: 720 },
-          //   // { width: 1080, height: 1920 },
-          // ];
         });
       }
 
       getPhoneSizeList().then(function (phoneSizeList) {
         window.phoneSizeList = phoneSizeList;
+        const currentPhoneSize = window.phoneSizeList.find(function (v) {
+          return v.width ===  window.currentPhoneSize.width && v.height ===  window.currentPhoneSize.height;
+        });
+        window.currentPhoneSize = currentPhoneSize ||  window.currentPhoneSize
         return updatePhoneSizeListHtml();
       });
 
@@ -1437,6 +1438,7 @@
       //   centeredSlides: true,
       // });
       function setPhoneSize(config) {
+        // 上报分辨率
         $.ajax({
           url:
             baseUrl +
@@ -1450,8 +1452,10 @@
             userCardId: window.userCardId,
             width: config.width,
             height: config.height,
+            resolvingPowerId: config.id,
           },
         });
+        // 修改云机分辨率
         wsss.send(
           JSON.stringify({
             type: 'setPhoneSize',
@@ -1461,11 +1465,13 @@
             },
           }),
         );
+        // 通知其他在线端
         wsss.send(
           JSON.stringify({
             type: 'forwardMsg',
             data: {
               code: 'phoneSizeChange',
+              id: config.id,
               width: config.width,
               height: config.height,
               desc: '分辨率修改', // 可选
@@ -1482,6 +1488,7 @@
       // });
       $('#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);