WXtrialInterface.html 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182
  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. <style>
  37. .try-use-wrap,
  38. .buy-phone-wrap,
  39. .look-wrap {
  40. width: 100%;
  41. height: 100%;
  42. position: fixed;
  43. top: 0;
  44. left: 0;
  45. z-index: 9999;
  46. background: rgba(0, 0, 0, 0.5);
  47. display: none;
  48. }
  49. .try-use-container {
  50. width: 80%;
  51. height: 409px;
  52. position: absolute;
  53. top: 50%;
  54. left: 50%;
  55. transform: translate(-50%, -50%);
  56. background-color: #FFFFFF;
  57. border-radius: 0.66em;
  58. }
  59. .time-close-wrap {
  60. width: 5.46em;
  61. height: 2em;
  62. line-height: 2em;
  63. text-align: center;
  64. position: absolute;
  65. top: 0.24em;
  66. right: 0.3em;
  67. background: rgba(0, 0, 0, 0.49);
  68. border-radius: 1.26em;
  69. font-size: 12px;
  70. color: #FFFFFF;
  71. }
  72. .bug-wrap {
  73. width: 90%;
  74. height: 115px;
  75. background: #FFFFFF;
  76. border-radius: 10px;
  77. position: absolute;
  78. top: 50%;
  79. left: 50%;
  80. transform: translate(-50%, -50%);
  81. }
  82. .bug-title {
  83. text-align: center;
  84. margin: 25px 0;
  85. font-size: 18px;
  86. font-weight: 600;
  87. color: #333333;
  88. }
  89. .btn-list {
  90. width: 100%;
  91. height: 44px;
  92. line-height: 44px;
  93. border-top: 1px solid rgba(238, 238, 238, 1);
  94. position: absolute;
  95. bottom: 0;
  96. left: 0;
  97. display: flex;
  98. align-items: center;
  99. }
  100. .btn {
  101. flex: 1;
  102. text-align: center;
  103. }
  104. .cannel-btn {
  105. font-size: 18px;
  106. color: #666666;
  107. }
  108. .go-bug {
  109. font-size: 18px;
  110. color: #3B7FFF;
  111. border-left: 1px solid rgba(238, 238, 238, 1);
  112. }
  113. </style>
  114. </head>
  115. <body class="scroll h-player" style="overscroll-behavior: contain;">
  116. <div class="container" id="player">
  117. <div class="muted" id="btnMuted">
  118. <div class="control-right-img" data-id="1">
  119. <img src="../static/img/xuanfu_icon.png">
  120. </div>
  121. </div>
  122. <div id="wine">
  123. <video id="playerVideo" muted="muted" x5-video-orientation="landscape" playsinline="true" autoplay="true"
  124. webkit-playsinline="true" x5-playsinline="true" x5-video-player-type="h5" x5-video-player-fullscreen="false"
  125. style="pointer-events: none;object-fit: fill;width: 100%;height:100%"></video>
  126. <div id="box"></div>
  127. <audio preload="auto" autoplay controls poster="images/loader-thumb.jpg" id="audioPlayer"
  128. style="position: absolute;top: 0;width: 0;height: 0;"></audio>
  129. </div>
  130. <div class="leftmains">
  131. <div class="PictureQualityMain">
  132. <div class="PictureQuality" data-id="4">高清</div>
  133. <div class="PictureQuality avit" data-id="3">标清</div>
  134. <div class="PictureQuality" data-id="2">极速</div>
  135. </div>
  136. <div class="operation">
  137. <div class="upload" id="showsuss" data-text="uploads">
  138. <img src="../static/img/wx/shangchuan_icon.png">
  139. <div>上传</div>
  140. </div>
  141. <div class="upload" onclick="showShearPlate()" data-text="Shearplate">
  142. <img src="../static/img/wx/jianqieban_icon.png">
  143. <div>剪贴板</div>
  144. </div>
  145. <div class="upload" id="upload" data-text="Signout">
  146. <img src="../static/img/wx/tuichu_icon.png">
  147. <div>退出</div>
  148. </div>
  149. </div>
  150. </div>
  151. <div class="bottommains">
  152. <div class="botmat1">
  153. <div class="botmat1img" data-text="gengduo">
  154. <img src="../static/img/wx/gengduo_icon.png">
  155. </div>
  156. </div>
  157. <div class="botmat1">
  158. <div class="botmat1img" data-text="home">
  159. <img src="../static/img/wx/home_icon.png">
  160. </div>
  161. </div>
  162. <div class="botmat1">
  163. <div class="botmat1img" data-text="return">
  164. <img src="../static/img/wx/fanhui_icon.png">
  165. </div>
  166. </div>
  167. </div>
  168. <img class="loading loading_sceen_pic" />
  169. </div>
  170. <div class="mask">
  171. <div class="box-shear-plate"></div>
  172. <img class="close" onclick="handleClose()" src="img/guanbi_icon@2x.png" alt="">
  173. </div>
  174. <div class="weui-mask_transparent"></div>
  175. <div class="weui-toast weui_loading_toast weui-toast--visible">
  176. <div class="weui_loading"><i class="weui-loading weui-icon_toast"></i></div>
  177. <p class="weui-toast_content">数据加载中</p>
  178. </div>
  179. <div class="try-use-wrap">
  180. <div class="try-use-container">
  181. <video width="100%" height="100%" id="source" muted autoplay="autoplay" loop="loop">
  182. 您的浏览器不支持 video 标签。
  183. </video>
  184. <div class="time-close-wrap"><span class="time-node"></span> 关闭</div>
  185. </div>
  186. </div>
  187. <div class="buy-phone-wrap">
  188. <div class="bug-wrap">
  189. <div class="bug-title">获得极致体验服务请购买云手机</div>
  190. <div class="btn-list">
  191. <div class="btn cannel-btn">取消</div>
  192. <div class="btn go-bug">去购买</div>
  193. </div>
  194. </div>
  195. </div>
  196. <div class="look-wrap">
  197. <div class="bug-wrap">
  198. <div class="bug-title">关闭广告会退出云手机是否继续观看</div>
  199. <div class="btn-list">
  200. <div class="btn cannel-btn cannel-ad-btn">放弃</div>
  201. <div class="btn go-bug looking">继续观看</div>
  202. </div>
  203. </div>
  204. </div>
  205. <body oncontextmenu="Back()">
  206. </body>
  207. <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
  208. <script src="https://lf1-cdn-tos.bytegoofy.com/goofy/developer/jssdk/jssdk-1.0.3.js"></script>
  209. <script type="text/javascript" src="../static/js/jquery-1.11.0.min.js"></script>
  210. <script type="text/javascript" src="helper.js"></script>
  211. <script type="text/javascript" src="pcm-player.js"></script>
  212. <script type="text/javascript" src="https://cdn.bootcss.com/vConsole/3.2.0/vconsole.min.js"></script>
  213. <script src="https://cdn.bootcss.com/jquery-weui/1.2.1/js/jquery-weui.min.js"></script>
  214. <script type="text/javascript" src="WXdraw.js"></script>
  215. <script type="text/javascript" src="jmuxer.js"></script>
  216. <script type="text/javascript" src="spsParser.js"></script>
  217. <script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js"></script>
  218. <script>
  219. var url = window.location.href;
  220. url = url.split('/');
  221. var baseUrl = url[0] + '//' + url[2];
  222. var parameters = GetRequest();
  223. var form = {};
  224. form.token = parameters['token'];
  225. form.userCardId = parameters['userCardId'];
  226. var videoTimer = null, videoTime = 0, adType = 0, sourceType = 0, disconnectionFlag = false, getDate = false;
  227. if (parameters['mealType'] === 'VIP') {
  228. $(".loading_sceen_pic").attr('src', '../static/img/home_bg_VIP.png');
  229. } else if (parameters['mealType'] === 'SVIP') {
  230. $(".loading_sceen_pic").attr('src', '../static/img/home_bg_SVIP.png');
  231. } else if (parameters['mealType'] === 'STAR') {
  232. $(".loading_sceen_pic").attr('src', '../static/img/home_bg_STAR.png');
  233. } else if (parameters['mealType'] === 'STARPRO') {
  234. $(".loading_sceen_pic").attr('src', '../static/img/home_bg_PRO.png');
  235. }
  236. adInit();
  237. var isAudioPlay = false;
  238. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  239. var video = document.getElementById("playerVideo");
  240. video.play();
  241. setTimeout(() => { // 抖音环境需要设置延时,不然会有video默认图显示
  242. $.alert({
  243. title: '提示',
  244. text: '开始使用云手机',
  245. onOK: function () {
  246. setTimeout(() => {
  247. isAudioPlay = true;
  248. }, 1000);
  249. }
  250. });
  251. }, 1000)
  252. } else {
  253. $.alert({
  254. title: '提示',
  255. text: '开始使用云手机',
  256. onOK: function () {
  257. var video = document.getElementById("playerVideo");
  258. video.play();
  259. isAudioPlay = true;
  260. }
  261. });
  262. }
  263. //云机倒计时
  264. let validTime = parameters['validTime'] || 10000;
  265. if (validTime > 32000) {
  266. validTime = 32000
  267. }
  268. let detailTime = validTime * 60 * 1000;
  269. setTimeout(() => {
  270. $('.bug-title').eq(0).text('尊敬的用户您的云手机试用时间已到期');
  271. getDate = true;
  272. $('.buy-phone-wrap').eq(0).show();
  273. }, detailTime)
  274. var topwinHeight = window.screen.height - window.innerHeight + 30; //计算title top 头部
  275. $('#wine').css({
  276. "width": window.screen.width,
  277. "height": window.screen.height - topwinHeight - 20,
  278. "position": "absolute"
  279. });
  280. $('.loading').css({
  281. "width": window.screen.width,
  282. "height": window.screen.height - topwinHeight - 20
  283. });
  284. var winese = document.createElement("wine");
  285. wine.style.top = "-" + winese + 'px';
  286. var isVisuable = true;
  287. var isFeed = true;
  288. var isFinish = false;
  289. var myVideo = document.getElementById("playerVideo");
  290. Module = {};
  291. Module.onRuntimeInitialized = function () {
  292. isFinish = true;
  293. }
  294. var isWSS = true;
  295. var ip = parameters["ip"];
  296. var cardToken = parameters["cardToken"];
  297. cardToken = cardToken && decodeURIComponent(cardToken);
  298. var appletPushAddress = parameters["appletPushAddress"];
  299. var socketURL = isWSS ? "wss://" + appletPushAddress + "?cardIp=" + ip + "&token=" + cardToken + "&type=business" : "ws://" + appletPushAddress + "?cardIp=" + ip + "&token=" + cardToken;
  300. var jmuxer = new JMuxer({
  301. node: 'playerVideo',
  302. flushingTime: 33,
  303. fps: 30,
  304. mode: 'video',
  305. debug: false
  306. });
  307. window.onload = function () {
  308. var myPlay = document.getElementById("wine");
  309. myPlay.onkeydown = function (event) {
  310. ExexuteKeyDown(e.keyCode);
  311. }
  312. }
  313. var ws, errorTime = 0;
  314. doConnect();
  315. // 节流
  316. // 设置一个标志
  317. function throttle(fn, delay) {
  318. let flag = true;
  319. errorTime += delay;
  320. return () => {
  321. if (!flag) return;
  322. flag = false;
  323. timer = setTimeout(() => {
  324. fn();
  325. flag = true;
  326. }, delay);
  327. };
  328. }
  329. var intervaler;
  330. function doConnect() {
  331. ws = new WebSocket(socketURL);
  332. ws.binaryType = 'arraybuffer';
  333. intervaler = setInterval(() => {
  334. if (ws.readyState === 1) {
  335. ws.send("ping");
  336. } else {
  337. clearInterval(intervaler);
  338. $.toast("画面异常,请重新进入", "text");
  339. quit();
  340. }
  341. }, 3000);
  342. ws.addEventListener('open', function (event) {
  343. // sn只要长度满足17位随机数,不需要从后台获取
  344. var verifyBuffer = VerifyCode('RK3923C1201900139', cardToken);
  345. console.log("鉴权报文:" + PrintArry(verifyBuffer));
  346. ws.send(verifyBuffer);
  347. });
  348. ws.addEventListener('error', function (event) {
  349. ws.close();
  350. clearInterval(intervaler);
  351. throttle(doConnect, 100);
  352. if (errorTime > 1000) {
  353. $.toast("画面异常,请重新进入", "text");
  354. wsss.close();
  355. quit();
  356. }
  357. });
  358. ws.addEventListener('message', function (event) {
  359. var data = ParseProto(event.data); //JAVA服务器转发
  360. if (isAudioPlay) {
  361. $('.weui-mask_transparent').hide();
  362. $('.weui-toast').hide();
  363. $('.loading').hide();
  364. }
  365. var input = new Uint8Array(event.data);
  366. if (data.audio != null && isAudioPlay) { //喂音频
  367. if (input[0] == 0xff) {
  368. if (isFinish) {
  369. decodeAAC(input);
  370. }
  371. }
  372. }
  373. if (data.frameType != undefined && data.frameType != 1 && data.frameType != 6) {
  374. if (data.frameType == 7) {
  375. let info = spsParser(data.video);
  376. if (info.width != myVideo.videoWidth && info.height != myVideo.videoHeight) {
  377. if (myVideo.videoWidth == 0) {
  378. console.log("SPS计算得到宽 %d, 高 %d, 控件宽 %d, %d", info.width, info.height, myVideo.videoWidth, myVideo.videoHeight);
  379. }
  380. }
  381. }
  382. }
  383. if (data.video != null) { //喂视频
  384. if (data.frameType == 0x05 && isVisuable) {
  385. isFeed = true;
  386. }
  387. if (data.frameType == 7 || data.frameType == 8) {
  388. isFeed = true;
  389. isAudioPlay = true;
  390. }
  391. if (isFeed) {
  392. jmuxer.feed(data);
  393. }
  394. }
  395. });
  396. }
  397. var hidden, visibilityChange;
  398. if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support
  399. hidden = "hidden";
  400. visibilityChange = "visibilitychange";
  401. } else if (typeof document.msHidden !== "undefined") {
  402. hidden = "msHidden";
  403. visibilityChange = "msvisibilitychange";
  404. } else if (typeof document.webkitHidden !== "undefined") {
  405. hidden = "webkitHidden";
  406. visibilityChange = "webkitvisibilitychange";
  407. }
  408. // 处理页面可见属性的改变
  409. document.addEventListener("visibilitychange", function () {
  410. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  411. visibilitychange();
  412. } else if (window.__wxjs_environment === 'miniprogram') {
  413. visibilitychange();
  414. } else {
  415. if (document[hidden]) {
  416. ws.close();
  417. wsss.close();
  418. uni.webView.navigateTo({
  419. url: '/pages/index/index'
  420. });
  421. }
  422. }
  423. }, false);
  424. function visibilitychange() {
  425. if (document.visibilityState == "visible") {
  426. var buffer = RequestIFrame();
  427. ws.send(buffer);
  428. isVisuable = true;
  429. } else {
  430. isVisuable = false;
  431. isFeed = false;
  432. myVideo.pause();
  433. }
  434. }
  435. myVideo.addEventListener('pause', function () {
  436. isFeed = false;
  437. });
  438. var decodeCount = 1;
  439. var player = new PCMPlayer({
  440. encoding: '16bitInt',
  441. channels: 2,
  442. sampleRate: 44100,
  443. flushingTime: 22,
  444. debug: false
  445. });
  446. function handleClose() {
  447. $('.mask').hide();
  448. }
  449. function decodeAAC(data) {
  450. var retPtr = Module._malloc(4 * 5 * 1024); // 接收的数据
  451. var inputPtr = Module._malloc(4 * data.length); // 输入数据
  452. for (var i = 0; i < data.length; i++) {
  453. Module.HEAPU8[(inputPtr) + i] = data[i]; //转换为堆数据
  454. }
  455. var pcmLen = Module._feedData(retPtr, inputPtr, data.length);
  456. if (pcmLen >= 0) {
  457. var pcmData = new Uint8Array(pcmLen);
  458. for (var i = 0; i < pcmLen; i++) {
  459. pcmData[i] = Module.HEAPU8[(retPtr) + i]
  460. }
  461. player.feed(pcmData);
  462. }
  463. decodeCount++;
  464. Module._free(inputPtr);
  465. Module._free(retPtr);
  466. }
  467. //解协议
  468. function ParseProto(data) {
  469. var input = new Uint8Array(data),
  470. duration,
  471. video,
  472. frameType,
  473. audio;
  474. if (input[0] == 0 && input[1] == 0 && input[2] == 0 && input[3] == 1) {
  475. video = input;
  476. duration = 24;
  477. var nalType = input[4] & 0x1f;
  478. frameType = nalType;
  479. if (!isFeed) {
  480. if (nalType == 0x05 && isVisuable) {
  481. isFeed = true;
  482. }
  483. }
  484. } else if (input[0] == 0xff) {
  485. audio = input;
  486. duration = 24;
  487. } else if (input[0] == 0x68) {
  488. if (input[23] == 0x5c) {
  489. console.log("收到消息:" + PrintArry(input));
  490. if (CheckVerifyCode(input)) {
  491. ws.send(ConfigChannel('RK3923C1201900139'));
  492. var checkBuffer = GetScreenState();
  493. ws.send(checkBuffer);
  494. }
  495. else {
  496. $.toast("画面异常,请重新进入", "text");
  497. clearInterval(intervaler);
  498. quit();
  499. ws.close();
  500. wsss.close();
  501. }
  502. }
  503. if (input[23] == 0x05) { //横竖屏标识
  504. var state = CheckScreenDirection(input.slice(24, 24 + 8));
  505. if (state == 1) {
  506. console.log("安卓卡此时竖屏");
  507. //竖屏处理
  508. resolving = 1;
  509. } else {
  510. console.log("安卓卡此时横屏");
  511. //横屏处理
  512. resolving = 0;
  513. }
  514. }
  515. if (input[23] == 0x0B)//多端登录处理, 数据从索引24开始取, input 是接收到的原始数据
  516. {
  517. var jsonobj = checkMultiLoginInfo(input);
  518. }
  519. }
  520. return {
  521. audio: audio,
  522. video: video,
  523. duration: duration,
  524. frameType: frameType
  525. };
  526. }
  527. function GetRequest() {
  528. var url = location.search; // 获取url中"?"符后的字串
  529. var obj = new Object();
  530. if (url.indexOf("?") != -1) {
  531. var str = url.substr(1);
  532. strs = str.split("&");
  533. for (var i = 0; i < strs.length; i++) {
  534. obj[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
  535. }
  536. }
  537. return obj;
  538. }
  539. function Back() {
  540. ExexuteKeyDown(4);
  541. window.event.returnValue = false;
  542. return false;
  543. }
  544. var form = {};
  545. form.token = parameters['token'];
  546. form.userCardId = parameters['userCardId'];
  547. function array_unique(arr) {
  548. return arr.filter(function (e, i) {
  549. return arr.indexOf(e) === i;
  550. })
  551. }
  552. var cutList = [];
  553. let timer, isFlag = true;
  554. function showShearPlate() {
  555. if (!isControl) {
  556. return
  557. }
  558. stopManyClick(() => {
  559. $('.box-shear-plate').empty();
  560. $.ajax({
  561. url: baseUrl + "/api/public/v5/shear/content",
  562. headers: {
  563. 'Authorization': form.token
  564. },
  565. type: 'get',
  566. dataType: 'json',
  567. success: function (res) {
  568. if (res.status === 0) {
  569. if (res.data.length) {
  570. cutList = array_unique(res.data)
  571. var str = '<div class="title">剪贴板<div onclick="handleClear()" class="btn-clear">清空</div></div><div class="slide-wrapper-content">'
  572. cutList.forEach(function (item) {
  573. str += "<div class='slide-wrapper'><div class='slide-scroll animate-slide-start'><div class='slide-content'><div onclick='handleCopy(\"" + item.content + "\")'>" + item.content + "</div></div><div class='slide-content-button'><button onclick='handleDelete(" + item.id + ")'>删除</button></div></div></div>"
  574. })
  575. str += '</div>'
  576. $('.box-shear-plate').append(str);
  577. } else {
  578. $('.box-shear-plate').append('<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>')
  579. }
  580. $('.mask').show();
  581. initSlider();
  582. } else {
  583. $('.box-shear-plate').append('<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>')
  584. $('.mask').show();
  585. }
  586. }
  587. })
  588. })
  589. }
  590. //防止提示一秒内重复显示
  591. function stopManyClick(fn) {
  592. if (isFlag) {
  593. fn();
  594. }
  595. isFlag = false;
  596. if (timer) { clearTimeout(timer); }
  597. timer = setTimeout(() => { isFlag = true }, 1500);
  598. }
  599. // 清空剪贴板
  600. function handleClear() {
  601. var ids = '';
  602. cutList.forEach(function (item) {
  603. ids += 'ids=' + item.id + '&'
  604. });
  605. ids = ids.substring(0, ids.lastIndexOf('&'));
  606. $.confirm("确定清空剪贴板?", function () {
  607. $.ajax({
  608. url: baseUrl + "/api/public/v5/shear/content?" + ids,
  609. headers: {
  610. 'Authorization': form.token
  611. },
  612. type: 'DELETE',
  613. dataType: 'json',
  614. success: function (res) {
  615. if (res.status === 0) {
  616. showShearPlate();
  617. } else {
  618. $.toast(res.msg, "text");
  619. }
  620. }
  621. })
  622. });
  623. }
  624. function handleCopy(content) {
  625. var cutting = {
  626. "type": "cutting",
  627. "data": {
  628. "str": content
  629. }
  630. };
  631. wsss.send(JSON.stringify(cutting));
  632. }
  633. // 删除剪贴板
  634. function handleDelete(id) {
  635. $.ajax({
  636. url: baseUrl + "/api/public/v5/shear/content?ids=" + id,
  637. headers: {
  638. 'Authorization': form.token
  639. },
  640. type: 'DELETE',
  641. dataType: 'json',
  642. success: function (res) {
  643. if (res.status === 0) {
  644. showShearPlate();
  645. } else {
  646. $.toast(res.msg, "text");
  647. }
  648. }
  649. })
  650. }
  651. function initSlider() {
  652. //手指滑动多少距离就认为是滑成功
  653. //这个值不能太大,否则影响斜着滑动时,垂直滑动的流畅性,也不能太小,太灵敏也不好
  654. var diffXDistance = 50;
  655. //当前滑动的对象
  656. var currentObject;
  657. //上一次滑动的对象
  658. var lastObject;
  659. //是否可以左右滑动,在上下滑的时候禁止左右滑
  660. var canSlide = true;
  661. //用于记录按下的点
  662. var startPoint;
  663. $(".slide-content").css({
  664. width: $(".slide-wrapper").width()
  665. });
  666. document.body.removeEventListener('touchmove', function (e) {
  667. e.preventDefault()
  668. }, {
  669. passive: false
  670. })
  671. $(".slide-scroll").css({
  672. width: $(".slide-wrapper").width() + $(".slide-content-button").width()
  673. }).on('touchstart', function (e) {
  674. currentObject = this;
  675. startPoint = {
  676. x: e.originalEvent.changedTouches[0].pageX,
  677. y: e.originalEvent.changedTouches[0].pageY
  678. };
  679. }).on('touchmove', function (e) {
  680. //如果是左右滑动,就禁止上下的滑动
  681. //如果是上下的滑动,就禁止左右滑动
  682. if (Math.abs(e.originalEvent.changedTouches[0].pageX - startPoint.x) > Math.abs(e.originalEvent.changedTouches[0].pageY - startPoint.y)) {
  683. event.preventDefault();
  684. } else {
  685. canSlide = false;
  686. }
  687. }).on('touchend', function (e) {
  688. //如果是上下滑动,这里就直接返回了
  689. if (!canSlide) {
  690. canSlide = true;
  691. return true;
  692. }
  693. //点击除当前左滑对象之外的任意其他位置
  694. if (lastObject && currentObject != lastObject) {
  695. //右滑→
  696. $(lastObject).removeClass("animate-slide");
  697. //清空上一个左滑的对象
  698. lastObject = undefined;
  699. }
  700. var diffX = e.originalEvent.changedTouches[0].pageX - startPoint.x;
  701. if (diffX < -diffXDistance) {
  702. //左滑←
  703. $(currentObject).addClass("animate-slide");
  704. if (lastObject && lastObject != currentObject) {
  705. //右滑→
  706. $(lastObject).removeClass("animate-slide");
  707. }
  708. //记录上一个左滑的对象
  709. lastObject = currentObject;
  710. } else if (diffX >= diffXDistance) {
  711. if (currentObject == lastObject) {
  712. //右滑→
  713. $(currentObject).removeClass("animate-slide");
  714. //清空上一个左滑的对象
  715. lastObject = undefined;
  716. }
  717. }
  718. });
  719. }
  720. var btnMuted = document.querySelector("#btnMuted");
  721. btnMuted && (function () {
  722. var setHistory = function (left, top) {
  723. try {
  724. localStorage.setItem("muted-btn-loc", JSON.stringify({
  725. left: left,
  726. top: top
  727. }));
  728. } catch (ex) { }
  729. };
  730. var getHistory = function () {
  731. try {
  732. var value = localStorage.getItem("muted-btn-loc");
  733. if (!value) return null;
  734. value = JSON.parse(value);
  735. if (!value) return null;
  736. return value;
  737. } catch (ex) {
  738. return null
  739. }
  740. };
  741. var fixLoc = function (loc) {
  742. var rect = btnMuted.getBoundingClientRect();
  743. rect = {
  744. top: rect.top,
  745. left: rect.left,
  746. width: rect.width,
  747. height: rect.height
  748. }; //部分低版本浏览器,该属性为只读
  749. if (loc) {
  750. rect.left = loc.left;
  751. rect.top = loc.top;
  752. }
  753. var minX = 0;
  754. var minY = 0;
  755. var docRect = document.documentElement.getBoundingClientRect();
  756. var maxY = docRect.height - rect.height;
  757. var maxX = docRect.width - rect.width;
  758. var left = rect.left;
  759. var top = rect.top;
  760. left = Math.min(left, maxX);
  761. left = Math.max(left, minX);
  762. top = Math.min(top, maxY);
  763. top = Math.max(top, minY);
  764. if (loc || top !== rect.top || left !== rect.left) {
  765. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  766. }
  767. }
  768. window.addEventListener("resize", function () {
  769. fixLoc();
  770. });
  771. var touchPoint = {
  772. pageY: 0,
  773. pageX: 0
  774. };
  775. var currentLoc = {
  776. top: 0,
  777. left: 0,
  778. curTop: 0,
  779. curLeft: 0
  780. };
  781. var toMove = false;
  782. var touchmove = function (e) {
  783. e.preventDefault();
  784. var point = e.changedTouches[0];
  785. var top = -touchPoint.pageY + point.pageY;
  786. var left = -touchPoint.pageX + point.pageX;
  787. if (toMove) {
  788. top += currentLoc.top;
  789. left += currentLoc.left;
  790. currentLoc.curLeft = left;
  791. currentLoc.curTop = top;
  792. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  793. } else {
  794. if (Math.abs(top) >= 5 || Math.abs(left) >= 5) {
  795. toMove = true;
  796. }
  797. }
  798. };
  799. var touchend = function () {
  800. window.removeEventListener("touchmove", touchmove, {
  801. passive: false
  802. });
  803. window.removeEventListener("touchend", touchend, {
  804. passive: false
  805. });
  806. if (toMove) {
  807. setHistory(currentLoc.curLeft, currentLoc.curTop);
  808. fixLoc();
  809. } else {
  810. //按点击处理
  811. var set = $('.control-right-img').attr("data-id")
  812. if (set == '1') {
  813. $('.control-right-img').attr({
  814. "data-id": "2"
  815. })
  816. $(".leftmains").css({
  817. "right": "0rem"
  818. })
  819. } else {
  820. $('.control-right-img').attr({
  821. "data-id": "1"
  822. })
  823. $(".leftmains").css({
  824. "right": "-4rem"
  825. })
  826. }
  827. }
  828. }
  829. btnMuted.addEventListener("touchstart", function (e) {
  830. e.preventDefault();
  831. toMove = false;
  832. var point = e.changedTouches[0];
  833. touchPoint.pageX = point.pageX;
  834. touchPoint.pageY = point.pageY;
  835. var rect = e.target.getBoundingClientRect();
  836. currentLoc.top = rect.top;
  837. currentLoc.left = rect.left;
  838. window.addEventListener("touchmove", touchmove, {
  839. passive: false
  840. });
  841. window.addEventListener("touchend", touchend, {
  842. passive: false
  843. });
  844. }, {
  845. passive: false
  846. });
  847. var history = getHistory();
  848. if (history) {
  849. fixLoc(history);
  850. }
  851. btnMuted.classList.remove("hide");
  852. })();
  853. $("#upload").on("click", function () {
  854. clearInterval(intervaler);
  855. quit();
  856. ws.close();
  857. wsss.close();
  858. })
  859. function selectText(x) {
  860. if (document.selection) {
  861. var range = document.body.createTextRange();
  862. range.moveToElementText(x);
  863. range.select();
  864. } else if (window.getSelection) {
  865. var selection = window.getSelection();
  866. var range = document.createRange();
  867. selection.removeAllRanges();
  868. range.selectNodeContents(x);
  869. selection.addRange(range);
  870. }
  871. }
  872. // 激活码广告相关配置
  873. function getConfigByPhoneType() {
  874. return new Promise((resolve, reject) => {
  875. $.ajax({
  876. url: baseUrl + "/api/pay/v5/trialCodeConfig/getConfigByPhoneType",
  877. headers: {
  878. 'Authorization': form.token
  879. },
  880. data: {
  881. userCardId: form.userCardId,
  882. phoneType: form.mealType
  883. },
  884. type: 'get',
  885. dataType: 'json',
  886. success: function (res) {
  887. console.log(res)
  888. let obj = res.data;
  889. if (res.status === 0) {
  890. resolve(obj)
  891. } else {
  892. $.toast(res.msg, "text");
  893. }
  894. }
  895. })
  896. })
  897. }
  898. //列表
  899. function getSetmealList() {
  900. return new Promise((resolve, reject) => {
  901. $.ajax({
  902. url: baseUrl + "/api/resources/v4/freetrial/setmeal/list",
  903. headers: {
  904. 'Authorization': form.token
  905. },
  906. type: 'get',
  907. dataType: 'json',
  908. success: function (res) {
  909. if (res.status === 0) {
  910. let list = res.data;
  911. list.map((item) => {
  912. if (item.phoneType === parameters['mealType']) {
  913. resolve(item)
  914. }
  915. })
  916. } else {
  917. $.toast(res.msg, "text");
  918. }
  919. }
  920. })
  921. })
  922. }
  923. //广告信息
  924. function adInit() {
  925. sourceType = parameters['sourceType'];
  926. if (sourceType == 1) {
  927. getSetmealList().then((res) => {
  928. if (res.pushFlowAdvert === 1) {
  929. getAdList(15);
  930. }
  931. if (res.intervalSwitch === 1) {
  932. let time = res.intervalAdvertDuration * 60 * 1000;
  933. setInterval(() => {
  934. $('.try-use-wrap').eq(0).hide();
  935. getAdList(16);
  936. }, time);
  937. }
  938. })
  939. } else if (sourceType == 2) {
  940. getConfigByPhoneType().then((res) => {
  941. if (res.isDisconnectionTime === 1) {
  942. let time = res.disconnectionTime * 60 * 1000;
  943. setTimeout(() => {
  944. disconnectionFlag = true;
  945. $('.buy-phone-wrap').eq(0).show();
  946. }, time);
  947. }
  948. if (res.isShowAd === 1) {
  949. getAdList(15);
  950. }
  951. if (res.isIntervalPlayAd === 1) {
  952. let time = res.intervalPlayAdTime * 60 * 1000;
  953. setInterval(() => {
  954. $('.try-use-wrap').eq(0).hide();
  955. getAdList(16);
  956. }, time);
  957. }
  958. })
  959. }
  960. }
  961. // 广告接口
  962. function getAdList(type) {
  963. adType = type;
  964. $.ajax({
  965. url: baseUrl + "/api/public/v5/advertising/getAdInfoByAdPlace",
  966. headers: {
  967. 'Authorization': form.token
  968. },
  969. data: JSON.stringify({
  970. adPlace: type,
  971. os: 0
  972. }),
  973. type: 'POST',
  974. dataType: 'json',
  975. contentType: "application/json;charset=UTF-8",
  976. success: function (res) {
  977. if (res.status === 0) {
  978. let list = res.data;
  979. let indexs = Math.floor(Math.random() * list.length);
  980. videoTime = list[indexs].forcedTime;
  981. // $('#source').src = list[0].adVideoBase.videoUrl;
  982. $("#source").attr("src", list[indexs].adVideoBase.videoUrl);//更新url
  983. $("#source").attr("autoplay", "true");//直接播放
  984. videoTimer = setInterval(() => {
  985. if (videoTime > 0) {
  986. videoTime--;
  987. $('.time-node').eq(0).text(videoTime + 's');
  988. } else {
  989. clearInterval(videoTimer);
  990. $('.time-node').eq(0).text('');
  991. }
  992. }, 1000)
  993. if (adType === 16 && sourceType == 1) { // 间隔广告和试用才上报
  994. report(0);
  995. }
  996. $('.try-use-wrap').eq(0).show();
  997. } else {
  998. $.toast(res.msg, "text");
  999. }
  1000. }
  1001. })
  1002. }
  1003. //间隔广告上报
  1004. function report(type) {
  1005. $.ajax({
  1006. url: baseUrl + "/api/resources/v1/trial/report",
  1007. headers: {
  1008. 'Authorization': form.token
  1009. },
  1010. data: JSON.stringify({
  1011. userCardId: form.userCardId,
  1012. reportType: type
  1013. }),
  1014. type: 'POST',
  1015. dataType: 'json',
  1016. contentType: "application/json;charset=UTF-8",
  1017. success: function (res) { }
  1018. })
  1019. }
  1020. //关闭广告
  1021. $('.time-close-wrap')[0].addEventListener('click', () => {
  1022. $('.buy-phone-wrap').eq(0).show();
  1023. })
  1024. // 点击取消
  1025. $('.cannel-btn')[0].addEventListener('click', () => {
  1026. $('.buy-phone-wrap').eq(0).hide();
  1027. if (disconnectionFlag || getDate) {//设置了断线时间,取消直接退出
  1028. systemBuriedPoint('激活码-断线-取消');
  1029. quit();
  1030. return
  1031. }
  1032. let pointName = '';
  1033. if (sourceType == 1) {
  1034. pointName = videoTime == 0 ? '免费试用-关闭-取消' : '免费试用-强制关闭-取消';
  1035. } else {
  1036. pointName = videoTime == 0 ? '激活码-关闭-取消' : '激活码-强制关闭-取消';
  1037. }
  1038. systemBuriedPoint(pointName);
  1039. if (videoTime == 0) {
  1040. if (adType === 16 && sourceType == 1) {
  1041. report(1);
  1042. }
  1043. $('.try-use-wrap').eq(0).hide();
  1044. return
  1045. }
  1046. $('.look-wrap').eq(0).show();
  1047. })
  1048. // 点击去购买
  1049. $('.go-bug')[0].addEventListener('click', () => {
  1050. let pointName = '';
  1051. if (disconnectionFlag) {
  1052. pointName = '激活码-断线-去购买';
  1053. } else if (sourceType == 1) {
  1054. pointName = videoTime == 0 ? '免费试用-关闭-去购买' : '免费试用-强制关闭-去购买';
  1055. } else {
  1056. pointName = videoTime == 0 ? '激活码-关闭-去购买' : '激活码-强制关闭-去购买';
  1057. }
  1058. systemBuriedPoint(pointName);
  1059. if (getDate) {
  1060. wx.miniProgram.navigateTo({
  1061. url: '/packageA/order/buy/index'
  1062. })
  1063. } else {
  1064. wx.miniProgram.navigateTo({
  1065. url: '/packageA/order/renew/index?record=' + form.userCardId
  1066. })
  1067. }
  1068. })
  1069. // 放弃
  1070. $('.cannel-ad-btn')[0].addEventListener('click', () => {
  1071. if (sourceType == 1) {
  1072. systemBuriedPoint('免费试用-强制关闭-放弃');
  1073. } else {
  1074. systemBuriedPoint('激活码-强制关闭-放弃');
  1075. }
  1076. quit();
  1077. })
  1078. // 继续观看
  1079. $('.looking')[0].addEventListener('click', () => {
  1080. $('.look-wrap').eq(0).hide();
  1081. if (sourceType == 1) {
  1082. systemBuriedPoint('免费试用-强制关闭-继续观看');
  1083. } else {
  1084. systemBuriedPoint('激活码-强制关闭-继续观看');
  1085. }
  1086. })
  1087. // 埋点
  1088. function systemBuriedPoint(pointName) {
  1089. $.ajax({
  1090. url: baseUrl + "/api/public/v1/systemBuriedPoint/stat",
  1091. headers: {
  1092. 'Authorization': form.token
  1093. },
  1094. type: 'post',
  1095. data: JSON.stringify({
  1096. pointName: pointName
  1097. }),
  1098. contentType: "application/json",
  1099. dataType: 'json',
  1100. success: function (res) { }
  1101. })
  1102. }
  1103. function quit() {
  1104. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  1105. tt.miniProgram.switchTab({
  1106. url: '/pages/home/home'
  1107. })
  1108. } else if (window.__wxjs_environment === 'miniprogram') {
  1109. wx.miniProgram.switchTab({
  1110. url: '/pages/home/home'
  1111. })
  1112. } else {
  1113. uni.webView.navigateTo({
  1114. url: '/pages/index/index'
  1115. });
  1116. }
  1117. }
  1118. window.onbeforeunload = function () {
  1119. ws.close();
  1120. wsss.close();
  1121. }
  1122. </script>
  1123. <script type="text/javascript" src="aac.js"></script>
  1124. </body>
  1125. </html>