WXtrialInterface.html 51 KB

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