WXtrialInterface.html 26 KB

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