ソースを参照

Merge branch 'dev-5.3.1' of http://192.168.32.253:3000/Software/android-cloud-H5 into dev-5.3.1

huangxiaojing 2 年 前
コミット
f1f1638f18
共有5 個のファイルを変更した98 個の追加213 個の削除を含む
  1. 2 4
      package-lock.json
  2. 13 0
      pages/test-call-app.vue
  3. 8 31
      plugins/callapp.js
  4. 59 177
      static/screenAndroid/WXtrialInterface.html
  5. 16 1
      static/screenIos/WXtrialInterface.html

+ 2 - 4
package-lock.json

@@ -2527,7 +2527,7 @@
       "version": "2.6.12",
       "resolved": "https://registry.npmmirror.com/core-js/-/core-js-2.6.12.tgz",
       "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==",
-      "deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.",
+      "deprecated": "core-js@<3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.",
       "hasInstallScript": true
     },
     "node_modules/@nuxt/builder": {
@@ -6437,7 +6437,6 @@
       "version": "3.22.7",
       "resolved": "https://registry.npmmirror.com/core-js/-/core-js-3.22.7.tgz",
       "integrity": "sha512-Jt8SReuDKVNZnZEzyEQT5eK6T2RRCXkfTq7Lo09kpm+fHjgGewSbNjV+Wt4yZMhPDdzz2x1ulI5z/w4nxpBseg==",
-      "deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.",
       "hasInstallScript": true
     },
     "node_modules/core-js-compat": {
@@ -16696,8 +16695,7 @@
     "node_modules/stable": {
       "version": "0.1.8",
       "resolved": "https://registry.npmmirror.com/stable/-/stable-0.1.8.tgz",
-      "integrity": "sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w==",
-      "deprecated": "Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility"
+      "integrity": "sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w=="
     },
     "node_modules/stack-trace": {
       "version": "0.0.10",

+ 13 - 0
pages/test-call-app.vue

@@ -11,6 +11,19 @@
         >唤起支付宝扫一扫</v-btn
       >
     </div>
+    <!-- <div class="mt-2">
+      URL Scheme
+      <a :href="$callSzx.generateScheme({ path: '' })">{{
+        $callSzx.generateScheme({ path: '' })
+      }}</a>
+    </div>
+    <div class="mt-2">URL Scheme <a href="szxapp://">szxapp://</a></div>
+    <div class="mt-2 break-words">
+      Intent
+      <a :href="$callSzx.generateIntent({ path: '' })">{{
+        $callSzx.generateIntent({ path: '' })
+      }}</a>
+    </div> -->
   </v-container>
 </template>
 

+ 8 - 31
plugins/callapp.js

@@ -1,21 +1,12 @@
 import CallApp from 'callapp-lib';
 
-export default function (c, i) {
+export default function ({ $userAgent }, i) {
+  const scheme = $userAgent.isIos ? 'szxiOSApp' : 'opengeminiapp';
   i(
     'callSzx',
     new CallApp({
-      scheme: {
-        protocol: 'SZXIosAPP',
-        host: '',
-        // port: 80,
-      },
-      intent: {
-        package: 'com.gemini.cloud.client',
-        // action: '',
-        // category: '',
-        // component: '',
-        scheme: 'SZXIosAPP',
-      },
+      scheme: { protocol: scheme, host: '' },
+      intent: { package: 'com.gemini.cloud.client', scheme },
       timeout: 2000,
       yingyongbao:
         'https://a.app.qq.com/o/simple.jsp?pkgname=com.gemini.cloud.client',
@@ -26,15 +17,8 @@ export default function (c, i) {
   i(
     'callWechat',
     new CallApp({
-      scheme: {
-        protocol: 'weixin',
-        host: '',
-        // port: 80,
-      },
-      intent: {
-        package: 'com.tencent.mm',
-        scheme: 'weixin',
-      },
+      scheme: { protocol: 'weixin', host: '' },
+      intent: { package: 'com.tencent.mm', scheme: 'weixin' },
       timeout: 2000,
       appstore: 'https://apps.apple.com/cn/app/id414478124',
       fallback: 'https://weixin.qq.com',
@@ -43,15 +27,8 @@ export default function (c, i) {
   i(
     'callAlipay',
     new CallApp({
-      scheme: {
-        protocol: 'alipayqr',
-        host: 'platformapi/startapp',
-        // port: 80,
-      },
-      intent: {
-        package: 'com.eg.android.AlipayGphone',
-        scheme: 'alipayqr',
-      },
+      scheme: { protocol: 'alipayqr', host: 'platformapi/startapp' },
+      intent: { package: 'com.eg.android.AlipayGphone', scheme: 'alipayqr' },
       timeout: 2000,
       appstore: 'https://apps.apple.com/cn/app/id333206289',
       fallback: 'https://www.alipay.com',

+ 59 - 177
static/screenAndroid/WXtrialInterface.html

@@ -189,6 +189,7 @@
       src="https://cdn.bootcss.com/vConsole/3.2.0/vconsole.min.js"
     ></script>
     <script src="https://cdn.bootcss.com/jquery-weui/1.2.1/js/jquery-weui.min.js"></script>
+    <script type="text/javascript" src="WXdraw.js"></script>
     <script type="text/javascript" src="jmuxer.js"></script>
     <script type="text/javascript" src="spsParser.js"></script>
     <script
@@ -201,9 +202,9 @@
       var baseUrl = url[0] + '//' + url[2];
 
       var parameters = GetRequest();
-      var token = parameters['token'];
-      var userCardId = parameters['userCardId'];
-      var mealType = parameters['mealType'];
+      var form = {};
+      form.token = parameters['token'];
+      form.userCardId = parameters['userCardId'];
       var videoTimer = null,
         videoTime = 0,
         adType = 0,
@@ -231,92 +232,6 @@
         $('.loading_sceen_pic').attr('src', '../static/img/home_bg_PRO.png');
       }
       initAD();
-      let dbName = parameters['username'],
-        version = 1,
-        storeName = 'usercard';
-      let indexedDB = window.indexedDB;
-      let db, socketURL, cUrl, cardToken, resolvingPower;
-      const request = indexedDB.open(dbName, version);
-      request.onsuccess = function (event) {
-        db = event.target.result; // 数据库对象
-        console.log('数据库打开成功');
-      };
-
-      request.onerror = function (event) {
-        console.log('数据库打开报错');
-      };
-
-      request.onupgradeneeded = function (event) {
-        // 数据库创建或升级的时候会触发
-        console.log('onupgradeneeded');
-        db = event.target.result; // 数据库对象
-        let objectStore;
-        if (!db.objectStoreNames.contains(storeName)) {
-          objectStore = db.createObjectStore(storeName, { keyPath: 'id' }); // 创建表
-        }
-      };
-      // 添加数据
-      function addData(db, storeName, data) {
-        let request = db
-          .transaction([storeName], 'readwrite') // 事务对象 指定表格名称和操作模式("只读"或"读写")
-          .objectStore(storeName) // 仓库对象
-          .add(data);
-
-        request.onsuccess = function (event) {
-          console.log('数据写入成功');
-        };
-
-        request.onerror = function (event) {
-          console.log('数据写入失败');
-          throw new Error(event.target.error);
-        };
-      }
-
-      // 根据id获取数据
-      function getDataByKey(db, storeName, key) {
-        let transaction = db.transaction([storeName]); // 事务
-        let objectStore = transaction.objectStore(storeName); // 仓库对象
-        let request = objectStore.get(key);
-
-        request.onerror = function (event) {
-          connect('add');
-        };
-
-        request.onsuccess = function (event) {
-          console.log('主键查询结果: ', request.result);
-          if (request.result) {
-            socketURL = request.result.socketURL;
-            cUrl = request.result.cUrl;
-            cardToken = request.result.cardToken;
-            resolvingPower = request.result.resolvingPower;
-            doConnectBusiness();
-            doConnectDirectives();
-          } else {
-            connect('add');
-          }
-        };
-      }
-
-      // 根据id修改数
-      function updateDB(db, storeName, data) {
-        let request = db
-          .transaction([storeName], 'readwrite') // 事务对象
-          .objectStore(storeName) // 仓库对象
-          .put(data);
-
-        request.onsuccess = function () {
-          console.log('数据更新成功');
-        };
-
-        request.onerror = function () {
-          console.log('数据更新失败');
-        };
-      }
-
-      // 由于打开indexDB是异步的加个定时器避免 db对象还没获取到值导致 报错
-      setTimeout(() => {
-        getDataByKey(db, storeName, userCardId);
-      }, 1000);
       var isAudioPlay = false;
       if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
         var video = document.getElementById('playerVideo');
@@ -376,72 +291,21 @@
       Module.onRuntimeInitialized = function () {
         isFinish = true;
       };
-      function connect() {
-        $.ajax({
-          url: baseUrl + '/api/resources/user/cloud/connect',
-          type: 'post',
-          data: JSON.stringify({
-            userCardId: Number(userCardId),
-          }),
-          headers: {
-            'content-Type': 'application/json',
-            Authorization: token,
-          },
-          dataType: 'json',
-          async: false,
-          success: function (res) {
-            if (res.status === 0) {
-              if (res.data.internetHttps) {
-                socketURL =
-                  'wss://' +
-                  res.data.internetHttps +
-                  '/plugflow?cardIp=' +
-                  res.data.localIp +
-                  '&token=' +
-                  res.data.cardToken +
-                  '&type=business';
-                cUrl =
-                  'wss://' +
-                  res.data.internetHttps +
-                  '/businessChannel?cardIp=' +
-                  res.data.localIp +
-                  '&token=' +
-                  res.data.cardToken +
-                  '&type=directives';
-                cardToken = res.data.cardToken;
-                resolvingPower = res.data.resolvingPower;
-                doConnectBusiness();
-                doConnectDirectives();
-                if (type === 'add') {
-                  addData(db, storeName, {
-                    id: userCardId,
-                    socketURL: socketURL,
-                    cUrl: cUrl,
-                    cardToken: res.data.cardToken,
-                    resolvingPower: res.data.resolvingPower,
-                  });
-                } else {
-                  updateDB(db, storeName, {
-                    id: userCardId,
-                    socketURL: socketURL,
-                    cUrl: cUrl,
-                    cardToken: res.data.cardToken,
-                    resolvingPower: res.data.resolvingPower,
-                  });
-                }
-              } else {
-                $.toast('网络异常,请稍后重试', 'text');
-              }
-            } else {
-              $.toast('画面异常,请重新进入', 'text');
-              clearInterval(intervaler);
-              quit();
-              ws.close();
-              wsss.close();
-            }
-          },
-        });
-      }
+
+      var isWSS = true;
+      var ip = parameters['ip'];
+      var cardToken = parameters['cardToken'];
+      cardToken = cardToken && decodeURIComponent(cardToken);
+      var appletPushAddress = parameters['appletPushAddress'];
+      var socketURL = isWSS
+        ? 'wss://' +
+          appletPushAddress +
+          '?cardIp=' +
+          ip +
+          '&token=' +
+          cardToken +
+          '&type=business'
+        : 'ws://' + appletPushAddress + '?cardIp=' + ip + '&token=' + cardToken;
 
       var jmuxer = new JMuxer({
         node: 'playerVideo',
@@ -460,7 +324,7 @@
       };
       var ws,
         errorTime = 0;
-
+      doConnect();
       // 节流
       // 设置一个标志
       function throttle(fn, delay) {
@@ -476,7 +340,7 @@
         };
       }
       var intervaler;
-      function doConnectBusiness() {
+      function doConnect() {
         ws = new WebSocket(socketURL);
         ws.binaryType = 'arraybuffer';
         intervaler = setInterval(() => {
@@ -499,7 +363,7 @@
         ws.addEventListener('error', function (event) {
           ws.close();
           clearInterval(intervaler);
-          throttle(doConnectBusiness, 100);
+          throttle(doConnect, 100);
           if (errorTime > 1000) {
             $.toast('画面异常,请重新进入', 'text');
             wsss.close();
@@ -683,7 +547,11 @@
               var checkBuffer = GetScreenState();
               ws.send(checkBuffer);
             } else {
-              connect('update');
+              $.toast('画面异常,请重新进入', 'text');
+              clearInterval(intervaler);
+              quit();
+              ws.close();
+              wsss.close();
             }
           }
           if (input[23] == 0x05) {
@@ -733,6 +601,9 @@
         return false;
       }
 
+      var form = {};
+      form.token = parameters['token'];
+      form.userCardId = parameters['userCardId'];
       function array_unique(arr) {
         return arr.filter(function (e, i) {
           return arr.indexOf(e) === i;
@@ -750,7 +621,7 @@
           $.ajax({
             url: baseUrl + '/api/public/v5/shear/content',
             headers: {
-              Authorization: token,
+              Authorization: form.token,
             },
             type: 'get',
             dataType: 'json',
@@ -813,7 +684,7 @@
           $.ajax({
             url: baseUrl + '/api/public/v5/shear/content?' + ids,
             headers: {
-              Authorization: token,
+              Authorization: form.token,
             },
             type: 'DELETE',
             dataType: 'json',
@@ -841,7 +712,7 @@
         $.ajax({
           url: baseUrl + '/api/public/v5/shear/content?ids=' + id,
           headers: {
-            Authorization: token,
+            Authorization: form.token,
           },
           type: 'DELETE',
           dataType: 'json',
@@ -1112,15 +983,16 @@
           $.ajax({
             url: baseUrl + '/api/pay/v5/trialCodeConfig/getConfigByPhoneType',
             headers: {
-              Authorization: token,
+              Authorization: form.token,
             },
             data: {
-              userCardId: userCardId,
-              phoneType: mealType,
+              userCardId: form.userCardId,
+              phoneType: form.mealType,
             },
             type: 'get',
             dataType: 'json',
             success: function (res) {
+              console.log(res);
               let obj = res.data;
               if (res.status === 0) {
                 resolve(obj);
@@ -1137,7 +1009,7 @@
           $.ajax({
             url: baseUrl + '/api/resources/v4/freetrial/setmeal/list',
             headers: {
-              Authorization: token,
+              Authorization: form.token,
             },
             type: 'get',
             dataType: 'json',
@@ -1171,7 +1043,7 @@
         return $.ajax({
           url: baseUrl + '/api/public/v5/advertising/getAdInfoByAdPlace',
           headers: {
-            Authorization: token,
+            Authorization: form.token,
           },
           data: JSON.stringify({
             adPlace: adType,
@@ -1382,10 +1254,10 @@
         $.ajax({
           url: baseUrl + '/api/resources/v1/trial/report',
           headers: {
-            Authorization: token,
+            Authorization: form.token,
           },
           data: JSON.stringify({
-            userCardId: userCardId,
+            userCardId: form.userCardId,
             reportType: type,
           }),
           type: 'POST',
@@ -1396,6 +1268,9 @@
       }
       //关闭广告
       $('.time-close-wrap')[0].addEventListener('click', () => {
+        if(videoTime == 0) {
+          reportFrequency()
+        }
         $('.buy-phone-wrap').eq(0).show();
       });
       // 点击取消
@@ -1448,12 +1323,7 @@
         } else {
           // 过期续费按钮进入
           wx.miniProgram.navigateTo({
-            url:
-              `/packageA/order/renew/index?buyType=${
-                sourceType == 1
-                  ? '试用弹窗购买按钮进入-普通试用'
-                  : '试用弹窗购买按钮进入-激活码试用'
-              }&record=` + userCardId,
+            url: `/packageA/order/renew/index?buyType=${sourceType == 1 ? '试用弹窗购买按钮进入-普通试用' : '试用弹窗购买按钮进入-激活码试用'}&record=` + form.userCardId,
           });
         }
       });
@@ -1480,7 +1350,7 @@
         $.ajax({
           url: baseUrl + '/api/public/v1/systemBuriedPoint/stat',
           headers: {
-            Authorization: token,
+            Authorization: form.token,
           },
           type: 'post',
           data: JSON.stringify({
@@ -1491,6 +1361,19 @@
           success: function (res) {},
         });
       }
+      // 观看广告次数上报
+      function reportFrequency() {
+        $.ajax({
+          url: baseUrl + '/api/resoures/v1/trial/reportFrequency/' + form.userCardId,
+          headers: {
+            Authorization: form.token
+          },
+          type: 'post',
+          contentType: 'application/json',
+          dataType: 'json',
+          success: function (res) {},
+        });
+      }
       function quit() {
         if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
           tt.miniProgram.switchTab({
@@ -1511,7 +1394,6 @@
         wsss.close();
       };
     </script>
-    <script type="text/javascript" src="WXdraw.js"></script>
     <script type="text/javascript" src="aac.js"></script>
   </body>
 </html>

+ 16 - 1
static/screenIos/WXtrialInterface.html

@@ -1177,7 +1177,19 @@
           getAD();
         });
       }
-
+      // 观看广告次数上报
+      function reportFrequency() {
+        $.ajax({
+          url: baseUrl + '/api/resoures/v1/trial/reportFrequency/' + form.userCardId,
+          headers: {
+            Authorization: form.token
+          },
+          type: 'post',
+          contentType: 'application/json',
+          dataType: 'json',
+          success: function (res) {},
+        });
+      }
       //间隔广告上报
       function report(type) {
         $.ajax({
@@ -1197,6 +1209,9 @@
       }
       //关闭广告
       $('.time-close-wrap')[0].addEventListener('click', () => {
+        if(videoTime == 0) {
+          reportFrequency()
+        }
         $('.buy-phone-wrap').eq(0).show();
       });
       // 点击取消