WXtrialInterface.html 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243
  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://unpkg.com/@dcloudio/uni-webview-js@0.0.2/index.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. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  340. tt.miniProgram.switchTab({
  341. url: '/pages/home/home'
  342. })
  343. } else if (window.__wxjs_environment === 'miniprogram') {
  344. wx.miniProgram.switchTab({
  345. url: '/pages/home/home'
  346. })
  347. } else {
  348. document.addEventListener('UniAppJSBridgeReady', function () {
  349. uni.webView.navigateTo({
  350. url: '/pages/index/index'
  351. });
  352. })
  353. }
  354. }
  355. }, 3000);
  356. ws.addEventListener('open', function (event) {
  357. // sn只要长度满足17位随机数,不需要从后台获取
  358. var verifyBuffer = VerifyCode('RK3923C1201900139', cardToken);
  359. console.log("鉴权报文:" + PrintArry(verifyBuffer));
  360. ws.send(verifyBuffer);
  361. });
  362. ws.addEventListener('error', function (event) {
  363. ws.close();
  364. clearInterval(intervaler);
  365. throttle(doConnect, 100);
  366. if (errorTime > 1000) {
  367. $.toast("画面异常,请重新进入", "text");
  368. wsss.close();
  369. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  370. tt.miniProgram.switchTab({
  371. url: '/pages/home/home'
  372. })
  373. } else if (window.__wxjs_environment === 'miniprogram') {
  374. wx.miniProgram.switchTab({
  375. url: '/pages/home/home'
  376. })
  377. } else {
  378. document.addEventListener('UniAppJSBridgeReady', function () {
  379. uni.webView.navigateTo({
  380. url: '/pages/index/index'
  381. });
  382. })
  383. }
  384. }
  385. });
  386. ws.addEventListener('message', function (event) {
  387. var data = ParseProto(event.data); //JAVA服务器转发
  388. if (isAudioPlay) {
  389. $('.weui-mask_transparent').hide();
  390. $('.weui-toast').hide();
  391. $('.loading').hide();
  392. }
  393. var input = new Uint8Array(event.data);
  394. if (data.audio != null && isAudioPlay) { //喂音频
  395. if (input[0] == 0xff) {
  396. if (isFinish) {
  397. decodeAAC(input);
  398. }
  399. }
  400. }
  401. if (data.frameType != undefined && data.frameType != 1 && data.frameType != 6) {
  402. if (data.frameType == 7) {
  403. let info = spsParser(data.video);
  404. if (info.width != myVideo.videoWidth && info.height != myVideo.videoHeight) {
  405. if (myVideo.videoWidth == 0) {
  406. console.log("SPS计算得到宽 %d, 高 %d, 控件宽 %d, %d", info.width, info.height, myVideo.videoWidth, myVideo.videoHeight);
  407. }
  408. }
  409. }
  410. }
  411. if (data.video != null) { //喂视频
  412. if (data.frameType == 0x05 && isVisuable) {
  413. isFeed = true;
  414. }
  415. if (data.frameType == 7 || data.frameType == 8) {
  416. isFeed = true;
  417. isAudioPlay = true;
  418. }
  419. if (isFeed) {
  420. jmuxer.feed(data);
  421. }
  422. }
  423. });
  424. }
  425. var hidden, visibilityChange;
  426. if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support
  427. hidden = "hidden";
  428. visibilityChange = "visibilitychange";
  429. } else if (typeof document.msHidden !== "undefined") {
  430. hidden = "msHidden";
  431. visibilityChange = "msvisibilitychange";
  432. } else if (typeof document.webkitHidden !== "undefined") {
  433. hidden = "webkitHidden";
  434. visibilityChange = "webkitvisibilitychange";
  435. }
  436. // 处理页面可见属性的改变
  437. document.addEventListener("visibilitychange", function () {
  438. console.log(document[hidden]);
  439. if (document[hidden]) {
  440. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  441. tt.miniProgram.switchTab({
  442. url: '/pages/home/home'
  443. })
  444. } else if (window.__wxjs_environment === 'miniprogram') {
  445. wx.miniProgram.switchTab({
  446. url: '/pages/home/home'
  447. })
  448. } else {
  449. document.addEventListener('UniAppJSBridgeReady', function () {
  450. uni.webView.navigateTo({
  451. url: '/pages/index/index'
  452. });
  453. })
  454. }
  455. }
  456. }, false);
  457. myVideo.addEventListener('pause', function () {
  458. isFeed = false;
  459. });
  460. var decodeCount = 1;
  461. var player = new PCMPlayer({
  462. encoding: '16bitInt',
  463. channels: 2,
  464. sampleRate: 44100,
  465. flushingTime: 22,
  466. debug: false
  467. });
  468. function handleClose() {
  469. $('.mask').hide();
  470. }
  471. function decodeAAC(data) {
  472. var retPtr = Module._malloc(4 * 5 * 1024); // 接收的数据
  473. var inputPtr = Module._malloc(4 * data.length); // 输入数据
  474. for (var i = 0; i < data.length; i++) {
  475. Module.HEAPU8[(inputPtr) + i] = data[i]; //转换为堆数据
  476. }
  477. var pcmLen = Module._feedData(retPtr, inputPtr, data.length);
  478. if (pcmLen >= 0) {
  479. var pcmData = new Uint8Array(pcmLen);
  480. for (var i = 0; i < pcmLen; i++) {
  481. pcmData[i] = Module.HEAPU8[(retPtr) + i]
  482. }
  483. player.feed(pcmData);
  484. }
  485. decodeCount++;
  486. Module._free(inputPtr);
  487. Module._free(retPtr);
  488. }
  489. //解协议
  490. function ParseProto(data) {
  491. var input = new Uint8Array(data),
  492. duration,
  493. video,
  494. frameType,
  495. audio;
  496. if (input[0] == 0 && input[1] == 0 && input[2] == 0 && input[3] == 1) {
  497. video = input;
  498. duration = 24;
  499. var nalType = input[4] & 0x1f;
  500. frameType = nalType;
  501. if (!isFeed) {
  502. if (nalType == 0x05 && isVisuable) {
  503. isFeed = true;
  504. }
  505. }
  506. } else if (input[0] == 0xff) {
  507. audio = input;
  508. duration = 24;
  509. } else if (input[0] == 0x68) {
  510. if (input[23] == 0x5c) {
  511. console.log("收到消息:" + PrintArry(input));
  512. if (CheckVerifyCode(input)) {
  513. ws.send(ConfigChannel('RK3923C1201900139'));
  514. var checkBuffer = GetScreenState();
  515. ws.send(checkBuffer);
  516. }
  517. else {
  518. $.toast("画面异常,请重新进入", "text");
  519. clearInterval(intervaler);
  520. ws.close();
  521. wsss.close();
  522. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  523. tt.miniProgram.switchTab({
  524. url: '/pages/home/home'
  525. })
  526. } else if (window.__wxjs_environment === 'miniprogram') {
  527. wx.miniProgram.switchTab({
  528. url: '/pages/home/home'
  529. })
  530. } else {
  531. document.addEventListener('UniAppJSBridgeReady', function () {
  532. uni.webView.navigateTo({
  533. url: '/pages/index/index'
  534. });
  535. })
  536. }
  537. }
  538. }
  539. if (input[23] == 0x05) { //横竖屏标识
  540. var state = CheckScreenDirection(input.slice(24, 24 + 8));
  541. if (state == 1) {
  542. console.log("安卓卡此时竖屏");
  543. //竖屏处理
  544. resolving = 1;
  545. } else {
  546. console.log("安卓卡此时横屏");
  547. //横屏处理
  548. resolving = 0;
  549. }
  550. }
  551. if (input[23] == 0x0B)//多端登录处理, 数据从索引24开始取, input 是接收到的原始数据
  552. {
  553. var jsonobj = checkMultiLoginInfo(input);
  554. }
  555. }
  556. return {
  557. audio: audio,
  558. video: video,
  559. duration: duration,
  560. frameType: frameType
  561. };
  562. }
  563. function GetRequest() {
  564. var url = location.search; // 获取url中"?"符后的字串
  565. var obj = new Object();
  566. if (url.indexOf("?") != -1) {
  567. var str = url.substr(1);
  568. strs = str.split("&");
  569. for (var i = 0; i < strs.length; i++) {
  570. obj[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
  571. }
  572. }
  573. return obj;
  574. }
  575. function Back() {
  576. ExexuteKeyDown(4);
  577. window.event.returnValue = false;
  578. return false;
  579. }
  580. var form = {};
  581. form.token = parameters['token'];
  582. form.userCardId = parameters['userCardId'];
  583. function array_unique(arr) {
  584. return arr.filter(function (e, i) {
  585. return arr.indexOf(e) === i;
  586. })
  587. }
  588. var cutList = [];
  589. let timer, isFlag = true;
  590. function showShearPlate() {
  591. if (!isControl) {
  592. return
  593. }
  594. stopManyClick(() => {
  595. $('.box-shear-plate').empty();
  596. $.ajax({
  597. url: baseUrl + "/api/public/v5/shear/content",
  598. headers: {
  599. 'Authorization': form.token
  600. },
  601. type: 'get',
  602. dataType: 'json',
  603. success: function (res) {
  604. if (res.status === 0) {
  605. if (res.data.length) {
  606. cutList = array_unique(res.data)
  607. var str = '<div class="title">剪贴板<div onclick="handleClear()" class="btn-clear">清空</div></div><div class="slide-wrapper-content">'
  608. cutList.forEach(function (item) {
  609. 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>"
  610. })
  611. str += '</div>'
  612. $('.box-shear-plate').append(str);
  613. } else {
  614. $('.box-shear-plate').append('<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>')
  615. }
  616. $('.mask').show();
  617. initSlider();
  618. } else {
  619. $('.box-shear-plate').append('<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>')
  620. $('.mask').show();
  621. }
  622. }
  623. })
  624. })
  625. }
  626. //防止提示一秒内重复显示
  627. function stopManyClick(fn) {
  628. if (isFlag) {
  629. fn();
  630. }
  631. isFlag = false;
  632. if (timer) { clearTimeout(timer); }
  633. timer = setTimeout(() => { isFlag = true }, 1500);
  634. }
  635. // 清空剪贴板
  636. function handleClear() {
  637. var ids = '';
  638. cutList.forEach(function (item) {
  639. ids += 'ids=' + item.id + '&'
  640. });
  641. ids = ids.substring(0, ids.lastIndexOf('&'));
  642. $.confirm("确定清空剪贴板?", function () {
  643. $.ajax({
  644. url: baseUrl + "/api/public/v5/shear/content?" + ids,
  645. headers: {
  646. 'Authorization': form.token
  647. },
  648. type: 'DELETE',
  649. dataType: 'json',
  650. success: function (res) {
  651. if (res.status === 0) {
  652. showShearPlate();
  653. } else {
  654. $.toast(res.msg, "text");
  655. }
  656. }
  657. })
  658. });
  659. }
  660. function handleCopy(content) {
  661. var cutting = {
  662. "type": "cutting",
  663. "data": {
  664. "str": content
  665. }
  666. };
  667. wsss.send(JSON.stringify(cutting));
  668. }
  669. // 删除剪贴板
  670. function handleDelete(id) {
  671. $.ajax({
  672. url: baseUrl + "/api/public/v5/shear/content?ids=" + id,
  673. headers: {
  674. 'Authorization': form.token
  675. },
  676. type: 'DELETE',
  677. dataType: 'json',
  678. success: function (res) {
  679. if (res.status === 0) {
  680. showShearPlate();
  681. } else {
  682. $.toast(res.msg, "text");
  683. }
  684. }
  685. })
  686. }
  687. function initSlider() {
  688. //手指滑动多少距离就认为是滑成功
  689. //这个值不能太大,否则影响斜着滑动时,垂直滑动的流畅性,也不能太小,太灵敏也不好
  690. var diffXDistance = 50;
  691. //当前滑动的对象
  692. var currentObject;
  693. //上一次滑动的对象
  694. var lastObject;
  695. //是否可以左右滑动,在上下滑的时候禁止左右滑
  696. var canSlide = true;
  697. //用于记录按下的点
  698. var startPoint;
  699. $(".slide-content").css({
  700. width: $(".slide-wrapper").width()
  701. });
  702. document.body.removeEventListener('touchmove', function (e) {
  703. e.preventDefault()
  704. }, {
  705. passive: false
  706. })
  707. $(".slide-scroll").css({
  708. width: $(".slide-wrapper").width() + $(".slide-content-button").width()
  709. }).on('touchstart', function (e) {
  710. currentObject = this;
  711. startPoint = {
  712. x: e.originalEvent.changedTouches[0].pageX,
  713. y: e.originalEvent.changedTouches[0].pageY
  714. };
  715. }).on('touchmove', function (e) {
  716. //如果是左右滑动,就禁止上下的滑动
  717. //如果是上下的滑动,就禁止左右滑动
  718. if (Math.abs(e.originalEvent.changedTouches[0].pageX - startPoint.x) > Math.abs(e.originalEvent.changedTouches[0].pageY - startPoint.y)) {
  719. event.preventDefault();
  720. } else {
  721. canSlide = false;
  722. }
  723. }).on('touchend', function (e) {
  724. //如果是上下滑动,这里就直接返回了
  725. if (!canSlide) {
  726. canSlide = true;
  727. return true;
  728. }
  729. //点击除当前左滑对象之外的任意其他位置
  730. if (lastObject && currentObject != lastObject) {
  731. //右滑→
  732. $(lastObject).removeClass("animate-slide");
  733. //清空上一个左滑的对象
  734. lastObject = undefined;
  735. }
  736. var diffX = e.originalEvent.changedTouches[0].pageX - startPoint.x;
  737. if (diffX < -diffXDistance) {
  738. //左滑←
  739. $(currentObject).addClass("animate-slide");
  740. if (lastObject && lastObject != currentObject) {
  741. //右滑→
  742. $(lastObject).removeClass("animate-slide");
  743. }
  744. //记录上一个左滑的对象
  745. lastObject = currentObject;
  746. } else if (diffX >= diffXDistance) {
  747. if (currentObject == lastObject) {
  748. //右滑→
  749. $(currentObject).removeClass("animate-slide");
  750. //清空上一个左滑的对象
  751. lastObject = undefined;
  752. }
  753. }
  754. });
  755. }
  756. var btnMuted = document.querySelector("#btnMuted");
  757. btnMuted && (function () {
  758. var setHistory = function (left, top) {
  759. try {
  760. localStorage.setItem("muted-btn-loc", JSON.stringify({
  761. left: left,
  762. top: top
  763. }));
  764. } catch (ex) { }
  765. };
  766. var getHistory = function () {
  767. try {
  768. var value = localStorage.getItem("muted-btn-loc");
  769. if (!value) return null;
  770. value = JSON.parse(value);
  771. if (!value) return null;
  772. return value;
  773. } catch (ex) {
  774. return null
  775. }
  776. };
  777. var fixLoc = function (loc) {
  778. var rect = btnMuted.getBoundingClientRect();
  779. rect = {
  780. top: rect.top,
  781. left: rect.left,
  782. width: rect.width,
  783. height: rect.height
  784. }; //部分低版本浏览器,该属性为只读
  785. if (loc) {
  786. rect.left = loc.left;
  787. rect.top = loc.top;
  788. }
  789. var minX = 0;
  790. var minY = 0;
  791. var docRect = document.documentElement.getBoundingClientRect();
  792. var maxY = docRect.height - rect.height;
  793. var maxX = docRect.width - rect.width;
  794. var left = rect.left;
  795. var top = rect.top;
  796. left = Math.min(left, maxX);
  797. left = Math.max(left, minX);
  798. top = Math.min(top, maxY);
  799. top = Math.max(top, minY);
  800. if (loc || top !== rect.top || left !== rect.left) {
  801. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  802. }
  803. }
  804. window.addEventListener("resize", function () {
  805. fixLoc();
  806. });
  807. var touchPoint = {
  808. pageY: 0,
  809. pageX: 0
  810. };
  811. var currentLoc = {
  812. top: 0,
  813. left: 0,
  814. curTop: 0,
  815. curLeft: 0
  816. };
  817. var toMove = false;
  818. var touchmove = function (e) {
  819. e.preventDefault();
  820. var point = e.changedTouches[0];
  821. var top = -touchPoint.pageY + point.pageY;
  822. var left = -touchPoint.pageX + point.pageX;
  823. if (toMove) {
  824. top += currentLoc.top;
  825. left += currentLoc.left;
  826. currentLoc.curLeft = left;
  827. currentLoc.curTop = top;
  828. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  829. } else {
  830. if (Math.abs(top) >= 5 || Math.abs(left) >= 5) {
  831. toMove = true;
  832. }
  833. }
  834. };
  835. var touchend = function () {
  836. window.removeEventListener("touchmove", touchmove, {
  837. passive: false
  838. });
  839. window.removeEventListener("touchend", touchend, {
  840. passive: false
  841. });
  842. if (toMove) {
  843. setHistory(currentLoc.curLeft, currentLoc.curTop);
  844. fixLoc();
  845. } else {
  846. //按点击处理
  847. var set = $('.control-right-img').attr("data-id")
  848. if (set == '1') {
  849. $('.control-right-img').attr({
  850. "data-id": "2"
  851. })
  852. $(".leftmains").css({
  853. "right": "0rem"
  854. })
  855. } else {
  856. $('.control-right-img').attr({
  857. "data-id": "1"
  858. })
  859. $(".leftmains").css({
  860. "right": "-4rem"
  861. })
  862. }
  863. }
  864. }
  865. btnMuted.addEventListener("touchstart", function (e) {
  866. e.preventDefault();
  867. toMove = false;
  868. var point = e.changedTouches[0];
  869. touchPoint.pageX = point.pageX;
  870. touchPoint.pageY = point.pageY;
  871. var rect = e.target.getBoundingClientRect();
  872. currentLoc.top = rect.top;
  873. currentLoc.left = rect.left;
  874. window.addEventListener("touchmove", touchmove, {
  875. passive: false
  876. });
  877. window.addEventListener("touchend", touchend, {
  878. passive: false
  879. });
  880. }, {
  881. passive: false
  882. });
  883. var history = getHistory();
  884. if (history) {
  885. fixLoc(history);
  886. }
  887. btnMuted.classList.remove("hide");
  888. })();
  889. $("#upload").on("click", function () {
  890. clearInterval(intervaler);
  891. ws.close();
  892. wsss.close();
  893. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  894. tt.miniProgram.switchTab({
  895. url: '/pages/home/home'
  896. })
  897. } else if (window.__wxjs_environment === 'miniprogram') {
  898. wx.miniProgram.switchTab({
  899. url: '/pages/home/home'
  900. })
  901. } else {
  902. document.addEventListener('UniAppJSBridgeReady', function () {
  903. uni.webView.navigateTo({
  904. url: '/pages/index/index'
  905. });
  906. })
  907. }
  908. })
  909. function selectText(x) {
  910. if (document.selection) {
  911. var range = document.body.createTextRange();
  912. range.moveToElementText(x);
  913. range.select();
  914. } else if (window.getSelection) {
  915. var selection = window.getSelection();
  916. var range = document.createRange();
  917. selection.removeAllRanges();
  918. range.selectNodeContents(x);
  919. selection.addRange(range);
  920. }
  921. }
  922. // 激活码广告相关配置
  923. function getConfigByPhoneType() {
  924. return new Promise((resolve, reject) => {
  925. $.ajax({
  926. url: baseUrl + "/api/pay/v5/trialCodeConfig/getConfigByPhoneType",
  927. headers: {
  928. 'Authorization': form.token
  929. },
  930. data: {
  931. userCardId: form.userCardId,
  932. phoneType: form.mealType
  933. },
  934. type: 'get',
  935. dataType: 'json',
  936. success: function (res) {
  937. console.log(res)
  938. let obj = res.data;
  939. if (res.status === 0) {
  940. resolve(obj)
  941. } else {
  942. $.toast(res.msg, "text");
  943. }
  944. }
  945. })
  946. })
  947. }
  948. //列表
  949. function getSetmealList() {
  950. return new Promise((resolve, reject) => {
  951. $.ajax({
  952. url: baseUrl + "/api/resources/v4/freetrial/setmeal/list",
  953. headers: {
  954. 'Authorization': form.token
  955. },
  956. type: 'get',
  957. dataType: 'json',
  958. success: function (res) {
  959. if (res.status === 0) {
  960. let list = res.data;
  961. list.map((item) => {
  962. if (item.phoneType === parameters['mealType']) {
  963. resolve(item)
  964. }
  965. })
  966. } else {
  967. $.toast(res.msg, "text");
  968. }
  969. }
  970. })
  971. })
  972. }
  973. //广告信息
  974. function adInit() {
  975. sourceType = parameters['sourceType'];
  976. if (sourceType == 1) {
  977. getSetmealList().then((res) => {
  978. if (res.pushFlowAdvert === 1) {
  979. getAdList(15);
  980. }
  981. if (res.intervalSwitch === 1) {
  982. let time = res.intervalAdvertDuration * 60 * 1000;
  983. setInterval(() => {
  984. $('.try-use-wrap').eq(0).hide();
  985. getAdList(16);
  986. }, time);
  987. }
  988. })
  989. } else if (sourceType == 2) {
  990. getConfigByPhoneType().then((res) => {
  991. if (res.isDisconnectionTime === 1) {
  992. let time = res.disconnectionTime * 60 * 1000;
  993. setTimeout(() => {
  994. disconnectionFlag = true;
  995. $('.buy-phone-wrap').eq(0).show();
  996. }, time);
  997. }
  998. if (res.isShowAd === 1) {
  999. getAdList(15);
  1000. }
  1001. if (res.isIntervalPlayAd === 1) {
  1002. let time = res.intervalPlayAdTime * 60 * 1000;
  1003. setInterval(() => {
  1004. $('.try-use-wrap').eq(0).hide();
  1005. getAdList(16);
  1006. }, time);
  1007. }
  1008. })
  1009. }
  1010. }
  1011. // 广告接口
  1012. function getAdList(type) {
  1013. adType = type;
  1014. $.ajax({
  1015. url: baseUrl + "/api/public/v5/advertising/getAdInfoByAdPlace",
  1016. headers: {
  1017. 'Authorization': form.token
  1018. },
  1019. data: JSON.stringify({
  1020. adPlace: type,
  1021. os: 0
  1022. }),
  1023. type: 'POST',
  1024. dataType: 'json',
  1025. contentType: "application/json;charset=UTF-8",
  1026. success: function (res) {
  1027. if (res.status === 0) {
  1028. let list = res.data;
  1029. let indexs = Math.floor(Math.random() * list.length);
  1030. videoTime = list[indexs].forcedTime;
  1031. // $('#source').src = list[0].adVideoBase.videoUrl;
  1032. $("#source").attr("src", list[indexs].adVideoBase.videoUrl);//更新url
  1033. $("#source").attr("autoplay", "true");//直接播放
  1034. videoTimer = setInterval(() => {
  1035. if (videoTime > 0) {
  1036. videoTime--;
  1037. $('.time-node').eq(0).text(videoTime + 's');
  1038. } else {
  1039. clearInterval(videoTimer);
  1040. $('.time-node').eq(0).text('');
  1041. }
  1042. }, 1000)
  1043. if (adType === 16 && sourceType == 1) { // 间隔广告和试用才上报
  1044. report(0);
  1045. }
  1046. $('.try-use-wrap').eq(0).show();
  1047. } else {
  1048. $.toast(res.msg, "text");
  1049. }
  1050. }
  1051. })
  1052. }
  1053. //间隔广告上报
  1054. function report(type) {
  1055. $.ajax({
  1056. url: baseUrl + "/api/resources/v1/trial/report",
  1057. headers: {
  1058. 'Authorization': form.token
  1059. },
  1060. data: JSON.stringify({
  1061. userCardId: form.userCardId,
  1062. reportType: type
  1063. }),
  1064. type: 'POST',
  1065. dataType: 'json',
  1066. contentType: "application/json;charset=UTF-8",
  1067. success: function (res) { }
  1068. })
  1069. }
  1070. //关闭广告
  1071. $('.time-close-wrap')[0].addEventListener('click', () => {
  1072. $('.buy-phone-wrap').eq(0).show();
  1073. })
  1074. // 点击取消
  1075. $('.cannel-btn')[0].addEventListener('click', () => {
  1076. $('.buy-phone-wrap').eq(0).hide();
  1077. if (disconnectionFlag || getDate) {//设置了断线时间,取消直接退出
  1078. systemBuriedPoint('激活码-断线-取消');
  1079. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  1080. tt.miniProgram.switchTab({
  1081. url: '/pages/home/home'
  1082. })
  1083. } else if (window.__wxjs_environment === 'miniprogram') {
  1084. wx.miniProgram.switchTab({
  1085. url: '/pages/home/home'
  1086. })
  1087. } else {
  1088. document.addEventListener('UniAppJSBridgeReady', function () {
  1089. uni.webView.navigateTo({
  1090. url: '/pages/index/index'
  1091. });
  1092. })
  1093. }
  1094. return
  1095. }
  1096. let pointName = '';
  1097. if (sourceType == 1) {
  1098. pointName = videoTime == 0 ? '免费试用-关闭-取消' : '免费试用-强制关闭-取消';
  1099. } else {
  1100. pointName = videoTime == 0 ? '激活码-关闭-取消' : '激活码-强制关闭-取消';
  1101. }
  1102. systemBuriedPoint(pointName);
  1103. if (videoTime == 0) {
  1104. if (adType === 16 && sourceType == 1) {
  1105. report(1);
  1106. }
  1107. $('.try-use-wrap').eq(0).hide();
  1108. return
  1109. }
  1110. $('.look-wrap').eq(0).show();
  1111. })
  1112. // 点击去购买
  1113. $('.go-bug')[0].addEventListener('click', () => {
  1114. let pointName = '';
  1115. if (disconnectionFlag) {
  1116. pointName = '激活码-断线-去购买';
  1117. } else if (sourceType == 1) {
  1118. pointName = videoTime == 0 ? '免费试用-关闭-去购买' : '免费试用-强制关闭-去购买';
  1119. } else {
  1120. pointName = videoTime == 0 ? '激活码-关闭-去购买' : '激活码-强制关闭-去购买';
  1121. }
  1122. systemBuriedPoint(pointName);
  1123. if (getDate) {
  1124. wx.miniProgram.navigateTo({
  1125. url: '/packageA/order/buy/index'
  1126. })
  1127. } else {
  1128. wx.miniProgram.navigateTo({
  1129. url: '/packageA/order/renew/index?record=' + form.userCardId
  1130. })
  1131. }
  1132. })
  1133. // 放弃
  1134. $('.cannel-ad-btn')[0].addEventListener('click', () => {
  1135. if (sourceType == 1) {
  1136. systemBuriedPoint('免费试用-强制关闭-放弃');
  1137. } else {
  1138. systemBuriedPoint('激活码-强制关闭-放弃');
  1139. }
  1140. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  1141. tt.miniProgram.switchTab({
  1142. url: '/pages/home/home'
  1143. })
  1144. } else if (window.__wxjs_environment === 'miniprogram') {
  1145. wx.miniProgram.switchTab({
  1146. url: '/pages/home/home'
  1147. })
  1148. } else {
  1149. document.addEventListener('UniAppJSBridgeReady', function () {
  1150. uni.webView.navigateTo({
  1151. url: '/pages/index/index'
  1152. });
  1153. })
  1154. }
  1155. })
  1156. // 继续观看
  1157. $('.looking')[0].addEventListener('click', () => {
  1158. $('.look-wrap').eq(0).hide();
  1159. if (sourceType == 1) {
  1160. systemBuriedPoint('免费试用-强制关闭-继续观看');
  1161. } else {
  1162. systemBuriedPoint('激活码-强制关闭-继续观看');
  1163. }
  1164. })
  1165. // 埋点
  1166. function systemBuriedPoint(pointName) {
  1167. $.ajax({
  1168. url: baseUrl + "/api/public/v1/systemBuriedPoint/stat",
  1169. headers: {
  1170. 'Authorization': form.token
  1171. },
  1172. type: 'post',
  1173. data: JSON.stringify({
  1174. pointName: pointName
  1175. }),
  1176. contentType: "application/json",
  1177. dataType: 'json',
  1178. success: function (res) { }
  1179. })
  1180. }
  1181. window.onbeforeunload = function () {
  1182. ws.close();
  1183. wsss.close();
  1184. }
  1185. </script>
  1186. <script type="text/javascript" src="aac.js"></script>
  1187. </body>
  1188. </html>