WXtrialInterface.html 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825
  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="1803000">高清</div>
  55. <div class="PictureQuality avit" data-id="1243000">标清</div>
  56. <div class="PictureQuality" data-id="400000">极速</div>
  57. <div class="PictureQuality" data-id="200">自动</div>
  58. </div>
  59. <div class="operation">
  60. <div class="upload" id="showsuss" data-text="uploads">
  61. <img src="../static/img/wx/shangchuan_icon.png">
  62. <div>上传</div>
  63. </div>
  64. <div class="upload" onclick="showShearPlate()" data-text="Shearplate">
  65. <img src="../static/img/wx/jianqieban_icon.png">
  66. <div>剪贴板</div>
  67. </div>
  68. <div class="upload" id="upload" data-text="Signout">
  69. <img src="../static/img/wx/tuichu_icon.png">
  70. <div>退出</div>
  71. </div>
  72. </div>
  73. </div>
  74. <div class="bottommains">
  75. <div class="botmat1">
  76. <div class="botmat1img" data-text="gengduo">
  77. <img src="../static/img/wx/gengduo_icon.png">
  78. </div>
  79. </div>
  80. <div class="botmat1">
  81. <div class="botmat1img" data-text="home">
  82. <img src="../static/img/wx/home_icon.png">
  83. </div>
  84. </div>
  85. <div class="botmat1">
  86. <div class="botmat1img" data-text="return">
  87. <img src="../static/img/wx/fanhui_icon.png">
  88. </div>
  89. </div>
  90. </div>
  91. <img class="loading loading_sceen_pic" />
  92. </div>
  93. <div class="mask">
  94. <div class="box-shear-plate"></div>
  95. <img class="close" onclick="handleClose()" src="img/guanbi_icon@2x.png" alt="">
  96. </div>
  97. <div class="weui-mask_transparent"></div>
  98. <div class="weui-toast weui_loading_toast weui-toast--visible">
  99. <div class="weui_loading"><i class="weui-loading weui-icon_toast"></i></div>
  100. <p class="weui-toast_content">数据加载中</p>
  101. </div>
  102. <body oncontextmenu="Back()">
  103. </body>
  104. <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
  105. <script src="https://lf1-cdn-tos.bytegoofy.com/goofy/developer/jssdk/jssdk-1.0.3.js"></script>
  106. <script type="text/javascript" src="../static/js/jquery-1.11.0.min.js"></script>
  107. <script type="text/javascript" src="helper.js"></script>
  108. <script type="text/javascript" src="pcm-player.js"></script>
  109. <script type="text/javascript" src="https://cdn.bootcss.com/vConsole/3.2.0/vconsole.min.js"></script>
  110. <script src="https://cdn.bootcss.com/jquery-weui/1.2.1/js/jquery-weui.min.js"></script>
  111. <script type="text/javascript" src="WXdraw.js?v=110"></script>
  112. <script type="text/javascript" src="jmuxer.js"></script>
  113. <script>
  114. var parameters = GetRequest();
  115. if (parameters['mealType'] === 'VIP') {
  116. $(".loading_sceen_pic").attr('src', '../static/img/home_bg_VIP.png');
  117. } else if (parameters['mealType'] === 'SVIP') {
  118. $(".loading_sceen_pic").attr('src', '../static/img/home_bg_SVIP.png');
  119. } else if (parameters['mealType'] === 'STAR') {
  120. $(".loading_sceen_pic").attr('src', '../static/img/home_bg_STAR.png');
  121. } else if (parameters['mealType'] === 'STARPRO') {
  122. $(".loading_sceen_pic").attr('src', '../static/img/home_bg_STARPRO.png');
  123. }
  124. var isAudioPlay = false;
  125. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  126. var video = document.getElementById("playerVideo");
  127. video.play();
  128. setTimeout(() => { // 抖音环境需要设置延时,不然会有video默认图显示
  129. $.alert({
  130. title: '提示',
  131. text: '开始使用云手机',
  132. onOK: function () {
  133. setTimeout(() => {
  134. isAudioPlay = true;
  135. }, 1000);
  136. }
  137. });
  138. }, 1000)
  139. } else {
  140. $.alert({
  141. title: '提示',
  142. text: '开始使用云手机',
  143. onOK: function () {
  144. var video = document.getElementById("playerVideo");
  145. video.play();
  146. isAudioPlay = true;
  147. }
  148. });
  149. }
  150. var topwinHeight = window.screen.height - window.innerHeight + 30; //计算title top 头部
  151. $('#wine').css({
  152. "width": window.screen.width,
  153. "height": window.screen.height - topwinHeight - 20,
  154. "position": "absolute"
  155. });
  156. $('.loading').css({
  157. "width": window.screen.width,
  158. "height": window.screen.height - topwinHeight - 20
  159. });
  160. var winese = document.createElement("wine");
  161. wine.style.top = "-" + winese + 'px';
  162. var requestCount = 0;
  163. var isVisuable = true;
  164. var isFeed = true;
  165. var isDrag = false;
  166. var isEnough = true;
  167. var isFinish = false;
  168. var delayTime = new Date().getTime();
  169. var curTime = new Date().getTime();
  170. var myVideo = document.getElementById("playerVideo");
  171. Module = {};
  172. Module.onRuntimeInitialized = function () {
  173. isFinish = true;
  174. }
  175. var isWSS = true;
  176. var ip = parameters["ip"];
  177. var cardToken = parameters["cardToken"];
  178. cardToken = cardToken && cardToken.replace(/@/g, "=");
  179. var appletPushAddress = parameters["appletPushAddress"];
  180. var socketURL = isWSS ? "wss://" + appletPushAddress + "?cardIp=" + ip + "&token=" + cardToken : "ws://" + appletPushAddress + "?cardIp=" + ip + "&token=" + cardToken;
  181. var jmuxer = new JMuxer({
  182. node: 'playerVideo',
  183. flushingTime: 33,
  184. fps: 30,
  185. mode: 'video',
  186. debug: false
  187. });
  188. window.onload = function () {
  189. curTime = new Date().getTime();
  190. var myPlay = document.getElementById("wine");
  191. myPlay.onkeydown = function (event) {
  192. ExexuteKeyDown(e.keyCode);
  193. }
  194. }
  195. var ws, errorTime = 0;
  196. doConnect();
  197. // 节流
  198. // 设置一个标志
  199. function throttle(fn, delay) {
  200. let flag = true;
  201. errorTime += delay;
  202. return () => {
  203. if (!flag) return;
  204. flag = false;
  205. timer = setTimeout(() => {
  206. fn();
  207. flag = true;
  208. }, delay);
  209. };
  210. }
  211. var intervaler;
  212. function doConnect() {
  213. ws = new WebSocket(socketURL);
  214. ws.binaryType = 'arraybuffer';
  215. intervaler = setInterval(() => {
  216. if (ws.readyState === 1) {
  217. ws.send("ping");
  218. } else {
  219. clearInterval(intervaler);
  220. $.toast("画面异常,请重新进入", "text");
  221. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  222. tt.miniProgram.switchTab({
  223. url: '/pages/home/home'
  224. })
  225. } else {
  226. wx.miniProgram.switchTab({
  227. url: '/pages/home/home'
  228. })
  229. }
  230. }
  231. }, 3000);
  232. ws.addEventListener('open', function (event) {
  233. // sn只要长度满足17位随机数,不需要从后台获取
  234. var verifyBuffer = VerifyCode('RK3923C1201900139', cardToken);
  235. console.log("鉴权报文:" + PrintArry(verifyBuffer));
  236. ws.send(verifyBuffer);
  237. });
  238. ws.addEventListener('error', function (event) {
  239. ws.close();
  240. clearInterval(intervaler);
  241. throttle(doConnect, 100);
  242. if (errorTime > 1000) {
  243. $.toast("画面异常,请重新进入", "text");
  244. wsss.close();
  245. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  246. tt.miniProgram.switchTab({
  247. url: '/pages/home/home'
  248. })
  249. } else {
  250. wx.miniProgram.switchTab({
  251. url: '/pages/home/home'
  252. })
  253. }
  254. }
  255. });
  256. ws.addEventListener('message', function (event) {
  257. var data = ParseProto(event.data); //JAVA服务器转发
  258. if (isAudioPlay) {
  259. $('.weui-mask_transparent').hide();
  260. $('.weui-toast').hide();
  261. $('.loading').hide();
  262. }
  263. var input = new Uint8Array(event.data);
  264. if (data.audio != null && isAudioPlay) { //喂音频
  265. if (input[0] == 0xff) {
  266. if (isFinish) {
  267. decodeAAC(input);
  268. }
  269. }
  270. }
  271. if (data.video != null) { //喂视频
  272. if (isFeed) {
  273. jmuxer.feed(data);
  274. }
  275. }
  276. });
  277. }
  278. document.addEventListener("visibilitychange", function () {
  279. if (document.visibilityState == "visible") {
  280. var buffer = RequestIFrame();
  281. ws.send(buffer);
  282. isVisuable = true;
  283. } else {
  284. isVisuable = false;
  285. isFeed = false;
  286. myVideo.pause();
  287. }
  288. });
  289. myVideo.addEventListener('pause', function () {
  290. isFeed = false;
  291. });
  292. var decodeCount = 1;
  293. var player = new PCMPlayer({
  294. encoding: '16bitInt',
  295. channels: 2,
  296. sampleRate: 44100,
  297. flushingTime: 22,
  298. debug: false
  299. });
  300. function handleClose() {
  301. $('.mask').hide();
  302. }
  303. function decodeAAC(data) {
  304. var retPtr = Module._malloc(4 * 5 * 1024); // 接收的数据
  305. var inputPtr = Module._malloc(4 * data.length); // 输入数据
  306. for (var i = 0; i < data.length; i++) {
  307. Module.HEAPU8[(inputPtr) + i] = data[i]; //转换为堆数据
  308. }
  309. var pcmLen = Module._feedData(retPtr, inputPtr, data.length);
  310. if (pcmLen >= 0) {
  311. var pcmData = new Uint8Array(pcmLen);
  312. for (var i = 0; i < pcmLen; i++) {
  313. pcmData[i] = Module.HEAPU8[(retPtr) + i]
  314. }
  315. player.feed(pcmData);
  316. }
  317. decodeCount++;
  318. Module._free(inputPtr);
  319. Module._free(retPtr);
  320. }
  321. //解协议
  322. function ParseProto(data) {
  323. var input = new Uint8Array(data),
  324. duration,
  325. video,
  326. audio;
  327. if (input[0] == 0 && input[1] == 0 && input[2] == 0 && input[3] == 1) {
  328. video = input;
  329. duration = 24;
  330. var nalType = input[4] & 0x1f;
  331. if (!isFeed) {
  332. if (nalType == 0x05 && isVisuable) {
  333. isFeed = true;
  334. }
  335. }
  336. } else if (input[0] == 0xff) {
  337. if (!isEnough) {
  338. requestCount++;
  339. }
  340. audio = input;
  341. if (new Date().getTime() - curTime > 100) {
  342. delayTime = new Date().getTime();
  343. }
  344. curTime = new Date().getTime();
  345. duration = 24;
  346. } else if (input[0] == 0x68) {
  347. if (input[23] == 0x5c) {
  348. console.log("收到消息:" + PrintArry(input));
  349. if (CheckVerifyCode(input)) {
  350. ws.send(ConfigChannel('RK3923C1201900139'));
  351. var checkBuffer = GetScreenState();
  352. ws.send(checkBuffer);
  353. }
  354. else {
  355. $.toast("画面异常,请重新进入", "text");
  356. clearInterval(intervaler);
  357. ws.close();
  358. wsss.close();
  359. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  360. tt.miniProgram.switchTab({
  361. url: '/pages/home/home'
  362. })
  363. } else {
  364. wx.miniProgram.switchTab({
  365. url: '/pages/home/home'
  366. })
  367. }
  368. }
  369. }
  370. if (input[23] == 0x05) { //横竖屏标识
  371. var state = CheckScreenDirection(input.slice(24, 24 + 8));
  372. if (state == 1) {
  373. console.log("安卓卡此时竖屏");
  374. //竖屏处理
  375. resolving = 1;
  376. } else {
  377. console.log("安卓卡此时横屏");
  378. //横屏处理
  379. resolving = 0;
  380. }
  381. }
  382. if (input[23] == 0x0B)//多端登录处理, 数据从索引24开始取, input 是接收到的原始数据
  383. {
  384. var jsonobj = checkMultiLoginInfo(input);
  385. }
  386. }
  387. return {
  388. audio: audio,
  389. video: video,
  390. duration: duration
  391. };
  392. }
  393. function GetRequest() {
  394. var url = location.search; // 获取url中"?"符后的字串
  395. var obj = new Object();
  396. if (url.indexOf("?") != -1) {
  397. var str = url.substr(1);
  398. strs = str.split("&");
  399. for (var i = 0; i < strs.length; i++) {
  400. obj[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
  401. }
  402. }
  403. return obj;
  404. }
  405. function Back() {
  406. ExexuteKeyDown(4);
  407. window.event.returnValue = false;
  408. return false;
  409. }
  410. var url = window.location.href;
  411. url = url.split('/');
  412. var baseUrl = url[0] + '//' + url[2];
  413. var form = {};
  414. form.token = parameters['token'];
  415. form.userCardId = parameters['userCardId'];
  416. function array_unique(arr) {
  417. return arr.filter(function (e, i) {
  418. return arr.indexOf(e) === i;
  419. })
  420. }
  421. var cutList = [];
  422. let timer, isFlag = true;
  423. function showShearPlate() {
  424. stopManyClick(() => {
  425. $('.box-shear-plate').empty();
  426. $.ajax({
  427. url: baseUrl + "/api/public/v5/shear/content",
  428. headers: {
  429. 'Authorization': form.token
  430. },
  431. type: 'get',
  432. dataType: 'json',
  433. success: function (res) {
  434. if (res.status === 0) {
  435. if (res.data.length) {
  436. cutList = array_unique(res.data)
  437. var str = '<div class="title">剪贴板<div onclick="handleClear()" class="btn-clear">清空</div></div><div class="slide-wrapper-content">'
  438. cutList.forEach(function (item) {
  439. 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>"
  440. })
  441. str += '</div>'
  442. $('.box-shear-plate').append(str);
  443. } else {
  444. $('.box-shear-plate').append('<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>')
  445. }
  446. $('.mask').show();
  447. initSlider();
  448. } else {
  449. $('.box-shear-plate').append('<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>')
  450. $('.mask').show();
  451. }
  452. }
  453. })
  454. })
  455. }
  456. //防止提示一秒内重复显示
  457. function stopManyClick(fn) {
  458. if (isFlag) {
  459. fn();
  460. }
  461. isFlag = false;
  462. if (timer) { clearTimeout(timer); }
  463. timer = setTimeout(() => { isFlag = true }, 1500);
  464. }
  465. // 清空剪贴板
  466. function handleClear() {
  467. var ids = '';
  468. cutList.forEach(function (item) {
  469. ids += 'ids=' + item.id + '&'
  470. });
  471. ids = ids.substring(0, ids.lastIndexOf('&'));
  472. $.confirm("确定清空剪贴板?", function () {
  473. $.ajax({
  474. url: baseUrl + "/api/public/v5/shear/content?" + ids,
  475. headers: {
  476. 'Authorization': form.token
  477. },
  478. type: 'DELETE',
  479. dataType: 'json',
  480. success: function (res) {
  481. if (res.status === 0) {
  482. showShearPlate();
  483. } else {
  484. $.toast(res.msg, "text");
  485. }
  486. }
  487. })
  488. });
  489. }
  490. function handleCopy(content) {
  491. var cutting = {
  492. "type": "cutting",
  493. "data": {
  494. "str": content
  495. }
  496. };
  497. wsss.send(JSON.stringify(cutting));
  498. }
  499. // 删除剪贴板
  500. function handleDelete(id) {
  501. $.ajax({
  502. url: baseUrl + "/api/public/v5/shear/content?ids=" + id,
  503. headers: {
  504. 'Authorization': form.token
  505. },
  506. type: 'DELETE',
  507. dataType: 'json',
  508. success: function (res) {
  509. if (res.status === 0) {
  510. showShearPlate();
  511. } else {
  512. $.toast(res.msg, "text");
  513. }
  514. }
  515. })
  516. }
  517. function initSlider() {
  518. //手指滑动多少距离就认为是滑成功
  519. //这个值不能太大,否则影响斜着滑动时,垂直滑动的流畅性,也不能太小,太灵敏也不好
  520. var diffXDistance = 50;
  521. //当前滑动的对象
  522. var currentObject;
  523. //上一次滑动的对象
  524. var lastObject;
  525. //是否可以左右滑动,在上下滑的时候禁止左右滑
  526. var canSlide = true;
  527. //用于记录按下的点
  528. var startPoint;
  529. $(".slide-content").css({
  530. width: $(".slide-wrapper").width()
  531. });
  532. document.body.removeEventListener('touchmove', function (e) {
  533. e.preventDefault()
  534. }, {
  535. passive: false
  536. })
  537. $(".slide-scroll").css({
  538. width: $(".slide-wrapper").width() + $(".slide-content-button").width()
  539. }).on('touchstart', function (e) {
  540. currentObject = this;
  541. startPoint = {
  542. x: e.originalEvent.changedTouches[0].pageX,
  543. y: e.originalEvent.changedTouches[0].pageY
  544. };
  545. }).on('touchmove', function (e) {
  546. //如果是左右滑动,就禁止上下的滑动
  547. //如果是上下的滑动,就禁止左右滑动
  548. if (Math.abs(e.originalEvent.changedTouches[0].pageX - startPoint.x) > Math.abs(e.originalEvent.changedTouches[0].pageY - startPoint.y)) {
  549. event.preventDefault();
  550. } else {
  551. canSlide = false;
  552. }
  553. }).on('touchend', function (e) {
  554. //如果是上下滑动,这里就直接返回了
  555. if (!canSlide) {
  556. canSlide = true;
  557. return true;
  558. }
  559. //点击除当前左滑对象之外的任意其他位置
  560. if (lastObject && currentObject != lastObject) {
  561. //右滑→
  562. $(lastObject).removeClass("animate-slide");
  563. //清空上一个左滑的对象
  564. lastObject = undefined;
  565. }
  566. var diffX = e.originalEvent.changedTouches[0].pageX - startPoint.x;
  567. if (diffX < -diffXDistance) {
  568. //左滑←
  569. $(currentObject).addClass("animate-slide");
  570. if (lastObject && lastObject != currentObject) {
  571. //右滑→
  572. $(lastObject).removeClass("animate-slide");
  573. }
  574. //记录上一个左滑的对象
  575. lastObject = currentObject;
  576. } else if (diffX >= diffXDistance) {
  577. if (currentObject == lastObject) {
  578. //右滑→
  579. $(currentObject).removeClass("animate-slide");
  580. //清空上一个左滑的对象
  581. lastObject = undefined;
  582. }
  583. }
  584. });
  585. }
  586. var orientation = 0; //0 竖屏,1横屏
  587. var btnMuted = document.querySelector("#btnMuted");
  588. btnMuted && (function () {
  589. var setHistory = function (left, top) {
  590. try {
  591. localStorage.setItem("muted-btn-loc", JSON.stringify({
  592. left: left,
  593. top: top
  594. }));
  595. } catch (ex) { }
  596. };
  597. var getHistory = function () {
  598. try {
  599. var value = localStorage.getItem("muted-btn-loc");
  600. if (!value) return null;
  601. value = JSON.parse(value);
  602. if (!value) return null;
  603. return value;
  604. } catch (ex) {
  605. return null
  606. }
  607. };
  608. var fixLoc = function (loc) {
  609. var rect = btnMuted.getBoundingClientRect();
  610. rect = {
  611. top: rect.top,
  612. left: rect.left,
  613. width: rect.width,
  614. height: rect.height
  615. }; //部分低版本浏览器,该属性为只读
  616. if (loc) {
  617. rect.left = loc.left;
  618. rect.top = loc.top;
  619. }
  620. var minX = 0;
  621. var minY = 0;
  622. var docRect = document.documentElement.getBoundingClientRect();
  623. var maxY = docRect.height - rect.height;
  624. var maxX = docRect.width - rect.width;
  625. var left = rect.left;
  626. var top = rect.top;
  627. left = Math.min(left, maxX);
  628. left = Math.max(left, minX);
  629. top = Math.min(top, maxY);
  630. top = Math.max(top, minY);
  631. if (loc || top !== rect.top || left !== rect.left) {
  632. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  633. }
  634. }
  635. window.addEventListener("resize", function () {
  636. fixLoc();
  637. });
  638. var touchPoint = {
  639. pageY: 0,
  640. pageX: 0
  641. };
  642. var currentLoc = {
  643. top: 0,
  644. left: 0,
  645. curTop: 0,
  646. curLeft: 0
  647. };
  648. var toMove = false;
  649. var touchmove = function (e) {
  650. e.preventDefault();
  651. var point = e.changedTouches[0];
  652. var top = -touchPoint.pageY + point.pageY;
  653. var left = -touchPoint.pageX + point.pageX;
  654. if (toMove) {
  655. top += currentLoc.top;
  656. left += currentLoc.left;
  657. currentLoc.curLeft = left;
  658. currentLoc.curTop = top;
  659. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  660. } else {
  661. if (Math.abs(top) >= 5 || Math.abs(left) >= 5) {
  662. toMove = true;
  663. }
  664. }
  665. };
  666. var touchend = function () {
  667. window.removeEventListener("touchmove", touchmove, {
  668. passive: false
  669. });
  670. window.removeEventListener("touchend", touchend, {
  671. passive: false
  672. });
  673. if (toMove) {
  674. setHistory(currentLoc.curLeft, currentLoc.curTop);
  675. fixLoc();
  676. } else {
  677. //按点击处理
  678. var set = $('.control-right-img').attr("data-id")
  679. if (set == '1') {
  680. $('.control-right-img').attr({
  681. "data-id": "2"
  682. })
  683. $(".leftmains").css({
  684. "right": "0rem"
  685. })
  686. } else {
  687. $('.control-right-img').attr({
  688. "data-id": "1"
  689. })
  690. $(".leftmains").css({
  691. "right": "-4rem"
  692. })
  693. }
  694. }
  695. }
  696. btnMuted.addEventListener("touchstart", function (e) {
  697. e.preventDefault();
  698. toMove = false;
  699. var point = e.changedTouches[0];
  700. touchPoint.pageX = point.pageX;
  701. touchPoint.pageY = point.pageY;
  702. var rect = e.target.getBoundingClientRect();
  703. currentLoc.top = rect.top;
  704. currentLoc.left = rect.left;
  705. window.addEventListener("touchmove", touchmove, {
  706. passive: false
  707. });
  708. window.addEventListener("touchend", touchend, {
  709. passive: false
  710. });
  711. }, {
  712. passive: false
  713. });
  714. var history = getHistory();
  715. if (history) {
  716. fixLoc(history);
  717. }
  718. btnMuted.classList.remove("hide");
  719. })();
  720. $(".boximg").on("click", function () {
  721. $(".mainbox").css({
  722. "display": "none"
  723. })
  724. })
  725. // 剪贴板
  726. $(".sboxbu").on("click", function () {
  727. $(".sbox").css({
  728. "display": "none"
  729. })
  730. })
  731. // 剪贴板
  732. $(".uploadss").on("click", function () {
  733. $(".sbox").css({
  734. "display": "none"
  735. })
  736. })
  737. $("#upload").on("click", function () {
  738. clearInterval(intervaler);
  739. ws.close();
  740. wsss.close();
  741. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  742. tt.miniProgram.switchTab({
  743. url: '/pages/home/home'
  744. })
  745. } else {
  746. wx.miniProgram.switchTab({
  747. url: '/pages/home/home'
  748. })
  749. }
  750. })
  751. function selectText(x) {
  752. if (document.selection) {
  753. var range = document.body.createTextRange();
  754. range.moveToElementText(x);
  755. range.select();
  756. } else if (window.getSelection) {
  757. var selection = window.getSelection();
  758. var range = document.createRange();
  759. selection.removeAllRanges();
  760. range.selectNodeContents(x);
  761. selection.addRange(range);
  762. }
  763. }
  764. function cp(x) {
  765. $(".mainbox").css({
  766. "display": "none"
  767. })
  768. $(".sbox").css({
  769. "display": "block"
  770. })
  771. selectText(x);
  772. document.execCommand("copy");
  773. }
  774. window.onbeforeunload = function () {
  775. ws.close();
  776. wsss.close();
  777. }
  778. </script>
  779. <script type="text/javascript" src="aac.js"></script>
  780. </body>
  781. </html>