WXtrialInterface.html 36 KB

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