WXtrialInterface.html 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title></title>
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <meta name="x5-orientation" content="portrait" />
  8. <meta name="screen-orientation" content="portrait" />
  9. <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
  10. <meta name="apple-mobile-web-app-capable" content="yes">
  11. <!-- 删除苹果默认的工具栏和菜单栏 -->
  12. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  13. <!-- 设置苹果工具栏颜? -->
  14. <meta name="format-detection" content="telphone=no, email=no">
  15. <!-- 忽略页面中的数字识别为电话,忽略email识别 -->
  16. <!-- 启用360浏览器的极速模?(webkit) -->
  17. <meta name="renderer" content="webkit">
  18. <!-- 针对手持设备优化,主要是针对一些老的不识别viewport的浏览器,比如黑? -->
  19. <meta name="HandheldFriendly" content="true">
  20. <!-- 微软的老式浏览? -->
  21. <meta name="MobileOptimized" content="320">
  22. <!-- 不能旋转,问题出在这 -->
  23. <!-- UC强制全屏 -->
  24. <meta name="full-screen" content="yes">
  25. <!-- QQ强制全屏 -->
  26. <meta name="x5-fullscreen" content="true">
  27. <!-- UC应用模式 -->
  28. <meta name="browsermode" content="application">
  29. <!-- QQ应用模式 -->
  30. <meta name="x5-page-mode" content="app">
  31. <!-- windows phone 点击无高? -->
  32. <meta name="msapplication-tap-highlight" content="no">
  33. <link rel="stylesheet" type="text/css" href="css/WXtrialInterface.css" />
  34. <link rel="stylesheet" href="https://cdn.bootcss.com/weui/1.1.3/style/weui.min.css" />
  35. <link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.1/css/jquery-weui.min.css" />
  36. </head>
  37. <body class="scroll h-player" style="overscroll-behavior: contain;">
  38. <div class="container" id="player">
  39. <div class="muted" id="btnMuted">
  40. <div class="control-right-img" data-id="1">
  41. <img src="../static/img/xuanfu_icon.png">
  42. </div>
  43. </div>
  44. <div id="wine">
  45. <video id="playerVideo" muted="muted" x5-video-orientation="landscape" playsinline="true" autoplay="true"
  46. webkit-playsinline="true" x5-playsinline="true" x5-video-player-type="h5" x5-video-player-fullscreen="false"
  47. style="pointer-events: none;object-fit: fill;width: 100%;height:100%"></video>
  48. <div id="box"></div>
  49. <audio preload="auto" autoplay controls poster="images/loader-thumb.jpg" id="audioPlayer"
  50. style="position: absolute;top: 0;width: 0;height: 0;"></audio>
  51. </div>
  52. <div class="leftmains">
  53. <div class="PictureQualityMain">
  54. <div class="PictureQuality" data-id="4">高清</div>
  55. <div class="PictureQuality avit" data-id="3">标清</div>
  56. <div class="PictureQuality" data-id="2">极速</div>
  57. </div>
  58. <div class="operation">
  59. <div class="upload" id="showsuss" data-text="uploads">
  60. <img src="../static/img/wx/shangchuan_icon.png">
  61. <div>上传</div>
  62. </div>
  63. <div class="upload" onclick="showShearPlate()" data-text="Shearplate">
  64. <img src="../static/img/wx/jianqieban_icon.png">
  65. <div>剪贴板</div>
  66. </div>
  67. <div class="upload" id="upload" data-text="Signout">
  68. <img src="../static/img/wx/tuichu_icon.png">
  69. <div>退出</div>
  70. </div>
  71. </div>
  72. </div>
  73. <div class="bottommains">
  74. <div class="botmat1">
  75. <div class="botmat1img" data-text="gengduo">
  76. <img src="../static/img/wx/gengduo_icon.png">
  77. </div>
  78. </div>
  79. <div class="botmat1">
  80. <div class="botmat1img" data-text="home">
  81. <img src="../static/img/wx/home_icon.png">
  82. </div>
  83. </div>
  84. <div class="botmat1">
  85. <div class="botmat1img" data-text="return">
  86. <img src="../static/img/wx/fanhui_icon.png">
  87. </div>
  88. </div>
  89. </div>
  90. <img class="loading loading_sceen_pic" />
  91. </div>
  92. <div class="mask">
  93. <div class="box-shear-plate"></div>
  94. <img class="close" onclick="handleClose()" src="img/guanbi_icon@2x.png" alt="">
  95. </div>
  96. <div class="weui-mask_transparent"></div>
  97. <div class="weui-toast weui_loading_toast weui-toast--visible">
  98. <div class="weui_loading"><i class="weui-loading weui-icon_toast"></i></div>
  99. <p class="weui-toast_content">数据加载中</p>
  100. </div>
  101. <div class="try-use-wrap">
  102. <div class="try-use-container">
  103. <video width="100%" height="100%" muted autoplay="autoplay" loop="loop">
  104. <source id="source" src="http://110.53.221.195:8210/document/newFile/download/0/3dn9b4585511476691c6?fileKey=LowLevelMultipartUpload_16522192367175270411" type="video/mp4"></source>
  105. 您的浏览器不支持 video 标签。
  106. </video>
  107. <div class="time-close-wrap"><span class="time-node"></span> 关闭</div>
  108. </div>
  109. </div>
  110. <div class="buy-phone-wrap">
  111. <div class="bug-wrap">
  112. <div class="bug-title">体验完整云手机服务请前往购买</div>
  113. <div class="btn-list">
  114. <div class="btn cannel-btn">取消</div>
  115. <div class="btn go-bug">去购买</div>
  116. </div>
  117. </div>
  118. </div>
  119. <div class="look-wrap">
  120. <div class="bug-wrap">
  121. <div class="bug-title">关闭广告会退出云手机是否继续观看</div>
  122. <div class="btn-list">
  123. <div class="btn cannel-btn cannel-ad-btn">放弃</div>
  124. <div class="btn go-bug looking">继续观看</div>
  125. </div>
  126. </div>
  127. </div>
  128. <body oncontextmenu="Back()">
  129. </body>
  130. <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
  131. <script src="https://lf1-cdn-tos.bytegoofy.com/goofy/developer/jssdk/jssdk-1.0.3.js"></script>
  132. <script type="text/javascript" src="../static/js/jquery-1.11.0.min.js"></script>
  133. <script type="text/javascript" src="helper.js"></script>
  134. <script type="text/javascript" src="pcm-player.js"></script>
  135. <script type="text/javascript" src="https://cdn.bootcss.com/vConsole/3.2.0/vconsole.min.js"></script>
  136. <script src="https://cdn.bootcss.com/jquery-weui/1.2.1/js/jquery-weui.min.js"></script>
  137. <script type="text/javascript" src="WXdraw.js"></script>
  138. <script type="text/javascript" src="jmuxer.js"></script>
  139. <script type="text/javascript" src="spsParser.js"></script>
  140. <script>
  141. var baseUrl = 'http://14.18.190.141:24380'
  142. var parameters = GetRequest();
  143. var form = {};
  144. form.token = parameters['token'];
  145. form.userCardId = 1710808;
  146. var videoTimer = null, videoTime = 0, adType = 0, sourceType = 2;
  147. if (parameters['mealType'] === 'VIP') {
  148. $(".loading_sceen_pic").attr('src', '../static/img/home_bg_VIP.png');
  149. } else if (parameters['mealType'] === 'SVIP') {
  150. $(".loading_sceen_pic").attr('src', '../static/img/home_bg_SVIP.png');
  151. } else if (parameters['mealType'] === 'STAR') {
  152. $(".loading_sceen_pic").attr('src', '../static/img/home_bg_STAR.png');
  153. } else if (parameters['mealType'] === 'STARPRO') {
  154. $(".loading_sceen_pic").attr('src', '../static/img/home_bg_PRO.png');
  155. }
  156. adInit();
  157. var isAudioPlay = false;
  158. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  159. var video = document.getElementById("playerVideo");
  160. video.play();
  161. setTimeout(() => { // 抖音环境需要设置延时,不然会有video默认图显示
  162. $.alert({
  163. title: '提示',
  164. text: '开始使用云手机',
  165. onOK: function () {
  166. setTimeout(() => {
  167. isAudioPlay = true;
  168. }, 1000);
  169. }
  170. });
  171. }, 1000)
  172. } else {
  173. // $.alert({
  174. // title: '提示',
  175. // text: '开始使用云手机',
  176. // onOK: function () {
  177. // var video = document.getElementById("playerVideo");
  178. // video.play();
  179. // isAudioPlay = true;
  180. // }
  181. // });
  182. }
  183. //
  184. function getConfigByPhoneType() {
  185. return new Promise((resolve, reject) => {
  186. $.ajax({
  187. url: baseUrl + "/api/pay/v5/trialCodeConfig/getConfigByPhoneType",
  188. headers: {
  189. 'Authorization': form.token
  190. },
  191. data: {
  192. userCardId: 1710808,
  193. phoneType: 'STARPRO'
  194. },
  195. type: 'get',
  196. dataType: 'json',
  197. success: function (res) {
  198. console.log(res)
  199. // if (res.status === 0) {
  200. // let list = res.data;
  201. // list.map((item) => {
  202. // // if(item.phoneType === parameters['mealType']){
  203. // if(item.phoneType === 'STARPRO'){
  204. // resolve(item)
  205. // }
  206. // })
  207. // } else {
  208. // $.toast(res.msg, "text");
  209. // }
  210. }
  211. })
  212. })
  213. }
  214. //列表
  215. function getSetmealList() {
  216. return new Promise((resolve, reject) => {
  217. $.ajax({
  218. url: baseUrl + "/api/resources/v4/freetrial/setmeal/list",
  219. headers: {
  220. 'Authorization': form.token
  221. },
  222. type: 'get',
  223. dataType: 'json',
  224. success: function (res) {
  225. if (res.status === 0) {
  226. let list = res.data;
  227. list.map((item) => {
  228. // if(item.phoneType === parameters['mealType']){
  229. if(item.phoneType === 'STARPRO'){
  230. resolve(item)
  231. }
  232. })
  233. } else {
  234. $.toast(res.msg, "text");
  235. }
  236. }
  237. })
  238. })
  239. }
  240. //广告信息
  241. function adInit() {
  242. // sourceType = parameters['sourceType'];
  243. if(sourceType == 1) {
  244. getSetmealList().then((res) => {
  245. if(res.pushFlowAdvert === 1){
  246. getAdList(15);
  247. }
  248. if(res.intervalSwitch === 1) {
  249. let time = res.intervalAdvertDuration * 60 * 1000;
  250. setInterval(() => {
  251. $('.try-use-wrap').eq(0).hide();
  252. getAdList(16);
  253. }, time);
  254. }
  255. })
  256. }else if(sourceType === 2) {
  257. getConfigByPhoneType().then((res) => {
  258. if(res.pushFlowAdvert === 1){
  259. getAdList(15);
  260. }
  261. if(res.intervalSwitch === 1) {
  262. let time = res.intervalAdvertDuration * 60 * 1000;
  263. setInterval(() => {
  264. $('.try-use-wrap').eq(0).hide();
  265. getAdList(16);
  266. }, time);
  267. }
  268. })
  269. }
  270. }
  271. // 广告接口
  272. function getAdList(type){
  273. adType = type;
  274. $.ajax({
  275. url: baseUrl + "/api/public/v5/advertising/getAdInfoByAdPlace",
  276. headers: {
  277. 'Authorization': form.token
  278. },
  279. data: JSON.stringify({
  280. adPlace: type,
  281. os: 0
  282. }),
  283. type: 'POST',
  284. dataType: 'json',
  285. contentType: "application/json;charset=UTF-8",
  286. success: function (res) {
  287. if (res.status === 0) {
  288. let list = res.data;
  289. videoTime = list[0].forcedTime;
  290. $('#source').src = list[0].adVideoBase.videoUrl;
  291. videoTimer = setInterval(() =>{
  292. if(videoTime > 0) {
  293. videoTime--;
  294. $('.time-node').eq(0).text(videoTime + 's');
  295. } else {
  296. clearInterval(videoTimer);
  297. $('.time-node').eq(0).text('');
  298. }
  299. },1000)
  300. if (adType === 16 && sourceType == 1) { // 间隔广告和试用才上报
  301. report(0);
  302. }
  303. $('.try-use-wrap').eq(0).show();
  304. } else {
  305. $.toast(res.msg, "text");
  306. }
  307. }
  308. })
  309. }
  310. //间隔广告上报
  311. function report(type) {
  312. $.ajax({
  313. url: baseUrl + "/api/resources/v1/trial/report",
  314. headers: {
  315. 'Authorization': form.token
  316. },
  317. data: JSON.stringify({
  318. userCardId: form.userCardId,
  319. reportType: type
  320. }),
  321. type: 'POST',
  322. dataType: 'json',
  323. contentType: "application/json;charset=UTF-8",
  324. success: function (res) {}
  325. })
  326. }
  327. //关闭广告
  328. $('.time-close-wrap')[0].addEventListener('click', () => {
  329. $('.buy-phone-wrap').eq(0).show();
  330. })
  331. // 点击取消
  332. $('.cannel-btn')[0].addEventListener('click', () => {
  333. $('.buy-phone-wrap').eq(0).hide();
  334. let pointName = '';
  335. if(sourceType == 1){
  336. pointName = videoTime == 0 ? '免费试用-关闭-取消' : '免费试用-强制关闭-取消';
  337. } else {
  338. pointName = videoTime == 0 ? '激活码-关闭-取消' : '激活码-强制关闭-取消';
  339. }
  340. systemBuriedPoint(pointName);
  341. if(videoTime == 0) {
  342. if (adType === 16 && sourceType == 1) {
  343. report(1);
  344. }
  345. $('.try-use-wrap').eq(0).hide();
  346. return
  347. }
  348. $('.look-wrap').eq(0).show();
  349. })
  350. // 点击去购买
  351. $('.go-bug')[0].addEventListener('click', () => {
  352. let pointName = '';
  353. if(sourceType == 1){
  354. pointName = videoTime == 0 ? '免费试用-关闭-去购买' : '免费试用-强制关闭-去购买';
  355. } else {
  356. pointName = videoTime == 0 ? '激活码-关闭-去购买' : '激活码-强制关闭-去购买';
  357. }
  358. systemBuriedPoint(pointName);
  359. wx.miniProgram.switchTab({
  360. url: '/pages/home/home'
  361. })
  362. })
  363. // 放弃
  364. $('.cannel-ad-btn')[0].addEventListener('click', () => {
  365. if(sourceType == 1){
  366. systemBuriedPoint('免费试用-强制关闭-放弃');
  367. } else {
  368. systemBuriedPoint('激活码-强制关闭-放弃');
  369. }
  370. wx.miniProgram.switchTab({
  371. url: '/pages/home/home'
  372. })
  373. })
  374. // 继续观看
  375. $('.looking')[0].addEventListener('click', () => {
  376. $('.look-wrap').eq(0).hide();
  377. if(sourceType == 1){
  378. systemBuriedPoint('免费试用-强制关闭-继续观看');
  379. } else {
  380. systemBuriedPoint('激活码-强制关闭-继续观看');
  381. }
  382. })
  383. var topwinHeight = window.screen.height - window.innerHeight + 30; //计算title top 头部
  384. $('#wine').css({
  385. "width": window.screen.width,
  386. "height": window.screen.height - topwinHeight - 20,
  387. "position": "absolute"
  388. });
  389. $('.loading').css({
  390. "width": window.screen.width,
  391. "height": window.screen.height - topwinHeight - 20
  392. });
  393. var winese = document.createElement("wine");
  394. wine.style.top = "-" + winese + 'px';
  395. var isVisuable = true;
  396. var isFeed = true;
  397. var isFinish = false;
  398. var isWaitSps = false;
  399. var myVideo = document.getElementById("playerVideo");
  400. Module = {};
  401. Module.onRuntimeInitialized = function () {
  402. isFinish = true;
  403. }
  404. var isWSS = true;
  405. var ip = parameters["ip"];
  406. var cardToken = parameters["cardToken"];
  407. cardToken = cardToken && cardToken.replace(/@/g, "=");
  408. var appletPushAddress = parameters["appletPushAddress"];
  409. var socketURL = isWSS ? "wss://" + appletPushAddress + "?cardIp=" + ip + "&token=" + cardToken : "ws://" + appletPushAddress + "?cardIp=" + ip + "&token=" + cardToken;
  410. var jmuxer = new JMuxer({
  411. node: 'playerVideo',
  412. flushingTime: 33,
  413. fps: 30,
  414. mode: 'video',
  415. debug: false
  416. });
  417. window.onload = function () {
  418. var myPlay = document.getElementById("wine");
  419. myPlay.onkeydown = function (event) {
  420. ExexuteKeyDown(e.keyCode);
  421. }
  422. }
  423. var ws, errorTime = 0;
  424. doConnect();
  425. // 节流
  426. // 设置一个标志
  427. function throttle(fn, delay) {
  428. let flag = true;
  429. errorTime += delay;
  430. return () => {
  431. if (!flag) return;
  432. flag = false;
  433. timer = setTimeout(() => {
  434. fn();
  435. flag = true;
  436. }, delay);
  437. };
  438. }
  439. var intervaler;
  440. function doConnect() {
  441. ws = new WebSocket(socketURL);
  442. ws.binaryType = 'arraybuffer';
  443. intervaler = setInterval(() => {
  444. if (ws.readyState === 1) {
  445. ws.send("ping");
  446. } else {
  447. clearInterval(intervaler);
  448. $.toast("画面异常,请重新进入1", "text");
  449. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  450. tt.miniProgram.switchTab({
  451. url: '/pages/home/home'
  452. })
  453. } else {
  454. wx.miniProgram.switchTab({
  455. url: '/pages/home/home'
  456. })
  457. }
  458. }
  459. }, 3000);
  460. ws.addEventListener('open', function (event) {
  461. // sn只要长度满足17位随机数,不需要从后台获取
  462. var verifyBuffer = VerifyCode('RK3923C1201900139', cardToken);
  463. console.log("鉴权报文:" + PrintArry(verifyBuffer));
  464. ws.send(verifyBuffer);
  465. });
  466. ws.addEventListener('error', function (event) {
  467. ws.close();
  468. clearInterval(intervaler);
  469. throttle(doConnect, 100);
  470. if (errorTime > 1000) {
  471. $.toast("画面异常,请重新进入2", "text");
  472. wsss.close();
  473. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  474. tt.miniProgram.switchTab({
  475. url: '/pages/home/home'
  476. })
  477. } else {
  478. wx.miniProgram.switchTab({
  479. url: '/pages/home/home'
  480. })
  481. }
  482. }
  483. });
  484. ws.addEventListener('message', function (event) {
  485. var data = ParseProto(event.data); //JAVA服务器转发
  486. if (isAudioPlay) {
  487. $('.weui-mask_transparent').hide();
  488. $('.weui-toast').hide();
  489. $('.loading').hide();
  490. }
  491. var input = new Uint8Array(event.data);
  492. if (data.audio != null && isAudioPlay) { //喂音频
  493. if (input[0] == 0xff) {
  494. if (isFinish) {
  495. decodeAAC(input);
  496. }
  497. }
  498. }
  499. if (data.frameType != undefined && data.frameType != 1 && data.frameType != 6) {
  500. if (data.frameType == 7) {
  501. let info = spsParser(data.video);
  502. if (info.width != myVideo.videoWidth && info.height != myVideo.videoHeight) {
  503. if (myVideo.videoWidth == 0) {
  504. console.log("SPS计算得到宽 %d, 高 %d, 控件宽 %d, %d", info.width, info.height, myVideo.videoWidth, myVideo.videoHeight);
  505. }
  506. }
  507. }
  508. }
  509. if (data.video != null) { //喂视频
  510. if (data.frameType == 0x05 && isVisuable) {
  511. isFeed = true;
  512. }
  513. if (data.frameType == 7 || data.frameType == 8) {
  514. isFeed = true;
  515. isAudioPlay = true;
  516. isWaitSps = false;
  517. }
  518. if (isFeed) {
  519. if (!isWaitSps) {
  520. jmuxer.feed(data);
  521. }
  522. }
  523. }
  524. });
  525. }
  526. document.addEventListener("visibilitychange", function () {
  527. if (document.visibilityState == "visible") {
  528. var buffer = RequestIFrame();
  529. ws.send(buffer);
  530. isVisuable = true;
  531. } else {
  532. isVisuable = false;
  533. isFeed = false;
  534. myVideo.pause();
  535. }
  536. });
  537. myVideo.addEventListener('pause', function () {
  538. isFeed = false;
  539. });
  540. var decodeCount = 1;
  541. var player = new PCMPlayer({
  542. encoding: '16bitInt',
  543. channels: 2,
  544. sampleRate: 44100,
  545. flushingTime: 22,
  546. debug: false
  547. });
  548. function handleClose() {
  549. $('.mask').hide();
  550. }
  551. function decodeAAC(data) {
  552. var retPtr = Module._malloc(4 * 5 * 1024); // 接收的数据
  553. var inputPtr = Module._malloc(4 * data.length); // 输入数据
  554. for (var i = 0; i < data.length; i++) {
  555. Module.HEAPU8[(inputPtr) + i] = data[i]; //转换为堆数据
  556. }
  557. var pcmLen = Module._feedData(retPtr, inputPtr, data.length);
  558. if (pcmLen >= 0) {
  559. var pcmData = new Uint8Array(pcmLen);
  560. for (var i = 0; i < pcmLen; i++) {
  561. pcmData[i] = Module.HEAPU8[(retPtr) + i]
  562. }
  563. player.feed(pcmData);
  564. }
  565. decodeCount++;
  566. Module._free(inputPtr);
  567. Module._free(retPtr);
  568. }
  569. //解协议
  570. function ParseProto(data) {
  571. var input = new Uint8Array(data),
  572. duration,
  573. video,
  574. frameType,
  575. audio;
  576. if (input[0] == 0 && input[1] == 0 && input[2] == 0 && input[3] == 1) {
  577. video = input;
  578. duration = 24;
  579. var nalType = input[4] & 0x1f;
  580. frameType = nalType;
  581. if (!isFeed) {
  582. if (nalType == 0x05 && isVisuable) {
  583. isFeed = true;
  584. }
  585. }
  586. } else if (input[0] == 0xff) {
  587. audio = input;
  588. duration = 24;
  589. } else if (input[0] == 0x68) {
  590. if (input[23] == 0x5c) {
  591. console.log("收到消息:" + PrintArry(input));
  592. if (CheckVerifyCode(input)) {
  593. ws.send(ConfigChannel('RK3923C1201900139'));
  594. var checkBuffer = GetScreenState();
  595. ws.send(checkBuffer);
  596. }
  597. else {
  598. $.toast("画面异常,请重新进入3", "text");
  599. clearInterval(intervaler);
  600. ws.close();
  601. wsss.close();
  602. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  603. tt.miniProgram.switchTab({
  604. url: '/pages/home/home'
  605. })
  606. } else {
  607. wx.miniProgram.switchTab({
  608. url: '/pages/home/home'
  609. })
  610. }
  611. }
  612. }
  613. if (input[23] == 0x05) { //横竖屏标识
  614. var state = CheckScreenDirection(input.slice(24, 24 + 8));
  615. if (state == 1) {
  616. console.log("安卓卡此时竖屏");
  617. //竖屏处理
  618. resolving = 1;
  619. } else {
  620. console.log("安卓卡此时横屏");
  621. //横屏处理
  622. resolving = 0;
  623. }
  624. }
  625. if (input[23] == 0x0B)//多端登录处理, 数据从索引24开始取, input 是接收到的原始数据
  626. {
  627. var jsonobj = checkMultiLoginInfo(input);
  628. }
  629. }
  630. return {
  631. audio: audio,
  632. video: video,
  633. duration: duration,
  634. frameType: frameType
  635. };
  636. }
  637. function GetRequest() {
  638. var url = location.search; // 获取url中"?"符后的字串
  639. var obj = new Object();
  640. if (url.indexOf("?") != -1) {
  641. var str = url.substr(1);
  642. strs = str.split("&");
  643. for (var i = 0; i < strs.length; i++) {
  644. obj[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
  645. }
  646. }
  647. return obj;
  648. }
  649. function Back() {
  650. ExexuteKeyDown(4);
  651. window.event.returnValue = false;
  652. return false;
  653. }
  654. var url = window.location.href;
  655. url = url.split('/');
  656. var baseUrl = url[0] + '//' + url[2];
  657. var form = {};
  658. form.token = parameters['token'];
  659. form.userCardId = parameters['userCardId'];
  660. function array_unique(arr) {
  661. return arr.filter(function (e, i) {
  662. return arr.indexOf(e) === i;
  663. })
  664. }
  665. var cutList = [];
  666. let timer, isFlag = true;
  667. function showShearPlate() {
  668. stopManyClick(() => {
  669. $('.box-shear-plate').empty();
  670. $.ajax({
  671. url: baseUrl + "/api/public/v5/shear/content",
  672. headers: {
  673. 'Authorization': form.token
  674. },
  675. type: 'get',
  676. dataType: 'json',
  677. success: function (res) {
  678. if (res.status === 0) {
  679. if (res.data.length) {
  680. cutList = array_unique(res.data)
  681. var str = '<div class="title">剪贴板<div onclick="handleClear()" class="btn-clear">清空</div></div><div class="slide-wrapper-content">'
  682. cutList.forEach(function (item) {
  683. str += "<div class='slide-wrapper'><div class='slide-scroll animate-slide-start'><div class='slide-content'><div onclick='handleCopy(\"" + item.content + "\")'>" + item.content + "</div></div><div class='slide-content-button'><button onclick='handleDelete(" + item.id + ")'>删除</button></div></div></div>"
  684. })
  685. str += '</div>'
  686. $('.box-shear-plate').append(str);
  687. } else {
  688. $('.box-shear-plate').append('<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>')
  689. }
  690. $('.mask').show();
  691. initSlider();
  692. } else {
  693. $('.box-shear-plate').append('<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>')
  694. $('.mask').show();
  695. }
  696. }
  697. })
  698. })
  699. }
  700. //防止提示一秒内重复显示
  701. function stopManyClick(fn) {
  702. if (isFlag) {
  703. fn();
  704. }
  705. isFlag = false;
  706. if (timer) { clearTimeout(timer); }
  707. timer = setTimeout(() => { isFlag = true }, 1500);
  708. }
  709. // 清空剪贴板
  710. function handleClear() {
  711. var ids = '';
  712. cutList.forEach(function (item) {
  713. ids += 'ids=' + item.id + '&'
  714. });
  715. ids = ids.substring(0, ids.lastIndexOf('&'));
  716. $.confirm("确定清空剪贴板?", function () {
  717. $.ajax({
  718. url: baseUrl + "/api/public/v5/shear/content?" + ids,
  719. headers: {
  720. 'Authorization': form.token
  721. },
  722. type: 'DELETE',
  723. dataType: 'json',
  724. success: function (res) {
  725. if (res.status === 0) {
  726. showShearPlate();
  727. } else {
  728. $.toast(res.msg, "text");
  729. }
  730. }
  731. })
  732. });
  733. }
  734. function handleCopy(content) {
  735. var cutting = {
  736. "type": "cutting",
  737. "data": {
  738. "str": content
  739. }
  740. };
  741. wsss.send(JSON.stringify(cutting));
  742. }
  743. // 删除剪贴板
  744. function handleDelete(id) {
  745. $.ajax({
  746. url: baseUrl + "/api/public/v5/shear/content?ids=" + id,
  747. headers: {
  748. 'Authorization': form.token
  749. },
  750. type: 'DELETE',
  751. dataType: 'json',
  752. success: function (res) {
  753. if (res.status === 0) {
  754. showShearPlate();
  755. } else {
  756. $.toast(res.msg, "text");
  757. }
  758. }
  759. })
  760. }
  761. function initSlider() {
  762. //手指滑动多少距离就认为是滑成功
  763. //这个值不能太大,否则影响斜着滑动时,垂直滑动的流畅性,也不能太小,太灵敏也不好
  764. var diffXDistance = 50;
  765. //当前滑动的对象
  766. var currentObject;
  767. //上一次滑动的对象
  768. var lastObject;
  769. //是否可以左右滑动,在上下滑的时候禁止左右滑
  770. var canSlide = true;
  771. //用于记录按下的点
  772. var startPoint;
  773. $(".slide-content").css({
  774. width: $(".slide-wrapper").width()
  775. });
  776. document.body.removeEventListener('touchmove', function (e) {
  777. e.preventDefault()
  778. }, {
  779. passive: false
  780. })
  781. $(".slide-scroll").css({
  782. width: $(".slide-wrapper").width() + $(".slide-content-button").width()
  783. }).on('touchstart', function (e) {
  784. currentObject = this;
  785. startPoint = {
  786. x: e.originalEvent.changedTouches[0].pageX,
  787. y: e.originalEvent.changedTouches[0].pageY
  788. };
  789. }).on('touchmove', function (e) {
  790. //如果是左右滑动,就禁止上下的滑动
  791. //如果是上下的滑动,就禁止左右滑动
  792. if (Math.abs(e.originalEvent.changedTouches[0].pageX - startPoint.x) > Math.abs(e.originalEvent.changedTouches[0].pageY - startPoint.y)) {
  793. event.preventDefault();
  794. } else {
  795. canSlide = false;
  796. }
  797. }).on('touchend', function (e) {
  798. //如果是上下滑动,这里就直接返回了
  799. if (!canSlide) {
  800. canSlide = true;
  801. return true;
  802. }
  803. //点击除当前左滑对象之外的任意其他位置
  804. if (lastObject && currentObject != lastObject) {
  805. //右滑→
  806. $(lastObject).removeClass("animate-slide");
  807. //清空上一个左滑的对象
  808. lastObject = undefined;
  809. }
  810. var diffX = e.originalEvent.changedTouches[0].pageX - startPoint.x;
  811. if (diffX < -diffXDistance) {
  812. //左滑←
  813. $(currentObject).addClass("animate-slide");
  814. if (lastObject && lastObject != currentObject) {
  815. //右滑→
  816. $(lastObject).removeClass("animate-slide");
  817. }
  818. //记录上一个左滑的对象
  819. lastObject = currentObject;
  820. } else if (diffX >= diffXDistance) {
  821. if (currentObject == lastObject) {
  822. //右滑→
  823. $(currentObject).removeClass("animate-slide");
  824. //清空上一个左滑的对象
  825. lastObject = undefined;
  826. }
  827. }
  828. });
  829. }
  830. var btnMuted = document.querySelector("#btnMuted");
  831. btnMuted && (function () {
  832. var setHistory = function (left, top) {
  833. try {
  834. localStorage.setItem("muted-btn-loc", JSON.stringify({
  835. left: left,
  836. top: top
  837. }));
  838. } catch (ex) { }
  839. };
  840. var getHistory = function () {
  841. try {
  842. var value = localStorage.getItem("muted-btn-loc");
  843. if (!value) return null;
  844. value = JSON.parse(value);
  845. if (!value) return null;
  846. return value;
  847. } catch (ex) {
  848. return null
  849. }
  850. };
  851. var fixLoc = function (loc) {
  852. var rect = btnMuted.getBoundingClientRect();
  853. rect = {
  854. top: rect.top,
  855. left: rect.left,
  856. width: rect.width,
  857. height: rect.height
  858. }; //部分低版本浏览器,该属性为只读
  859. if (loc) {
  860. rect.left = loc.left;
  861. rect.top = loc.top;
  862. }
  863. var minX = 0;
  864. var minY = 0;
  865. var docRect = document.documentElement.getBoundingClientRect();
  866. var maxY = docRect.height - rect.height;
  867. var maxX = docRect.width - rect.width;
  868. var left = rect.left;
  869. var top = rect.top;
  870. left = Math.min(left, maxX);
  871. left = Math.max(left, minX);
  872. top = Math.min(top, maxY);
  873. top = Math.max(top, minY);
  874. if (loc || top !== rect.top || left !== rect.left) {
  875. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  876. }
  877. }
  878. window.addEventListener("resize", function () {
  879. fixLoc();
  880. });
  881. var touchPoint = {
  882. pageY: 0,
  883. pageX: 0
  884. };
  885. var currentLoc = {
  886. top: 0,
  887. left: 0,
  888. curTop: 0,
  889. curLeft: 0
  890. };
  891. var toMove = false;
  892. var touchmove = function (e) {
  893. e.preventDefault();
  894. var point = e.changedTouches[0];
  895. var top = -touchPoint.pageY + point.pageY;
  896. var left = -touchPoint.pageX + point.pageX;
  897. if (toMove) {
  898. top += currentLoc.top;
  899. left += currentLoc.left;
  900. currentLoc.curLeft = left;
  901. currentLoc.curTop = top;
  902. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  903. } else {
  904. if (Math.abs(top) >= 5 || Math.abs(left) >= 5) {
  905. toMove = true;
  906. }
  907. }
  908. };
  909. var touchend = function () {
  910. window.removeEventListener("touchmove", touchmove, {
  911. passive: false
  912. });
  913. window.removeEventListener("touchend", touchend, {
  914. passive: false
  915. });
  916. if (toMove) {
  917. setHistory(currentLoc.curLeft, currentLoc.curTop);
  918. fixLoc();
  919. } else {
  920. //按点击处理
  921. var set = $('.control-right-img').attr("data-id")
  922. if (set == '1') {
  923. $('.control-right-img').attr({
  924. "data-id": "2"
  925. })
  926. $(".leftmains").css({
  927. "right": "0rem"
  928. })
  929. } else {
  930. $('.control-right-img').attr({
  931. "data-id": "1"
  932. })
  933. $(".leftmains").css({
  934. "right": "-4rem"
  935. })
  936. }
  937. }
  938. }
  939. btnMuted.addEventListener("touchstart", function (e) {
  940. e.preventDefault();
  941. toMove = false;
  942. var point = e.changedTouches[0];
  943. touchPoint.pageX = point.pageX;
  944. touchPoint.pageY = point.pageY;
  945. var rect = e.target.getBoundingClientRect();
  946. currentLoc.top = rect.top;
  947. currentLoc.left = rect.left;
  948. window.addEventListener("touchmove", touchmove, {
  949. passive: false
  950. });
  951. window.addEventListener("touchend", touchend, {
  952. passive: false
  953. });
  954. }, {
  955. passive: false
  956. });
  957. var history = getHistory();
  958. if (history) {
  959. fixLoc(history);
  960. }
  961. btnMuted.classList.remove("hide");
  962. })();
  963. $("#upload").on("click", function () {
  964. clearInterval(intervaler);
  965. ws.close();
  966. wsss.close();
  967. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  968. tt.miniProgram.switchTab({
  969. url: '/pages/home/home'
  970. })
  971. } else {
  972. wx.miniProgram.switchTab({
  973. url: '/pages/home/home'
  974. })
  975. }
  976. })
  977. // 埋点
  978. function systemBuriedPoint(pointName){
  979. $.ajax({
  980. url: baseUrl + "/api/public/v1/systemBuriedPoint/stat",
  981. headers: {
  982. 'Authorization': form.token
  983. },
  984. type: 'post',
  985. data:JSON.stringify({
  986. pointName: pointName
  987. }),
  988. contentType:"application/json",
  989. dataType: 'json',
  990. success: function (res) {}
  991. })
  992. }
  993. window.onbeforeunload = function () {
  994. ws.close();
  995. wsss.close();
  996. }
  997. </script>
  998. <script type="text/javascript" src="aac.js"></script>
  999. </body>
  1000. </html>