WXtrialInterface.html 40 KB

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