WXtrialInterface.html 40 KB

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