WXtrialInterface.html 21 KB

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