WXtrialInterface.html 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926
  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. <div class="try-use-wrap">
  103. <div class="try-use-container">
  104. <video width="100%" height="100%" muted autoplay="autoplay" loop="loop">
  105. <source id="source" src="http://110.53.221.195:8210/document/newFile/download/0/3dn9b4585511476691c6?fileKey=LowLevelMultipartUpload_16522192367175270411" type="video/mp4"></source>
  106. 您的浏览器不支持 video 标签。
  107. </video>
  108. <div class="time-close-wrap"><span class="time-node"></span> 关闭</div>
  109. </div>
  110. </div>
  111. <div class="buy-phone-wrap">
  112. <div class="bug-wrap">
  113. <div class="bug-title">体验完整云手机服务请前往购买</div>
  114. <div class="btn-list">
  115. <div class="btn cannel-btn">取消</div>
  116. <div class="btn go-bug">去购买</div>
  117. </div>
  118. </div>
  119. </div>
  120. <body oncontextmenu="Back()">
  121. </body>
  122. <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
  123. <script src="https://lf1-cdn-tos.bytegoofy.com/goofy/developer/jssdk/jssdk-1.0.3.js"></script>
  124. <script type="text/javascript" src="../static/js/jquery-1.11.0.min.js"></script>
  125. <script type="text/javascript" src="helper.js"></script>
  126. <script type="text/javascript" src="pcm-player.js"></script>
  127. <script type="text/javascript" src="https://cdn.bootcss.com/vConsole/3.2.0/vconsole.min.js"></script>
  128. <script src="https://cdn.bootcss.com/jquery-weui/1.2.1/js/jquery-weui.min.js"></script>
  129. <script type="text/javascript" src="WXdraw.js?v=110"></script>
  130. <script type="text/javascript" src="jmuxer.js"></script>
  131. <script>
  132. var baseUrl = 'http://192.168.31.198'
  133. var parameters = GetRequest();
  134. var form = {};
  135. form.token = parameters['token'];
  136. form.userCardId = parameters['userCardId'];
  137. var videoTimer = null, videoTime = 5;
  138. if (parameters['mealType'] === 'VIP') {
  139. $(".loading_sceen_pic").attr('src', '../static/img/home_bg_VIP.png');
  140. } else if (parameters['mealType'] === 'SVIP') {
  141. $(".loading_sceen_pic").attr('src', '../static/img/home_bg_SVIP.png');
  142. } else if (parameters['mealType'] === 'STAR') {
  143. $(".loading_sceen_pic").attr('src', '../static/img/home_bg_STAR.png');
  144. } else if (parameters['mealType'] === 'STARPRO') {
  145. $(".loading_sceen_pic").attr('src', '../static/img/home_bg_PRO.png');
  146. }
  147. adList();
  148. var isAudioPlay = false;
  149. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  150. var video = document.getElementById("playerVideo");
  151. video.play();
  152. setTimeout(() => { // 抖音环境需要设置延时,不然会有video默认图显示
  153. $.alert({
  154. title: '提示',
  155. text: '开始使用云手机',
  156. onOK: function () {
  157. setTimeout(() => {
  158. isAudioPlay = true;
  159. }, 1000);
  160. }
  161. });
  162. }, 1000)
  163. } else {
  164. // $.alert({
  165. // title: '提示',
  166. // text: '开始使用云手机',
  167. // onOK: function () {
  168. // var video = document.getElementById("playerVideo");
  169. // video.play();
  170. // isAudioPlay = true;
  171. // }
  172. // });
  173. }
  174. //列表
  175. function getSetmealList() {
  176. return new Promise((resolve, reject) => {
  177. $.ajax({
  178. url: baseUrl + "/api/resources/v4/freetrial/setmeal/list",
  179. headers: {
  180. 'Authorization': form.token
  181. },
  182. type: 'get',
  183. dataType: 'json',
  184. success: function (res) {
  185. if (res.status === 0) {
  186. let list = res.data;
  187. list.map((item) => {
  188. // if(item.phoneType === parameters['mealType']){
  189. if(item.phoneType === 'SVIP'){
  190. resolve(item)
  191. }
  192. })
  193. }
  194. }
  195. })
  196. })
  197. }
  198. //广告信息
  199. function adList() {
  200. getSetmealList().then((res) => {
  201. if(res.pushFlowAdvert === 1){
  202. $.ajax({
  203. url: baseUrl + "/api/public/v5/advertising/getAdInfoByAdPlace",
  204. headers: {
  205. 'Authorization': form.token
  206. },
  207. data: JSON.stringify({
  208. adPlace: 15,
  209. os: 0
  210. }),
  211. type: 'post',
  212. dataType: 'json',
  213. success: function (res) {
  214. if (res.status === 0) {
  215. let list = res.data.data;
  216. let videoTime = list[0].forcedTime;
  217. $('#source').src = list[0].forcedTime;
  218. videoTimer = setInterval(() =>{
  219. if(videoTime > 0) {
  220. videoTime--;
  221. $('.time-node').eq(0).text(videoTime);
  222. } else {
  223. clearInterval(videoTimer);
  224. $('.time-node').eq(0).text('');
  225. }
  226. },1000)
  227. $('.try-use-wrap').eq(0).show();
  228. }
  229. }
  230. })
  231. }
  232. })
  233. }
  234. //关闭广告
  235. $('.time-close-wrap')[0].addEventListener('click', () => {
  236. $('.try-use-wrap').eq(0).hide();
  237. $('.buy-phone-wrap').eq(0).show();
  238. })
  239. // 点击取消
  240. $('.cannel-btn')[0].addEventListener('click', () => {
  241. $('.buy-phone-wrap').eq(0).hide();
  242. })
  243. // 点击去购买
  244. $('.go-bug')[0].addEventListener('click', () => {
  245. wx.miniProgram.switchTab({
  246. url: '/pages/home/home'
  247. })
  248. })
  249. var topwinHeight = window.screen.height - window.innerHeight + 30; //计算title top 头部
  250. $('#wine').css({
  251. "width": window.screen.width,
  252. "height": window.screen.height - topwinHeight - 20,
  253. "position": "absolute"
  254. });
  255. $('.loading').css({
  256. "width": window.screen.width,
  257. "height": window.screen.height - topwinHeight - 20
  258. });
  259. var winese = document.createElement("wine");
  260. wine.style.top = "-" + winese + 'px';
  261. var requestCount = 0;
  262. var isVisuable = true;
  263. var isFeed = true;
  264. var isDrag = false;
  265. var isEnough = true;
  266. var isFinish = false;
  267. var delayTime = new Date().getTime();
  268. var curTime = new Date().getTime();
  269. var myVideo = document.getElementById("playerVideo");
  270. Module = {};
  271. Module.onRuntimeInitialized = function () {
  272. isFinish = true;
  273. }
  274. var isWSS = true;
  275. var ip = parameters["ip"];
  276. var cardToken = parameters["cardToken"];
  277. cardToken = cardToken && cardToken.replace(/@/g, "=");
  278. cardToken = cardToken.replace(/\$/g, "+");
  279. var appletPushAddress = parameters["appletPushAddress"];
  280. var socketURL = isWSS ? "wss://" + appletPushAddress + "?cardIp=" + ip + "&token=" + cardToken : "ws://" + appletPushAddress + "?cardIp=" + ip + "&token=" + cardToken;
  281. var jmuxer = new JMuxer({
  282. node: 'playerVideo',
  283. flushingTime: 33,
  284. fps: 30,
  285. mode: 'video',
  286. debug: false
  287. });
  288. window.onload = function () {
  289. curTime = new Date().getTime();
  290. var myPlay = document.getElementById("wine");
  291. myPlay.onkeydown = function (event) {
  292. ExexuteKeyDown(e.keyCode);
  293. }
  294. }
  295. var ws, errorTime = 0;
  296. doConnect();
  297. // 节流
  298. // 设置一个标志
  299. function throttle(fn, delay) {
  300. let flag = true;
  301. errorTime += delay;
  302. return () => {
  303. if (!flag) return;
  304. flag = false;
  305. timer = setTimeout(() => {
  306. fn();
  307. flag = true;
  308. }, delay);
  309. };
  310. }
  311. var intervaler;
  312. function doConnect() {
  313. ws = new WebSocket(socketURL);
  314. ws.binaryType = 'arraybuffer';
  315. intervaler = setInterval(() => {
  316. if (ws.readyState === 1) {
  317. ws.send("ping");
  318. } else {
  319. clearInterval(intervaler);
  320. $.toast("画面异常,请重新进入", "text");
  321. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  322. tt.miniProgram.switchTab({
  323. url: '/pages/home/home'
  324. })
  325. } else {
  326. wx.miniProgram.switchTab({
  327. url: '/pages/home/home'
  328. })
  329. }
  330. }
  331. }, 3000);
  332. ws.addEventListener('open', function (event) {
  333. // sn只要长度满足17位随机数,不需要从后台获取
  334. var verifyBuffer = VerifyCode('RK3923C1201900139', cardToken);
  335. console.log("鉴权报文:" + PrintArry(verifyBuffer));
  336. ws.send(verifyBuffer);
  337. });
  338. ws.addEventListener('error', function (event) {
  339. ws.close();
  340. clearInterval(intervaler);
  341. throttle(doConnect, 100);
  342. if (errorTime > 1000) {
  343. $.toast("画面异常,请重新进入", "text");
  344. wsss.close();
  345. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  346. tt.miniProgram.switchTab({
  347. url: '/pages/home/home'
  348. })
  349. } else {
  350. wx.miniProgram.switchTab({
  351. url: '/pages/home/home'
  352. })
  353. }
  354. }
  355. });
  356. ws.addEventListener('message', function (event) {
  357. var data = ParseProto(event.data); //JAVA服务器转发
  358. if (isAudioPlay) {
  359. $('.weui-mask_transparent').hide();
  360. $('.weui-toast').hide();
  361. $('.loading').hide();
  362. }
  363. var input = new Uint8Array(event.data);
  364. if (data.audio != null && isAudioPlay) { //喂音频
  365. if (input[0] == 0xff) {
  366. if (isFinish) {
  367. decodeAAC(input);
  368. }
  369. }
  370. }
  371. if (data.video != null) { //喂视频
  372. if (isFeed) {
  373. jmuxer.feed(data);
  374. }
  375. }
  376. });
  377. }
  378. document.addEventListener("visibilitychange", function () {
  379. if (document.visibilityState == "visible") {
  380. var buffer = RequestIFrame();
  381. ws.send(buffer);
  382. isVisuable = true;
  383. } else {
  384. isVisuable = false;
  385. isFeed = false;
  386. myVideo.pause();
  387. }
  388. });
  389. myVideo.addEventListener('pause', function () {
  390. isFeed = false;
  391. });
  392. var decodeCount = 1;
  393. var player = new PCMPlayer({
  394. encoding: '16bitInt',
  395. channels: 2,
  396. sampleRate: 44100,
  397. flushingTime: 22,
  398. debug: false
  399. });
  400. function handleClose() {
  401. $('.mask').hide();
  402. }
  403. function decodeAAC(data) {
  404. var retPtr = Module._malloc(4 * 5 * 1024); // 接收的数据
  405. var inputPtr = Module._malloc(4 * data.length); // 输入数据
  406. for (var i = 0; i < data.length; i++) {
  407. Module.HEAPU8[(inputPtr) + i] = data[i]; //转换为堆数据
  408. }
  409. var pcmLen = Module._feedData(retPtr, inputPtr, data.length);
  410. if (pcmLen >= 0) {
  411. var pcmData = new Uint8Array(pcmLen);
  412. for (var i = 0; i < pcmLen; i++) {
  413. pcmData[i] = Module.HEAPU8[(retPtr) + i]
  414. }
  415. player.feed(pcmData);
  416. }
  417. decodeCount++;
  418. Module._free(inputPtr);
  419. Module._free(retPtr);
  420. }
  421. //解协议
  422. function ParseProto(data) {
  423. var input = new Uint8Array(data),
  424. duration,
  425. video,
  426. audio;
  427. if (input[0] == 0 && input[1] == 0 && input[2] == 0 && input[3] == 1) {
  428. video = input;
  429. duration = 24;
  430. var nalType = input[4] & 0x1f;
  431. if (!isFeed) {
  432. if (nalType == 0x05 && isVisuable) {
  433. isFeed = true;
  434. }
  435. }
  436. } else if (input[0] == 0xff) {
  437. if (!isEnough) {
  438. requestCount++;
  439. }
  440. audio = input;
  441. if (new Date().getTime() - curTime > 100) {
  442. delayTime = new Date().getTime();
  443. }
  444. curTime = new Date().getTime();
  445. duration = 24;
  446. } else if (input[0] == 0x68) {
  447. if (input[23] == 0x5c) {
  448. console.log("收到消息:" + PrintArry(input));
  449. if (CheckVerifyCode(input)) {
  450. ws.send(ConfigChannel('RK3923C1201900139'));
  451. var checkBuffer = GetScreenState();
  452. ws.send(checkBuffer);
  453. }
  454. else {
  455. $.toast("画面异常,请重新进入", "text");
  456. clearInterval(intervaler);
  457. ws.close();
  458. wsss.close();
  459. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  460. tt.miniProgram.switchTab({
  461. url: '/pages/home/home'
  462. })
  463. } else {
  464. wx.miniProgram.switchTab({
  465. url: '/pages/home/home'
  466. })
  467. }
  468. }
  469. }
  470. if (input[23] == 0x05) { //横竖屏标识
  471. var state = CheckScreenDirection(input.slice(24, 24 + 8));
  472. if (state == 1) {
  473. console.log("安卓卡此时竖屏");
  474. //竖屏处理
  475. resolving = 1;
  476. } else {
  477. console.log("安卓卡此时横屏");
  478. //横屏处理
  479. resolving = 0;
  480. }
  481. }
  482. if (input[23] == 0x0B)//多端登录处理, 数据从索引24开始取, input 是接收到的原始数据
  483. {
  484. var jsonobj = checkMultiLoginInfo(input);
  485. }
  486. }
  487. return {
  488. audio: audio,
  489. video: video,
  490. duration: duration
  491. };
  492. }
  493. function GetRequest() {
  494. var url = location.search; // 获取url中"?"符后的字串
  495. var obj = new Object();
  496. if (url.indexOf("?") != -1) {
  497. var str = url.substr(1);
  498. strs = str.split("&");
  499. for (var i = 0; i < strs.length; i++) {
  500. obj[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
  501. }
  502. }
  503. return obj;
  504. }
  505. function Back() {
  506. ExexuteKeyDown(4);
  507. window.event.returnValue = false;
  508. return false;
  509. }
  510. var url = window.location.href;
  511. url = url.split('/');
  512. var baseUrl = url[0] + '//' + url[2];
  513. var form = {};
  514. form.token = parameters['token'];
  515. form.userCardId = parameters['userCardId'];
  516. function array_unique(arr) {
  517. return arr.filter(function (e, i) {
  518. return arr.indexOf(e) === i;
  519. })
  520. }
  521. var cutList = [];
  522. let timer, isFlag = true;
  523. function showShearPlate() {
  524. stopManyClick(() => {
  525. $('.box-shear-plate').empty();
  526. $.ajax({
  527. url: baseUrl + "/api/public/v5/shear/content",
  528. headers: {
  529. 'Authorization': form.token
  530. },
  531. type: 'get',
  532. dataType: 'json',
  533. success: function (res) {
  534. if (res.status === 0) {
  535. if (res.data.length) {
  536. cutList = array_unique(res.data)
  537. var str = '<div class="title">剪贴板<div onclick="handleClear()" class="btn-clear">清空</div></div><div class="slide-wrapper-content">'
  538. cutList.forEach(function (item) {
  539. 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>"
  540. })
  541. str += '</div>'
  542. $('.box-shear-plate').append(str);
  543. } else {
  544. $('.box-shear-plate').append('<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>')
  545. }
  546. $('.mask').show();
  547. initSlider();
  548. } else {
  549. $('.box-shear-plate').append('<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>')
  550. $('.mask').show();
  551. }
  552. }
  553. })
  554. })
  555. }
  556. //防止提示一秒内重复显示
  557. function stopManyClick(fn) {
  558. if (isFlag) {
  559. fn();
  560. }
  561. isFlag = false;
  562. if (timer) { clearTimeout(timer); }
  563. timer = setTimeout(() => { isFlag = true }, 1500);
  564. }
  565. // 清空剪贴板
  566. function handleClear() {
  567. var ids = '';
  568. cutList.forEach(function (item) {
  569. ids += 'ids=' + item.id + '&'
  570. });
  571. ids = ids.substring(0, ids.lastIndexOf('&'));
  572. $.confirm("确定清空剪贴板?", function () {
  573. $.ajax({
  574. url: baseUrl + "/api/public/v5/shear/content?" + ids,
  575. headers: {
  576. 'Authorization': form.token
  577. },
  578. type: 'DELETE',
  579. dataType: 'json',
  580. success: function (res) {
  581. if (res.status === 0) {
  582. showShearPlate();
  583. } else {
  584. $.toast(res.msg, "text");
  585. }
  586. }
  587. })
  588. });
  589. }
  590. function handleCopy(content) {
  591. var cutting = {
  592. "type": "cutting",
  593. "data": {
  594. "str": content
  595. }
  596. };
  597. wsss.send(JSON.stringify(cutting));
  598. }
  599. // 删除剪贴板
  600. function handleDelete(id) {
  601. $.ajax({
  602. url: baseUrl + "/api/public/v5/shear/content?ids=" + id,
  603. headers: {
  604. 'Authorization': form.token
  605. },
  606. type: 'DELETE',
  607. dataType: 'json',
  608. success: function (res) {
  609. if (res.status === 0) {
  610. showShearPlate();
  611. } else {
  612. $.toast(res.msg, "text");
  613. }
  614. }
  615. })
  616. }
  617. function initSlider() {
  618. //手指滑动多少距离就认为是滑成功
  619. //这个值不能太大,否则影响斜着滑动时,垂直滑动的流畅性,也不能太小,太灵敏也不好
  620. var diffXDistance = 50;
  621. //当前滑动的对象
  622. var currentObject;
  623. //上一次滑动的对象
  624. var lastObject;
  625. //是否可以左右滑动,在上下滑的时候禁止左右滑
  626. var canSlide = true;
  627. //用于记录按下的点
  628. var startPoint;
  629. $(".slide-content").css({
  630. width: $(".slide-wrapper").width()
  631. });
  632. document.body.removeEventListener('touchmove', function (e) {
  633. e.preventDefault()
  634. }, {
  635. passive: false
  636. })
  637. $(".slide-scroll").css({
  638. width: $(".slide-wrapper").width() + $(".slide-content-button").width()
  639. }).on('touchstart', function (e) {
  640. currentObject = this;
  641. startPoint = {
  642. x: e.originalEvent.changedTouches[0].pageX,
  643. y: e.originalEvent.changedTouches[0].pageY
  644. };
  645. }).on('touchmove', function (e) {
  646. //如果是左右滑动,就禁止上下的滑动
  647. //如果是上下的滑动,就禁止左右滑动
  648. if (Math.abs(e.originalEvent.changedTouches[0].pageX - startPoint.x) > Math.abs(e.originalEvent.changedTouches[0].pageY - startPoint.y)) {
  649. event.preventDefault();
  650. } else {
  651. canSlide = false;
  652. }
  653. }).on('touchend', function (e) {
  654. //如果是上下滑动,这里就直接返回了
  655. if (!canSlide) {
  656. canSlide = true;
  657. return true;
  658. }
  659. //点击除当前左滑对象之外的任意其他位置
  660. if (lastObject && currentObject != lastObject) {
  661. //右滑→
  662. $(lastObject).removeClass("animate-slide");
  663. //清空上一个左滑的对象
  664. lastObject = undefined;
  665. }
  666. var diffX = e.originalEvent.changedTouches[0].pageX - startPoint.x;
  667. if (diffX < -diffXDistance) {
  668. //左滑←
  669. $(currentObject).addClass("animate-slide");
  670. if (lastObject && lastObject != currentObject) {
  671. //右滑→
  672. $(lastObject).removeClass("animate-slide");
  673. }
  674. //记录上一个左滑的对象
  675. lastObject = currentObject;
  676. } else if (diffX >= diffXDistance) {
  677. if (currentObject == lastObject) {
  678. //右滑→
  679. $(currentObject).removeClass("animate-slide");
  680. //清空上一个左滑的对象
  681. lastObject = undefined;
  682. }
  683. }
  684. });
  685. }
  686. var orientation = 0; //0 竖屏,1横屏
  687. var btnMuted = document.querySelector("#btnMuted");
  688. btnMuted && (function () {
  689. var setHistory = function (left, top) {
  690. try {
  691. localStorage.setItem("muted-btn-loc", JSON.stringify({
  692. left: left,
  693. top: top
  694. }));
  695. } catch (ex) { }
  696. };
  697. var getHistory = function () {
  698. try {
  699. var value = localStorage.getItem("muted-btn-loc");
  700. if (!value) return null;
  701. value = JSON.parse(value);
  702. if (!value) return null;
  703. return value;
  704. } catch (ex) {
  705. return null
  706. }
  707. };
  708. var fixLoc = function (loc) {
  709. var rect = btnMuted.getBoundingClientRect();
  710. rect = {
  711. top: rect.top,
  712. left: rect.left,
  713. width: rect.width,
  714. height: rect.height
  715. }; //部分低版本浏览器,该属性为只读
  716. if (loc) {
  717. rect.left = loc.left;
  718. rect.top = loc.top;
  719. }
  720. var minX = 0;
  721. var minY = 0;
  722. var docRect = document.documentElement.getBoundingClientRect();
  723. var maxY = docRect.height - rect.height;
  724. var maxX = docRect.width - rect.width;
  725. var left = rect.left;
  726. var top = rect.top;
  727. left = Math.min(left, maxX);
  728. left = Math.max(left, minX);
  729. top = Math.min(top, maxY);
  730. top = Math.max(top, minY);
  731. if (loc || top !== rect.top || left !== rect.left) {
  732. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  733. }
  734. }
  735. window.addEventListener("resize", function () {
  736. fixLoc();
  737. });
  738. var touchPoint = {
  739. pageY: 0,
  740. pageX: 0
  741. };
  742. var currentLoc = {
  743. top: 0,
  744. left: 0,
  745. curTop: 0,
  746. curLeft: 0
  747. };
  748. var toMove = false;
  749. var touchmove = function (e) {
  750. e.preventDefault();
  751. var point = e.changedTouches[0];
  752. var top = -touchPoint.pageY + point.pageY;
  753. var left = -touchPoint.pageX + point.pageX;
  754. if (toMove) {
  755. top += currentLoc.top;
  756. left += currentLoc.left;
  757. currentLoc.curLeft = left;
  758. currentLoc.curTop = top;
  759. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  760. } else {
  761. if (Math.abs(top) >= 5 || Math.abs(left) >= 5) {
  762. toMove = true;
  763. }
  764. }
  765. };
  766. var touchend = function () {
  767. window.removeEventListener("touchmove", touchmove, {
  768. passive: false
  769. });
  770. window.removeEventListener("touchend", touchend, {
  771. passive: false
  772. });
  773. if (toMove) {
  774. setHistory(currentLoc.curLeft, currentLoc.curTop);
  775. fixLoc();
  776. } else {
  777. //按点击处理
  778. var set = $('.control-right-img').attr("data-id")
  779. if (set == '1') {
  780. $('.control-right-img').attr({
  781. "data-id": "2"
  782. })
  783. $(".leftmains").css({
  784. "right": "0rem"
  785. })
  786. } else {
  787. $('.control-right-img').attr({
  788. "data-id": "1"
  789. })
  790. $(".leftmains").css({
  791. "right": "-4rem"
  792. })
  793. }
  794. }
  795. }
  796. btnMuted.addEventListener("touchstart", function (e) {
  797. e.preventDefault();
  798. toMove = false;
  799. var point = e.changedTouches[0];
  800. touchPoint.pageX = point.pageX;
  801. touchPoint.pageY = point.pageY;
  802. var rect = e.target.getBoundingClientRect();
  803. currentLoc.top = rect.top;
  804. currentLoc.left = rect.left;
  805. window.addEventListener("touchmove", touchmove, {
  806. passive: false
  807. });
  808. window.addEventListener("touchend", touchend, {
  809. passive: false
  810. });
  811. }, {
  812. passive: false
  813. });
  814. var history = getHistory();
  815. if (history) {
  816. fixLoc(history);
  817. }
  818. btnMuted.classList.remove("hide");
  819. })();
  820. $(".boximg").on("click", function () {
  821. $(".mainbox").css({
  822. "display": "none"
  823. })
  824. })
  825. // 剪贴板
  826. $(".sboxbu").on("click", function () {
  827. $(".sbox").css({
  828. "display": "none"
  829. })
  830. })
  831. // 剪贴板
  832. $(".uploadss").on("click", function () {
  833. $(".sbox").css({
  834. "display": "none"
  835. })
  836. })
  837. $("#upload").on("click", function () {
  838. clearInterval(intervaler);
  839. ws.close();
  840. wsss.close();
  841. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  842. tt.miniProgram.switchTab({
  843. url: '/pages/home/home'
  844. })
  845. } else {
  846. wx.miniProgram.switchTab({
  847. url: '/pages/home/home'
  848. })
  849. }
  850. })
  851. function selectText(x) {
  852. if (document.selection) {
  853. var range = document.body.createTextRange();
  854. range.moveToElementText(x);
  855. range.select();
  856. } else if (window.getSelection) {
  857. var selection = window.getSelection();
  858. var range = document.createRange();
  859. selection.removeAllRanges();
  860. range.selectNodeContents(x);
  861. selection.addRange(range);
  862. }
  863. }
  864. function cp(x) {
  865. $(".mainbox").css({
  866. "display": "none"
  867. })
  868. $(".sbox").css({
  869. "display": "block"
  870. })
  871. selectText(x);
  872. document.execCommand("copy");
  873. }
  874. window.onbeforeunload = function () {
  875. ws.close();
  876. wsss.close();
  877. }
  878. </script>
  879. <script type="text/javascript" src="aac.js"></script>
  880. </body>
  881. </html>