WXtrialInterface.html 25 KB

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