Procházet zdrojové kódy

Merge branch 'develop' of Software/android-cloud-H5 into release/v5.4.0

zengzhixiang před 2 roky
rodič
revize
62714a2734

+ 4 - 0
.env.development

@@ -19,3 +19,7 @@ UMENG_DATASOURCES_APP_KEY = "62ad961905844627b5b8638c"
 
 # 百度统计
 BAIDU_TONGJI_KEY = "fb2fdf29d47485e36ea2ec253bf6ac06"
+
+SZX_APP_IOS_SCHEME = "shuangzixingiOSAppTest"
+
+SZX_APP_ANDROID_SCHEME = "opengeminiapp"

+ 5 - 0
.env.production

@@ -16,3 +16,8 @@ UMENG_DATASOURCES_APP_KEY = "62ad961905844627b5b8638c"
 
 # 百度统计
 BAIDU_TONGJI_KEY = "fb2fdf29d47485e36ea2ec253bf6ac06"
+
+
+SZX_APP_IOS_SCHEME = "shuangzixingiOSApp"
+
+SZX_APP_ANDROID_SCHEME = "opengeminiapp"

+ 4 - 0
.env.test

@@ -17,3 +17,7 @@ UMENG_DATASOURCES_APP_KEY = "62ad961905844627b5b8638c"
 
 # 百度统计
 BAIDU_TONGJI_KEY = "fb2fdf29d47485e36ea2ec253bf6ac06"
+
+SZX_APP_IOS_SCHEME = "shuangzixingiOSAppTest"
+
+SZX_APP_ANDROID_SCHEME = "opengeminiapp"

+ 4 - 0
.env.uat

@@ -17,3 +17,7 @@ UMENG_DATASOURCES_APP_KEY = "62ad961905844627b5b8638c"
 
 # 百度统计
 BAIDU_TONGJI_KEY = "fb2fdf29d47485e36ea2ec253bf6ac06"
+
+SZX_APP_IOS_SCHEME = "shuangzixingiOSAppTest"
+
+SZX_APP_ANDROID_SCHEME = "opengeminiapp"

+ 138 - 46
pages/activity/invite-user/index.vue

@@ -24,8 +24,7 @@
         <v-btn class="share-button" rounded @click="share()">
           <template v-if="!($userAgent.isSzx || $userAgent.isSzxBrowser)"
             >复制链接</template
-          >分享好友赚<template v-if="type === 1">星币</template
-          ><template v-else-if="type === 2">手机时长</template>
+          >分享好友
         </v-btn>
         <!-- <button @click="share()">邀请</button> -->
       </div>
@@ -54,43 +53,74 @@
     </div>
 
     <div v-if="type === 2" class="box box3">
-      <div class="box-header">收益明细</div>
+      <div class="box-header">激活码明细</div>
       <div class="box-main">
-        <table class="w-full code-table">
-          <thead class="text-left text-sm whitespace-nowrap break-normal">
-            <tr>
-              <th class="w-120px">获得的时间</th>
-              <th>激活码编号</th>
-              <th class="w-60px">使用状态</th>
-            </tr>
-          </thead>
-          <tbody class="text-xs">
-            <tr v-for="(item, index) in myActivationCode" :key="index">
-              <td class="whitespace-nowrap break-normal">
-                {{ item.createTime }}
-              </td>
-              <td class="whitespace-nowrap break-normal">
-                <div class="flex">
-                  <span>{{ item.activationCode }} </span
-                  ><span class="ml-auto">|</span><v-btn
-                    text
-                    small
-                    color="#991AD2"
-                    class="copy-btn"
-                    @click="copyCode(item)"
-                    >复制</v-btn
-                  >
-                </div>
-              </td>
-              <td class="whitespace-nowrap break-normal text-right">
-                <span v-if="item.activationUse" style="color: #dd1b0d"
-                  >已使用</span
-                >
-                <span v-else>未使用</span>
-              </td>
-            </tr>
-          </tbody>
-        </table>
+        <div class="code-table">
+          <div class="table-header">
+            <table class="w-full">
+              <colgroup>
+                <col class="time-col" />
+                <col class="code-col" />
+                <col class="status-col" />
+              </colgroup>
+              <thead class="text-left text-sm whitespace-nowrap break-normal">
+                <tr>
+                  <th class="">获得的时间</th>
+                  <th>激活码编号</th>
+                  <th class="">使用状态</th>
+                </tr>
+              </thead>
+            </table>
+          </div>
+          <div class="table-body">
+            <table class="w-full">
+              <colgroup>
+                <col class="time-col" />
+                <col class="code-col" />
+                <col class="status-col" />
+              </colgroup>
+              <tbody class="text-xs">
+                <tr v-for="(item, index) in myActivationCode" :key="index">
+                  <td class="whitespace-nowrap break-normal">
+                    {{ item.createTime | formatDate('MM月DD日 HH:mm:ss') }}
+                  </td>
+                  <td class="whitespace-nowrap break-normal">
+                    <div class="flex">
+                      <span class="font-mono"
+                        >{{ item.activationCode | activationCodeMask }} </span
+                      ><span class="mx-1">|</span
+                      ><v-btn
+                        text
+                        small
+                        color="#991AD2"
+                        class="copy-btn"
+                        @click="copyCode(item)"
+                        >复制</v-btn
+                      >
+                    </div>
+                  </td>
+                  <td class="whitespace-nowrap break-normal text-right">
+                    <span v-if="item.activationUse" style="color: #dd1b0d"
+                      >已使用</span
+                    >
+                    <span v-else>未使用</span>
+                  </td>
+                </tr>
+              </tbody>
+            </table>
+            <div
+              v-intersect.quiet="codeLoadMoreIntersect"
+              class="flex item-center justify-center"
+            >
+              <!-- <v-progress-circular indeterminate  ></v-progress-circular> -->
+              <v-btn :loading="codeIsLoading" text small>
+                <template v-if="codeIsLoading">加载中</template>
+                <template v-else-if="codeHasMore">加载更多</template>
+                <template v-else>没有更多</template>
+              </v-btn>
+            </div>
+          </div>
+        </div>
         <!-- <div class="code-list">
           <div
             v-for="(item, index) in 10"
@@ -147,7 +177,11 @@ import * as clipboard from 'clipboard-polyfill/text';
 export default {
   // auth: false,
   name: 'InviteUser',
-  filters: {},
+  filters: {
+    activationCodeMask(value) {
+      return value.replace(/(?<=^.{4})(.*)(?=.{4}$)/, '***');
+    },
+  },
   // async asyncData({ $axios }) {
   //   // 页面初始化前触发
   //   const res = await $axios.$get(
@@ -175,6 +209,13 @@ export default {
       },
       activityRules: '',
       myActivationCode: [],
+      myCodeFrom: {
+        actibityId: null,
+        pageNum: 1,
+        pageSize: 8,
+      },
+      codeTotal: -1,
+      codeIsLoading: false,
     };
   },
   async fetch() {
@@ -184,7 +225,7 @@ export default {
       this.$native.setShareInfo(this.shareInfo);
       await Promise.all([
         this.getActivityRules(),
-        this.type === 2 && this.getMyActivationCode(),
+        this.type === 2 && this.getMyActivationCode(this.myCodeFrom),
       ]);
     } catch (error) {
       this.$toast.error(error.message);
@@ -200,6 +241,12 @@ export default {
     // },
   },
   computed: {
+    codeHasMore() {
+      return (
+        this.codeTotal < 0 ||
+        this.myCodeFrom.pageNum * this.myCodeFrom.pageSize < this.codeTotal
+      );
+    },
     dataList() {
       switch (this.type) {
         case 1: {
@@ -302,12 +349,33 @@ export default {
       );
       // res.data.type = 2;
       this.data = res.data;
+      this.myCodeFrom.actibityId = res.data.activityId;
     },
-    async getMyActivationCode() {
-      const res = await this.$axios.$get(
-        '/activity/v1/inviteUser/orderRelation/myActivationCode',
-      );
-      this.myActivationCode = res.data.list;
+    async getMyActivationCode(params) {
+      try {
+        this.codeIsLoading = true;
+
+        const res = await this.$axios.$get(
+          '/activity/v1/inviteUser/orderRelation/myActivationCode',
+          {
+            params,
+          },
+        );
+        this.codeTotal = res.data.total;
+
+        this.myActivationCode.push(
+          ...(res.data.list ?? []),
+          // ...Array.from({ length: 8 }).fill({
+          //   createTime: '2022-08-01 14:33:11',
+          //   activationCode: 'XXXXXXXXXXXXXXXXXXX',
+          //   activationUse: 1,
+          // }),
+        );
+
+        this.myCodeFrom = params;
+      } finally {
+        this.codeIsLoading = false;
+      }
     },
     async share() {
       // console.log(this);
@@ -336,7 +404,7 @@ export default {
         this.$native.share(this.shareInfo);
       } else {
         // 浏览器环境
-        await clipboard.writeText(`${this.shareInfo.gotoUrl} 唔即云手机`);
+        await clipboard.writeText(`${this.shareInfo.link} 唔即云手机`);
         // throw new Error('1231');
         this.$toast.success('链接复制成功');
       }
@@ -365,6 +433,14 @@ export default {
       await clipboard.writeText(item.activationCode);
       this.$toast.success('复制成功');
     },
+    codeLoadMoreIntersect(event) {
+      if (event[0].isIntersecting && this.codeHasMore && !this.codeIsLoading) {
+        this.getMyActivationCode({
+          ...this.myCodeFrom,
+          pageNum: this.myCodeFrom.pageNum + 1,
+        });
+      }
+    },
   },
 };
 </script>
@@ -496,6 +572,17 @@ export default {
   }
 }
 .code-table {
+  .table-body {
+    max-height: 30px * 8;
+    overflow-y: auto;
+  }
+  .time-col {
+    width: 120px;
+  }
+  .status-col {
+    width: 60px;
+  }
+
   // width: 100%;
   tr {
     height: 30px;
@@ -505,6 +592,11 @@ export default {
     height: 30px;
     color: #333;
   }
+  // tbody {
+  //   // max-height: 200px;
+  //   // overflow-y: auto;
+  //   // display: block;
+  // }
   .copy-btn {
     min-width: 0 !important;
     height: auto !important;

+ 101 - 0
pages/customer-service.vue

@@ -0,0 +1,101 @@
+<template lang="">
+  <div></div>
+</template>
+<script>
+export default {
+  head() {
+    return {
+      script: [
+        {
+          src: 'https://qiyukf.com/script/98112bcf552907c28ee450c6a58269c3.js',
+          async: true,
+          callback: () => {
+            // console.log(window.ysf);
+            this.init(window.ysf);
+          },
+        },
+      ],
+    };
+  },
+  computed: {
+    isAutoOpen() {
+      return this.$route.query.autoopen === 'true';
+    },
+    isOnunread() {
+      return this.$route.query.onunread === 'true';
+    },
+  },
+  mounted() {},
+  methods: {
+    async init(ysf) {
+      this.ysf = ysf;
+      // console.log(ysf);
+
+      await new Promise((resolve, reject) => {
+        ysf('onready', resolve);
+      });
+
+      await new Promise((resolve, reject) => {
+        ysf('config', {
+          uid: String(this.$auth.user.id),
+          name: this.$auth.user.userName,
+          mobile: this.$auth.user.phone,
+          email: this.$auth.user.email,
+          data: JSON.stringify([
+            { key: 'real_name', value: this.$auth.user.userName },
+            { key: 'mobile_phone', hidden: true, value: this.$auth.user.phone },
+            { key: 'email', value: this.$auth.user.email },
+            // {
+            //   key: 'avatar',
+            //   label: '头像',
+            //   value:
+            //     'https://ysf.qiyukf.net/operation/080659b993a45dd546fbd71efd5ef000',
+            // }, // 访客头像
+            {
+              index: 0,
+              key: 'account',
+              label: '账号',
+              value: this.$auth.user.phone,
+              // href: 'http://example.domain/user/zhangsan',
+            },
+            // { index: 1, key: 'sex', label: '性别', value: '先生' },
+            // {
+            //   index: 5,
+            //   key: 'reg_date',
+            //   label: '注册日期',
+            //   value: '2015-11-16',
+            // },
+            // {
+            //   index: 6,
+            //   key: 'last_login',
+            //   label: '上次登录时间',
+            //   value: '2015-12-22 15:38:54',
+            // },
+          ]),
+          language: 'zh-cn',
+          success: resolve,
+          error: reject,
+        });
+      });
+      if (this.isAutoOpen) {
+        this.open();
+      }
+      if (this.isOnunread) {
+        this.onunread();
+      }
+    },
+    open(data) {
+      this.ysf('open', data);
+    },
+    getUnreadMsg() {
+      const result = this.ysf('getUnreadMsg');
+      console.log(result.total, result.type, result.message);
+    },
+    onunread() {
+      this.ysf('onunread', (result) => {
+        console.log(result.total, result.type, result.message);
+      });
+    },
+  },
+};
+</script>

+ 5 - 3
plugins/callapp.js

@@ -1,12 +1,14 @@
 import CallApp from 'callapp-lib';
 
 export default function ({ $userAgent }, i) {
-  const scheme = $userAgent.isIos ? 'szxiOSApp' : 'opengeminiapp';
+  const szxScheme = $userAgent.isIos
+    ? process.env.SZX_APP_IOS_SCHEME
+    : process.env.SZX_APP_ANDROID_SCHEME;
   i(
     'callSzx',
     new CallApp({
-      scheme: { protocol: scheme, host: '' },
-      intent: { package: 'com.gemini.cloud.client', scheme },
+      scheme: { protocol: szxScheme, host: '' },
+      intent: { package: 'com.gemini.cloud.client', szxScheme },
       timeout: 2000,
       yingyongbao:
         'https://a.app.qq.com/o/simple.jsp?pkgname=com.gemini.cloud.client',

+ 1 - 0
plugins/jweixin.js

@@ -1,4 +1,5 @@
 import wx from 'jweixin-module';
+console.log("🚀 ~ file: jweixin.js ~ line 2 ~ wx", wx)
 
 // import Vue from 'vue';
 // import { getConfig } from '~/api/wx/index.js';

+ 2 - 2
plugins/native.js

@@ -1,4 +1,4 @@
-export default function ({ $userAgent }, i) {
+export default function ({ $userAgent, $wx }, i) {
   // const before = () => {
   //   if ($userAgent.isApp) {
   //     return;
@@ -48,7 +48,7 @@ export default function ({ $userAgent }, i) {
       }
 
       if ($userAgent.isMiniProgram) {
-        this.$wx.miniProgram.postMessage({
+        $wx?.miniProgram?.postMessage({
           data: {
             action: 'updateAppMessageShareData',
             params: {

+ 119 - 88
static/screenAndroid/WXdraw.js

@@ -22,7 +22,7 @@ url = url.split('/');
 var parameters = GetRequest();
 var videoWidth, videoHeight;
 var isControl = false; // 是否是观看模式
-changIsControl(false);
+changIsControl(true);
 var isAuth = parameters['authPhone']; // 是否是获取的云手机
 
 var wsss,
@@ -122,70 +122,54 @@ function doConnectDirectives() {
        * @type {string} isAuth 当前云机类型 - huo: 获取的云机,none: 自己的云机
        * @type {string} username 当前登录的双子星账号username
        */
-      switch (String(result.data.code)) {
-        case '3000': {
-          // 被询问控制
-          if (isControl) {
-            // 回复有控制
+
+      if (result.data.username !== username) {
+        switch (String(result.data.code)) {
+          case '3000': {
+            if (isControl) {
+              // 回复有控制
+              wsss.send(
+                JSON.stringify({
+                  type: 'forwardMsg',
+                  data: {
+                    code: '4000',
+                    username,
+                    desc: '有控制', // 可选
+                  },
+                }),
+              );
+              return;
+            }
+            // 回复有观看
             wsss.send(
               JSON.stringify({
                 type: 'forwardMsg',
                 data: {
-                  code: '4000',
+                  code: '4100',
                   username,
-                  desc: '有控制', // 可选
+                  desc: '有观看', // 可选
                 },
               }),
             );
             return;
           }
-          // 回复有观看
-          wsss.send(
-            JSON.stringify({
-              type: 'forwardMsg',
-              data: {
-                code: '4100',
-                username,
-                desc: '有观看', // 可选
-              },
-            }),
-          );
-          return;
-        }
-        case '4100': {
-          // 收到观看回复
-          changIsControl(true);
-          return;
-        }
-        case '4000': {
-          // 收到控制权回复
-
-          // 同账号,共同控制
-          if (result.data.username === username) {
-            changIsControl(true);
-            return;
-          }
-
-          // 不同账号
+          case '4000': {
+            if (isAuth === 'huo') {
+              $.confirm(
+                '授权方已收回控制权,您进入观看屏幕模式',
+                function () {
+                  //点击确认后的回调函数
+                  changIsControl(false);
+                },
+                function () {
+                  changIsControl(false);
+                  //点击取消后的回调函数
+                  quit();
+                },
+              );
+              return;
+            }
 
-          // 当前是获取方
-          if (isAuth === 'huo') {
-            $.confirm(
-              '授权方已收回控制权,您进入观看屏幕模式',
-              function () {
-                //点击确认后的回调函数
-                changIsControl(false);
-              },
-              function () {
-                changIsControl(false);
-                //点击取消后的回调函数
-                quit();
-              },
-            );
-            return;
-          }
-          if (!isControl) {
-            // 当前是授权方切没有控制权
             $.confirm(
               '当前云手机正在授控,是否请求获取云手机控制权?',
               function () {
@@ -206,32 +190,38 @@ function doConnectDirectives() {
                 changIsControl(false);
               },
             );
+
             return;
           }
-          return;
-        }
-        case '5000': {
-          if (isControl && isAuth === 'huo') {
-            $.confirm(
-              '授权方已收回控制权,您进入观看屏幕模式',
-              function () {
-                //点击确认后的回调函数
-                changIsControl(false);
-              },
-              function () {
-                changIsControl(false);
-                //点击取消后的回调函数
-                quit();
-              },
-            );
+          case '5000': {
+            // if (result.data.username === username) {
+            //   changIsControl(true);
+            //   return;
+            // }
+            if (isAuth === 'huo') {
+              $.confirm(
+                '授权方已收回控制权,您进入观看屏幕模式',
+                function () {
+                  //点击确认后的回调函数
+                  changIsControl(false);
+                },
+                function () {
+                  changIsControl(false);
+                  //点击取消后的回调函数
+                  quit();
+                },
+              );
+              return;
+            }
+
+            return;
+          }
+          default: {
             return;
           }
-          return;
-        }
-        default: {
-          return;
         }
       }
+      return;
     }
     if (result.type === 'payInitiateEvent') {
       var url = window.location.href;
@@ -265,22 +255,63 @@ function doConnectDirectives() {
     }
     if (result.type === 'getPhoneSize' || result.type === 'setPhoneSize') {
       // console.log(result);
-      const data = window.phoneSizeList.find(function (v) {
-        return (
-          v.width === Math.min(result.data.width, result.data.height) &&
-          v.height === Math.max(result.data.width, result.data.height) &&
-          v.dpi === result.data.dpi
-        );
-      });
-      window.currentPhoneSize = data || {
-        width: Math.min(result.data.width, result.data.height),
-        height: Math.max(result.data.width, result.data.height),
-        dpi: result.data.dpi,
-      };
+      if (
+        window.currentPhoneSize &&
+        (window.currentPhoneSize.width !==
+          Math.min(result.data.width, result.data.height) ||
+          window.currentPhoneSize.height !==
+            Math.max(result.data.width, result.data.height) ||
+          window.currentPhoneSize.dpi !== result.data.dpi)
+      ) {
+        // 获取到的分辨率与当前分辨率不符
 
-      if (result.type === 'setPhoneSize') {
-        lastSetPhone = Date.now();
+        const data = window.phoneSizeList.find(function (v) {
+          return (
+            v.width === Math.min(result.data.width, result.data.height) &&
+            v.height === Math.max(result.data.width, result.data.height) &&
+            v.dpi === result.data.dpi
+          );
+        });
+        window.currentPhoneSize = data || {
+          width: Math.min(result.data.width, result.data.height),
+          height: Math.max(result.data.width, result.data.height),
+          dpi: result.data.dpi,
+        };
+
+        if (result.type === 'setPhoneSize') {
+          lastSetPhone = Date.now();
+        }
+        // if (result.type === 'getPhoneSize') {
+        // 上报给后端
+        $.ajax({
+          url:
+            baseUrl +
+            '/api/resources/v5/machine/resolution/operationResolvingPower',
+          headers: {
+            Authorization: token,
+          },
+          type: 'post',
+          dataType: 'json',
+          contentType: 'application/json; charset=UTF-8',
+          data: JSON.stringify({
+            userCardId: window.userCardId,
+            resolvingPowerId: window.currentPhoneSize.id,
+          }),
+        });
       }
+      // }
+
+      updateDB(db, storeName, {
+        id: userCardId,
+        socketURL: socketURL,
+        cUrl: cUrl,
+        cardToken: cardToken,
+        resolvingPower: resolvingPower,
+        width: window.currentPhoneSize.width,
+        height: window.currentPhoneSize.height,
+        dpi: window.currentPhoneSize.dpi,
+      });
+
       return;
     }
   };

+ 31 - 29
static/screenAndroid/WXtrialInterface.html

@@ -359,6 +359,13 @@
             cUrl = request.result.cUrl;
             cardToken = request.result.cardToken;
             resolvingPower = request.result.resolvingPower;
+
+            window.currentPhoneSize = {
+              width: request.result.width,
+              height: request.result.height,
+              dpi: request.result.dpi,
+            };
+
             doConnectBusiness();
             doConnectDirectives();
           } else {
@@ -494,6 +501,9 @@
                     cUrl: cUrl,
                     cardToken: res.data.cardToken,
                     resolvingPower: res.data.resolvingPower,
+                    width: res.data.width,
+                    height: res.data.high,
+                    dpi: res.data.dpi,
                   });
                 } else {
                   updateDB(db, storeName, {
@@ -502,8 +512,23 @@
                     cUrl: cUrl,
                     cardToken: res.data.cardToken,
                     resolvingPower: res.data.resolvingPower,
+                    width: res.data.width,
+                    height: res.data.high,
+                    dpi: res.data.dpi,
                   });
                 }
+                const data = window.phoneSizeList.find(function (v) {
+                  return (
+                    v.width === res.data.width &&
+                    v.height === res.data.height &&
+                    v.dpi === res.data.dpi
+                  );
+                });
+                window.currentPhoneSize = data || {
+                  width: res.data.width,
+                  height: res.data.height,
+                  dpi: res.data.dpi,
+                };
               } else {
                 $.toast('网络异常,请稍后重试', 'text');
                 setTimeout(() => {
@@ -907,7 +932,7 @@
         if (!isControl) {
           return;
         }
-        stopManyClick(() => {
+        stopManyClick(function () {
           new Promise((resolve, reject) => {
             if (window.navigator.clipboard) {
               window.navigator.clipboard
@@ -937,7 +962,7 @@
             }
           }).then(function () {
             $('.box-shear-plate').empty();
-            $.ajax({
+            return $.ajax({
               url: baseUrl + '/api/public/v5/shear/content',
               headers: {
                 Authorization: token,
@@ -1741,11 +1766,6 @@
       // 分辨率列表
       window.phoneSizeList = [];
       // 当前生效的分辨率
-      window.currentPhoneSize = {
-        // id: 1,
-        width: 720,
-        height: 1280,
-      };
       // 选中的分辨率
       // window.activePhoneSize = window.currentPhoneSize;
 
@@ -1778,13 +1798,13 @@
         // window.phoneSizeListBack = phoneSizeList; // 备份下数据,用户横竖切换时。
         const currentPhoneSize = window.phoneSizeList.find(function (v) {
           return (
-            v.width ===
-              window.currentPhoneSize[resolving ? 'width' : 'height'] &&
-            v.height ===
-              window.currentPhoneSize[resolving ? 'height' : 'width'] &&
+            window.currentPhoneSize &&
+            v.width === window.currentPhoneSize.width &&
+            v.height === window.currentPhoneSize.height &&
             v.dpi === window.currentPhoneSize.dpi
           );
         });
+
         window.currentPhoneSize = currentPhoneSize || window.currentPhoneSize;
         // return updatePhoneSizeListHtml();
       });
@@ -1836,24 +1856,6 @@
         //   }),
         // );
         // 上报分辨率
-        $.ajax({
-          url:
-            baseUrl +
-            '/api/resources/v5/machine/resolution/operationResolvingPower',
-          headers: {
-            Authorization: token,
-          },
-          type: 'post',
-          dataType: 'json',
-          contentType: 'application/json; charset=UTF-8',
-          data: JSON.stringify({
-            userCardId: window.userCardId,
-            resolvingPowerId: config.id,
-            // width: config.width,
-            // height: config.height,
-            // dpi: config.dpi,
-          }),
-        });
         window.currentPhoneSize = config;
       }
       // wsss.addEventListener('message', function (event) {

+ 119 - 93
static/screenIos/WXdraw.js

@@ -21,7 +21,7 @@ var parameters = GetRequest();
 
 var videoWidth, videoHeight;
 var isControl = false; // 是否是观看模式
-changIsControl(false);
+changIsControl(true);
 var isAuth = parameters['authPhone']; // 是否是获取的云手机
 var wsss;
 var errorTime = 0;
@@ -130,70 +130,54 @@ function doConnectDirectives() {
        * @type {string} isAuth 当前云机类型 - huo: 获取的云机,none: 自己的云机
        * @type {string} username 当前登录的双子星账号username
        */
-      switch (String(result.data.code)) {
-        case '3000': {
-          // 被询问控制
-          if (isControl) {
-            // 回复有控制
+
+      if (result.data.username !== username) {
+        switch (String(result.data.code)) {
+          case '3000': {
+            if (isControl) {
+              // 回复有控制
+              wsss.send(
+                JSON.stringify({
+                  type: 'forwardMsg',
+                  data: {
+                    code: '4000',
+                    username,
+                    desc: '有控制', // 可选
+                  },
+                }),
+              );
+              return;
+            }
+            // 回复有观看
             wsss.send(
               JSON.stringify({
                 type: 'forwardMsg',
                 data: {
-                  code: '4000',
+                  code: '4100',
                   username,
-                  desc: '有控制', // 可选
+                  desc: '有观看', // 可选
                 },
               }),
             );
             return;
           }
-          // 回复有观看
-          wsss.send(
-            JSON.stringify({
-              type: 'forwardMsg',
-              data: {
-                code: '4100',
-                username,
-                desc: '有观看', // 可选
-              },
-            }),
-          );
-          return;
-        }
-        case '4100': {
-          // 收到观看回复
-          changIsControl(true);
-          return;
-        }
-        case '4000': {
-          // 收到控制权回复
-
-          // 同账号,共同控制
-          if (result.data.username === username) {
-            changIsControl(true);
-            return;
-          }
-
-          // 不同账号
+          case '4000': {
+            if (isAuth === 'huo') {
+              $.confirm(
+                '授权方已收回控制权,您进入观看屏幕模式',
+                function () {
+                  //点击确认后的回调函数
+                  changIsControl(false);
+                },
+                function () {
+                  changIsControl(false);
+                  //点击取消后的回调函数
+                  quit();
+                },
+              );
+              return;
+            }
 
-          // 当前是获取方
-          if (isAuth === 'huo') {
-            $.confirm(
-              '授权方已收回控制权,您进入观看屏幕模式',
-              function () {
-                //点击确认后的回调函数
-                changIsControl(false);
-              },
-              function () {
-                changIsControl(false);
-                //点击取消后的回调函数
-                quit();
-              },
-            );
-            return;
-          }
-          if (!isControl) {
-            // 当前是授权方切没有控制权
             $.confirm(
               '当前云手机正在授控,是否请求获取云手机控制权?',
               function () {
@@ -214,37 +198,38 @@ function doConnectDirectives() {
                 changIsControl(false);
               },
             );
+
             return;
           }
-          return;
-        }
-        case '5000': {
-          // if (result.data.username === username) {
-          //   changIsControl(true);
-          //   return;
-          // }
-          if (isControl && isAuth === 'huo') {
-            $.confirm(
-              '授权方已收回控制权,您进入观看屏幕模式',
-              function () {
-                //点击确认后的回调函数
-                changIsControl(false);
-              },
-              function () {
-                changIsControl(false);
-                //点击取消后的回调函数
-                quit();
-              },
-            );
+          case '5000': {
+            // if (result.data.username === username) {
+            //   changIsControl(true);
+            //   return;
+            // }
+            if (isAuth === 'huo') {
+              $.confirm(
+                '授权方已收回控制权,您进入观看屏幕模式',
+                function () {
+                  //点击确认后的回调函数
+                  changIsControl(false);
+                },
+                function () {
+                  changIsControl(false);
+                  //点击取消后的回调函数
+                  quit();
+                },
+              );
+              return;
+            }
+
+            return;
+          }
+          default: {
             return;
           }
-
-          return;
-        }
-        default: {
-          return;
         }
       }
+      return;
     }
     if (result.type === 'payInitiateEvent') {
       var url = window.location.href;
@@ -278,22 +263,63 @@ function doConnectDirectives() {
     }
     if (result.type === 'getPhoneSize' || result.type === 'setPhoneSize') {
       // console.log(result);
-      const data = window.phoneSizeList.find(function (v) {
-        return (
-          v.width === Math.min(result.data.width, result.data.height) &&
-          v.height === Math.max(result.data.width, result.data.height) &&
-          v.dpi === result.data.dpi
-        );
-      });
-      window.currentPhoneSize = data || {
-        width: Math.min(result.data.width, result.data.height),
-        height: Math.max(result.data.width, result.data.height),
-        dpi: result.data.dpi,
-      };
+      if (
+        window.currentPhoneSize &&
+        (window.currentPhoneSize.width !==
+          Math.min(result.data.width, result.data.height) ||
+          window.currentPhoneSize.height !==
+            Math.max(result.data.width, result.data.height) ||
+          window.currentPhoneSize.dpi !== result.data.dpi)
+      ) {
+        // 获取到的分辨率与当前分辨率不符
 
-      if (result.type === 'setPhoneSize') {
-        lastSetPhone = Date.now();
+        const data = window.phoneSizeList.find(function (v) {
+          return (
+            v.width === Math.min(result.data.width, result.data.height) &&
+            v.height === Math.max(result.data.width, result.data.height) &&
+            v.dpi === result.data.dpi
+          );
+        });
+        window.currentPhoneSize = data || {
+          width: Math.min(result.data.width, result.data.height),
+          height: Math.max(result.data.width, result.data.height),
+          dpi: result.data.dpi,
+        };
+
+        if (result.type === 'setPhoneSize') {
+          lastSetPhone = Date.now();
+        }
+        // if (result.type === 'getPhoneSize') {
+        // 上报给后端
+        $.ajax({
+          url:
+            baseUrl +
+            '/api/resources/v5/machine/resolution/operationResolvingPower',
+          headers: {
+            Authorization: token,
+          },
+          type: 'post',
+          dataType: 'json',
+          contentType: 'application/json; charset=UTF-8',
+          data: JSON.stringify({
+            userCardId: window.userCardId,
+            resolvingPowerId: window.currentPhoneSize.id,
+          }),
+        });
       }
+      // }
+
+      updateDB(db, storeName, {
+        id: userCardId,
+        socketURL: socketURL,
+        cUrl: cUrl,
+        cardToken: cardToken,
+        resolvingPower: resolvingPower,
+        width: window.currentPhoneSize.width,
+        height: window.currentPhoneSize.height,
+        dpi: window.currentPhoneSize.dpi,
+      });
+
       return;
     }
   };

+ 33 - 29
static/screenIos/WXtrialInterface.html

@@ -64,7 +64,7 @@
       {{~}}
     </template>
     <template id="template-shear">
-      {{? it.length}}
+      {{? it.length }}
       <div class="title">
         剪贴板
         <div class="btn-clear">清空</div>
@@ -436,6 +436,13 @@
             cUrl = request.result.cUrl;
             cardToken = request.result.cardToken;
             resolvingPower = request.result.resolvingPower;
+
+            window.currentPhoneSize = {
+              width: request.result.width,
+              height: request.result.height,
+              dpi: request.result.dpi,
+            };
+
             doConnectBusiness();
             doConnectDirectives();
           } else {
@@ -513,6 +520,9 @@
                     cUrl: cUrl,
                     cardToken: res.data.cardToken,
                     resolvingPower: res.data.resolvingPower,
+                    width: res.data.width,
+                    height: res.data.high,
+                    dpi: res.data.dpi,
                   });
                 } else {
                   updateDB(db, storeName, {
@@ -521,8 +531,23 @@
                     cUrl: cUrl,
                     cardToken: res.data.cardToken,
                     resolvingPower: res.data.resolvingPower,
+                    width: res.data.width,
+                    height: res.data.high,
+                    dpi: res.data.dpi,
                   });
                 }
+                const data = window.phoneSizeList.find(function (v) {
+                  return (
+                    v.width === res.data.width &&
+                    v.height === res.data.height &&
+                    v.dpi === res.data.dpi
+                  );
+                });
+                window.currentPhoneSize = data || {
+                  width: res.data.width,
+                  height: res.data.height,
+                  dpi: res.data.dpi,
+                };
               } else {
                 $.toast('网络异常,请稍后重试', 'text');
                 setTimeout(() => {
@@ -624,6 +649,9 @@
       });
 
       function showShearPlate() {
+        if (!isControl) {
+          return;
+        }
         stopManyClick(function () {
           new Promise((resolve, reject) => {
             if (window.navigator.clipboard) {
@@ -1543,11 +1571,6 @@
       // 分辨率列表
       window.phoneSizeList = [];
       // 当前生效的分辨率
-      window.currentPhoneSize = {
-        // id: 1,
-        width: 720,
-        height: 1280,
-      };
       // 选中的分辨率
       // window.activePhoneSize = window.currentPhoneSize;
 
@@ -1580,13 +1603,13 @@
         // window.phoneSizeListBack = phoneSizeList; // 备份下数据,用户横竖切换时。
         const currentPhoneSize = window.phoneSizeList.find(function (v) {
           return (
-            v.width ===
-              window.currentPhoneSize[resolving ? 'width' : 'height'] &&
-            v.height ===
-              window.currentPhoneSize[resolving ? 'height' : 'width'] &&
+            window.currentPhoneSize &&
+            v.width === window.currentPhoneSize.width &&
+            v.height === window.currentPhoneSize.height &&
             v.dpi === window.currentPhoneSize.dpi
           );
         });
+
         window.currentPhoneSize = currentPhoneSize || window.currentPhoneSize;
         // return updatePhoneSizeListHtml();
       });
@@ -1639,25 +1662,6 @@
         //   }),
         // );
         // 上报分辨率
-        $.ajax({
-          url:
-            baseUrl +
-            '/api/resources/v5/machine/resolution/operationResolvingPower',
-          headers: {
-            Authorization: token,
-          },
-          type: 'post',
-          dataType: 'json',
-          contentType: 'application/json; charset=UTF-8',
-          data: JSON.stringify({
-            userCardId: window.userCardId,
-            resolvingPowerId: config.id,
-            // width: config.width,
-            // height: config.height,
-            // dpi: config.dpi,
-          }),
-        });
-
         window.currentPhoneSize = config;
       }
       // wsss.addEventListener('message', function (event) {