WXtrialInterface.html 36 KB

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