WXtrialInterface.html 22 KB

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