WXtrialInterface.html 36 KB

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