WXtrialInterface.html 21 KB

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