WXtrialInterface.html 49 KB

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