WXtrialInterface.html 38 KB

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