WXtrialInterface.html 45 KB

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