WXtrialInterface.html 36 KB

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