WXtrialInterface.html 21 KB

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