WXtrialInterface.html 22 KB

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