WXtrialInterface.html 45 KB

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