WXtrialInterface.html 40 KB

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