WXtrialInterface.html 45 KB

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