WXtrialInterface.html 36 KB

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