WXtrialInterface.html 42 KB

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