WXtrialInterface.html 33 KB

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