WXtrialInterface.html 35 KB

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