WXtrialInterface.html 22 KB

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