WXtrialInterface.html 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168
  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 : "ws://" + appletPushAddress + "?cardIp=" + ip + "&token=" + cardToken;
  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. stopManyClick(() => {
  551. $('.box-shear-plate').empty();
  552. $.ajax({
  553. url: baseUrl + "/api/public/v5/shear/content",
  554. headers: {
  555. 'Authorization': form.token
  556. },
  557. type: 'get',
  558. dataType: 'json',
  559. success: function (res) {
  560. if (res.status === 0) {
  561. if (res.data.length) {
  562. cutList = array_unique(res.data)
  563. var str = '<div class="title">剪贴板<div onclick="handleClear()" class="btn-clear">清空</div></div><div class="slide-wrapper-content">'
  564. cutList.forEach(function (item) {
  565. 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>"
  566. })
  567. str += '</div>'
  568. $('.box-shear-plate').append(str);
  569. } else {
  570. $('.box-shear-plate').append('<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>')
  571. }
  572. $('.mask').show();
  573. initSlider();
  574. } else {
  575. $('.box-shear-plate').append('<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>')
  576. $('.mask').show();
  577. }
  578. }
  579. })
  580. })
  581. }
  582. //防止提示一秒内重复显示
  583. function stopManyClick(fn) {
  584. if (isFlag) {
  585. fn();
  586. }
  587. isFlag = false;
  588. if (timer) { clearTimeout(timer); }
  589. timer = setTimeout(() => { isFlag = true }, 1500);
  590. }
  591. // 清空剪贴板
  592. function handleClear() {
  593. var ids = '';
  594. cutList.forEach(function (item) {
  595. ids += 'ids=' + item.id + '&'
  596. });
  597. ids = ids.substring(0, ids.lastIndexOf('&'));
  598. $.confirm("确定清空剪贴板?", function () {
  599. $.ajax({
  600. url: baseUrl + "/api/public/v5/shear/content?" + ids,
  601. headers: {
  602. 'Authorization': form.token
  603. },
  604. type: 'DELETE',
  605. dataType: 'json',
  606. success: function (res) {
  607. if (res.status === 0) {
  608. showShearPlate();
  609. } else {
  610. $.toast(res.msg, "text");
  611. }
  612. }
  613. })
  614. });
  615. }
  616. function handleCopy(content) {
  617. var cutting = {
  618. "type": "cutting",
  619. "data": {
  620. "str": content
  621. }
  622. };
  623. wsss.send(JSON.stringify(cutting));
  624. }
  625. // 删除剪贴板
  626. function handleDelete(id) {
  627. $.ajax({
  628. url: baseUrl + "/api/public/v5/shear/content?ids=" + id,
  629. headers: {
  630. 'Authorization': form.token
  631. },
  632. type: 'DELETE',
  633. dataType: 'json',
  634. success: function (res) {
  635. if (res.status === 0) {
  636. showShearPlate();
  637. } else {
  638. $.toast(res.msg, "text");
  639. }
  640. }
  641. })
  642. }
  643. function initSlider() {
  644. //手指滑动多少距离就认为是滑成功
  645. //这个值不能太大,否则影响斜着滑动时,垂直滑动的流畅性,也不能太小,太灵敏也不好
  646. var diffXDistance = 50;
  647. //当前滑动的对象
  648. var currentObject;
  649. //上一次滑动的对象
  650. var lastObject;
  651. //是否可以左右滑动,在上下滑的时候禁止左右滑
  652. var canSlide = true;
  653. //用于记录按下的点
  654. var startPoint;
  655. $(".slide-content").css({
  656. width: $(".slide-wrapper").width()
  657. });
  658. document.body.removeEventListener('touchmove', function (e) {
  659. e.preventDefault()
  660. }, {
  661. passive: false
  662. })
  663. $(".slide-scroll").css({
  664. width: $(".slide-wrapper").width() + $(".slide-content-button").width()
  665. }).on('touchstart', function (e) {
  666. currentObject = this;
  667. startPoint = {
  668. x: e.originalEvent.changedTouches[0].pageX,
  669. y: e.originalEvent.changedTouches[0].pageY
  670. };
  671. }).on('touchmove', function (e) {
  672. //如果是左右滑动,就禁止上下的滑动
  673. //如果是上下的滑动,就禁止左右滑动
  674. if (Math.abs(e.originalEvent.changedTouches[0].pageX - startPoint.x) > Math.abs(e.originalEvent.changedTouches[0].pageY - startPoint.y)) {
  675. event.preventDefault();
  676. } else {
  677. canSlide = false;
  678. }
  679. }).on('touchend', function (e) {
  680. //如果是上下滑动,这里就直接返回了
  681. if (!canSlide) {
  682. canSlide = true;
  683. return true;
  684. }
  685. //点击除当前左滑对象之外的任意其他位置
  686. if (lastObject && currentObject != lastObject) {
  687. //右滑→
  688. $(lastObject).removeClass("animate-slide");
  689. //清空上一个左滑的对象
  690. lastObject = undefined;
  691. }
  692. var diffX = e.originalEvent.changedTouches[0].pageX - startPoint.x;
  693. if (diffX < -diffXDistance) {
  694. //左滑←
  695. $(currentObject).addClass("animate-slide");
  696. if (lastObject && lastObject != currentObject) {
  697. //右滑→
  698. $(lastObject).removeClass("animate-slide");
  699. }
  700. //记录上一个左滑的对象
  701. lastObject = currentObject;
  702. } else if (diffX >= diffXDistance) {
  703. if (currentObject == lastObject) {
  704. //右滑→
  705. $(currentObject).removeClass("animate-slide");
  706. //清空上一个左滑的对象
  707. lastObject = undefined;
  708. }
  709. }
  710. });
  711. }
  712. var btnMuted = document.querySelector("#btnMuted");
  713. btnMuted && (function () {
  714. var setHistory = function (left, top) {
  715. try {
  716. localStorage.setItem("muted-btn-loc", JSON.stringify({
  717. left: left,
  718. top: top
  719. }));
  720. } catch (ex) { }
  721. };
  722. var getHistory = function () {
  723. try {
  724. var value = localStorage.getItem("muted-btn-loc");
  725. if (!value) return null;
  726. value = JSON.parse(value);
  727. if (!value) return null;
  728. return value;
  729. } catch (ex) {
  730. return null
  731. }
  732. };
  733. var fixLoc = function (loc) {
  734. var rect = btnMuted.getBoundingClientRect();
  735. rect = {
  736. top: rect.top,
  737. left: rect.left,
  738. width: rect.width,
  739. height: rect.height
  740. }; //部分低版本浏览器,该属性为只读
  741. if (loc) {
  742. rect.left = loc.left;
  743. rect.top = loc.top;
  744. }
  745. var minX = 0;
  746. var minY = 0;
  747. var docRect = document.documentElement.getBoundingClientRect();
  748. var maxY = docRect.height - rect.height;
  749. var maxX = docRect.width - rect.width;
  750. var left = rect.left;
  751. var top = rect.top;
  752. left = Math.min(left, maxX);
  753. left = Math.max(left, minX);
  754. top = Math.min(top, maxY);
  755. top = Math.max(top, minY);
  756. if (loc || top !== rect.top || left !== rect.left) {
  757. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  758. }
  759. }
  760. window.addEventListener("resize", function () {
  761. fixLoc();
  762. });
  763. var touchPoint = {
  764. pageY: 0,
  765. pageX: 0
  766. };
  767. var currentLoc = {
  768. top: 0,
  769. left: 0,
  770. curTop: 0,
  771. curLeft: 0
  772. };
  773. var toMove = false;
  774. var touchmove = function (e) {
  775. e.preventDefault();
  776. var point = e.changedTouches[0];
  777. var top = -touchPoint.pageY + point.pageY;
  778. var left = -touchPoint.pageX + point.pageX;
  779. if (toMove) {
  780. top += currentLoc.top;
  781. left += currentLoc.left;
  782. currentLoc.curLeft = left;
  783. currentLoc.curTop = top;
  784. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  785. } else {
  786. if (Math.abs(top) >= 5 || Math.abs(left) >= 5) {
  787. toMove = true;
  788. }
  789. }
  790. };
  791. var touchend = function () {
  792. window.removeEventListener("touchmove", touchmove, {
  793. passive: false
  794. });
  795. window.removeEventListener("touchend", touchend, {
  796. passive: false
  797. });
  798. if (toMove) {
  799. setHistory(currentLoc.curLeft, currentLoc.curTop);
  800. fixLoc();
  801. } else {
  802. //按点击处理
  803. var set = $('.control-right-img').attr("data-id")
  804. if (set == '1') {
  805. $('.control-right-img').attr({
  806. "data-id": "2"
  807. })
  808. $(".leftmains").css({
  809. "right": "0rem"
  810. })
  811. } else {
  812. $('.control-right-img').attr({
  813. "data-id": "1"
  814. })
  815. $(".leftmains").css({
  816. "right": "-4rem"
  817. })
  818. }
  819. }
  820. }
  821. btnMuted.addEventListener("touchstart", function (e) {
  822. e.preventDefault();
  823. toMove = false;
  824. var point = e.changedTouches[0];
  825. touchPoint.pageX = point.pageX;
  826. touchPoint.pageY = point.pageY;
  827. var rect = e.target.getBoundingClientRect();
  828. currentLoc.top = rect.top;
  829. currentLoc.left = rect.left;
  830. window.addEventListener("touchmove", touchmove, {
  831. passive: false
  832. });
  833. window.addEventListener("touchend", touchend, {
  834. passive: false
  835. });
  836. }, {
  837. passive: false
  838. });
  839. var history = getHistory();
  840. if (history) {
  841. fixLoc(history);
  842. }
  843. btnMuted.classList.remove("hide");
  844. })();
  845. $("#upload").on("click", function () {
  846. clearInterval(intervaler);
  847. ws.close();
  848. wsss.close();
  849. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  850. tt.miniProgram.switchTab({
  851. url: '/pages/home/home'
  852. })
  853. } else {
  854. wx.miniProgram.switchTab({
  855. url: '/pages/home/home'
  856. })
  857. }
  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) {//设置了断线时间,取消直接退出
  1028. systemBuriedPoint('激活码-断线-取消');
  1029. wx.miniProgram.switchTab({
  1030. url: '/pages/home/home'
  1031. })
  1032. return
  1033. }
  1034. let pointName = '';
  1035. if(sourceType == 1){
  1036. pointName = videoTime == 0 ? '免费试用-关闭-取消' : '免费试用-强制关闭-取消';
  1037. } else {
  1038. pointName = videoTime == 0 ? '激活码-关闭-取消' : '激活码-强制关闭-取消';
  1039. }
  1040. systemBuriedPoint(pointName);
  1041. if(videoTime == 0) {
  1042. if (adType === 16 && sourceType == 1) {
  1043. report(1);
  1044. }
  1045. $('.try-use-wrap').eq(0).hide();
  1046. return
  1047. }
  1048. $('.look-wrap').eq(0).show();
  1049. })
  1050. // 点击去购买
  1051. $('.go-bug')[0].addEventListener('click', () => {
  1052. let pointName = '';
  1053. if(disconnectionFlag) {
  1054. pointName = '激活码-断线-去购买';
  1055. } else if(sourceType == 1){
  1056. pointName = videoTime == 0 ? '免费试用-关闭-去购买' : '免费试用-强制关闭-去购买';
  1057. } else {
  1058. pointName = videoTime == 0 ? '激活码-关闭-去购买' : '激活码-强制关闭-去购买';
  1059. }
  1060. systemBuriedPoint(pointName);
  1061. if(getDate){
  1062. wx.miniProgram.navigateTo({
  1063. url: '/packageA/order/buy/index'
  1064. })
  1065. } else {
  1066. wx.miniProgram.navigateTo({
  1067. url: '/packageA/order/renew/index?record=' + form.userCardId
  1068. })
  1069. }
  1070. })
  1071. // 放弃
  1072. $('.cannel-ad-btn')[0].addEventListener('click', () => {
  1073. if(sourceType == 1){
  1074. systemBuriedPoint('免费试用-强制关闭-放弃');
  1075. } else {
  1076. systemBuriedPoint('激活码-强制关闭-放弃');
  1077. }
  1078. wx.miniProgram.switchTab({
  1079. url: '/pages/home/home'
  1080. })
  1081. })
  1082. // 继续观看
  1083. $('.looking')[0].addEventListener('click', () => {
  1084. $('.look-wrap').eq(0).hide();
  1085. if(sourceType == 1){
  1086. systemBuriedPoint('免费试用-强制关闭-继续观看');
  1087. } else {
  1088. systemBuriedPoint('激活码-强制关闭-继续观看');
  1089. }
  1090. })
  1091. // 埋点
  1092. function systemBuriedPoint(pointName){
  1093. $.ajax({
  1094. url: baseUrl + "/api/public/v1/systemBuriedPoint/stat",
  1095. headers: {
  1096. 'Authorization': form.token
  1097. },
  1098. type: 'post',
  1099. data:JSON.stringify({
  1100. pointName: pointName
  1101. }),
  1102. contentType:"application/json",
  1103. dataType: 'json',
  1104. success: function (res) {}
  1105. })
  1106. }
  1107. window.onbeforeunload = function () {
  1108. ws.close();
  1109. wsss.close();
  1110. }
  1111. </script>
  1112. <script type="text/javascript" src="aac.js"></script>
  1113. </body>
  1114. </html>