WXtrialInterface.html 36 KB

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