WXtrialInterface.html 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <title></title>
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  7. <meta name="x5-orientation" content="portrait" />
  8. <meta name="screen-orientation" content="portrait" />
  9. <meta
  10. name="viewport"
  11. content="width=device-width, initial-scale=1, user-scalable=no"
  12. />
  13. <meta name="apple-mobile-web-app-capable" content="yes" />
  14. <!-- 删除苹果默认的工具栏和菜单栏 -->
  15. <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  16. <!-- 设置苹果工具栏颜? -->
  17. <meta name="format-detection" content="telphone=no, email=no" />
  18. <!-- 忽略页面中的数字识别为电话,忽略email识别 -->
  19. <!-- 启用360浏览器的极速模?(webkit) -->
  20. <meta name="renderer" content="webkit" />
  21. <!-- 针对手持设备优化,主要是针对一些老的不识别viewport的浏览器,比如黑? -->
  22. <meta name="HandheldFriendly" content="true" />
  23. <!-- 微软的老式浏览? -->
  24. <meta name="MobileOptimized" content="320" />
  25. <!-- 不能旋转,问题出在这 -->
  26. <!-- UC强制全屏 -->
  27. <meta name="full-screen" content="yes" />
  28. <!-- QQ强制全屏 -->
  29. <meta name="x5-fullscreen" content="true" />
  30. <!-- UC应用模式 -->
  31. <meta name="browsermode" content="application" />
  32. <!-- QQ应用模式 -->
  33. <meta name="x5-page-mode" content="app" />
  34. <!-- windows phone 点击无高? -->
  35. <meta name="msapplication-tap-highlight" content="no" />
  36. <link rel="stylesheet" type="text/css" href="css/WXtrialInterface.css" />
  37. <link
  38. rel="stylesheet"
  39. href="https://cdn.bootcss.com/weui/1.1.3/style/weui.min.css"
  40. />
  41. <link
  42. rel="stylesheet"
  43. href="https://cdn.bootcss.com/jquery-weui/1.2.1/css/jquery-weui.min.css"
  44. />
  45. </head>
  46. <body class="scroll h-player" style="overscroll-behavior: contain">
  47. <div class="container" id="player">
  48. <div class="muted" id="btnMuted">
  49. <div class="control-right-img" data-id="1">
  50. <img src="../static/img/xuanfu_icon.png" />
  51. </div>
  52. </div>
  53. <div id="wine">
  54. <video
  55. id="playerVideo"
  56. x5-video-orientation="landscape"
  57. playsinline="true"
  58. autoplay="true"
  59. webkit-playsinline="true"
  60. x5-playsinline="true"
  61. x5-video-player-type="h5"
  62. x5-video-player-fullscreen="false"
  63. style="
  64. pointer-events: none;
  65. object-fit: fill;
  66. width: 100%;
  67. height: 100%;
  68. "
  69. ></video>
  70. <div id="box"></div>
  71. <audio
  72. preload="auto"
  73. autoplay
  74. controls
  75. poster="images/loader-thumb.jpg"
  76. id="audioPlayer"
  77. style="position: absolute; top: 0; width: 0; height: 0"
  78. ></audio>
  79. </div>
  80. <div class="leftmains">
  81. <div class="PictureQualityMain">
  82. <div class="PictureQuality" data-id="4">高清</div>
  83. <div class="PictureQuality avit" data-id="3">标清</div>
  84. <div class="PictureQuality" data-id="2">极速</div>
  85. </div>
  86. <div class="operation">
  87. <div class="upload" id="showsuss" data-text="uploads">
  88. <img src="../static/img/wx/shangchuan_icon.png" />
  89. <div>上传</div>
  90. </div>
  91. <div class="upload" onclick="showShearPlate()" data-text="Shearplate">
  92. <img src="../static/img/wx/jianqieban_icon.png" />
  93. <div>剪贴板</div>
  94. </div>
  95. <div class="upload" id="upload" data-text="Signout">
  96. <img src="../static/img/wx/tuichu_icon.png" />
  97. <div>退出</div>
  98. </div>
  99. </div>
  100. </div>
  101. <div class="bottommains">
  102. <div class="botmat1">
  103. <div class="botmat1img" data-text="gengduo">
  104. <img src="../static/img/wx/gengduo_icon.png" />
  105. </div>
  106. </div>
  107. <div class="botmat1">
  108. <div class="botmat1img" data-text="home">
  109. <img src="../static/img/wx/home_icon.png" />
  110. </div>
  111. </div>
  112. <div class="botmat1">
  113. <div class="botmat1img" data-text="return">
  114. <img src="../static/img/wx/fanhui_icon.png" />
  115. </div>
  116. </div>
  117. </div>
  118. <img class="loading loading_sceen_pic" />
  119. </div>
  120. <div class="mask">
  121. <div class="box-shear-plate"></div>
  122. <img
  123. class="close"
  124. onclick="handleClose()"
  125. src="img/guanbi_icon@2x.png"
  126. alt=""
  127. />
  128. </div>
  129. <div class="weui-mask_transparent"></div>
  130. <div class="weui-toast weui_loading_toast weui-toast--visible">
  131. <div class="weui_loading">
  132. <i class="weui-loading weui-icon_toast"></i>
  133. </div>
  134. <p class="weui-toast_content">数据加载中</p>
  135. </div>
  136. <div class="try-use-wrap">
  137. <div class="try-use-container">
  138. <video
  139. width="100%"
  140. height="100%"
  141. id="source"
  142. autoplay="autoplay"
  143. loop="loop"
  144. webkit-playsinline="true"
  145. playsinline="true"
  146. x5-video-player-type="h5-page"
  147. >
  148. 您的浏览器不支持 video 标签。
  149. </video>
  150. <div class="time-close-wrap"><span class="time-node"></span> 关闭</div>
  151. </div>
  152. </div>
  153. <div class="buy-phone-wrap">
  154. <div class="bug-wrap">
  155. <div class="bug-title">获得极致体验服务请购买云手机</div>
  156. <div class="btn-list">
  157. <div class="btn cannel-btn">取消</div>
  158. <div class="btn go-bug">去购买</div>
  159. </div>
  160. </div>
  161. </div>
  162. <div class="look-wrap">
  163. <div class="bug-wrap">
  164. <div class="bug-title">关闭广告会退出云手机是否继续观看</div>
  165. <div class="btn-list">
  166. <div class="btn cannel-btn cannel-ad-btn">放弃</div>
  167. <div class="btn go-bug looking">继续观看</div>
  168. </div>
  169. </div>
  170. </div>
  171. <body oncontextmenu="Back()"></body>
  172. <script
  173. type="text/javascript"
  174. src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"
  175. ></script>
  176. <script src="https://lf1-cdn-tos.bytegoofy.com/goofy/developer/jssdk/jssdk-1.0.3.js"></script>
  177. <script
  178. type="text/javascript"
  179. src="../static/js/jquery-1.11.0.min.js"
  180. ></script>
  181. <script type="text/javascript" src="helper.js"></script>
  182. <script type="text/javascript" src="pcm-player.js"></script>
  183. <script
  184. type="text/javascript"
  185. src="https://cdn.bootcss.com/vConsole/3.2.0/vconsole.min.js"
  186. ></script>
  187. <script src="https://cdn.bootcss.com/jquery-weui/1.2.1/js/jquery-weui.min.js"></script>
  188. <script type="text/javascript" src="WXdraw.js"></script>
  189. <script type="text/javascript" src="jmuxer.js"></script>
  190. <script type="text/javascript" src="spsParser.js"></script>
  191. <script
  192. type="text/javascript"
  193. src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js"
  194. ></script>
  195. <script>
  196. var url = window.location.href;
  197. url = url.split('/');
  198. var baseUrl = url[0] + '//' + url[2];
  199. var parameters = GetRequest();
  200. var form = {};
  201. form.token = parameters['token'];
  202. form.userCardId = parameters['userCardId'];
  203. var videoTimer = null,
  204. videoTime = 0,
  205. adType = 0,
  206. sourceType = isNaN(parameters['sourceType'])
  207. ? 0
  208. : +parameters['sourceType'],
  209. disconnectionFlag = false,
  210. getDate = false;
  211. var isDev =
  212. /^192\.168\./.test(location.host) ||
  213. /^127\.0\.0\.1/.test(location.host) ||
  214. /^localhost/.test(location.host);
  215. if (isDev) {
  216. baseUrl = 'http://gntest.phone.androidscloud.com:1280';
  217. sourceType = 2;
  218. }
  219. if (parameters['mealType'] === 'VIP') {
  220. $('.loading_sceen_pic').attr('src', '../static/img/home_bg_VIP.png');
  221. } else if (parameters['mealType'] === 'SVIP') {
  222. $('.loading_sceen_pic').attr('src', '../static/img/home_bg_SVIP.png');
  223. } else if (parameters['mealType'] === 'STAR') {
  224. $('.loading_sceen_pic').attr('src', '../static/img/home_bg_STAR.png');
  225. } else if (parameters['mealType'] === 'STARPRO') {
  226. $('.loading_sceen_pic').attr('src', '../static/img/home_bg_PRO.png');
  227. }
  228. initAD();
  229. let dbName = parameters['username'],
  230. version = 1,
  231. storeName = 'usercard';
  232. let indexedDB = window.indexedDB;
  233. let db, socketURL, cUrl, cardToken, resolvingPower;
  234. const request = indexedDB.open(dbName, version);
  235. request.onsuccess = function (event) {
  236. db = event.target.result; // 数据库对象
  237. console.log('数据库打开成功');
  238. };
  239. request.onerror = function (event) {
  240. console.log('数据库打开报错');
  241. };
  242. request.onupgradeneeded = function (event) {
  243. // 数据库创建或升级的时候会触发
  244. console.log('onupgradeneeded');
  245. db = event.target.result; // 数据库对象
  246. let objectStore;
  247. if (!db.objectStoreNames.contains(storeName)) {
  248. objectStore = db.createObjectStore(storeName, { keyPath: 'id' }); // 创建表
  249. }
  250. };
  251. // 添加数据
  252. function addData(db, storeName, data) {
  253. let request = db
  254. .transaction([storeName], 'readwrite') // 事务对象 指定表格名称和操作模式("只读"或"读写")
  255. .objectStore(storeName) // 仓库对象
  256. .add(data);
  257. request.onsuccess = function (event) {
  258. console.log('数据写入成功');
  259. };
  260. request.onerror = function (event) {
  261. console.log('数据写入失败');
  262. throw new Error(event.target.error);
  263. };
  264. }
  265. // 根据id获取数据
  266. function getDataByKey(db, storeName, key) {
  267. let transaction = db.transaction([storeName]); // 事务
  268. let objectStore = transaction.objectStore(storeName); // 仓库对象
  269. let request = objectStore.get(key);
  270. request.onerror = function (event) {
  271. connect();
  272. };
  273. request.onsuccess = function (event) {
  274. console.log('主键查询结果: ', request.result);
  275. if (request.result) {
  276. socketURL = request.result.socketURL;
  277. cUrl = request.result.cUrl;
  278. cardToken = request.result.cardToken;
  279. resolvingPower = request.result.resolvingPower;
  280. doConnectBusiness();
  281. doConnectDirectives();
  282. } else {
  283. connect();
  284. }
  285. };
  286. }
  287. // 根据id修改数
  288. function updateDB(db, storeName, data) {
  289. let request = db
  290. .transaction([storeName], 'readwrite') // 事务对象
  291. .objectStore(storeName) // 仓库对象
  292. .put(data);
  293. request.onsuccess = function () {
  294. console.log('数据更新成功');
  295. };
  296. request.onerror = function () {
  297. console.log('数据更新失败');
  298. };
  299. }
  300. // 由于打开indexDB是异步的加个定时器避免 db对象还没获取到值导致 报错
  301. setTimeout(() => {
  302. getDataByKey(db, storeName, form.userCardId);
  303. }, 1000);
  304. var isAudioPlay = false;
  305. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  306. var video = document.getElementById('playerVideo');
  307. video.play();
  308. setTimeout(() => {
  309. // 抖音环境需要设置延时,不然会有video默认图显示
  310. $.alert({
  311. title: '提示',
  312. text: '开始使用云手机',
  313. onOK: function () {
  314. setTimeout(() => {
  315. isAudioPlay = true;
  316. }, 1000);
  317. },
  318. });
  319. }, 1000);
  320. } else {
  321. $.alert({
  322. title: '提示',
  323. text: '开始使用云手机',
  324. onOK: function () {
  325. var video = document.getElementById('playerVideo');
  326. video.play();
  327. isAudioPlay = true;
  328. },
  329. });
  330. }
  331. //云机倒计时
  332. let validTime = parameters['validTime'] || 10000;
  333. if (validTime > 32000) {
  334. validTime = 32000;
  335. }
  336. let detailTime = validTime * 60 * 1000;
  337. setTimeout(() => {
  338. $('.bug-title').eq(0).text('尊敬的用户您的云手机试用时间已到期');
  339. getDate = true;
  340. $('.buy-phone-wrap').eq(0).show();
  341. }, detailTime);
  342. var topwinHeight = window.screen.height - window.innerHeight + 30; //计算title top 头部
  343. $('#wine').css({
  344. width: window.screen.width,
  345. height: window.screen.height - topwinHeight - 20,
  346. position: 'absolute',
  347. });
  348. $('.loading').css({
  349. width: window.screen.width,
  350. height: window.screen.height - topwinHeight - 20,
  351. });
  352. var winese = document.createElement('wine');
  353. wine.style.top = '-' + winese + 'px';
  354. var isVisuable = true;
  355. var isFeed = true;
  356. var isFinish = false;
  357. var myVideo = document.getElementById('playerVideo');
  358. Module = {};
  359. Module.onRuntimeInitialized = function () {
  360. isFinish = true;
  361. };
  362. function connect() {
  363. $.ajax({
  364. url: baseUrl + '/api/resources/user/cloud/connect',
  365. type: 'post',
  366. data: JSON.stringify({
  367. userCardId: Number(form.userCardId),
  368. }),
  369. headers: {
  370. 'content-Type': 'application/json',
  371. Authorization: form.token,
  372. },
  373. dataType: 'json',
  374. async: false,
  375. success: function (res) {
  376. if (res.status === 0) {
  377. if (res.data.internetHttps) {
  378. socketURL =
  379. 'wss://' +
  380. res.data.internetHttps +
  381. '/plugflow?cardIp=' +
  382. res.data.localIp +
  383. '&token=' +
  384. res.data.cardToken +
  385. '&type=business';
  386. cUrl =
  387. 'wss://' +
  388. res.data.internetHttps +
  389. '/businessChannel?cardIp=' +
  390. res.data.localIp +
  391. '&token=' +
  392. res.data.cardToken +
  393. '&type=directives';
  394. cardToken = res.data.cardToken;
  395. resolvingPower = res.data.resolvingPower;
  396. addData(db, storeName, {
  397. id: form.userCardId,
  398. socketURL: socketURL,
  399. cUrl: cUrl,
  400. cardToken: res.data.cardToken,
  401. resolvingPower: res.data.resolvingPower,
  402. });
  403. doConnectBusiness();
  404. doConnectDirectives();
  405. } else {
  406. $.toast('网络异常,请稍后重试', 'text');
  407. }
  408. } else {
  409. $.toast('画面异常,请重新进入', 'text');
  410. clearInterval(intervaler);
  411. quit();
  412. ws.close();
  413. wsss.close();
  414. }
  415. },
  416. });
  417. }
  418. var jmuxer = new JMuxer({
  419. node: 'playerVideo',
  420. flushingTime: 33,
  421. fps: 30,
  422. mode: 'video',
  423. debug: false,
  424. });
  425. window.onload = function () {
  426. var myPlay = document.getElementById('wine');
  427. myPlay.onkeydown = function (event) {
  428. ExexuteKeyDown(e.keyCode);
  429. };
  430. };
  431. var ws,
  432. errorTime = 0;
  433. // 节流
  434. // 设置一个标志
  435. function throttle(fn, delay) {
  436. let flag = true;
  437. errorTime += delay;
  438. return () => {
  439. if (!flag) return;
  440. flag = false;
  441. timer = setTimeout(() => {
  442. fn();
  443. flag = true;
  444. }, delay);
  445. };
  446. }
  447. var intervaler;
  448. function doConnectBusiness() {
  449. ws = new WebSocket(socketURL);
  450. ws.binaryType = 'arraybuffer';
  451. intervaler = setInterval(() => {
  452. if (ws.readyState === 1) {
  453. ws.send('ping');
  454. } else {
  455. clearInterval(intervaler);
  456. $.toast('画面异常,请重新进入', 'text');
  457. quit();
  458. }
  459. }, 3000);
  460. ws.addEventListener('open', function (event) {
  461. // sn只要长度满足17位随机数,不需要从后台获取
  462. var verifyBuffer = VerifyCode('RK3923C1201900139', cardToken);
  463. console.log('鉴权报文:' + PrintArry(verifyBuffer));
  464. ws.send(verifyBuffer);
  465. });
  466. ws.addEventListener('error', function (event) {
  467. ws.close();
  468. clearInterval(intervaler);
  469. throttle(doConnectBusiness, 100);
  470. if (errorTime > 1000) {
  471. $.toast('画面异常,请重新进入', 'text');
  472. wsss.close();
  473. quit();
  474. }
  475. });
  476. ws.addEventListener('message', function (event) {
  477. var data = ParseProto(event.data); //JAVA服务器转发
  478. if (isAudioPlay) {
  479. $('.weui-mask_transparent').hide();
  480. $('.weui-toast').hide();
  481. $('.loading').hide();
  482. }
  483. var input = new Uint8Array(event.data);
  484. if (data.audio != null && isAudioPlay) {
  485. //喂音频
  486. if (input[0] == 0xff) {
  487. if (isFinish) {
  488. decodeAAC(input);
  489. }
  490. }
  491. }
  492. if (
  493. data.frameType != undefined &&
  494. data.frameType != 1 &&
  495. data.frameType != 6
  496. ) {
  497. if (data.frameType == 7) {
  498. let info = spsParser(data.video);
  499. if (
  500. info.width != myVideo.videoWidth &&
  501. info.height != myVideo.videoHeight
  502. ) {
  503. if (myVideo.videoWidth == 0) {
  504. console.log(
  505. 'SPS计算得到宽 %d, 高 %d, 控件宽 %d, %d',
  506. info.width,
  507. info.height,
  508. myVideo.videoWidth,
  509. myVideo.videoHeight,
  510. );
  511. }
  512. }
  513. }
  514. }
  515. if (data.video != null) {
  516. //喂视频
  517. if (data.frameType == 0x05 && isVisuable) {
  518. isFeed = true;
  519. }
  520. if (data.frameType == 7 || data.frameType == 8) {
  521. isFeed = true;
  522. isAudioPlay = true;
  523. }
  524. if (isFeed) {
  525. jmuxer.feed(data);
  526. }
  527. }
  528. });
  529. }
  530. var hidden, visibilityChange;
  531. if (typeof document.hidden !== 'undefined') {
  532. // Opera 12.10 and Firefox 18 and later support
  533. hidden = 'hidden';
  534. visibilityChange = 'visibilitychange';
  535. } else if (typeof document.msHidden !== 'undefined') {
  536. hidden = 'msHidden';
  537. visibilityChange = 'msvisibilitychange';
  538. } else if (typeof document.webkitHidden !== 'undefined') {
  539. hidden = 'webkitHidden';
  540. visibilityChange = 'webkitvisibilitychange';
  541. }
  542. // 处理页面可见属性的改变
  543. document.addEventListener(
  544. 'visibilitychange',
  545. function () {
  546. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  547. visibilitychange();
  548. } else if (window.__wxjs_environment === 'miniprogram') {
  549. visibilitychange();
  550. } else {
  551. if (document[hidden]) {
  552. ws.close();
  553. wsss.close();
  554. uni.webView.navigateTo({
  555. url: '/pages/index/index',
  556. });
  557. }
  558. }
  559. },
  560. false,
  561. );
  562. function visibilitychange() {
  563. if (document.visibilityState == 'visible') {
  564. var buffer = RequestIFrame();
  565. ws.send(buffer);
  566. isVisuable = true;
  567. } else {
  568. isVisuable = false;
  569. isFeed = false;
  570. myVideo.pause();
  571. }
  572. }
  573. myVideo.addEventListener('pause', function () {
  574. isFeed = false;
  575. });
  576. var decodeCount = 1;
  577. var player = new PCMPlayer({
  578. encoding: '16bitInt',
  579. channels: 2,
  580. sampleRate: 44100,
  581. flushingTime: 22,
  582. debug: false,
  583. });
  584. function handleClose() {
  585. $('.mask').hide();
  586. }
  587. function decodeAAC(data) {
  588. var retPtr = Module._malloc(4 * 5 * 1024); // 接收的数据
  589. var inputPtr = Module._malloc(4 * data.length); // 输入数据
  590. for (var i = 0; i < data.length; i++) {
  591. Module.HEAPU8[inputPtr + i] = data[i]; //转换为堆数据
  592. }
  593. var pcmLen = Module._feedData(retPtr, inputPtr, data.length);
  594. if (pcmLen >= 0) {
  595. var pcmData = new Uint8Array(pcmLen);
  596. for (var i = 0; i < pcmLen; i++) {
  597. pcmData[i] = Module.HEAPU8[retPtr + i];
  598. }
  599. player.feed(pcmData);
  600. }
  601. decodeCount++;
  602. Module._free(inputPtr);
  603. Module._free(retPtr);
  604. }
  605. //解协议
  606. function ParseProto(data) {
  607. var input = new Uint8Array(data),
  608. duration,
  609. video,
  610. frameType,
  611. audio;
  612. if (input[0] == 0 && input[1] == 0 && input[2] == 0 && input[3] == 1) {
  613. video = input;
  614. duration = 24;
  615. var nalType = input[4] & 0x1f;
  616. frameType = nalType;
  617. if (!isFeed) {
  618. if (nalType == 0x05 && isVisuable) {
  619. isFeed = true;
  620. }
  621. }
  622. } else if (input[0] == 0xff) {
  623. audio = input;
  624. duration = 24;
  625. } else if (input[0] == 0x68) {
  626. if (input[23] == 0x5c) {
  627. console.log('收到消息:' + PrintArry(input));
  628. if (CheckVerifyCode(input)) {
  629. ws.send(ConfigChannel('RK3923C1201900139'));
  630. var checkBuffer = GetScreenState();
  631. ws.send(checkBuffer);
  632. } else {
  633. connect();
  634. }
  635. }
  636. if (input[23] == 0x05) {
  637. //横竖屏标识
  638. var state = CheckScreenDirection(input.slice(24, 24 + 8));
  639. if (state == 1) {
  640. console.log('安卓卡此时竖屏');
  641. //竖屏处理
  642. resolving = 1;
  643. } else {
  644. console.log('安卓卡此时横屏');
  645. //横屏处理
  646. resolving = 0;
  647. }
  648. }
  649. if (input[23] == 0x0b) {
  650. //多端登录处理, 数据从索引24开始取, input 是接收到的原始数据
  651. var jsonobj = checkMultiLoginInfo(input);
  652. }
  653. }
  654. return {
  655. audio: audio,
  656. video: video,
  657. duration: duration,
  658. frameType: frameType,
  659. };
  660. }
  661. function GetRequest() {
  662. var url = location.search; // 获取url中"?"符后的字串
  663. var obj = new Object();
  664. if (url.indexOf('?') != -1) {
  665. var str = url.substr(1);
  666. strs = str.split('&');
  667. for (var i = 0; i < strs.length; i++) {
  668. obj[strs[i].split('=')[0]] = strs[i].split('=')[1];
  669. }
  670. }
  671. return obj;
  672. }
  673. function Back() {
  674. ExexuteKeyDown(4);
  675. window.event.returnValue = false;
  676. return false;
  677. }
  678. function array_unique(arr) {
  679. return arr.filter(function (e, i) {
  680. return arr.indexOf(e) === i;
  681. });
  682. }
  683. var cutList = [];
  684. let timer,
  685. isFlag = true;
  686. function showShearPlate() {
  687. if (!isControl) {
  688. return;
  689. }
  690. stopManyClick(() => {
  691. $('.box-shear-plate').empty();
  692. $.ajax({
  693. url: baseUrl + '/api/public/v5/shear/content',
  694. headers: {
  695. Authorization: form.token,
  696. },
  697. type: 'get',
  698. dataType: 'json',
  699. success: function (res) {
  700. if (res.status === 0) {
  701. if (res.data.length) {
  702. cutList = array_unique(res.data);
  703. var str =
  704. '<div class="title">剪贴板<div onclick="handleClear()" class="btn-clear">清空</div></div><div class="slide-wrapper-content">';
  705. cutList.forEach(function (item) {
  706. str +=
  707. "<div class='slide-wrapper'><div class='slide-scroll animate-slide-start'><div class='slide-content'><div onclick='handleCopy(\"" +
  708. item.content +
  709. '")\'>' +
  710. item.content +
  711. "</div></div><div class='slide-content-button'><button onclick='handleDelete(" +
  712. item.id +
  713. ")'>删除</button></div></div></div>";
  714. });
  715. str += '</div>';
  716. $('.box-shear-plate').append(str);
  717. } else {
  718. $('.box-shear-plate').append(
  719. '<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>',
  720. );
  721. }
  722. $('.mask').show();
  723. initSlider();
  724. } else {
  725. $('.box-shear-plate').append(
  726. '<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>',
  727. );
  728. $('.mask').show();
  729. }
  730. },
  731. });
  732. });
  733. }
  734. //防止提示一秒内重复显示
  735. function stopManyClick(fn) {
  736. if (isFlag) {
  737. fn();
  738. }
  739. isFlag = false;
  740. if (timer) {
  741. clearTimeout(timer);
  742. }
  743. timer = setTimeout(() => {
  744. isFlag = true;
  745. }, 1500);
  746. }
  747. // 清空剪贴板
  748. function handleClear() {
  749. var ids = '';
  750. cutList.forEach(function (item) {
  751. ids += 'ids=' + item.id + '&';
  752. });
  753. ids = ids.substring(0, ids.lastIndexOf('&'));
  754. $.confirm('确定清空剪贴板?', function () {
  755. $.ajax({
  756. url: baseUrl + '/api/public/v5/shear/content?' + ids,
  757. headers: {
  758. Authorization: form.token,
  759. },
  760. type: 'DELETE',
  761. dataType: 'json',
  762. success: function (res) {
  763. if (res.status === 0) {
  764. showShearPlate();
  765. } else {
  766. $.toast(res.msg, 'text');
  767. }
  768. },
  769. });
  770. });
  771. }
  772. function handleCopy(content) {
  773. var cutting = {
  774. type: 'cutting',
  775. data: {
  776. str: content,
  777. },
  778. };
  779. wsss.send(JSON.stringify(cutting));
  780. }
  781. // 删除剪贴板
  782. function handleDelete(id) {
  783. $.ajax({
  784. url: baseUrl + '/api/public/v5/shear/content?ids=' + id,
  785. headers: {
  786. Authorization: form.token,
  787. },
  788. type: 'DELETE',
  789. dataType: 'json',
  790. success: function (res) {
  791. if (res.status === 0) {
  792. showShearPlate();
  793. } else {
  794. $.toast(res.msg, 'text');
  795. }
  796. },
  797. });
  798. }
  799. function initSlider() {
  800. //手指滑动多少距离就认为是滑成功
  801. //这个值不能太大,否则影响斜着滑动时,垂直滑动的流畅性,也不能太小,太灵敏也不好
  802. var diffXDistance = 50;
  803. //当前滑动的对象
  804. var currentObject;
  805. //上一次滑动的对象
  806. var lastObject;
  807. //是否可以左右滑动,在上下滑的时候禁止左右滑
  808. var canSlide = true;
  809. //用于记录按下的点
  810. var startPoint;
  811. $('.slide-content').css({
  812. width: $('.slide-wrapper').width(),
  813. });
  814. document.body.removeEventListener(
  815. 'touchmove',
  816. function (e) {
  817. e.preventDefault();
  818. },
  819. {
  820. passive: false,
  821. },
  822. );
  823. $('.slide-scroll')
  824. .css({
  825. width:
  826. $('.slide-wrapper').width() + $('.slide-content-button').width(),
  827. })
  828. .on('touchstart', function (e) {
  829. currentObject = this;
  830. startPoint = {
  831. x: e.originalEvent.changedTouches[0].pageX,
  832. y: e.originalEvent.changedTouches[0].pageY,
  833. };
  834. })
  835. .on('touchmove', function (e) {
  836. //如果是左右滑动,就禁止上下的滑动
  837. //如果是上下的滑动,就禁止左右滑动
  838. if (
  839. Math.abs(e.originalEvent.changedTouches[0].pageX - startPoint.x) >
  840. Math.abs(e.originalEvent.changedTouches[0].pageY - startPoint.y)
  841. ) {
  842. event.preventDefault();
  843. } else {
  844. canSlide = false;
  845. }
  846. })
  847. .on('touchend', function (e) {
  848. //如果是上下滑动,这里就直接返回了
  849. if (!canSlide) {
  850. canSlide = true;
  851. return true;
  852. }
  853. //点击除当前左滑对象之外的任意其他位置
  854. if (lastObject && currentObject != lastObject) {
  855. //右滑→
  856. $(lastObject).removeClass('animate-slide');
  857. //清空上一个左滑的对象
  858. lastObject = undefined;
  859. }
  860. var diffX = e.originalEvent.changedTouches[0].pageX - startPoint.x;
  861. if (diffX < -diffXDistance) {
  862. //左滑←
  863. $(currentObject).addClass('animate-slide');
  864. if (lastObject && lastObject != currentObject) {
  865. //右滑→
  866. $(lastObject).removeClass('animate-slide');
  867. }
  868. //记录上一个左滑的对象
  869. lastObject = currentObject;
  870. } else if (diffX >= diffXDistance) {
  871. if (currentObject == lastObject) {
  872. //右滑→
  873. $(currentObject).removeClass('animate-slide');
  874. //清空上一个左滑的对象
  875. lastObject = undefined;
  876. }
  877. }
  878. });
  879. }
  880. var btnMuted = document.querySelector('#btnMuted');
  881. btnMuted &&
  882. (function () {
  883. var setHistory = function (left, top) {
  884. try {
  885. localStorage.setItem(
  886. 'muted-btn-loc',
  887. JSON.stringify({
  888. left: left,
  889. top: top,
  890. }),
  891. );
  892. } catch (ex) {}
  893. };
  894. var getHistory = function () {
  895. try {
  896. var value = localStorage.getItem('muted-btn-loc');
  897. if (!value) return null;
  898. value = JSON.parse(value);
  899. if (!value) return null;
  900. return value;
  901. } catch (ex) {
  902. return null;
  903. }
  904. };
  905. var fixLoc = function (loc) {
  906. var rect = btnMuted.getBoundingClientRect();
  907. rect = {
  908. top: rect.top,
  909. left: rect.left,
  910. width: rect.width,
  911. height: rect.height,
  912. }; //部分低版本浏览器,该属性为只读
  913. if (loc) {
  914. rect.left = loc.left;
  915. rect.top = loc.top;
  916. }
  917. var minX = 0;
  918. var minY = 0;
  919. var docRect = document.documentElement.getBoundingClientRect();
  920. var maxY = docRect.height - rect.height;
  921. var maxX = docRect.width - rect.width;
  922. var left = rect.left;
  923. var top = rect.top;
  924. left = Math.min(left, maxX);
  925. left = Math.max(left, minX);
  926. top = Math.min(top, maxY);
  927. top = Math.max(top, minY);
  928. if (loc || top !== rect.top || left !== rect.left) {
  929. btnMuted.style.cssText +=
  930. 'left:' + left + 'px;top:' + top + 'px;';
  931. }
  932. };
  933. window.addEventListener('resize', function () {
  934. fixLoc();
  935. });
  936. var touchPoint = {
  937. pageY: 0,
  938. pageX: 0,
  939. };
  940. var currentLoc = {
  941. top: 0,
  942. left: 0,
  943. curTop: 0,
  944. curLeft: 0,
  945. };
  946. var toMove = false;
  947. var touchmove = function (e) {
  948. e.preventDefault();
  949. var point = e.changedTouches[0];
  950. var top = -touchPoint.pageY + point.pageY;
  951. var left = -touchPoint.pageX + point.pageX;
  952. if (toMove) {
  953. top += currentLoc.top;
  954. left += currentLoc.left;
  955. currentLoc.curLeft = left;
  956. currentLoc.curTop = top;
  957. btnMuted.style.cssText +=
  958. 'left:' + left + 'px;top:' + top + 'px;';
  959. } else {
  960. if (Math.abs(top) >= 5 || Math.abs(left) >= 5) {
  961. toMove = true;
  962. }
  963. }
  964. };
  965. var touchend = function () {
  966. window.removeEventListener('touchmove', touchmove, {
  967. passive: false,
  968. });
  969. window.removeEventListener('touchend', touchend, {
  970. passive: false,
  971. });
  972. if (toMove) {
  973. setHistory(currentLoc.curLeft, currentLoc.curTop);
  974. fixLoc();
  975. } else {
  976. //按点击处理
  977. var set = $('.control-right-img').attr('data-id');
  978. if (set == '1') {
  979. $('.control-right-img').attr({
  980. 'data-id': '2',
  981. });
  982. $('.leftmains').css({
  983. right: '0rem',
  984. });
  985. } else {
  986. $('.control-right-img').attr({
  987. 'data-id': '1',
  988. });
  989. $('.leftmains').css({
  990. right: '-4rem',
  991. });
  992. }
  993. }
  994. };
  995. btnMuted.addEventListener(
  996. 'touchstart',
  997. function (e) {
  998. e.preventDefault();
  999. toMove = false;
  1000. var point = e.changedTouches[0];
  1001. touchPoint.pageX = point.pageX;
  1002. touchPoint.pageY = point.pageY;
  1003. var rect = e.target.getBoundingClientRect();
  1004. currentLoc.top = rect.top;
  1005. currentLoc.left = rect.left;
  1006. window.addEventListener('touchmove', touchmove, {
  1007. passive: false,
  1008. });
  1009. window.addEventListener('touchend', touchend, {
  1010. passive: false,
  1011. });
  1012. },
  1013. {
  1014. passive: false,
  1015. },
  1016. );
  1017. var history = getHistory();
  1018. if (history) {
  1019. fixLoc(history);
  1020. }
  1021. btnMuted.classList.remove('hide');
  1022. })();
  1023. $('#upload').on('click', function () {
  1024. clearInterval(intervaler);
  1025. quit();
  1026. ws.close();
  1027. wsss.close();
  1028. });
  1029. function selectText(x) {
  1030. if (document.selection) {
  1031. var range = document.body.createTextRange();
  1032. range.moveToElementText(x);
  1033. range.select();
  1034. } else if (window.getSelection) {
  1035. var selection = window.getSelection();
  1036. var range = document.createRange();
  1037. selection.removeAllRanges();
  1038. range.selectNodeContents(x);
  1039. selection.addRange(range);
  1040. }
  1041. }
  1042. // 激活码广告相关配置
  1043. function getConfigByPhoneType() {
  1044. return new Promise((resolve, reject) => {
  1045. $.ajax({
  1046. url: baseUrl + '/api/pay/v5/trialCodeConfig/getConfigByPhoneType',
  1047. headers: {
  1048. Authorization: form.token,
  1049. },
  1050. data: {
  1051. userCardId: form.userCardId,
  1052. phoneType: form.mealType,
  1053. },
  1054. type: 'get',
  1055. dataType: 'json',
  1056. success: function (res) {
  1057. let obj = res.data;
  1058. if (res.status === 0) {
  1059. resolve(obj);
  1060. } else {
  1061. $.toast(res.msg, 'text');
  1062. }
  1063. },
  1064. });
  1065. });
  1066. }
  1067. //列表
  1068. function getSetmealList() {
  1069. return new Promise((resolve, reject) => {
  1070. $.ajax({
  1071. url: baseUrl + '/api/resources/v4/freetrial/setmeal/list',
  1072. headers: {
  1073. Authorization: form.token,
  1074. },
  1075. type: 'get',
  1076. dataType: 'json',
  1077. success: function (res) {
  1078. if (res.status === 0) {
  1079. let list = res.data;
  1080. list.map((item) => {
  1081. if (item.phoneType === parameters['mealType']) {
  1082. resolve(item);
  1083. }
  1084. });
  1085. } else {
  1086. $.toast(res.msg, 'text');
  1087. }
  1088. },
  1089. });
  1090. });
  1091. }
  1092. //广告信息
  1093. var adData = null; // 广告数据
  1094. var adLastTime = 0; // 广告时间
  1095. var intervalTime = 0; // 间隔时间
  1096. // let adType = 0;
  1097. console.log(
  1098. '🚀 ~ file: WXtrialInterface.html ~ line 973 ~ sourceType',
  1099. sourceType,
  1100. );
  1101. // 拉取广告数据
  1102. function getAD() {
  1103. return $.ajax({
  1104. url: baseUrl + '/api/public/v5/advertising/getAdInfoByAdPlace',
  1105. headers: {
  1106. Authorization: form.token,
  1107. },
  1108. data: JSON.stringify({
  1109. adPlace: adType,
  1110. os: 0,
  1111. }),
  1112. type: 'POST',
  1113. dataType: 'json',
  1114. contentType: 'application/json;charset=UTF-8',
  1115. }).then(function (res) {
  1116. if (res.status === 0) {
  1117. var list = res.data.filter(
  1118. (v) => v.adType === 1 && !!v.adVideoBase.videoUrl,
  1119. );
  1120. adData = list[Math.floor(Math.random() * list.length)];
  1121. console.log(
  1122. '🚀 ~ file: WXtrialInterface.html ~ line 990 ~ getAD ~ adData',
  1123. adData,
  1124. );
  1125. return adData;
  1126. } else {
  1127. return Promise.reject(new Error(res.msg));
  1128. }
  1129. });
  1130. }
  1131. // 播放广告
  1132. function playAD() {
  1133. var nowTime = Date.now();
  1134. if (
  1135. adData &&
  1136. // [1, 2].includes(sourceType) &&
  1137. $('.try-use-wrap').eq(0).is(':hidden') &&
  1138. nowTime > adLastTime + intervalTime
  1139. ) {
  1140. $('#source').attr('src', adData.adVideoBase.videoUrl);
  1141. $('.try-use-wrap').eq(0).show();
  1142. $('#source')[0].play();
  1143. videoTime = adData.forcedTime;
  1144. adData = null;
  1145. adLastTime = nowTime;
  1146. videoTimer = setInterval(() => {
  1147. if (videoTime > 0) {
  1148. videoTime--;
  1149. $('.time-node')
  1150. .eq(0)
  1151. .text(videoTime + 's');
  1152. } else {
  1153. clearInterval(videoTimer);
  1154. $('.time-node').eq(0).text('');
  1155. }
  1156. }, 1000);
  1157. if (intervalTime > 0) {
  1158. // 间隔广告拉取下一次广告数据
  1159. adType = 16;
  1160. getAD();
  1161. }
  1162. if (adType === 16 && sourceType == 1) {
  1163. // 间隔广告和试用才上报
  1164. report(0);
  1165. }
  1166. }
  1167. }
  1168. /**
  1169. * 初始化广告
  1170. * 因移动端video无法自动播放,play()方法不能异步调用。
  1171. * 解决方案,初始化时预先请求广告数据,在用户对云手机touchmove事件中去播放广告并请求下一次广告数据。
  1172. */
  1173. function initAD() {
  1174. console.log(
  1175. '🚀 ~ file: WXtrialInterface.html ~ line 1052 ~ initAD ~ sourceType',
  1176. sourceType,
  1177. );
  1178. (function () {
  1179. switch (sourceType) {
  1180. case 1: {
  1181. return getSetmealList().then(function (res) {
  1182. intervalTime =
  1183. res.intervalSwitch === 1
  1184. ? res.intervalAdvertDuration * 1000 * 60
  1185. : 0;
  1186. if (res.pushFlowAdvert === 1) {
  1187. adType = 15;
  1188. adTime = 0;
  1189. } else if (intervalTime > 0) {
  1190. adType = 16;
  1191. adTime = date.now();
  1192. }
  1193. });
  1194. }
  1195. case 2: {
  1196. return getConfigByPhoneType().then(function (res) {
  1197. if (res.isDisconnectionTime === 1) {
  1198. var time = res.disconnectionTime * 60 * 1000;
  1199. setTimeout(() => {
  1200. disconnectionFlag = true;
  1201. $('.buy-phone-wrap').eq(0).show();
  1202. }, time);
  1203. }
  1204. intervalTime =
  1205. res.isIntervalPlayAd === 1
  1206. ? res.intervalPlayAdTime * 1000 * 60
  1207. : 0;
  1208. if (res.isShowAd === 1) {
  1209. adType = 15;
  1210. adTime = 0;
  1211. } else if (intervalTime > 0) {
  1212. adType = 16;
  1213. adTime = date.now();
  1214. }
  1215. });
  1216. }
  1217. default: {
  1218. return Promise.reject();
  1219. }
  1220. }
  1221. })().then(function () {
  1222. console.log(adType);
  1223. this.$('#wine').on('touchstart', playAD);
  1224. getAD();
  1225. });
  1226. }
  1227. //广告信息
  1228. // function adInit() {
  1229. // sourceType = parameters['sourceType'];
  1230. // if (sourceType == 1) {
  1231. // getSetmealList().then((res) => {
  1232. // if (res.pushFlowAdvert === 1) {
  1233. // getAdList(15);
  1234. // }
  1235. // if (res.intervalSwitch === 1) {
  1236. // let time = res.intervalAdvertDuration * 60 * 1000;
  1237. // setInterval(() => {
  1238. // $('.try-use-wrap').eq(0).hide();
  1239. // getAdList(16);
  1240. // }, time);
  1241. // }
  1242. // })
  1243. // } else if (sourceType == 2) {
  1244. // getConfigByPhoneType().then((res) => {
  1245. // if (res.isDisconnectionTime === 1) {
  1246. // let time = res.disconnectionTime * 60 * 1000;
  1247. // setTimeout(() => {
  1248. // disconnectionFlag = true;
  1249. // $('.buy-phone-wrap').eq(0).show();
  1250. // }, time);
  1251. // }
  1252. // if (res.isShowAd === 1) {
  1253. // getAdList(15);
  1254. // }
  1255. // if (res.isIntervalPlayAd === 1) {
  1256. // let time = res.intervalPlayAdTime * 60 * 1000;
  1257. // setInterval(() => {
  1258. // $('.try-use-wrap').eq(0).hide();
  1259. // getAdList(16);
  1260. // }, time);
  1261. // }
  1262. // })
  1263. // }
  1264. // }
  1265. // 广告接口
  1266. // function getAdList(type) {
  1267. // adType = type;
  1268. // $.ajax({
  1269. // url: baseUrl + '/api/public/v5/advertising/getAdInfoByAdPlace',
  1270. // headers: {
  1271. // Authorization: form.token,
  1272. // },
  1273. // data: JSON.stringify({
  1274. // adPlace: type,
  1275. // os: 0,
  1276. // }),
  1277. // type: 'POST',
  1278. // dataType: 'json',
  1279. // contentType: 'application/json;charset=UTF-8',
  1280. // success: function (res) {
  1281. // if (res.status === 0) {
  1282. // let list = res.data;
  1283. // let indexs = Math.floor(Math.random() * list.length);
  1284. // videoTime = list[indexs].forcedTime;
  1285. // // $('#source').src = list[0].adVideoBase.videoUrl;
  1286. // $('#source').attr('src', list[indexs].adVideoBase.videoUrl); //更新url
  1287. // $('#source').attr('autoplay', 'true'); //直接播放
  1288. // videoTimer = setInterval(() => {
  1289. // if (videoTime > 0) {
  1290. // videoTime--;
  1291. // $('.time-node')
  1292. // .eq(0)
  1293. // .text(videoTime + 's');
  1294. // } else {
  1295. // clearInterval(videoTimer);
  1296. // $('.time-node').eq(0).text('');
  1297. // }
  1298. // }, 1000);
  1299. // if (adType === 16 && sourceType == 1) {
  1300. // // 间隔广告和试用才上报
  1301. // report(0);
  1302. // }
  1303. // $('.try-use-wrap').eq(0).show();
  1304. // } else {
  1305. // $.toast(res.msg, 'text');
  1306. // }
  1307. // },
  1308. // });
  1309. // }
  1310. //间隔广告上报
  1311. function report(type) {
  1312. $.ajax({
  1313. url: baseUrl + '/api/resources/v1/trial/report',
  1314. headers: {
  1315. Authorization: form.token,
  1316. },
  1317. data: JSON.stringify({
  1318. userCardId: form.userCardId,
  1319. reportType: type,
  1320. }),
  1321. type: 'POST',
  1322. dataType: 'json',
  1323. contentType: 'application/json;charset=UTF-8',
  1324. success: function (res) {},
  1325. });
  1326. }
  1327. //关闭广告
  1328. $('.time-close-wrap')[0].addEventListener('click', () => {
  1329. $('.buy-phone-wrap').eq(0).show();
  1330. });
  1331. // 点击取消
  1332. $('.cannel-btn')[0].addEventListener('click', () => {
  1333. $('.buy-phone-wrap').eq(0).hide();
  1334. if (disconnectionFlag || getDate) {
  1335. //设置了断线时间,取消直接退出
  1336. systemBuriedPoint('激活码-断线-取消');
  1337. quit();
  1338. return;
  1339. }
  1340. let pointName = '';
  1341. if (sourceType == 1) {
  1342. pointName =
  1343. videoTime == 0 ? '免费试用-关闭-取消' : '免费试用-强制关闭-取消';
  1344. } else {
  1345. pointName =
  1346. videoTime == 0 ? '激活码-关闭-取消' : '激活码-强制关闭-取消';
  1347. }
  1348. systemBuriedPoint(pointName);
  1349. if (videoTime == 0) {
  1350. if (adType === 16 && sourceType == 1) {
  1351. report(1);
  1352. }
  1353. $('.try-use-wrap').eq(0).hide();
  1354. $('#source')[0].pause();
  1355. return;
  1356. }
  1357. $('.look-wrap').eq(0).show();
  1358. });
  1359. // 点击去购买
  1360. $('.go-bug')[0].addEventListener('click', () => {
  1361. let pointName = '';
  1362. if (disconnectionFlag) {
  1363. pointName = '激活码-断线-去购买';
  1364. } else if (sourceType == 1) {
  1365. pointName =
  1366. videoTime == 0
  1367. ? '免费试用-关闭-去购买'
  1368. : '免费试用-强制关闭-去购买';
  1369. } else {
  1370. pointName =
  1371. videoTime == 0 ? '激活码-关闭-去购买' : '激活码-强制关闭-去购买';
  1372. }
  1373. systemBuriedPoint(pointName);
  1374. if (getDate) {
  1375. wx.miniProgram.navigateTo({
  1376. url: '/packageA/order/buy/index?buyType=试用界面购买',
  1377. });
  1378. } else {
  1379. // 过期续费按钮进入
  1380. wx.miniProgram.navigateTo({
  1381. url:
  1382. `/packageA/order/renew/index?buyType=${
  1383. sourceType == 1
  1384. ? '试用弹窗购买按钮进入-普通试用'
  1385. : '试用弹窗购买按钮进入-激活码试用'
  1386. }&record=` + form.userCardId,
  1387. });
  1388. }
  1389. });
  1390. // 放弃
  1391. $('.cannel-ad-btn')[0].addEventListener('click', () => {
  1392. if (sourceType == 1) {
  1393. systemBuriedPoint('免费试用-强制关闭-放弃');
  1394. } else {
  1395. systemBuriedPoint('激活码-强制关闭-放弃');
  1396. }
  1397. quit();
  1398. });
  1399. // 继续观看
  1400. $('.looking')[0].addEventListener('click', () => {
  1401. $('.look-wrap').eq(0).hide();
  1402. if (sourceType == 1) {
  1403. systemBuriedPoint('免费试用-强制关闭-继续观看');
  1404. } else {
  1405. systemBuriedPoint('激活码-强制关闭-继续观看');
  1406. }
  1407. });
  1408. // 埋点
  1409. function systemBuriedPoint(pointName) {
  1410. $.ajax({
  1411. url: baseUrl + '/api/public/v1/systemBuriedPoint/stat',
  1412. headers: {
  1413. Authorization: form.token,
  1414. },
  1415. type: 'post',
  1416. data: JSON.stringify({
  1417. pointName: pointName,
  1418. }),
  1419. contentType: 'application/json',
  1420. dataType: 'json',
  1421. success: function (res) {},
  1422. });
  1423. }
  1424. function quit() {
  1425. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  1426. tt.miniProgram.switchTab({
  1427. url: '/pages/home/home',
  1428. });
  1429. } else if (window.__wxjs_environment === 'miniprogram') {
  1430. wx.miniProgram.switchTab({
  1431. url: '/pages/home/home',
  1432. });
  1433. } else {
  1434. uni.webView.navigateTo({
  1435. url: '/pages/index/index',
  1436. });
  1437. }
  1438. }
  1439. window.onbeforeunload = function () {
  1440. ws.close();
  1441. wsss.close();
  1442. };
  1443. </script>
  1444. <script type="text/javascript" src="aac.js"></script>
  1445. </body>
  1446. </html>