WXtrialInterface.html 36 KB

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