WXtrialInterface.html 22 KB

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