WXtrialInterface.html 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162
  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. <style>
  37. .try-use-wrap,
  38. .buy-phone-wrap,
  39. .look-wrap {
  40. width: 100%;
  41. height: 100%;
  42. position: fixed;
  43. top: 0;
  44. left: 0;
  45. z-index: 9999;
  46. background: rgba(0, 0, 0, 0.5);
  47. display: none;
  48. }
  49. .try-use-container {
  50. width: 80%;
  51. height: 409px;
  52. position: absolute;
  53. top: 50%;
  54. left: 50%;
  55. transform: translate(-50%, -50%);
  56. background-color: #FFFFFF;
  57. border-radius: 0.66em;
  58. }
  59. .time-close-wrap {
  60. width: 5.46em;
  61. height: 2em;
  62. line-height: 2em;
  63. text-align: center;
  64. position: absolute;
  65. top: 0.24em;
  66. right: 0.3em;
  67. background: rgba(0, 0, 0, 0.49);
  68. border-radius: 1.26em;
  69. font-size: 12px;
  70. color: #FFFFFF;
  71. }
  72. .bug-wrap {
  73. width: 90%;
  74. height: 115px;
  75. background: #FFFFFF;
  76. border-radius: 10px;
  77. position: absolute;
  78. top: 50%;
  79. left: 50%;
  80. transform: translate(-50%, -50%);
  81. }
  82. .bug-title {
  83. text-align: center;
  84. margin: 25px 0;
  85. font-size: 18px;
  86. font-weight: 600;
  87. color: #333333;
  88. }
  89. .btn-list {
  90. width: 100%;
  91. height: 44px;
  92. line-height: 44px;
  93. border-top: 1px solid rgba(238, 238, 238, 1);
  94. position: absolute;
  95. bottom: 0;
  96. left: 0;
  97. display: flex;
  98. align-items: center;
  99. }
  100. .btn {
  101. flex: 1;
  102. text-align: center;
  103. }
  104. .cannel-btn {
  105. font-size: 18px;
  106. color: #666666;
  107. }
  108. .go-bug {
  109. font-size: 18px;
  110. color: #3B7FFF;
  111. border-left: 1px solid rgba(238, 238, 238, 1);
  112. }
  113. </style>
  114. </head>
  115. <body class="scroll h-player" style="overscroll-behavior: contain;">
  116. <div class="container" id="player">
  117. <div class="muted" id="btnMuted">
  118. <div class="control-right-img" data-id="1">
  119. <img src="../static/img/xuanfu_icon.png">
  120. </div>
  121. </div>
  122. <div id="wine">
  123. <video id="playerVideo" muted="muted" x5-video-orientation="landscape" playsinline="true" autoplay="true"
  124. webkit-playsinline="true" x5-playsinline="true" x5-video-player-type="h5" x5-video-player-fullscreen="false"
  125. style="pointer-events: none;object-fit: fill;width: 100%;height:100%"></video>
  126. <div id="box"></div>
  127. <audio preload="auto" autoplay controls poster="images/loader-thumb.jpg" id="audioPlayer"
  128. style="position: absolute;top: 0;width: 0;height: 0;"></audio>
  129. </div>
  130. <div class="leftmains">
  131. <div class="PictureQualityMain">
  132. <div class="PictureQuality" data-id="4">高清</div>
  133. <div class="PictureQuality avit" data-id="3">标清</div>
  134. <div class="PictureQuality" data-id="2">极速</div>
  135. </div>
  136. <div class="operation">
  137. <div class="upload" id="showsuss" data-text="uploads">
  138. <img src="../static/img/wx/shangchuan_icon.png">
  139. <div>上传</div>
  140. </div>
  141. <div class="upload" onclick="showShearPlate()" data-text="Shearplate">
  142. <img src="../static/img/wx/jianqieban_icon.png">
  143. <div>剪贴板</div>
  144. </div>
  145. <div class="upload" id="upload" data-text="Signout">
  146. <img src="../static/img/wx/tuichu_icon.png">
  147. <div>退出</div>
  148. </div>
  149. </div>
  150. </div>
  151. <div class="bottommains">
  152. <div class="botmat1">
  153. <div class="botmat1img" data-text="gengduo">
  154. <img src="../static/img/wx/gengduo_icon.png">
  155. </div>
  156. </div>
  157. <div class="botmat1">
  158. <div class="botmat1img" data-text="home">
  159. <img src="../static/img/wx/home_icon.png">
  160. </div>
  161. </div>
  162. <div class="botmat1">
  163. <div class="botmat1img" data-text="return">
  164. <img src="../static/img/wx/fanhui_icon.png">
  165. </div>
  166. </div>
  167. </div>
  168. <img class="loading loading_sceen_pic" />
  169. </div>
  170. <div class="mask">
  171. <div class="box-shear-plate"></div>
  172. <img class="close" onclick="handleClose()" src="img/guanbi_icon@2x.png" alt="">
  173. </div>
  174. <div class="weui-mask_transparent"></div>
  175. <div class="weui-toast weui_loading_toast weui-toast--visible">
  176. <div class="weui_loading"><i class="weui-loading weui-icon_toast"></i></div>
  177. <p class="weui-toast_content">数据加载中</p>
  178. </div>
  179. <div class="try-use-wrap">
  180. <div class="try-use-container">
  181. <video width="100%" height="100%" id="source" muted autoplay="autoplay" loop="loop">
  182. 您的浏览器不支持 video 标签。
  183. </video>
  184. <div class="time-close-wrap"><span class="time-node"></span> 关闭</div>
  185. </div>
  186. </div>
  187. <div class="buy-phone-wrap">
  188. <div class="bug-wrap">
  189. <div class="bug-title">获得极致体验服务请购买云手机</div>
  190. <div class="btn-list">
  191. <div class="btn cannel-btn">取消</div>
  192. <div class="btn go-bug">去购买</div>
  193. </div>
  194. </div>
  195. </div>
  196. <div class="look-wrap">
  197. <div class="bug-wrap">
  198. <div class="bug-title">关闭广告会退出云手机是否继续观看</div>
  199. <div class="btn-list">
  200. <div class="btn cannel-btn cannel-ad-btn">放弃</div>
  201. <div class="btn go-bug looking">继续观看</div>
  202. </div>
  203. </div>
  204. </div>
  205. <body oncontextmenu="Back()">
  206. </body>
  207. <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
  208. <script src="https://lf1-cdn-tos.bytegoofy.com/goofy/developer/jssdk/jssdk-1.0.3.js"></script>
  209. <script type="text/javascript" src="../static/js/jquery-1.11.0.min.js"></script>
  210. <script type="text/javascript" src="helper.js"></script>
  211. <script type="text/javascript" src="pcm-player.js"></script>
  212. <script type="text/javascript" src="https://cdn.bootcss.com/vConsole/3.2.0/vconsole.min.js"></script>
  213. <script src="https://cdn.bootcss.com/jquery-weui/1.2.1/js/jquery-weui.min.js"></script>
  214. <script type="text/javascript" src="WXdraw.js"></script>
  215. <script type="text/javascript" src="jmuxer.js"></script>
  216. <script type="text/javascript" src="spsParser.js"></script>
  217. <script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js"></script>
  218. <script>
  219. var url = window.location.href;
  220. url = url.split('/');
  221. var baseUrl = url[0] + '//' + url[2];
  222. var parameters = GetRequest();
  223. var form = {};
  224. form.token = parameters['token'];
  225. form.userCardId = parameters['userCardId'];
  226. var videoTimer = null, videoTime = 0, adType = 0, sourceType = 0, disconnectionFlag = false, getDate = false;
  227. if (parameters['mealType'] === 'VIP') {
  228. $(".loading_sceen_pic").attr('src', '../static/img/home_bg_VIP.png');
  229. } else if (parameters['mealType'] === 'SVIP') {
  230. $(".loading_sceen_pic").attr('src', '../static/img/home_bg_SVIP.png');
  231. } else if (parameters['mealType'] === 'STAR') {
  232. $(".loading_sceen_pic").attr('src', '../static/img/home_bg_STAR.png');
  233. } else if (parameters['mealType'] === 'STARPRO') {
  234. $(".loading_sceen_pic").attr('src', '../static/img/home_bg_PRO.png');
  235. }
  236. adInit();
  237. var isAudioPlay = false;
  238. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  239. var video = document.getElementById("playerVideo");
  240. video.play();
  241. setTimeout(() => { // 抖音环境需要设置延时,不然会有video默认图显示
  242. $.alert({
  243. title: '提示',
  244. text: '开始使用云手机',
  245. onOK: function () {
  246. setTimeout(() => {
  247. isAudioPlay = true;
  248. }, 1000);
  249. }
  250. });
  251. }, 1000)
  252. } else {
  253. $.alert({
  254. title: '提示',
  255. text: '开始使用云手机',
  256. onOK: function () {
  257. var video = document.getElementById("playerVideo");
  258. video.play();
  259. isAudioPlay = true;
  260. }
  261. });
  262. }
  263. //云机倒计时
  264. let validTime = parameters['validTime'] || 10000;
  265. if (validTime > 32000) {
  266. validTime = 32000
  267. }
  268. let detailTime = validTime * 60 * 1000;
  269. setTimeout(() => {
  270. $('.bug-title').eq(0).text('尊敬的用户您的云手机试用时间已到期');
  271. getDate = true;
  272. $('.buy-phone-wrap').eq(0).show();
  273. }, detailTime)
  274. var topwinHeight = window.screen.height - window.innerHeight + 30; //计算title top 头部
  275. $('#wine').css({
  276. "width": window.screen.width,
  277. "height": window.screen.height - topwinHeight - 20,
  278. "position": "absolute"
  279. });
  280. $('.loading').css({
  281. "width": window.screen.width,
  282. "height": window.screen.height - topwinHeight - 20
  283. });
  284. var winese = document.createElement("wine");
  285. wine.style.top = "-" + winese + 'px';
  286. var isVisuable = true;
  287. var isFeed = true;
  288. var isFinish = false;
  289. var myVideo = document.getElementById("playerVideo");
  290. Module = {};
  291. Module.onRuntimeInitialized = function () {
  292. isFinish = true;
  293. }
  294. var isWSS = true;
  295. var ip = parameters["ip"];
  296. var cardToken = parameters["cardToken"];
  297. cardToken = cardToken && decodeURIComponent(cardToken);
  298. var appletPushAddress = parameters["appletPushAddress"];
  299. var socketURL = isWSS ? "wss://" + appletPushAddress + "?cardIp=" + ip + "&token=" + cardToken + "&type=business" : "ws://" + appletPushAddress + "?cardIp=" + ip + "&token=" + cardToken;
  300. var jmuxer = new JMuxer({
  301. node: 'playerVideo',
  302. flushingTime: 33,
  303. fps: 30,
  304. mode: 'video',
  305. debug: false
  306. });
  307. window.onload = function () {
  308. var myPlay = document.getElementById("wine");
  309. myPlay.onkeydown = function (event) {
  310. ExexuteKeyDown(e.keyCode);
  311. }
  312. }
  313. var ws, errorTime = 0;
  314. doConnect();
  315. // 节流
  316. // 设置一个标志
  317. function throttle(fn, delay) {
  318. let flag = true;
  319. errorTime += delay;
  320. return () => {
  321. if (!flag) return;
  322. flag = false;
  323. timer = setTimeout(() => {
  324. fn();
  325. flag = true;
  326. }, delay);
  327. };
  328. }
  329. var intervaler;
  330. function doConnect() {
  331. ws = new WebSocket(socketURL);
  332. ws.binaryType = 'arraybuffer';
  333. intervaler = setInterval(() => {
  334. if (ws.readyState === 1) {
  335. ws.send("ping");
  336. } else {
  337. clearInterval(intervaler);
  338. $.toast("画面异常,请重新进入", "text");
  339. quit();
  340. }
  341. }, 3000);
  342. ws.addEventListener('open', function (event) {
  343. // sn只要长度满足17位随机数,不需要从后台获取
  344. var verifyBuffer = VerifyCode('RK3923C1201900139', cardToken);
  345. console.log("鉴权报文:" + PrintArry(verifyBuffer));
  346. ws.send(verifyBuffer);
  347. });
  348. ws.addEventListener('error', function (event) {
  349. ws.close();
  350. clearInterval(intervaler);
  351. throttle(doConnect, 100);
  352. if (errorTime > 1000) {
  353. $.toast("画面异常,请重新进入", "text");
  354. wsss.close();
  355. quit();
  356. }
  357. });
  358. ws.addEventListener('message', function (event) {
  359. var data = ParseProto(event.data); //JAVA服务器转发
  360. if (isAudioPlay) {
  361. $('.weui-mask_transparent').hide();
  362. $('.weui-toast').hide();
  363. $('.loading').hide();
  364. }
  365. var input = new Uint8Array(event.data);
  366. if (data.audio != null && isAudioPlay) { //喂音频
  367. if (input[0] == 0xff) {
  368. if (isFinish) {
  369. decodeAAC(input);
  370. }
  371. }
  372. }
  373. if (data.frameType != undefined && data.frameType != 1 && data.frameType != 6) {
  374. if (data.frameType == 7) {
  375. let info = spsParser(data.video);
  376. if (info.width != myVideo.videoWidth && info.height != myVideo.videoHeight) {
  377. if (myVideo.videoWidth == 0) {
  378. console.log("SPS计算得到宽 %d, 高 %d, 控件宽 %d, %d", info.width, info.height, myVideo.videoWidth, myVideo.videoHeight);
  379. }
  380. }
  381. }
  382. }
  383. if (data.video != null) { //喂视频
  384. if (data.frameType == 0x05 && isVisuable) {
  385. isFeed = true;
  386. }
  387. if (data.frameType == 7 || data.frameType == 8) {
  388. isFeed = true;
  389. isAudioPlay = true;
  390. }
  391. if (isFeed) {
  392. jmuxer.feed(data);
  393. }
  394. }
  395. });
  396. }
  397. var hidden, visibilityChange;
  398. if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support
  399. hidden = "hidden";
  400. visibilityChange = "visibilitychange";
  401. } else if (typeof document.msHidden !== "undefined") {
  402. hidden = "msHidden";
  403. visibilityChange = "msvisibilitychange";
  404. } else if (typeof document.webkitHidden !== "undefined") {
  405. hidden = "webkitHidden";
  406. visibilityChange = "webkitvisibilitychange";
  407. }
  408. // 处理页面可见属性的改变
  409. document.addEventListener("visibilitychange", function () {
  410. console.log(document[hidden]);
  411. if (document[hidden]) {
  412. quit();
  413. ws.close();
  414. wsss.close();
  415. }
  416. }, false);
  417. myVideo.addEventListener('pause', function () {
  418. isFeed = false;
  419. });
  420. var decodeCount = 1;
  421. var player = new PCMPlayer({
  422. encoding: '16bitInt',
  423. channels: 2,
  424. sampleRate: 44100,
  425. flushingTime: 22,
  426. debug: false
  427. });
  428. function handleClose() {
  429. $('.mask').hide();
  430. }
  431. function decodeAAC(data) {
  432. var retPtr = Module._malloc(4 * 5 * 1024); // 接收的数据
  433. var inputPtr = Module._malloc(4 * data.length); // 输入数据
  434. for (var i = 0; i < data.length; i++) {
  435. Module.HEAPU8[(inputPtr) + i] = data[i]; //转换为堆数据
  436. }
  437. var pcmLen = Module._feedData(retPtr, inputPtr, data.length);
  438. if (pcmLen >= 0) {
  439. var pcmData = new Uint8Array(pcmLen);
  440. for (var i = 0; i < pcmLen; i++) {
  441. pcmData[i] = Module.HEAPU8[(retPtr) + i]
  442. }
  443. player.feed(pcmData);
  444. }
  445. decodeCount++;
  446. Module._free(inputPtr);
  447. Module._free(retPtr);
  448. }
  449. //解协议
  450. function ParseProto(data) {
  451. var input = new Uint8Array(data),
  452. duration,
  453. video,
  454. frameType,
  455. audio;
  456. if (input[0] == 0 && input[1] == 0 && input[2] == 0 && input[3] == 1) {
  457. video = input;
  458. duration = 24;
  459. var nalType = input[4] & 0x1f;
  460. frameType = nalType;
  461. if (!isFeed) {
  462. if (nalType == 0x05 && isVisuable) {
  463. isFeed = true;
  464. }
  465. }
  466. } else if (input[0] == 0xff) {
  467. audio = input;
  468. duration = 24;
  469. } else if (input[0] == 0x68) {
  470. if (input[23] == 0x5c) {
  471. console.log("收到消息:" + PrintArry(input));
  472. if (CheckVerifyCode(input)) {
  473. ws.send(ConfigChannel('RK3923C1201900139'));
  474. var checkBuffer = GetScreenState();
  475. ws.send(checkBuffer);
  476. }
  477. else {
  478. $.toast("画面异常,请重新进入", "text");
  479. clearInterval(intervaler);
  480. quit();
  481. ws.close();
  482. wsss.close();
  483. }
  484. }
  485. if (input[23] == 0x05) { //横竖屏标识
  486. var state = CheckScreenDirection(input.slice(24, 24 + 8));
  487. if (state == 1) {
  488. console.log("安卓卡此时竖屏");
  489. //竖屏处理
  490. resolving = 1;
  491. } else {
  492. console.log("安卓卡此时横屏");
  493. //横屏处理
  494. resolving = 0;
  495. }
  496. }
  497. if (input[23] == 0x0B)//多端登录处理, 数据从索引24开始取, input 是接收到的原始数据
  498. {
  499. var jsonobj = checkMultiLoginInfo(input);
  500. }
  501. }
  502. return {
  503. audio: audio,
  504. video: video,
  505. duration: duration,
  506. frameType: frameType
  507. };
  508. }
  509. function GetRequest() {
  510. var url = location.search; // 获取url中"?"符后的字串
  511. var obj = new Object();
  512. if (url.indexOf("?") != -1) {
  513. var str = url.substr(1);
  514. strs = str.split("&");
  515. for (var i = 0; i < strs.length; i++) {
  516. obj[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
  517. }
  518. }
  519. return obj;
  520. }
  521. function Back() {
  522. ExexuteKeyDown(4);
  523. window.event.returnValue = false;
  524. return false;
  525. }
  526. var form = {};
  527. form.token = parameters['token'];
  528. form.userCardId = parameters['userCardId'];
  529. function array_unique(arr) {
  530. return arr.filter(function (e, i) {
  531. return arr.indexOf(e) === i;
  532. })
  533. }
  534. var cutList = [];
  535. let timer, isFlag = true;
  536. function showShearPlate() {
  537. if (!isControl) {
  538. return
  539. }
  540. stopManyClick(() => {
  541. $('.box-shear-plate').empty();
  542. $.ajax({
  543. url: baseUrl + "/api/public/v5/shear/content",
  544. headers: {
  545. 'Authorization': form.token
  546. },
  547. type: 'get',
  548. dataType: 'json',
  549. success: function (res) {
  550. if (res.status === 0) {
  551. if (res.data.length) {
  552. cutList = array_unique(res.data)
  553. var str = '<div class="title">剪贴板<div onclick="handleClear()" class="btn-clear">清空</div></div><div class="slide-wrapper-content">'
  554. cutList.forEach(function (item) {
  555. 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>"
  556. })
  557. str += '</div>'
  558. $('.box-shear-plate').append(str);
  559. } else {
  560. $('.box-shear-plate').append('<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>')
  561. }
  562. $('.mask').show();
  563. initSlider();
  564. } else {
  565. $('.box-shear-plate').append('<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>')
  566. $('.mask').show();
  567. }
  568. }
  569. })
  570. })
  571. }
  572. //防止提示一秒内重复显示
  573. function stopManyClick(fn) {
  574. if (isFlag) {
  575. fn();
  576. }
  577. isFlag = false;
  578. if (timer) { clearTimeout(timer); }
  579. timer = setTimeout(() => { isFlag = true }, 1500);
  580. }
  581. // 清空剪贴板
  582. function handleClear() {
  583. var ids = '';
  584. cutList.forEach(function (item) {
  585. ids += 'ids=' + item.id + '&'
  586. });
  587. ids = ids.substring(0, ids.lastIndexOf('&'));
  588. $.confirm("确定清空剪贴板?", function () {
  589. $.ajax({
  590. url: baseUrl + "/api/public/v5/shear/content?" + ids,
  591. headers: {
  592. 'Authorization': form.token
  593. },
  594. type: 'DELETE',
  595. dataType: 'json',
  596. success: function (res) {
  597. if (res.status === 0) {
  598. showShearPlate();
  599. } else {
  600. $.toast(res.msg, "text");
  601. }
  602. }
  603. })
  604. });
  605. }
  606. function handleCopy(content) {
  607. var cutting = {
  608. "type": "cutting",
  609. "data": {
  610. "str": content
  611. }
  612. };
  613. wsss.send(JSON.stringify(cutting));
  614. }
  615. // 删除剪贴板
  616. function handleDelete(id) {
  617. $.ajax({
  618. url: baseUrl + "/api/public/v5/shear/content?ids=" + id,
  619. headers: {
  620. 'Authorization': form.token
  621. },
  622. type: 'DELETE',
  623. dataType: 'json',
  624. success: function (res) {
  625. if (res.status === 0) {
  626. showShearPlate();
  627. } else {
  628. $.toast(res.msg, "text");
  629. }
  630. }
  631. })
  632. }
  633. function initSlider() {
  634. //手指滑动多少距离就认为是滑成功
  635. //这个值不能太大,否则影响斜着滑动时,垂直滑动的流畅性,也不能太小,太灵敏也不好
  636. var diffXDistance = 50;
  637. //当前滑动的对象
  638. var currentObject;
  639. //上一次滑动的对象
  640. var lastObject;
  641. //是否可以左右滑动,在上下滑的时候禁止左右滑
  642. var canSlide = true;
  643. //用于记录按下的点
  644. var startPoint;
  645. $(".slide-content").css({
  646. width: $(".slide-wrapper").width()
  647. });
  648. document.body.removeEventListener('touchmove', function (e) {
  649. e.preventDefault()
  650. }, {
  651. passive: false
  652. })
  653. $(".slide-scroll").css({
  654. width: $(".slide-wrapper").width() + $(".slide-content-button").width()
  655. }).on('touchstart', function (e) {
  656. currentObject = this;
  657. startPoint = {
  658. x: e.originalEvent.changedTouches[0].pageX,
  659. y: e.originalEvent.changedTouches[0].pageY
  660. };
  661. }).on('touchmove', function (e) {
  662. //如果是左右滑动,就禁止上下的滑动
  663. //如果是上下的滑动,就禁止左右滑动
  664. if (Math.abs(e.originalEvent.changedTouches[0].pageX - startPoint.x) > Math.abs(e.originalEvent.changedTouches[0].pageY - startPoint.y)) {
  665. event.preventDefault();
  666. } else {
  667. canSlide = false;
  668. }
  669. }).on('touchend', function (e) {
  670. //如果是上下滑动,这里就直接返回了
  671. if (!canSlide) {
  672. canSlide = true;
  673. return true;
  674. }
  675. //点击除当前左滑对象之外的任意其他位置
  676. if (lastObject && currentObject != lastObject) {
  677. //右滑→
  678. $(lastObject).removeClass("animate-slide");
  679. //清空上一个左滑的对象
  680. lastObject = undefined;
  681. }
  682. var diffX = e.originalEvent.changedTouches[0].pageX - startPoint.x;
  683. if (diffX < -diffXDistance) {
  684. //左滑←
  685. $(currentObject).addClass("animate-slide");
  686. if (lastObject && lastObject != currentObject) {
  687. //右滑→
  688. $(lastObject).removeClass("animate-slide");
  689. }
  690. //记录上一个左滑的对象
  691. lastObject = currentObject;
  692. } else if (diffX >= diffXDistance) {
  693. if (currentObject == lastObject) {
  694. //右滑→
  695. $(currentObject).removeClass("animate-slide");
  696. //清空上一个左滑的对象
  697. lastObject = undefined;
  698. }
  699. }
  700. });
  701. }
  702. var btnMuted = document.querySelector("#btnMuted");
  703. btnMuted && (function () {
  704. var setHistory = function (left, top) {
  705. try {
  706. localStorage.setItem("muted-btn-loc", JSON.stringify({
  707. left: left,
  708. top: top
  709. }));
  710. } catch (ex) { }
  711. };
  712. var getHistory = function () {
  713. try {
  714. var value = localStorage.getItem("muted-btn-loc");
  715. if (!value) return null;
  716. value = JSON.parse(value);
  717. if (!value) return null;
  718. return value;
  719. } catch (ex) {
  720. return null
  721. }
  722. };
  723. var fixLoc = function (loc) {
  724. var rect = btnMuted.getBoundingClientRect();
  725. rect = {
  726. top: rect.top,
  727. left: rect.left,
  728. width: rect.width,
  729. height: rect.height
  730. }; //部分低版本浏览器,该属性为只读
  731. if (loc) {
  732. rect.left = loc.left;
  733. rect.top = loc.top;
  734. }
  735. var minX = 0;
  736. var minY = 0;
  737. var docRect = document.documentElement.getBoundingClientRect();
  738. var maxY = docRect.height - rect.height;
  739. var maxX = docRect.width - rect.width;
  740. var left = rect.left;
  741. var top = rect.top;
  742. left = Math.min(left, maxX);
  743. left = Math.max(left, minX);
  744. top = Math.min(top, maxY);
  745. top = Math.max(top, minY);
  746. if (loc || top !== rect.top || left !== rect.left) {
  747. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  748. }
  749. }
  750. window.addEventListener("resize", function () {
  751. fixLoc();
  752. });
  753. var touchPoint = {
  754. pageY: 0,
  755. pageX: 0
  756. };
  757. var currentLoc = {
  758. top: 0,
  759. left: 0,
  760. curTop: 0,
  761. curLeft: 0
  762. };
  763. var toMove = false;
  764. var touchmove = function (e) {
  765. e.preventDefault();
  766. var point = e.changedTouches[0];
  767. var top = -touchPoint.pageY + point.pageY;
  768. var left = -touchPoint.pageX + point.pageX;
  769. if (toMove) {
  770. top += currentLoc.top;
  771. left += currentLoc.left;
  772. currentLoc.curLeft = left;
  773. currentLoc.curTop = top;
  774. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  775. } else {
  776. if (Math.abs(top) >= 5 || Math.abs(left) >= 5) {
  777. toMove = true;
  778. }
  779. }
  780. };
  781. var touchend = function () {
  782. window.removeEventListener("touchmove", touchmove, {
  783. passive: false
  784. });
  785. window.removeEventListener("touchend", touchend, {
  786. passive: false
  787. });
  788. if (toMove) {
  789. setHistory(currentLoc.curLeft, currentLoc.curTop);
  790. fixLoc();
  791. } else {
  792. //按点击处理
  793. var set = $('.control-right-img').attr("data-id")
  794. if (set == '1') {
  795. $('.control-right-img').attr({
  796. "data-id": "2"
  797. })
  798. $(".leftmains").css({
  799. "right": "0rem"
  800. })
  801. } else {
  802. $('.control-right-img').attr({
  803. "data-id": "1"
  804. })
  805. $(".leftmains").css({
  806. "right": "-4rem"
  807. })
  808. }
  809. }
  810. }
  811. btnMuted.addEventListener("touchstart", function (e) {
  812. e.preventDefault();
  813. toMove = false;
  814. var point = e.changedTouches[0];
  815. touchPoint.pageX = point.pageX;
  816. touchPoint.pageY = point.pageY;
  817. var rect = e.target.getBoundingClientRect();
  818. currentLoc.top = rect.top;
  819. currentLoc.left = rect.left;
  820. window.addEventListener("touchmove", touchmove, {
  821. passive: false
  822. });
  823. window.addEventListener("touchend", touchend, {
  824. passive: false
  825. });
  826. }, {
  827. passive: false
  828. });
  829. var history = getHistory();
  830. if (history) {
  831. fixLoc(history);
  832. }
  833. btnMuted.classList.remove("hide");
  834. })();
  835. $("#upload").on("click", function () {
  836. clearInterval(intervaler);
  837. quit();
  838. ws.close();
  839. wsss.close();
  840. })
  841. function selectText(x) {
  842. if (document.selection) {
  843. var range = document.body.createTextRange();
  844. range.moveToElementText(x);
  845. range.select();
  846. } else if (window.getSelection) {
  847. var selection = window.getSelection();
  848. var range = document.createRange();
  849. selection.removeAllRanges();
  850. range.selectNodeContents(x);
  851. selection.addRange(range);
  852. }
  853. }
  854. // 激活码广告相关配置
  855. function getConfigByPhoneType() {
  856. return new Promise((resolve, reject) => {
  857. $.ajax({
  858. url: baseUrl + "/api/pay/v5/trialCodeConfig/getConfigByPhoneType",
  859. headers: {
  860. 'Authorization': form.token
  861. },
  862. data: {
  863. userCardId: form.userCardId,
  864. phoneType: form.mealType
  865. },
  866. type: 'get',
  867. dataType: 'json',
  868. success: function (res) {
  869. console.log(res)
  870. let obj = res.data;
  871. if (res.status === 0) {
  872. resolve(obj)
  873. } else {
  874. $.toast(res.msg, "text");
  875. }
  876. }
  877. })
  878. })
  879. }
  880. //列表
  881. function getSetmealList() {
  882. return new Promise((resolve, reject) => {
  883. $.ajax({
  884. url: baseUrl + "/api/resources/v4/freetrial/setmeal/list",
  885. headers: {
  886. 'Authorization': form.token
  887. },
  888. type: 'get',
  889. dataType: 'json',
  890. success: function (res) {
  891. if (res.status === 0) {
  892. let list = res.data;
  893. list.map((item) => {
  894. if (item.phoneType === parameters['mealType']) {
  895. resolve(item)
  896. }
  897. })
  898. } else {
  899. $.toast(res.msg, "text");
  900. }
  901. }
  902. })
  903. })
  904. }
  905. //广告信息
  906. function adInit() {
  907. sourceType = parameters['sourceType'];
  908. if (sourceType == 1) {
  909. getSetmealList().then((res) => {
  910. if (res.pushFlowAdvert === 1) {
  911. getAdList(15);
  912. }
  913. if (res.intervalSwitch === 1) {
  914. let time = res.intervalAdvertDuration * 60 * 1000;
  915. setInterval(() => {
  916. $('.try-use-wrap').eq(0).hide();
  917. getAdList(16);
  918. }, time);
  919. }
  920. })
  921. } else if (sourceType == 2) {
  922. getConfigByPhoneType().then((res) => {
  923. if (res.isDisconnectionTime === 1) {
  924. let time = res.disconnectionTime * 60 * 1000;
  925. setTimeout(() => {
  926. disconnectionFlag = true;
  927. $('.buy-phone-wrap').eq(0).show();
  928. }, time);
  929. }
  930. if (res.isShowAd === 1) {
  931. getAdList(15);
  932. }
  933. if (res.isIntervalPlayAd === 1) {
  934. let time = res.intervalPlayAdTime * 60 * 1000;
  935. setInterval(() => {
  936. $('.try-use-wrap').eq(0).hide();
  937. getAdList(16);
  938. }, time);
  939. }
  940. })
  941. }
  942. }
  943. // 广告接口
  944. function getAdList(type) {
  945. adType = type;
  946. $.ajax({
  947. url: baseUrl + "/api/public/v5/advertising/getAdInfoByAdPlace",
  948. headers: {
  949. 'Authorization': form.token
  950. },
  951. data: JSON.stringify({
  952. adPlace: type,
  953. os: 0
  954. }),
  955. type: 'POST',
  956. dataType: 'json',
  957. contentType: "application/json;charset=UTF-8",
  958. success: function (res) {
  959. if (res.status === 0) {
  960. let list = res.data;
  961. let indexs = Math.floor(Math.random() * list.length);
  962. videoTime = list[indexs].forcedTime;
  963. // $('#source').src = list[0].adVideoBase.videoUrl;
  964. $("#source").attr("src", list[indexs].adVideoBase.videoUrl);//更新url
  965. $("#source").attr("autoplay", "true");//直接播放
  966. videoTimer = setInterval(() => {
  967. if (videoTime > 0) {
  968. videoTime--;
  969. $('.time-node').eq(0).text(videoTime + 's');
  970. } else {
  971. clearInterval(videoTimer);
  972. $('.time-node').eq(0).text('');
  973. }
  974. }, 1000)
  975. if (adType === 16 && sourceType == 1) { // 间隔广告和试用才上报
  976. report(0);
  977. }
  978. $('.try-use-wrap').eq(0).show();
  979. } else {
  980. $.toast(res.msg, "text");
  981. }
  982. }
  983. })
  984. }
  985. //间隔广告上报
  986. function report(type) {
  987. $.ajax({
  988. url: baseUrl + "/api/resources/v1/trial/report",
  989. headers: {
  990. 'Authorization': form.token
  991. },
  992. data: JSON.stringify({
  993. userCardId: form.userCardId,
  994. reportType: type
  995. }),
  996. type: 'POST',
  997. dataType: 'json',
  998. contentType: "application/json;charset=UTF-8",
  999. success: function (res) { }
  1000. })
  1001. }
  1002. //关闭广告
  1003. $('.time-close-wrap')[0].addEventListener('click', () => {
  1004. $('.buy-phone-wrap').eq(0).show();
  1005. })
  1006. // 点击取消
  1007. $('.cannel-btn')[0].addEventListener('click', () => {
  1008. $('.buy-phone-wrap').eq(0).hide();
  1009. if (disconnectionFlag || getDate) {//设置了断线时间,取消直接退出
  1010. systemBuriedPoint('激活码-断线-取消');
  1011. quit();
  1012. return
  1013. }
  1014. let pointName = '';
  1015. if (sourceType == 1) {
  1016. pointName = videoTime == 0 ? '免费试用-关闭-取消' : '免费试用-强制关闭-取消';
  1017. } else {
  1018. pointName = videoTime == 0 ? '激活码-关闭-取消' : '激活码-强制关闭-取消';
  1019. }
  1020. systemBuriedPoint(pointName);
  1021. if (videoTime == 0) {
  1022. if (adType === 16 && sourceType == 1) {
  1023. report(1);
  1024. }
  1025. $('.try-use-wrap').eq(0).hide();
  1026. return
  1027. }
  1028. $('.look-wrap').eq(0).show();
  1029. })
  1030. // 点击去购买
  1031. $('.go-bug')[0].addEventListener('click', () => {
  1032. let pointName = '';
  1033. if (disconnectionFlag) {
  1034. pointName = '激活码-断线-去购买';
  1035. } else if (sourceType == 1) {
  1036. pointName = videoTime == 0 ? '免费试用-关闭-去购买' : '免费试用-强制关闭-去购买';
  1037. } else {
  1038. pointName = videoTime == 0 ? '激活码-关闭-去购买' : '激活码-强制关闭-去购买';
  1039. }
  1040. systemBuriedPoint(pointName);
  1041. if (getDate) {
  1042. wx.miniProgram.navigateTo({
  1043. url: '/packageA/order/buy/index'
  1044. })
  1045. } else {
  1046. wx.miniProgram.navigateTo({
  1047. url: '/packageA/order/renew/index?record=' + form.userCardId
  1048. })
  1049. }
  1050. })
  1051. // 放弃
  1052. $('.cannel-ad-btn')[0].addEventListener('click', () => {
  1053. if (sourceType == 1) {
  1054. systemBuriedPoint('免费试用-强制关闭-放弃');
  1055. } else {
  1056. systemBuriedPoint('激活码-强制关闭-放弃');
  1057. }
  1058. quit();
  1059. })
  1060. // 继续观看
  1061. $('.looking')[0].addEventListener('click', () => {
  1062. $('.look-wrap').eq(0).hide();
  1063. if (sourceType == 1) {
  1064. systemBuriedPoint('免费试用-强制关闭-继续观看');
  1065. } else {
  1066. systemBuriedPoint('激活码-强制关闭-继续观看');
  1067. }
  1068. })
  1069. // 埋点
  1070. function systemBuriedPoint(pointName) {
  1071. $.ajax({
  1072. url: baseUrl + "/api/public/v1/systemBuriedPoint/stat",
  1073. headers: {
  1074. 'Authorization': form.token
  1075. },
  1076. type: 'post',
  1077. data: JSON.stringify({
  1078. pointName: pointName
  1079. }),
  1080. contentType: "application/json",
  1081. dataType: 'json',
  1082. success: function (res) { }
  1083. })
  1084. }
  1085. function quit() {
  1086. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  1087. tt.miniProgram.switchTab({
  1088. url: '/pages/home/home'
  1089. })
  1090. } else if (window.__wxjs_environment === 'miniprogram') {
  1091. wx.miniProgram.switchTab({
  1092. url: '/pages/home/home'
  1093. })
  1094. } else {
  1095. uni.webView.navigateTo({
  1096. url: '/pages/index/index'
  1097. });
  1098. }
  1099. }
  1100. window.onbeforeunload = function () {
  1101. ws.close();
  1102. wsss.close();
  1103. }
  1104. </script>
  1105. <script type="text/javascript" src="aac.js"></script>
  1106. </body>
  1107. </html>