WXtrialInterface.html 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563
  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(type) {
  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.navigateBack({
  564. delta: 1
  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. new Promise((resolve, reject) => {
  701. if (window.navigator.clipboard) {
  702. window.navigator.clipboard
  703. .readText()
  704. .then(
  705. function (content) {
  706. return $.ajax({
  707. url: baseUrl + '/api/public/v5/shear/content',
  708. type: 'post',
  709. dataType: 'json',
  710. data: JSON.stringify({
  711. content: content,
  712. }),
  713. headers: {
  714. 'content-Type': 'application/json',
  715. Authorization: token,
  716. },
  717. });
  718. },
  719. function (err) {
  720. $.toast('读取剪贴板失败', 'text');
  721. },
  722. )
  723. .finally(resolve);
  724. } else {
  725. resolve();
  726. }
  727. }).then(function () {
  728. $('.box-shear-plate').empty();
  729. $.ajax({
  730. url: baseUrl + '/api/public/v5/shear/content',
  731. headers: {
  732. Authorization: token,
  733. },
  734. type: 'get',
  735. dataType: 'json',
  736. success: function (res) {
  737. if (res.status === 0) {
  738. if (res.data.length) {
  739. cutList = array_unique(res.data);
  740. var str =
  741. '<div class="title">剪贴板<div onclick="handleClear()" class="btn-clear">清空</div></div><div class="slide-wrapper-content">';
  742. cutList.forEach(function (item) {
  743. str +=
  744. "<div class='slide-wrapper'><div class='slide-scroll animate-slide-start'><div class='slide-content'><div onclick='handleCopy(\"" +
  745. item.content +
  746. '")\'>' +
  747. item.content +
  748. "</div></div><div class='slide-content-button'><button onclick='handleDelete(" +
  749. item.id +
  750. ")'>删除</button></div></div></div>";
  751. });
  752. str += '</div>';
  753. $('.box-shear-plate').append(str);
  754. } else {
  755. $('.box-shear-plate').append(
  756. '<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>',
  757. );
  758. }
  759. $('.mask').show();
  760. initSlider();
  761. } else {
  762. $('.box-shear-plate').append(
  763. '<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>',
  764. );
  765. $('.mask').show();
  766. }
  767. },
  768. });
  769. });
  770. });
  771. }
  772. //防止提示一秒内重复显示
  773. function stopManyClick(fn) {
  774. if (isFlag) {
  775. fn();
  776. }
  777. isFlag = false;
  778. if (timer) {
  779. clearTimeout(timer);
  780. }
  781. timer = setTimeout(() => {
  782. isFlag = true;
  783. }, 1500);
  784. }
  785. // 清空剪贴板
  786. function handleClear() {
  787. var ids = '';
  788. cutList.forEach(function (item) {
  789. ids += 'ids=' + item.id + '&';
  790. });
  791. ids = ids.substring(0, ids.lastIndexOf('&'));
  792. $.confirm('确定清空剪贴板?', function () {
  793. $.ajax({
  794. url: baseUrl + '/api/public/v5/shear/content?' + ids,
  795. headers: {
  796. Authorization: token,
  797. },
  798. type: 'DELETE',
  799. dataType: 'json',
  800. success: function (res) {
  801. if (res.status === 0) {
  802. showShearPlate();
  803. } else {
  804. $.toast(res.msg, 'text');
  805. }
  806. },
  807. });
  808. });
  809. }
  810. function handleCopy(content) {
  811. var cutting = {
  812. type: 'cutting',
  813. data: {
  814. str: content,
  815. },
  816. };
  817. wsss.send(JSON.stringify(cutting));
  818. }
  819. // 删除剪贴板
  820. function handleDelete(id) {
  821. $.ajax({
  822. url: baseUrl + '/api/public/v5/shear/content?ids=' + id,
  823. headers: {
  824. Authorization: token,
  825. },
  826. type: 'DELETE',
  827. dataType: 'json',
  828. success: function (res) {
  829. if (res.status === 0) {
  830. showShearPlate();
  831. } else {
  832. $.toast(res.msg, 'text');
  833. }
  834. },
  835. });
  836. }
  837. function initSlider() {
  838. //手指滑动多少距离就认为是滑成功
  839. //这个值不能太大,否则影响斜着滑动时,垂直滑动的流畅性,也不能太小,太灵敏也不好
  840. var diffXDistance = 50;
  841. //当前滑动的对象
  842. var currentObject;
  843. //上一次滑动的对象
  844. var lastObject;
  845. //是否可以左右滑动,在上下滑的时候禁止左右滑
  846. var canSlide = true;
  847. //用于记录按下的点
  848. var startPoint;
  849. $('.slide-content').css({
  850. width: $('.slide-wrapper').width(),
  851. });
  852. document.body.removeEventListener(
  853. 'touchmove',
  854. function (e) {
  855. e.preventDefault();
  856. },
  857. {
  858. passive: false,
  859. },
  860. );
  861. $('.slide-scroll')
  862. .css({
  863. width:
  864. $('.slide-wrapper').width() + $('.slide-content-button').width(),
  865. })
  866. .on('touchstart', function (e) {
  867. currentObject = this;
  868. startPoint = {
  869. x: e.originalEvent.changedTouches[0].pageX,
  870. y: e.originalEvent.changedTouches[0].pageY,
  871. };
  872. })
  873. .on('touchmove', function (e) {
  874. //如果是左右滑动,就禁止上下的滑动
  875. //如果是上下的滑动,就禁止左右滑动
  876. if (
  877. Math.abs(e.originalEvent.changedTouches[0].pageX - startPoint.x) >
  878. Math.abs(e.originalEvent.changedTouches[0].pageY - startPoint.y)
  879. ) {
  880. event.preventDefault();
  881. } else {
  882. canSlide = false;
  883. }
  884. })
  885. .on('touchend', function (e) {
  886. //如果是上下滑动,这里就直接返回了
  887. if (!canSlide) {
  888. canSlide = true;
  889. return true;
  890. }
  891. //点击除当前左滑对象之外的任意其他位置
  892. if (lastObject && currentObject != lastObject) {
  893. //右滑→
  894. $(lastObject).removeClass('animate-slide');
  895. //清空上一个左滑的对象
  896. lastObject = undefined;
  897. }
  898. var diffX = e.originalEvent.changedTouches[0].pageX - startPoint.x;
  899. if (diffX < -diffXDistance) {
  900. //左滑←
  901. $(currentObject).addClass('animate-slide');
  902. if (lastObject && lastObject != currentObject) {
  903. //右滑→
  904. $(lastObject).removeClass('animate-slide');
  905. }
  906. //记录上一个左滑的对象
  907. lastObject = currentObject;
  908. } else if (diffX >= diffXDistance) {
  909. if (currentObject == lastObject) {
  910. //右滑→
  911. $(currentObject).removeClass('animate-slide');
  912. //清空上一个左滑的对象
  913. lastObject = undefined;
  914. }
  915. }
  916. });
  917. }
  918. var btnMuted = document.querySelector('#btnMuted');
  919. btnMuted &&
  920. (function () {
  921. var setHistory = function (left, top) {
  922. try {
  923. localStorage.setItem(
  924. 'muted-btn-loc',
  925. JSON.stringify({
  926. left: left,
  927. top: top,
  928. }),
  929. );
  930. } catch (ex) {}
  931. };
  932. var getHistory = function () {
  933. try {
  934. var value = localStorage.getItem('muted-btn-loc');
  935. if (!value) return null;
  936. value = JSON.parse(value);
  937. if (!value) return null;
  938. return value;
  939. } catch (ex) {
  940. return null;
  941. }
  942. };
  943. var fixLoc = function (loc) {
  944. var rect = btnMuted.getBoundingClientRect();
  945. rect = {
  946. top: rect.top,
  947. left: rect.left,
  948. width: rect.width,
  949. height: rect.height,
  950. }; //部分低版本浏览器,该属性为只读
  951. if (loc) {
  952. rect.left = loc.left;
  953. rect.top = loc.top;
  954. }
  955. var minX = 0;
  956. var minY = 0;
  957. var docRect = document.documentElement.getBoundingClientRect();
  958. var maxY = docRect.height - rect.height;
  959. var maxX = docRect.width - rect.width;
  960. var left = rect.left;
  961. var top = rect.top;
  962. left = Math.min(left, maxX);
  963. left = Math.max(left, minX);
  964. top = Math.min(top, maxY);
  965. top = Math.max(top, minY);
  966. if (loc || top !== rect.top || left !== rect.left) {
  967. btnMuted.style.cssText +=
  968. 'left:' + left + 'px;top:' + top + 'px;';
  969. }
  970. };
  971. window.addEventListener('resize', function () {
  972. fixLoc();
  973. });
  974. var touchPoint = {
  975. pageY: 0,
  976. pageX: 0,
  977. };
  978. var currentLoc = {
  979. top: 0,
  980. left: 0,
  981. curTop: 0,
  982. curLeft: 0,
  983. };
  984. var toMove = false;
  985. var touchmove = function (e) {
  986. e.preventDefault();
  987. var point = e.changedTouches[0];
  988. var top = -touchPoint.pageY + point.pageY;
  989. var left = -touchPoint.pageX + point.pageX;
  990. if (toMove) {
  991. top += currentLoc.top;
  992. left += currentLoc.left;
  993. currentLoc.curLeft = left;
  994. currentLoc.curTop = top;
  995. btnMuted.style.cssText +=
  996. 'left:' + left + 'px;top:' + top + 'px;';
  997. } else {
  998. if (Math.abs(top) >= 5 || Math.abs(left) >= 5) {
  999. toMove = true;
  1000. }
  1001. }
  1002. };
  1003. var touchend = function () {
  1004. window.removeEventListener('touchmove', touchmove, {
  1005. passive: false,
  1006. });
  1007. window.removeEventListener('touchend', touchend, {
  1008. passive: false,
  1009. });
  1010. if (toMove) {
  1011. setHistory(currentLoc.curLeft, currentLoc.curTop);
  1012. fixLoc();
  1013. } else {
  1014. //按点击处理
  1015. var set = $('.control-right-img').attr('data-id');
  1016. if (set == '1') {
  1017. $('.control-right-img').attr({
  1018. 'data-id': '2',
  1019. });
  1020. $('.leftmains').css({
  1021. right: '0rem',
  1022. });
  1023. } else {
  1024. $('.control-right-img').attr({
  1025. 'data-id': '1',
  1026. });
  1027. $('.leftmains').css({
  1028. right: '-4rem',
  1029. });
  1030. }
  1031. }
  1032. };
  1033. btnMuted.addEventListener(
  1034. 'touchstart',
  1035. function (e) {
  1036. e.preventDefault();
  1037. toMove = false;
  1038. var point = e.changedTouches[0];
  1039. touchPoint.pageX = point.pageX;
  1040. touchPoint.pageY = point.pageY;
  1041. var rect = e.target.getBoundingClientRect();
  1042. currentLoc.top = rect.top;
  1043. currentLoc.left = rect.left;
  1044. window.addEventListener('touchmove', touchmove, {
  1045. passive: false,
  1046. });
  1047. window.addEventListener('touchend', touchend, {
  1048. passive: false,
  1049. });
  1050. },
  1051. {
  1052. passive: false,
  1053. },
  1054. );
  1055. var history = getHistory();
  1056. if (history) {
  1057. fixLoc(history);
  1058. }
  1059. btnMuted.classList.remove('hide');
  1060. })();
  1061. $('#upload').on('click', function () {
  1062. clearInterval(intervaler);
  1063. quit();
  1064. ws.close();
  1065. wsss.close();
  1066. });
  1067. function selectText(x) {
  1068. if (document.selection) {
  1069. var range = document.body.createTextRange();
  1070. range.moveToElementText(x);
  1071. range.select();
  1072. } else if (window.getSelection) {
  1073. var selection = window.getSelection();
  1074. var range = document.createRange();
  1075. selection.removeAllRanges();
  1076. range.selectNodeContents(x);
  1077. selection.addRange(range);
  1078. }
  1079. }
  1080. // 激活码广告相关配置
  1081. function getConfigByPhoneType() {
  1082. return new Promise((resolve, reject) => {
  1083. $.ajax({
  1084. url: baseUrl + '/api/pay/v5/trialCodeConfig/getConfigByPhoneType',
  1085. headers: {
  1086. Authorization: token,
  1087. },
  1088. data: {
  1089. userCardId: userCardId,
  1090. phoneType: mealType,
  1091. },
  1092. type: 'get',
  1093. dataType: 'json',
  1094. success: function (res) {
  1095. let obj = res.data;
  1096. if (res.status === 0) {
  1097. resolve(obj);
  1098. } else {
  1099. $.toast(res.msg, 'text');
  1100. }
  1101. },
  1102. });
  1103. });
  1104. }
  1105. //列表
  1106. function getSetmealList() {
  1107. return new Promise((resolve, reject) => {
  1108. $.ajax({
  1109. url: baseUrl + '/api/resources/v4/freetrial/setmeal/list',
  1110. headers: {
  1111. Authorization: token,
  1112. },
  1113. type: 'get',
  1114. dataType: 'json',
  1115. success: function (res) {
  1116. if (res.status === 0) {
  1117. let list = res.data;
  1118. list.map((item) => {
  1119. if (item.phoneType === parameters['mealType']) {
  1120. resolve(item);
  1121. }
  1122. });
  1123. } else {
  1124. $.toast(res.msg, 'text');
  1125. }
  1126. },
  1127. });
  1128. });
  1129. }
  1130. //广告信息
  1131. var adData = null; // 广告数据
  1132. var adLastTime = 0; // 广告时间
  1133. var intervalTime = 0; // 间隔时间
  1134. // let adType = 0;
  1135. console.log(
  1136. '🚀 ~ file: WXtrialInterface.html ~ line 973 ~ sourceType',
  1137. sourceType,
  1138. );
  1139. // 拉取广告数据
  1140. function getAD() {
  1141. return $.ajax({
  1142. url: baseUrl + '/api/public/v5/advertising/getAdInfoByAdPlace',
  1143. headers: {
  1144. Authorization: token,
  1145. },
  1146. data: JSON.stringify({
  1147. adPlace: adType,
  1148. os: 0,
  1149. }),
  1150. type: 'POST',
  1151. dataType: 'json',
  1152. contentType: 'application/json;charset=UTF-8',
  1153. }).then(function (res) {
  1154. if (res.status === 0) {
  1155. var list = res.data.filter(
  1156. (v) => v.adType === 1 && !!v.adVideoBase.videoUrl,
  1157. );
  1158. adData = list[Math.floor(Math.random() * list.length)];
  1159. console.log(
  1160. '🚀 ~ file: WXtrialInterface.html ~ line 990 ~ getAD ~ adData',
  1161. adData,
  1162. );
  1163. return adData;
  1164. } else {
  1165. return Promise.reject(new Error(res.msg));
  1166. }
  1167. });
  1168. }
  1169. // 播放广告
  1170. function playAD() {
  1171. var nowTime = Date.now();
  1172. if (
  1173. adData &&
  1174. // [1, 2].includes(sourceType) &&
  1175. $('.try-use-wrap').eq(0).is(':hidden') &&
  1176. nowTime > adLastTime + intervalTime
  1177. ) {
  1178. $('#source').attr('src', adData.adVideoBase.videoUrl);
  1179. $('.try-use-wrap').eq(0).show();
  1180. $('#source')[0].play();
  1181. videoTime = adData.forcedTime;
  1182. adData = null;
  1183. adLastTime = nowTime;
  1184. videoTimer = setInterval(() => {
  1185. if (videoTime > 0) {
  1186. videoTime--;
  1187. $('.time-node')
  1188. .eq(0)
  1189. .text(videoTime + 's');
  1190. } else {
  1191. clearInterval(videoTimer);
  1192. $('.time-node').eq(0).text('');
  1193. }
  1194. }, 1000);
  1195. if (intervalTime > 0) {
  1196. // 间隔广告拉取下一次广告数据
  1197. adType = 16;
  1198. getAD();
  1199. }
  1200. if (adType === 16 && sourceType == 1) {
  1201. // 间隔广告和试用才上报
  1202. report(0);
  1203. }
  1204. }
  1205. }
  1206. /**
  1207. * 初始化广告
  1208. * 因移动端video无法自动播放,play()方法不能异步调用。
  1209. * 解决方案,初始化时预先请求广告数据,在用户对云手机touchmove事件中去播放广告并请求下一次广告数据。
  1210. */
  1211. function initAD() {
  1212. console.log(
  1213. '🚀 ~ file: WXtrialInterface.html ~ line 1052 ~ initAD ~ sourceType',
  1214. sourceType,
  1215. );
  1216. (function () {
  1217. switch (sourceType) {
  1218. case 1: {
  1219. return getSetmealList().then(function (res) {
  1220. intervalTime =
  1221. res.intervalSwitch === 1
  1222. ? res.intervalAdvertDuration * 1000 * 60
  1223. : 0;
  1224. if (res.pushFlowAdvert === 1) {
  1225. adType = 15;
  1226. adTime = 0;
  1227. } else if (intervalTime > 0) {
  1228. adType = 16;
  1229. adTime = date.now();
  1230. }
  1231. });
  1232. }
  1233. case 2: {
  1234. return getConfigByPhoneType().then(function (res) {
  1235. if (res.isDisconnectionTime === 1) {
  1236. var time = res.disconnectionTime * 60 * 1000;
  1237. setTimeout(() => {
  1238. disconnectionFlag = true;
  1239. $('.buy-phone-wrap').eq(0).show();
  1240. }, time);
  1241. }
  1242. intervalTime =
  1243. res.isIntervalPlayAd === 1
  1244. ? res.intervalPlayAdTime * 1000 * 60
  1245. : 0;
  1246. if (res.isShowAd === 1) {
  1247. adType = 15;
  1248. adTime = 0;
  1249. } else if (intervalTime > 0) {
  1250. adType = 16;
  1251. adTime = date.now();
  1252. }
  1253. });
  1254. }
  1255. default: {
  1256. return Promise.reject();
  1257. }
  1258. }
  1259. })().then(function () {
  1260. console.log(adType);
  1261. this.$('#wine').on('touchstart', playAD);
  1262. getAD();
  1263. });
  1264. }
  1265. //广告信息
  1266. // function adInit() {
  1267. // sourceType = parameters['sourceType'];
  1268. // if (sourceType == 1) {
  1269. // getSetmealList().then((res) => {
  1270. // if (res.pushFlowAdvert === 1) {
  1271. // getAdList(15);
  1272. // }
  1273. // if (res.intervalSwitch === 1) {
  1274. // let time = res.intervalAdvertDuration * 60 * 1000;
  1275. // setInterval(() => {
  1276. // $('.try-use-wrap').eq(0).hide();
  1277. // getAdList(16);
  1278. // }, time);
  1279. // }
  1280. // })
  1281. // } else if (sourceType == 2) {
  1282. // getConfigByPhoneType().then((res) => {
  1283. // if (res.isDisconnectionTime === 1) {
  1284. // let time = res.disconnectionTime * 60 * 1000;
  1285. // setTimeout(() => {
  1286. // disconnectionFlag = true;
  1287. // $('.buy-phone-wrap').eq(0).show();
  1288. // }, time);
  1289. // }
  1290. // if (res.isShowAd === 1) {
  1291. // getAdList(15);
  1292. // }
  1293. // if (res.isIntervalPlayAd === 1) {
  1294. // let time = res.intervalPlayAdTime * 60 * 1000;
  1295. // setInterval(() => {
  1296. // $('.try-use-wrap').eq(0).hide();
  1297. // getAdList(16);
  1298. // }, time);
  1299. // }
  1300. // })
  1301. // }
  1302. // }
  1303. // 广告接口
  1304. // function getAdList(type) {
  1305. // adType = type;
  1306. // $.ajax({
  1307. // url: baseUrl + '/api/public/v5/advertising/getAdInfoByAdPlace',
  1308. // headers: {
  1309. // Authorization: form.token,
  1310. // },
  1311. // data: JSON.stringify({
  1312. // adPlace: type,
  1313. // os: 0,
  1314. // }),
  1315. // type: 'POST',
  1316. // dataType: 'json',
  1317. // contentType: 'application/json;charset=UTF-8',
  1318. // success: function (res) {
  1319. // if (res.status === 0) {
  1320. // let list = res.data;
  1321. // let indexs = Math.floor(Math.random() * list.length);
  1322. // videoTime = list[indexs].forcedTime;
  1323. // // $('#source').src = list[0].adVideoBase.videoUrl;
  1324. // $('#source').attr('src', list[indexs].adVideoBase.videoUrl); //更新url
  1325. // $('#source').attr('autoplay', 'true'); //直接播放
  1326. // videoTimer = setInterval(() => {
  1327. // if (videoTime > 0) {
  1328. // videoTime--;
  1329. // $('.time-node')
  1330. // .eq(0)
  1331. // .text(videoTime + 's');
  1332. // } else {
  1333. // clearInterval(videoTimer);
  1334. // $('.time-node').eq(0).text('');
  1335. // }
  1336. // }, 1000);
  1337. // if (adType === 16 && sourceType == 1) {
  1338. // // 间隔广告和试用才上报
  1339. // report(0);
  1340. // }
  1341. // $('.try-use-wrap').eq(0).show();
  1342. // } else {
  1343. // $.toast(res.msg, 'text');
  1344. // }
  1345. // },
  1346. // });
  1347. // }
  1348. //间隔广告上报
  1349. function report(type) {
  1350. $.ajax({
  1351. url: baseUrl + '/api/resources/v1/trial/report',
  1352. headers: {
  1353. Authorization: token,
  1354. },
  1355. data: JSON.stringify({
  1356. userCardId: userCardId,
  1357. reportType: type,
  1358. }),
  1359. type: 'POST',
  1360. dataType: 'json',
  1361. contentType: 'application/json;charset=UTF-8',
  1362. success: function (res) {},
  1363. });
  1364. }
  1365. // 观看广告次数上报
  1366. function reportFrequency() {
  1367. $.ajax({
  1368. url: baseUrl + '/api/resoures/v1/trial/reportFrequency/' + form.userCardId,
  1369. headers: {
  1370. Authorization: form.token
  1371. },
  1372. type: 'post',
  1373. contentType: 'application/json',
  1374. dataType: 'json',
  1375. success: function (res) {},
  1376. });
  1377. }
  1378. //关闭广告
  1379. $('.time-close-wrap')[0].addEventListener('click', () => {
  1380. if(videoTime == 0) {
  1381. reportFrequency()
  1382. }
  1383. $('.buy-phone-wrap').eq(0).show();
  1384. });
  1385. // 点击取消
  1386. $('.cannel-btn')[0].addEventListener('click', () => {
  1387. $('.buy-phone-wrap').eq(0).hide();
  1388. if (disconnectionFlag || getDate) {
  1389. //设置了断线时间,取消直接退出
  1390. systemBuriedPoint('激活码-断线-取消');
  1391. quit();
  1392. return;
  1393. }
  1394. let pointName = '';
  1395. if (sourceType == 1) {
  1396. pointName =
  1397. videoTime == 0 ? '免费试用-关闭-取消' : '免费试用-强制关闭-取消';
  1398. } else {
  1399. pointName =
  1400. videoTime == 0 ? '激活码-关闭-取消' : '激活码-强制关闭-取消';
  1401. }
  1402. systemBuriedPoint(pointName);
  1403. if (videoTime == 0) {
  1404. if (adType === 16 && sourceType == 1) {
  1405. report(1);
  1406. }
  1407. $('.try-use-wrap').eq(0).hide();
  1408. $('#source')[0].pause();
  1409. return;
  1410. }
  1411. $('.look-wrap').eq(0).show();
  1412. });
  1413. // 点击去购买
  1414. $('.go-bug')[0].addEventListener('click', () => {
  1415. let pointName = '';
  1416. if (disconnectionFlag) {
  1417. pointName = '激活码-断线-去购买';
  1418. } else if (sourceType == 1) {
  1419. pointName =
  1420. videoTime == 0
  1421. ? '免费试用-关闭-去购买'
  1422. : '免费试用-强制关闭-去购买';
  1423. } else {
  1424. pointName =
  1425. videoTime == 0 ? '激活码-关闭-去购买' : '激活码-强制关闭-去购买';
  1426. }
  1427. systemBuriedPoint(pointName);
  1428. if (getDate) {
  1429. wx.miniProgram.navigateTo({
  1430. url: '/packageA/order/buy/index?buyType=试用界面购买',
  1431. });
  1432. } else {
  1433. // 过期续费按钮进入
  1434. wx.miniProgram.navigateTo({
  1435. url:
  1436. `/packageA/order/renew/index?buyType=${
  1437. sourceType == 1
  1438. ? '试用弹窗购买按钮进入-普通试用'
  1439. : '试用弹窗购买按钮进入-激活码试用'
  1440. }&record=` + userCardId,
  1441. });
  1442. }
  1443. });
  1444. // 放弃
  1445. $('.cannel-ad-btn')[0].addEventListener('click', () => {
  1446. if (sourceType == 1) {
  1447. systemBuriedPoint('免费试用-强制关闭-放弃');
  1448. } else {
  1449. systemBuriedPoint('激活码-强制关闭-放弃');
  1450. }
  1451. quit();
  1452. });
  1453. // 继续观看
  1454. $('.looking')[0].addEventListener('click', () => {
  1455. $('.look-wrap').eq(0).hide();
  1456. if (sourceType == 1) {
  1457. systemBuriedPoint('免费试用-强制关闭-继续观看');
  1458. } else {
  1459. systemBuriedPoint('激活码-强制关闭-继续观看');
  1460. }
  1461. });
  1462. // 埋点
  1463. function systemBuriedPoint(pointName) {
  1464. $.ajax({
  1465. url: baseUrl + '/api/public/v1/systemBuriedPoint/stat',
  1466. headers: {
  1467. Authorization: token,
  1468. },
  1469. type: 'post',
  1470. data: JSON.stringify({
  1471. pointName: pointName,
  1472. }),
  1473. contentType: 'application/json',
  1474. dataType: 'json',
  1475. success: function (res) {},
  1476. });
  1477. }
  1478. function quit() {
  1479. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  1480. tt.miniProgram.switchTab({
  1481. url: '/pages/home/home',
  1482. });
  1483. } else if (window.__wxjs_environment === 'miniprogram') {
  1484. wx.miniProgram.switchTab({
  1485. url: '/pages/home/home',
  1486. });
  1487. } else {
  1488. uni.webView.navigateBack({
  1489. delta: 1
  1490. });
  1491. }
  1492. }
  1493. window.onbeforeunload = function () {
  1494. ws.close();
  1495. wsss.close();
  1496. };
  1497. </script>
  1498. <script type="text/javascript" src="WXdraw.js"></script>
  1499. <script type="text/javascript" src="aac.js"></script>
  1500. </body>
  1501. </html>