WXtrialInterface.html 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157
  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 + "&type=business" : "ws://" + appletPushAddress + "?cardIp=" + ip + "&token=" + cardToken + "&type=business";
  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. if (!isControl) {
  543. return
  544. }
  545. stopManyClick(() => {
  546. $('.box-shear-plate').empty();
  547. $.ajax({
  548. url: baseUrl + "/api/public/v5/shear/content",
  549. headers: {
  550. 'Authorization': form.token
  551. },
  552. type: 'get',
  553. dataType: 'json',
  554. success: function (res) {
  555. if (res.status === 0) {
  556. if (res.data.length) {
  557. cutList = array_unique(res.data)
  558. var str = '<div class="title">剪贴板<div onclick="handleClear()" class="btn-clear">清空</div></div><div class="slide-wrapper-content">'
  559. cutList.forEach(function (item) {
  560. 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>"
  561. })
  562. str += '</div>'
  563. $('.box-shear-plate').append(str);
  564. } else {
  565. $('.box-shear-plate').append('<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>')
  566. }
  567. $('.mask').show();
  568. initSlider();
  569. } else {
  570. $('.box-shear-plate').append('<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>')
  571. $('.mask').show();
  572. }
  573. }
  574. })
  575. })
  576. }
  577. //防止提示一秒内重复显示
  578. function stopManyClick(fn) {
  579. if (isFlag) {
  580. fn();
  581. }
  582. isFlag = false;
  583. if (timer) { clearTimeout(timer); }
  584. timer = setTimeout(() => { isFlag = true }, 1500);
  585. }
  586. // 清空剪贴板
  587. function handleClear() {
  588. var ids = '';
  589. cutList.forEach(function (item) {
  590. ids += 'ids=' + item.id + '&'
  591. });
  592. ids = ids.substring(0, ids.lastIndexOf('&'));
  593. $.confirm("确定清空剪贴板?", function () {
  594. $.ajax({
  595. url: baseUrl + "/api/public/v5/shear/content?" + ids,
  596. headers: {
  597. 'Authorization': form.token
  598. },
  599. type: 'DELETE',
  600. dataType: 'json',
  601. success: function (res) {
  602. if (res.status === 0) {
  603. showShearPlate();
  604. } else {
  605. $.toast(res.msg, "text");
  606. }
  607. }
  608. })
  609. });
  610. }
  611. function handleCopy(content) {
  612. var cutting = {
  613. "type": "cutting",
  614. "data": {
  615. "str": content
  616. }
  617. };
  618. wsss.send(JSON.stringify(cutting));
  619. }
  620. // 删除剪贴板
  621. function handleDelete(id) {
  622. $.ajax({
  623. url: baseUrl + "/api/public/v5/shear/content?ids=" + id,
  624. headers: {
  625. 'Authorization': form.token
  626. },
  627. type: 'DELETE',
  628. dataType: 'json',
  629. success: function (res) {
  630. if (res.status === 0) {
  631. showShearPlate();
  632. } else {
  633. $.toast(res.msg, "text");
  634. }
  635. }
  636. })
  637. }
  638. function initSlider() {
  639. //手指滑动多少距离就认为是滑成功
  640. //这个值不能太大,否则影响斜着滑动时,垂直滑动的流畅性,也不能太小,太灵敏也不好
  641. var diffXDistance = 50;
  642. //当前滑动的对象
  643. var currentObject;
  644. //上一次滑动的对象
  645. var lastObject;
  646. //是否可以左右滑动,在上下滑的时候禁止左右滑
  647. var canSlide = true;
  648. //用于记录按下的点
  649. var startPoint;
  650. $(".slide-content").css({
  651. width: $(".slide-wrapper").width()
  652. });
  653. document.body.removeEventListener('touchmove', function (e) {
  654. e.preventDefault()
  655. }, {
  656. passive: false
  657. })
  658. $(".slide-scroll").css({
  659. width: $(".slide-wrapper").width() + $(".slide-content-button").width()
  660. }).on('touchstart', function (e) {
  661. currentObject = this;
  662. startPoint = {
  663. x: e.originalEvent.changedTouches[0].pageX,
  664. y: e.originalEvent.changedTouches[0].pageY
  665. };
  666. }).on('touchmove', function (e) {
  667. //如果是左右滑动,就禁止上下的滑动
  668. //如果是上下的滑动,就禁止左右滑动
  669. if (Math.abs(e.originalEvent.changedTouches[0].pageX - startPoint.x) > Math.abs(e.originalEvent.changedTouches[0].pageY - startPoint.y)) {
  670. event.preventDefault();
  671. } else {
  672. canSlide = false;
  673. }
  674. }).on('touchend', function (e) {
  675. //如果是上下滑动,这里就直接返回了
  676. if (!canSlide) {
  677. canSlide = true;
  678. return true;
  679. }
  680. //点击除当前左滑对象之外的任意其他位置
  681. if (lastObject && currentObject != lastObject) {
  682. //右滑→
  683. $(lastObject).removeClass("animate-slide");
  684. //清空上一个左滑的对象
  685. lastObject = undefined;
  686. }
  687. var diffX = e.originalEvent.changedTouches[0].pageX - startPoint.x;
  688. if (diffX < -diffXDistance) {
  689. //左滑←
  690. $(currentObject).addClass("animate-slide");
  691. if (lastObject && lastObject != currentObject) {
  692. //右滑→
  693. $(lastObject).removeClass("animate-slide");
  694. }
  695. //记录上一个左滑的对象
  696. lastObject = currentObject;
  697. } else if (diffX >= diffXDistance) {
  698. if (currentObject == lastObject) {
  699. //右滑→
  700. $(currentObject).removeClass("animate-slide");
  701. //清空上一个左滑的对象
  702. lastObject = undefined;
  703. }
  704. }
  705. });
  706. }
  707. var btnMuted = document.querySelector("#btnMuted");
  708. btnMuted && (function () {
  709. var setHistory = function (left, top) {
  710. try {
  711. localStorage.setItem("muted-btn-loc", JSON.stringify({
  712. left: left,
  713. top: top
  714. }));
  715. } catch (ex) { }
  716. };
  717. var getHistory = function () {
  718. try {
  719. var value = localStorage.getItem("muted-btn-loc");
  720. if (!value) return null;
  721. value = JSON.parse(value);
  722. if (!value) return null;
  723. return value;
  724. } catch (ex) {
  725. return null
  726. }
  727. };
  728. var fixLoc = function (loc) {
  729. var rect = btnMuted.getBoundingClientRect();
  730. rect = {
  731. top: rect.top,
  732. left: rect.left,
  733. width: rect.width,
  734. height: rect.height
  735. }; //部分低版本浏览器,该属性为只读
  736. if (loc) {
  737. rect.left = loc.left;
  738. rect.top = loc.top;
  739. }
  740. var minX = 0;
  741. var minY = 0;
  742. var docRect = document.documentElement.getBoundingClientRect();
  743. var maxY = docRect.height - rect.height;
  744. var maxX = docRect.width - rect.width;
  745. var left = rect.left;
  746. var top = rect.top;
  747. left = Math.min(left, maxX);
  748. left = Math.max(left, minX);
  749. top = Math.min(top, maxY);
  750. top = Math.max(top, minY);
  751. if (loc || top !== rect.top || left !== rect.left) {
  752. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  753. }
  754. }
  755. window.addEventListener("resize", function () {
  756. fixLoc();
  757. });
  758. var touchPoint = {
  759. pageY: 0,
  760. pageX: 0
  761. };
  762. var currentLoc = {
  763. top: 0,
  764. left: 0,
  765. curTop: 0,
  766. curLeft: 0
  767. };
  768. var toMove = false;
  769. var touchmove = function (e) {
  770. e.preventDefault();
  771. var point = e.changedTouches[0];
  772. var top = -touchPoint.pageY + point.pageY;
  773. var left = -touchPoint.pageX + point.pageX;
  774. if (toMove) {
  775. top += currentLoc.top;
  776. left += currentLoc.left;
  777. currentLoc.curLeft = left;
  778. currentLoc.curTop = top;
  779. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  780. } else {
  781. if (Math.abs(top) >= 5 || Math.abs(left) >= 5) {
  782. toMove = true;
  783. }
  784. }
  785. };
  786. var touchend = function () {
  787. window.removeEventListener("touchmove", touchmove, {
  788. passive: false
  789. });
  790. window.removeEventListener("touchend", touchend, {
  791. passive: false
  792. });
  793. if (toMove) {
  794. setHistory(currentLoc.curLeft, currentLoc.curTop);
  795. fixLoc();
  796. } else {
  797. //按点击处理
  798. var set = $('.control-right-img').attr("data-id")
  799. if (set == '1') {
  800. $('.control-right-img').attr({
  801. "data-id": "2"
  802. })
  803. $(".leftmains").css({
  804. "right": "0rem"
  805. })
  806. } else {
  807. $('.control-right-img').attr({
  808. "data-id": "1"
  809. })
  810. $(".leftmains").css({
  811. "right": "-4rem"
  812. })
  813. }
  814. }
  815. }
  816. btnMuted.addEventListener("touchstart", function (e) {
  817. e.preventDefault();
  818. toMove = false;
  819. var point = e.changedTouches[0];
  820. touchPoint.pageX = point.pageX;
  821. touchPoint.pageY = point.pageY;
  822. var rect = e.target.getBoundingClientRect();
  823. currentLoc.top = rect.top;
  824. currentLoc.left = rect.left;
  825. window.addEventListener("touchmove", touchmove, {
  826. passive: false
  827. });
  828. window.addEventListener("touchend", touchend, {
  829. passive: false
  830. });
  831. }, {
  832. passive: false
  833. });
  834. var history = getHistory();
  835. if (history) {
  836. fixLoc(history);
  837. }
  838. btnMuted.classList.remove("hide");
  839. })();
  840. $("#upload").on("click", function () {
  841. clearInterval(intervaler);
  842. ws.close();
  843. wsss.close();
  844. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  845. tt.miniProgram.switchTab({
  846. url: '/pages/home/home'
  847. })
  848. } else {
  849. wx.miniProgram.switchTab({
  850. url: '/pages/home/home'
  851. })
  852. }
  853. })
  854. function selectText(x) {
  855. if (document.selection) {
  856. var range = document.body.createTextRange();
  857. range.moveToElementText(x);
  858. range.select();
  859. } else if (window.getSelection) {
  860. var selection = window.getSelection();
  861. var range = document.createRange();
  862. selection.removeAllRanges();
  863. range.selectNodeContents(x);
  864. selection.addRange(range);
  865. }
  866. }
  867. // 激活码广告相关配置
  868. function getConfigByPhoneType() {
  869. return new Promise((resolve, reject) => {
  870. $.ajax({
  871. url: baseUrl + "/api/pay/v5/trialCodeConfig/getConfigByPhoneType",
  872. headers: {
  873. 'Authorization': form.token
  874. },
  875. data: {
  876. userCardId: form.userCardId,
  877. phoneType: form.mealType
  878. },
  879. type: 'get',
  880. dataType: 'json',
  881. success: function (res) {
  882. console.log(res)
  883. let obj = res.data;
  884. if (res.status === 0) {
  885. resolve(obj)
  886. } else {
  887. $.toast(res.msg, "text");
  888. }
  889. }
  890. })
  891. })
  892. }
  893. //列表
  894. function getSetmealList() {
  895. return new Promise((resolve, reject) => {
  896. $.ajax({
  897. url: baseUrl + "/api/resources/v4/freetrial/setmeal/list",
  898. headers: {
  899. 'Authorization': form.token
  900. },
  901. type: 'get',
  902. dataType: 'json',
  903. success: function (res) {
  904. if (res.status === 0) {
  905. let list = res.data;
  906. list.map((item) => {
  907. if(item.phoneType === parameters['mealType']){
  908. resolve(item)
  909. }
  910. })
  911. } else {
  912. $.toast(res.msg, "text");
  913. }
  914. }
  915. })
  916. })
  917. }
  918. //广告信息
  919. function adInit() {
  920. sourceType = parameters['sourceType'];
  921. if(sourceType == 1) {
  922. getSetmealList().then((res) => {
  923. if(res.pushFlowAdvert === 1){
  924. getAdList(15);
  925. }
  926. if(res.intervalSwitch === 1) {
  927. let time = res.intervalAdvertDuration * 60 * 1000;
  928. setInterval(() => {
  929. $('.try-use-wrap').eq(0).hide();
  930. getAdList(16);
  931. }, time);
  932. }
  933. })
  934. }else if(sourceType == 2) {
  935. getConfigByPhoneType().then((res) => {
  936. if(res.isDisconnectionTime === 1){
  937. let time = res.disconnectionTime * 60 * 1000;
  938. setTimeout(() => {
  939. disconnectionFlag = true;
  940. $('.buy-phone-wrap').eq(0).show();
  941. }, time);
  942. }
  943. if(res.isShowAd === 1){
  944. getAdList(15);
  945. }
  946. if(res.isIntervalPlayAd === 1) {
  947. let time = res.intervalPlayAdTime * 60 * 1000;
  948. setInterval(() => {
  949. $('.try-use-wrap').eq(0).hide();
  950. getAdList(16);
  951. }, time);
  952. }
  953. })
  954. }
  955. }
  956. // 广告接口
  957. function getAdList(type){
  958. adType = type;
  959. $.ajax({
  960. url: baseUrl + "/api/public/v5/advertising/getAdInfoByAdPlace",
  961. headers: {
  962. 'Authorization': form.token
  963. },
  964. data: JSON.stringify({
  965. adPlace: type,
  966. os: 0
  967. }),
  968. type: 'POST',
  969. dataType: 'json',
  970. contentType: "application/json;charset=UTF-8",
  971. success: function (res) {
  972. if (res.status === 0) {
  973. let list = res.data;
  974. let indexs = Math.floor(Math.random()*list.length);
  975. videoTime = list[indexs].forcedTime;
  976. // $('#source').src = list[0].adVideoBase.videoUrl;
  977. $("#source").attr("src", list[indexs].adVideoBase.videoUrl);//更新url
  978. $("#source").attr("autoplay", "true");//直接播放
  979. videoTimer = setInterval(() =>{
  980. if(videoTime > 0) {
  981. videoTime--;
  982. $('.time-node').eq(0).text(videoTime + 's');
  983. } else {
  984. clearInterval(videoTimer);
  985. $('.time-node').eq(0).text('');
  986. }
  987. },1000)
  988. if (adType === 16 && sourceType == 1) { // 间隔广告和试用才上报
  989. report(0);
  990. }
  991. $('.try-use-wrap').eq(0).show();
  992. } else {
  993. $.toast(res.msg, "text");
  994. }
  995. }
  996. })
  997. }
  998. //间隔广告上报
  999. function report(type) {
  1000. $.ajax({
  1001. url: baseUrl + "/api/resources/v1/trial/report",
  1002. headers: {
  1003. 'Authorization': form.token
  1004. },
  1005. data: JSON.stringify({
  1006. userCardId: form.userCardId,
  1007. reportType: type
  1008. }),
  1009. type: 'POST',
  1010. dataType: 'json',
  1011. contentType: "application/json;charset=UTF-8",
  1012. success: function (res) {}
  1013. })
  1014. }
  1015. //关闭广告
  1016. $('.time-close-wrap')[0].addEventListener('click', () => {
  1017. $('.buy-phone-wrap').eq(0).show();
  1018. })
  1019. // 点击取消
  1020. $('.cannel-btn')[0].addEventListener('click', () => {
  1021. $('.buy-phone-wrap').eq(0).hide();
  1022. if (disconnectionFlag) {//设置了断线时间,取消直接退出
  1023. systemBuriedPoint('激活码-断线-取消');
  1024. wx.miniProgram.switchTab({
  1025. url: '/pages/home/home'
  1026. })
  1027. return
  1028. }
  1029. let pointName = '';
  1030. if(sourceType == 1){
  1031. pointName = videoTime == 0 ? '免费试用-关闭-取消' : '免费试用-强制关闭-取消';
  1032. } else {
  1033. pointName = videoTime == 0 ? '激活码-关闭-取消' : '激活码-强制关闭-取消';
  1034. }
  1035. systemBuriedPoint(pointName);
  1036. if(videoTime == 0) {
  1037. if (adType === 16 && sourceType == 1) {
  1038. report(1);
  1039. }
  1040. $('.try-use-wrap').eq(0).hide();
  1041. return
  1042. }
  1043. $('.look-wrap').eq(0).show();
  1044. })
  1045. // 点击去购买
  1046. $('.go-bug')[0].addEventListener('click', () => {
  1047. let pointName = '';
  1048. if(disconnectionFlag) {
  1049. pointName = '激活码-断线-去购买';
  1050. } else if(sourceType == 1){
  1051. pointName = videoTime == 0 ? '免费试用-关闭-去购买' : '免费试用-强制关闭-去购买';
  1052. } else {
  1053. pointName = videoTime == 0 ? '激活码-关闭-去购买' : '激活码-强制关闭-去购买';
  1054. }
  1055. systemBuriedPoint(pointName);
  1056. wx.miniProgram.navigateTo({
  1057. url: '/packageA/order/renew/index?record=' + form.userCardId
  1058. })
  1059. })
  1060. // 放弃
  1061. $('.cannel-ad-btn')[0].addEventListener('click', () => {
  1062. if(sourceType == 1){
  1063. systemBuriedPoint('免费试用-强制关闭-放弃');
  1064. } else {
  1065. systemBuriedPoint('激活码-强制关闭-放弃');
  1066. }
  1067. wx.miniProgram.switchTab({
  1068. url: '/pages/home/home'
  1069. })
  1070. })
  1071. // 继续观看
  1072. $('.looking')[0].addEventListener('click', () => {
  1073. $('.look-wrap').eq(0).hide();
  1074. if(sourceType == 1){
  1075. systemBuriedPoint('免费试用-强制关闭-继续观看');
  1076. } else {
  1077. systemBuriedPoint('激活码-强制关闭-继续观看');
  1078. }
  1079. })
  1080. // 埋点
  1081. function systemBuriedPoint(pointName){
  1082. $.ajax({
  1083. url: baseUrl + "/api/public/v1/systemBuriedPoint/stat",
  1084. headers: {
  1085. 'Authorization': form.token
  1086. },
  1087. type: 'post',
  1088. data:JSON.stringify({
  1089. pointName: pointName
  1090. }),
  1091. contentType:"application/json",
  1092. dataType: 'json',
  1093. success: function (res) {}
  1094. })
  1095. }
  1096. window.onbeforeunload = function () {
  1097. ws.close();
  1098. wsss.close();
  1099. }
  1100. </script>
  1101. <script type="text/javascript" src="aac.js"></script>
  1102. </body>
  1103. </html>