WXtrialInterface.html 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242
  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. return;
  1035. }
  1036. $('.look-wrap').eq(0).show();
  1037. });
  1038. // 点击去购买
  1039. $('.go-bug')[0].addEventListener('click', () => {
  1040. let pointName = '';
  1041. if (disconnectionFlag) {
  1042. pointName = '激活码-断线-去购买';
  1043. } else if (sourceType == 1) {
  1044. pointName =
  1045. videoTime == 0
  1046. ? '免费试用-关闭-去购买'
  1047. : '免费试用-强制关闭-去购买';
  1048. } else {
  1049. pointName =
  1050. videoTime == 0 ? '激活码-关闭-去购买' : '激活码-强制关闭-去购买';
  1051. }
  1052. systemBuriedPoint(pointName);
  1053. if (getDate) {
  1054. if (window.__wxjs_environment === 'miniprogram') {
  1055. wx.miniProgram.navigateTo({
  1056. url: '/packageA/order/buy/index?buyType=试用界面购买'
  1057. });
  1058. } else {
  1059. uni.webView.navigateTo({
  1060. url: '/pages/order/order',
  1061. });
  1062. }
  1063. } else {
  1064. if (window.__wxjs_environment === 'miniprogram') {
  1065. wx.miniProgram.navigateTo({
  1066. url: `/packageA/order/renew/index?buyType=${sourceType == 1 ? '试用弹窗购买按钮进入-普通试用' : '试用弹窗购买按钮进入-激活码试用'}&record=` + form.userCardId
  1067. });
  1068. } else {
  1069. uni.webView.navigateTo({
  1070. url: '/pages/order/order',
  1071. });
  1072. }
  1073. }
  1074. });
  1075. // 放弃
  1076. $('.cannel-ad-btn')[0].addEventListener('click', () => {
  1077. if (sourceType == 1) {
  1078. systemBuriedPoint('免费试用-强制关闭-放弃');
  1079. } else {
  1080. systemBuriedPoint('激活码-强制关闭-放弃');
  1081. }
  1082. quit();
  1083. });
  1084. // 继续观看
  1085. $('.looking')[0].addEventListener('click', () => {
  1086. $('.look-wrap').eq(0).hide();
  1087. if (sourceType == 1) {
  1088. systemBuriedPoint('免费试用-强制关闭-继续观看');
  1089. } else {
  1090. systemBuriedPoint('激活码-强制关闭-继续观看');
  1091. }
  1092. });
  1093. // 埋点
  1094. function systemBuriedPoint(pointName) {
  1095. $.ajax({
  1096. url: baseUrl + '/api/public/v1/systemBuriedPoint/stat',
  1097. headers: {
  1098. Authorization: form.token,
  1099. },
  1100. type: 'post',
  1101. data: JSON.stringify({
  1102. pointName: pointName,
  1103. }),
  1104. contentType: 'application/json',
  1105. dataType: 'json',
  1106. success: function (res) {},
  1107. });
  1108. }
  1109. function Close() {
  1110. // webworker 关闭,清理
  1111. var cmd = {
  1112. cmd: 0,
  1113. };
  1114. decodeWoker.postMessage(cmd);
  1115. decodeWoker.terminate();
  1116. webSocketWorker.postMessage(cmd);
  1117. webSocketWorker.terminate();
  1118. }
  1119. var isDrag = false;
  1120. myVideo.onkeydown = function (event) {
  1121. ExexuteKeyDown(e.keyCode);
  1122. };
  1123. var level = 2;
  1124. function switchSharpness() {
  1125. var cmd = {
  1126. type: 'switchSharpness',
  1127. };
  1128. decodeWoker.postMessage(cmd); //通知解码器worker切换分辨率
  1129. var buffer = makeSharpness(level);
  1130. webSocketWorker.postMessage(buffer);
  1131. if (level < 4) {
  1132. level++;
  1133. } else {
  1134. level = 0;
  1135. }
  1136. }
  1137. var hidden, visibilityChange;
  1138. if (typeof document.hidden !== 'undefined') {
  1139. // Opera 12.10 and Firefox 18 and later support
  1140. hidden = 'hidden';
  1141. visibilityChange = 'visibilitychange';
  1142. } else if (typeof document.msHidden !== 'undefined') {
  1143. hidden = 'msHidden';
  1144. visibilityChange = 'msvisibilitychange';
  1145. } else if (typeof document.webkitHidden !== 'undefined') {
  1146. hidden = 'webkitHidden';
  1147. visibilityChange = 'webkitvisibilitychange';
  1148. }
  1149. // 处理页面可见属性的改变
  1150. document.addEventListener(
  1151. 'visibilitychange',
  1152. function () {
  1153. if (document[hidden]) {
  1154. if (
  1155. !navigator.userAgent.toLowerCase().includes('toutiaomicroapp') ||
  1156. window.__wxjs_environment !== 'miniprogram'
  1157. ) {
  1158. ws.close();
  1159. wsss.close();
  1160. uni.webView.navigateTo({
  1161. url: '/pages/index/index',
  1162. });
  1163. }
  1164. }
  1165. },
  1166. false,
  1167. );
  1168. function quit() {
  1169. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  1170. tt.miniProgram.switchTab({
  1171. url: '/pages/home/home',
  1172. });
  1173. } else if (window.__wxjs_environment === 'miniprogram') {
  1174. wx.miniProgram.switchTab({
  1175. url: '/pages/home/home',
  1176. });
  1177. } else {
  1178. uni.webView.navigateTo({
  1179. url: '/pages/index/index',
  1180. });
  1181. }
  1182. }
  1183. window.onbeforeunload = function () {
  1184. wsss.close();
  1185. decodeWoker.postMessage('close');
  1186. decodeWoker.terminate();
  1187. webSocketWorker.terminate();
  1188. };
  1189. </script>
  1190. <script type="text/javascript" src="aac.js"></script>
  1191. </body>
  1192. </html>