WXtrialInterface.html 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title></title>
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <meta name="x5-orientation" content="portrait" />
  8. <meta name="screen-orientation" content="portrait" />
  9. <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
  10. <meta name="apple-mobile-web-app-capable" content="yes">
  11. <!-- 删除苹果默认的工具栏和菜单栏 -->
  12. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  13. <!-- 设置苹果工具栏颜? -->
  14. <meta name="format-detection" content="telphone=no, email=no">
  15. <!-- 忽略页面中的数字识别为电话,忽略email识别 -->
  16. <!-- 启用360浏览器的极速模?(webkit) -->
  17. <meta name="renderer" content="webkit">
  18. <!-- 针对手持设备优化,主要是针对一些老的不识别viewport的浏览器,比如黑? -->
  19. <meta name="HandheldFriendly" content="true">
  20. <!-- 微软的老式浏览? -->
  21. <meta name="MobileOptimized" content="320">
  22. <!-- 不能旋转,问题出在这 -->
  23. <!-- UC强制全屏 -->
  24. <meta name="full-screen" content="yes">
  25. <!-- QQ强制全屏 -->
  26. <meta name="x5-fullscreen" content="true">
  27. <!-- UC应用模式 -->
  28. <meta name="browsermode" content="application">
  29. <!-- QQ应用模式 -->
  30. <meta name="x5-page-mode" content="app">
  31. <!-- windows phone 点击无高? -->
  32. <meta name="msapplication-tap-highlight" content="no">
  33. <link rel="stylesheet" type="text/css" href="css/WXtrialInterface.css" />
  34. <link rel="stylesheet" href="https://cdn.bootcss.com/weui/1.1.3/style/weui.min.css" />
  35. <link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.1/css/jquery-weui.min.css" />
  36. <style>
  37. .try-use-wrap, .buy-phone-wrap, .look-wrap{
  38. width: 100%;
  39. height: 100%;
  40. position: fixed;
  41. top: 0;
  42. left: 0;
  43. z-index: 9999;
  44. background: rgba(0, 0, 0, 0.5);
  45. display: none;
  46. }
  47. .try-use-container{
  48. width: 80%;
  49. height: 409px;
  50. position: absolute;
  51. top: 50%;
  52. left: 50%;
  53. transform: translate(-50%, -50%);
  54. background-color: #FFFFFF;
  55. border-radius: 0.66em;
  56. }
  57. .time-close-wrap{
  58. width: 5.46em;
  59. height: 2em;
  60. line-height: 2em;
  61. text-align: center;
  62. position: absolute;
  63. top: 0.24em;
  64. right: 0.3em;
  65. background: rgba(0, 0, 0, 0.49);
  66. border-radius: 1.26em;
  67. font-size: 12px;
  68. color: #FFFFFF;
  69. }
  70. .bug-wrap{
  71. width: 90%;
  72. height: 115px;
  73. background: #FFFFFF;
  74. border-radius: 10px;
  75. position: absolute;
  76. top: 50%;
  77. left: 50%;
  78. transform: translate(-50%, -50%);
  79. }
  80. .bug-title{
  81. text-align: center;
  82. margin: 25px 0;
  83. font-size: 18px;
  84. font-weight: 600;
  85. color: #333333;
  86. }
  87. .btn-list{
  88. width: 100%;
  89. height: 44px;
  90. line-height: 44px;
  91. border-top: 1px solid rgba(238,238,238,1);
  92. position: absolute;
  93. bottom: 0;
  94. left: 0;
  95. display: flex;
  96. align-items: center;
  97. }
  98. .btn{
  99. flex: 1;
  100. text-align: center;
  101. }
  102. .cannel-btn{
  103. font-size: 18px;
  104. color: #666666;
  105. }
  106. .go-bug{
  107. font-size: 18px;
  108. color: #3B7FFF;
  109. border-left: 1px solid rgba(238,238,238,1);
  110. }
  111. </style>
  112. </head>
  113. <body class="scroll h-player" style="overscroll-behavior: contain;">
  114. <div class="container" id="player">
  115. <div class="muted" id="btnMuted">
  116. <div class="control-right-img" data-id="1">
  117. <img src="../static/img/xuanfu_icon.png">
  118. </div>
  119. </div>
  120. <div id="wine">
  121. <video id="playerVideo" muted="muted" x5-video-orientation="landscape" playsinline="true" autoplay="true"
  122. webkit-playsinline="true" x5-playsinline="true" x5-video-player-type="h5" x5-video-player-fullscreen="false"
  123. style="pointer-events: none;object-fit: fill;width: 100%;height:100%"></video>
  124. <div id="box"></div>
  125. <audio preload="auto" autoplay controls poster="images/loader-thumb.jpg" id="audioPlayer"
  126. style="position: absolute;top: 0;width: 0;height: 0;"></audio>
  127. </div>
  128. <div class="leftmains">
  129. <div class="PictureQualityMain">
  130. <div class="PictureQuality" data-id="4">高清</div>
  131. <div class="PictureQuality avit" data-id="3">标清</div>
  132. <div class="PictureQuality" data-id="2">极速</div>
  133. </div>
  134. <div class="operation">
  135. <div class="upload" id="showsuss" data-text="uploads">
  136. <img src="../static/img/wx/shangchuan_icon.png">
  137. <div>上传</div>
  138. </div>
  139. <div class="upload" onclick="showShearPlate()" data-text="Shearplate">
  140. <img src="../static/img/wx/jianqieban_icon.png">
  141. <div>剪贴板</div>
  142. </div>
  143. <div class="upload" id="upload" data-text="Signout">
  144. <img src="../static/img/wx/tuichu_icon.png">
  145. <div>退出</div>
  146. </div>
  147. </div>
  148. </div>
  149. <div class="bottommains">
  150. <div class="botmat1">
  151. <div class="botmat1img" data-text="gengduo">
  152. <img src="../static/img/wx/gengduo_icon.png">
  153. </div>
  154. </div>
  155. <div class="botmat1">
  156. <div class="botmat1img" data-text="home">
  157. <img src="../static/img/wx/home_icon.png">
  158. </div>
  159. </div>
  160. <div class="botmat1">
  161. <div class="botmat1img" data-text="return">
  162. <img src="../static/img/wx/fanhui_icon.png">
  163. </div>
  164. </div>
  165. </div>
  166. <img class="loading loading_sceen_pic" />
  167. </div>
  168. <div class="mask">
  169. <div class="box-shear-plate"></div>
  170. <img class="close" onclick="handleClose()" src="img/guanbi_icon@2x.png" alt="">
  171. </div>
  172. <div class="weui-mask_transparent"></div>
  173. <div class="weui-toast weui_loading_toast weui-toast--visible">
  174. <div class="weui_loading"><i class="weui-loading weui-icon_toast"></i></div>
  175. <p class="weui-toast_content">数据加载中</p>
  176. </div>
  177. <div class="try-use-wrap">
  178. <div class="try-use-container">
  179. <video width="100%" height="100%" id="source" muted autoplay="autoplay" loop="loop">
  180. 您的浏览器不支持 video 标签。
  181. </video>
  182. <div class="time-close-wrap"><span class="time-node"></span> 关闭</div>
  183. </div>
  184. </div>
  185. <div class="buy-phone-wrap">
  186. <div class="bug-wrap">
  187. <div class="bug-title">获得极致体验服务请购买云手机</div>
  188. <div class="btn-list">
  189. <div class="btn cannel-btn">取消</div>
  190. <div class="btn go-bug">去购买</div>
  191. </div>
  192. </div>
  193. </div>
  194. <div class="look-wrap">
  195. <div class="bug-wrap">
  196. <div class="bug-title">关闭广告会退出云手机是否继续观看</div>
  197. <div class="btn-list">
  198. <div class="btn cannel-btn cannel-ad-btn">放弃</div>
  199. <div class="btn go-bug looking">继续观看</div>
  200. </div>
  201. </div>
  202. </div>
  203. <body oncontextmenu="Back()">
  204. </body>
  205. <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
  206. <script src="https://lf1-cdn-tos.bytegoofy.com/goofy/developer/jssdk/jssdk-1.0.3.js"></script>
  207. <script type="text/javascript" src="../static/js/jquery-1.11.0.min.js"></script>
  208. <script type="text/javascript" src="helper.js"></script>
  209. <script type="text/javascript" src="pcm-player.js"></script>
  210. <script type="text/javascript" src="https://cdn.bootcss.com/vConsole/3.2.0/vconsole.min.js"></script>
  211. <script src="https://cdn.bootcss.com/jquery-weui/1.2.1/js/jquery-weui.min.js"></script>
  212. <script type="text/javascript" src="WXdraw.js"></script>
  213. <script type="text/javascript" src="jmuxer.js"></script>
  214. <script type="text/javascript" src="spsParser.js"></script>
  215. <script>
  216. var url = window.location.href;
  217. url = url.split('/');
  218. var baseUrl = url[0] + '//' + url[2];
  219. var parameters = GetRequest();
  220. var form = {};
  221. form.token = parameters['token'];
  222. form.userCardId = parameters['userCardId'];
  223. var videoTimer = null, videoTime = 0, adType = 0, sourceType = 0, disconnectionFlag = false, getDate = false;
  224. if (parameters['mealType'] === 'VIP') {
  225. $(".loading_sceen_pic").attr('src', '../static/img/home_bg_VIP.png');
  226. } else if (parameters['mealType'] === 'SVIP') {
  227. $(".loading_sceen_pic").attr('src', '../static/img/home_bg_SVIP.png');
  228. } else if (parameters['mealType'] === 'STAR') {
  229. $(".loading_sceen_pic").attr('src', '../static/img/home_bg_STAR.png');
  230. } else if (parameters['mealType'] === 'STARPRO') {
  231. $(".loading_sceen_pic").attr('src', '../static/img/home_bg_PRO.png');
  232. }
  233. adInit();
  234. var isAudioPlay = false;
  235. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  236. var video = document.getElementById("playerVideo");
  237. video.play();
  238. setTimeout(() => { // 抖音环境需要设置延时,不然会有video默认图显示
  239. $.alert({
  240. title: '提示',
  241. text: '开始使用云手机',
  242. onOK: function () {
  243. setTimeout(() => {
  244. isAudioPlay = true;
  245. }, 1000);
  246. }
  247. });
  248. }, 1000)
  249. } else {
  250. $.alert({
  251. title: '提示',
  252. text: '开始使用云手机',
  253. onOK: function () {
  254. var video = document.getElementById("playerVideo");
  255. video.play();
  256. isAudioPlay = true;
  257. }
  258. });
  259. }
  260. //云机倒计时
  261. let validTime = parameters['validTime'] || 10000;
  262. if(validTime > 32000) {
  263. validTime = 32000
  264. }
  265. let detailTime = validTime * 60 * 1000;
  266. setTimeout(() => {
  267. $('.bug-title').eq(0).text('尊敬的用户您的云手机试用时间已到期');
  268. getDate = true;
  269. $('.buy-phone-wrap').eq(0).show();
  270. }, detailTime)
  271. var topwinHeight = window.screen.height - window.innerHeight + 30; //计算title top 头部
  272. $('#wine').css({
  273. "width": window.screen.width,
  274. "height": window.screen.height - topwinHeight - 20,
  275. "position": "absolute"
  276. });
  277. $('.loading').css({
  278. "width": window.screen.width,
  279. "height": window.screen.height - topwinHeight - 20
  280. });
  281. var winese = document.createElement("wine");
  282. wine.style.top = "-" + winese + 'px';
  283. var isVisuable = true;
  284. var isFeed = true;
  285. var isFinish = false;
  286. var isWaitSps = false;
  287. var myVideo = document.getElementById("playerVideo");
  288. Module = {};
  289. Module.onRuntimeInitialized = function () {
  290. isFinish = true;
  291. }
  292. var isWSS = true;
  293. var ip = parameters["ip"];
  294. var cardToken = parameters["cardToken"];
  295. cardToken = cardToken && cardToken.replace(/@/g, "=");
  296. var appletPushAddress = parameters["appletPushAddress"];
  297. // "&type=business"
  298. var socketURL = isWSS ? "wss://" + appletPushAddress + "?cardIp=" + ip + "&token=" + cardToken : "ws://" + appletPushAddress + "?cardIp=" + ip + "&token=" + cardToken;
  299. var jmuxer = new JMuxer({
  300. node: 'playerVideo',
  301. flushingTime: 33,
  302. fps: 30,
  303. mode: 'video',
  304. debug: false
  305. });
  306. window.onload = function () {
  307. var myPlay = document.getElementById("wine");
  308. myPlay.onkeydown = function (event) {
  309. ExexuteKeyDown(e.keyCode);
  310. }
  311. }
  312. var ws, errorTime = 0;
  313. doConnect();
  314. // 节流
  315. // 设置一个标志
  316. function throttle(fn, delay) {
  317. let flag = true;
  318. errorTime += delay;
  319. return () => {
  320. if (!flag) return;
  321. flag = false;
  322. timer = setTimeout(() => {
  323. fn();
  324. flag = true;
  325. }, delay);
  326. };
  327. }
  328. var intervaler;
  329. function doConnect() {
  330. ws = new WebSocket(socketURL);
  331. ws.binaryType = 'arraybuffer';
  332. intervaler = setInterval(() => {
  333. if (ws.readyState === 1) {
  334. ws.send("ping");
  335. } else {
  336. clearInterval(intervaler);
  337. $.toast("画面异常,请重新进入", "text");
  338. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  339. tt.miniProgram.switchTab({
  340. url: '/pages/home/home'
  341. })
  342. } else {
  343. wx.miniProgram.switchTab({
  344. url: '/pages/home/home'
  345. })
  346. }
  347. }
  348. }, 3000);
  349. ws.addEventListener('open', function (event) {
  350. // sn只要长度满足17位随机数,不需要从后台获取
  351. var verifyBuffer = VerifyCode('RK3923C1201900139', cardToken);
  352. console.log("鉴权报文:" + PrintArry(verifyBuffer));
  353. ws.send(verifyBuffer);
  354. });
  355. ws.addEventListener('error', function (event) {
  356. ws.close();
  357. clearInterval(intervaler);
  358. throttle(doConnect, 100);
  359. if (errorTime > 1000) {
  360. $.toast("画面异常,请重新进入", "text");
  361. wsss.close();
  362. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  363. tt.miniProgram.switchTab({
  364. url: '/pages/home/home'
  365. })
  366. } else {
  367. wx.miniProgram.switchTab({
  368. url: '/pages/home/home'
  369. })
  370. }
  371. }
  372. });
  373. ws.addEventListener('message', function (event) {
  374. var data = ParseProto(event.data); //JAVA服务器转发
  375. if (isAudioPlay) {
  376. $('.weui-mask_transparent').hide();
  377. $('.weui-toast').hide();
  378. $('.loading').hide();
  379. }
  380. var input = new Uint8Array(event.data);
  381. if (data.audio != null && isAudioPlay) { //喂音频
  382. if (input[0] == 0xff) {
  383. if (isFinish) {
  384. decodeAAC(input);
  385. }
  386. }
  387. }
  388. if (data.frameType != undefined && data.frameType != 1 && data.frameType != 6) {
  389. if (data.frameType == 7) {
  390. let info = spsParser(data.video);
  391. if (info.width != myVideo.videoWidth && info.height != myVideo.videoHeight) {
  392. if (myVideo.videoWidth == 0) {
  393. console.log("SPS计算得到宽 %d, 高 %d, 控件宽 %d, %d", info.width, info.height, myVideo.videoWidth, myVideo.videoHeight);
  394. }
  395. }
  396. }
  397. }
  398. if (data.video != null) { //喂视频
  399. if (data.frameType == 0x05 && isVisuable) {
  400. isFeed = true;
  401. }
  402. if (data.frameType == 7 || data.frameType == 8) {
  403. isFeed = true;
  404. isAudioPlay = true;
  405. isWaitSps = false;
  406. }
  407. if (isFeed) {
  408. if (!isWaitSps) {
  409. jmuxer.feed(data);
  410. }
  411. }
  412. }
  413. });
  414. }
  415. document.addEventListener("visibilitychange", function () {
  416. if (document.visibilityState == "visible") {
  417. var buffer = RequestIFrame();
  418. ws.send(buffer);
  419. isVisuable = true;
  420. } else {
  421. isVisuable = false;
  422. isFeed = false;
  423. myVideo.pause();
  424. }
  425. });
  426. myVideo.addEventListener('pause', function () {
  427. isFeed = false;
  428. });
  429. var decodeCount = 1;
  430. var player = new PCMPlayer({
  431. encoding: '16bitInt',
  432. channels: 2,
  433. sampleRate: 44100,
  434. flushingTime: 22,
  435. debug: false
  436. });
  437. function handleClose() {
  438. $('.mask').hide();
  439. }
  440. function decodeAAC(data) {
  441. var retPtr = Module._malloc(4 * 5 * 1024); // 接收的数据
  442. var inputPtr = Module._malloc(4 * data.length); // 输入数据
  443. for (var i = 0; i < data.length; i++) {
  444. Module.HEAPU8[(inputPtr) + i] = data[i]; //转换为堆数据
  445. }
  446. var pcmLen = Module._feedData(retPtr, inputPtr, data.length);
  447. if (pcmLen >= 0) {
  448. var pcmData = new Uint8Array(pcmLen);
  449. for (var i = 0; i < pcmLen; i++) {
  450. pcmData[i] = Module.HEAPU8[(retPtr) + i]
  451. }
  452. player.feed(pcmData);
  453. }
  454. decodeCount++;
  455. Module._free(inputPtr);
  456. Module._free(retPtr);
  457. }
  458. //解协议
  459. function ParseProto(data) {
  460. var input = new Uint8Array(data),
  461. duration,
  462. video,
  463. frameType,
  464. audio;
  465. if (input[0] == 0 && input[1] == 0 && input[2] == 0 && input[3] == 1) {
  466. video = input;
  467. duration = 24;
  468. var nalType = input[4] & 0x1f;
  469. frameType = nalType;
  470. if (!isFeed) {
  471. if (nalType == 0x05 && isVisuable) {
  472. isFeed = true;
  473. }
  474. }
  475. } else if (input[0] == 0xff) {
  476. audio = input;
  477. duration = 24;
  478. } else if (input[0] == 0x68) {
  479. if (input[23] == 0x5c) {
  480. console.log("收到消息:" + PrintArry(input));
  481. if (CheckVerifyCode(input)) {
  482. ws.send(ConfigChannel('RK3923C1201900139'));
  483. var checkBuffer = GetScreenState();
  484. ws.send(checkBuffer);
  485. }
  486. else {
  487. $.toast("画面异常,请重新进入", "text");
  488. clearInterval(intervaler);
  489. ws.close();
  490. wsss.close();
  491. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  492. tt.miniProgram.switchTab({
  493. url: '/pages/home/home'
  494. })
  495. } else {
  496. wx.miniProgram.switchTab({
  497. url: '/pages/home/home'
  498. })
  499. }
  500. }
  501. }
  502. if (input[23] == 0x05) { //横竖屏标识
  503. var state = CheckScreenDirection(input.slice(24, 24 + 8));
  504. if (state == 1) {
  505. console.log("安卓卡此时竖屏");
  506. //竖屏处理
  507. resolving = 1;
  508. } else {
  509. console.log("安卓卡此时横屏");
  510. //横屏处理
  511. resolving = 0;
  512. }
  513. }
  514. if (input[23] == 0x0B)//多端登录处理, 数据从索引24开始取, input 是接收到的原始数据
  515. {
  516. var jsonobj = checkMultiLoginInfo(input);
  517. }
  518. }
  519. return {
  520. audio: audio,
  521. video: video,
  522. duration: duration,
  523. frameType: frameType
  524. };
  525. }
  526. function GetRequest() {
  527. var url = location.search; // 获取url中"?"符后的字串
  528. var obj = new Object();
  529. if (url.indexOf("?") != -1) {
  530. var str = url.substr(1);
  531. strs = str.split("&");
  532. for (var i = 0; i < strs.length; i++) {
  533. obj[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
  534. }
  535. }
  536. return obj;
  537. }
  538. function Back() {
  539. ExexuteKeyDown(4);
  540. window.event.returnValue = false;
  541. return false;
  542. }
  543. var form = {};
  544. form.token = parameters['token'];
  545. form.userCardId = parameters['userCardId'];
  546. function array_unique(arr) {
  547. return arr.filter(function (e, i) {
  548. return arr.indexOf(e) === i;
  549. })
  550. }
  551. var cutList = [];
  552. let timer, isFlag = true;
  553. function showShearPlate() {
  554. if (!isControl) {
  555. return
  556. }
  557. stopManyClick(() => {
  558. $('.box-shear-plate').empty();
  559. $.ajax({
  560. url: baseUrl + "/api/public/v5/shear/content",
  561. headers: {
  562. 'Authorization': form.token
  563. },
  564. type: 'get',
  565. dataType: 'json',
  566. success: function (res) {
  567. if (res.status === 0) {
  568. if (res.data.length) {
  569. cutList = array_unique(res.data)
  570. var str = '<div class="title">剪贴板<div onclick="handleClear()" class="btn-clear">清空</div></div><div class="slide-wrapper-content">'
  571. cutList.forEach(function (item) {
  572. 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>"
  573. })
  574. str += '</div>'
  575. $('.box-shear-plate').append(str);
  576. } else {
  577. $('.box-shear-plate').append('<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>')
  578. }
  579. $('.mask').show();
  580. initSlider();
  581. } else {
  582. $('.box-shear-plate').append('<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>')
  583. $('.mask').show();
  584. }
  585. }
  586. })
  587. })
  588. }
  589. //防止提示一秒内重复显示
  590. function stopManyClick(fn) {
  591. if (isFlag) {
  592. fn();
  593. }
  594. isFlag = false;
  595. if (timer) { clearTimeout(timer); }
  596. timer = setTimeout(() => { isFlag = true }, 1500);
  597. }
  598. // 清空剪贴板
  599. function handleClear() {
  600. var ids = '';
  601. cutList.forEach(function (item) {
  602. ids += 'ids=' + item.id + '&'
  603. });
  604. ids = ids.substring(0, ids.lastIndexOf('&'));
  605. $.confirm("确定清空剪贴板?", function () {
  606. $.ajax({
  607. url: baseUrl + "/api/public/v5/shear/content?" + ids,
  608. headers: {
  609. 'Authorization': form.token
  610. },
  611. type: 'DELETE',
  612. dataType: 'json',
  613. success: function (res) {
  614. if (res.status === 0) {
  615. showShearPlate();
  616. } else {
  617. $.toast(res.msg, "text");
  618. }
  619. }
  620. })
  621. });
  622. }
  623. function handleCopy(content) {
  624. var cutting = {
  625. "type": "cutting",
  626. "data": {
  627. "str": content
  628. }
  629. };
  630. wsss.send(JSON.stringify(cutting));
  631. }
  632. // 删除剪贴板
  633. function handleDelete(id) {
  634. $.ajax({
  635. url: baseUrl + "/api/public/v5/shear/content?ids=" + id,
  636. headers: {
  637. 'Authorization': form.token
  638. },
  639. type: 'DELETE',
  640. dataType: 'json',
  641. success: function (res) {
  642. if (res.status === 0) {
  643. showShearPlate();
  644. } else {
  645. $.toast(res.msg, "text");
  646. }
  647. }
  648. })
  649. }
  650. function initSlider() {
  651. //手指滑动多少距离就认为是滑成功
  652. //这个值不能太大,否则影响斜着滑动时,垂直滑动的流畅性,也不能太小,太灵敏也不好
  653. var diffXDistance = 50;
  654. //当前滑动的对象
  655. var currentObject;
  656. //上一次滑动的对象
  657. var lastObject;
  658. //是否可以左右滑动,在上下滑的时候禁止左右滑
  659. var canSlide = true;
  660. //用于记录按下的点
  661. var startPoint;
  662. $(".slide-content").css({
  663. width: $(".slide-wrapper").width()
  664. });
  665. document.body.removeEventListener('touchmove', function (e) {
  666. e.preventDefault()
  667. }, {
  668. passive: false
  669. })
  670. $(".slide-scroll").css({
  671. width: $(".slide-wrapper").width() + $(".slide-content-button").width()
  672. }).on('touchstart', function (e) {
  673. currentObject = this;
  674. startPoint = {
  675. x: e.originalEvent.changedTouches[0].pageX,
  676. y: e.originalEvent.changedTouches[0].pageY
  677. };
  678. }).on('touchmove', function (e) {
  679. //如果是左右滑动,就禁止上下的滑动
  680. //如果是上下的滑动,就禁止左右滑动
  681. if (Math.abs(e.originalEvent.changedTouches[0].pageX - startPoint.x) > Math.abs(e.originalEvent.changedTouches[0].pageY - startPoint.y)) {
  682. event.preventDefault();
  683. } else {
  684. canSlide = false;
  685. }
  686. }).on('touchend', function (e) {
  687. //如果是上下滑动,这里就直接返回了
  688. if (!canSlide) {
  689. canSlide = true;
  690. return true;
  691. }
  692. //点击除当前左滑对象之外的任意其他位置
  693. if (lastObject && currentObject != lastObject) {
  694. //右滑→
  695. $(lastObject).removeClass("animate-slide");
  696. //清空上一个左滑的对象
  697. lastObject = undefined;
  698. }
  699. var diffX = e.originalEvent.changedTouches[0].pageX - startPoint.x;
  700. if (diffX < -diffXDistance) {
  701. //左滑←
  702. $(currentObject).addClass("animate-slide");
  703. if (lastObject && lastObject != currentObject) {
  704. //右滑→
  705. $(lastObject).removeClass("animate-slide");
  706. }
  707. //记录上一个左滑的对象
  708. lastObject = currentObject;
  709. } else if (diffX >= diffXDistance) {
  710. if (currentObject == lastObject) {
  711. //右滑→
  712. $(currentObject).removeClass("animate-slide");
  713. //清空上一个左滑的对象
  714. lastObject = undefined;
  715. }
  716. }
  717. });
  718. }
  719. var btnMuted = document.querySelector("#btnMuted");
  720. btnMuted && (function () {
  721. var setHistory = function (left, top) {
  722. try {
  723. localStorage.setItem("muted-btn-loc", JSON.stringify({
  724. left: left,
  725. top: top
  726. }));
  727. } catch (ex) { }
  728. };
  729. var getHistory = function () {
  730. try {
  731. var value = localStorage.getItem("muted-btn-loc");
  732. if (!value) return null;
  733. value = JSON.parse(value);
  734. if (!value) return null;
  735. return value;
  736. } catch (ex) {
  737. return null
  738. }
  739. };
  740. var fixLoc = function (loc) {
  741. var rect = btnMuted.getBoundingClientRect();
  742. rect = {
  743. top: rect.top,
  744. left: rect.left,
  745. width: rect.width,
  746. height: rect.height
  747. }; //部分低版本浏览器,该属性为只读
  748. if (loc) {
  749. rect.left = loc.left;
  750. rect.top = loc.top;
  751. }
  752. var minX = 0;
  753. var minY = 0;
  754. var docRect = document.documentElement.getBoundingClientRect();
  755. var maxY = docRect.height - rect.height;
  756. var maxX = docRect.width - rect.width;
  757. var left = rect.left;
  758. var top = rect.top;
  759. left = Math.min(left, maxX);
  760. left = Math.max(left, minX);
  761. top = Math.min(top, maxY);
  762. top = Math.max(top, minY);
  763. if (loc || top !== rect.top || left !== rect.left) {
  764. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  765. }
  766. }
  767. window.addEventListener("resize", function () {
  768. fixLoc();
  769. });
  770. var touchPoint = {
  771. pageY: 0,
  772. pageX: 0
  773. };
  774. var currentLoc = {
  775. top: 0,
  776. left: 0,
  777. curTop: 0,
  778. curLeft: 0
  779. };
  780. var toMove = false;
  781. var touchmove = function (e) {
  782. e.preventDefault();
  783. var point = e.changedTouches[0];
  784. var top = -touchPoint.pageY + point.pageY;
  785. var left = -touchPoint.pageX + point.pageX;
  786. if (toMove) {
  787. top += currentLoc.top;
  788. left += currentLoc.left;
  789. currentLoc.curLeft = left;
  790. currentLoc.curTop = top;
  791. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  792. } else {
  793. if (Math.abs(top) >= 5 || Math.abs(left) >= 5) {
  794. toMove = true;
  795. }
  796. }
  797. };
  798. var touchend = function () {
  799. window.removeEventListener("touchmove", touchmove, {
  800. passive: false
  801. });
  802. window.removeEventListener("touchend", touchend, {
  803. passive: false
  804. });
  805. if (toMove) {
  806. setHistory(currentLoc.curLeft, currentLoc.curTop);
  807. fixLoc();
  808. } else {
  809. //按点击处理
  810. var set = $('.control-right-img').attr("data-id")
  811. if (set == '1') {
  812. $('.control-right-img').attr({
  813. "data-id": "2"
  814. })
  815. $(".leftmains").css({
  816. "right": "0rem"
  817. })
  818. } else {
  819. $('.control-right-img').attr({
  820. "data-id": "1"
  821. })
  822. $(".leftmains").css({
  823. "right": "-4rem"
  824. })
  825. }
  826. }
  827. }
  828. btnMuted.addEventListener("touchstart", function (e) {
  829. e.preventDefault();
  830. toMove = false;
  831. var point = e.changedTouches[0];
  832. touchPoint.pageX = point.pageX;
  833. touchPoint.pageY = point.pageY;
  834. var rect = e.target.getBoundingClientRect();
  835. currentLoc.top = rect.top;
  836. currentLoc.left = rect.left;
  837. window.addEventListener("touchmove", touchmove, {
  838. passive: false
  839. });
  840. window.addEventListener("touchend", touchend, {
  841. passive: false
  842. });
  843. }, {
  844. passive: false
  845. });
  846. var history = getHistory();
  847. if (history) {
  848. fixLoc(history);
  849. }
  850. btnMuted.classList.remove("hide");
  851. })();
  852. $("#upload").on("click", function () {
  853. clearInterval(intervaler);
  854. ws.close();
  855. wsss.close();
  856. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  857. tt.miniProgram.switchTab({
  858. url: '/pages/home/home'
  859. })
  860. } else {
  861. wx.miniProgram.switchTab({
  862. url: '/pages/home/home'
  863. })
  864. }
  865. })
  866. function selectText(x) {
  867. if (document.selection) {
  868. var range = document.body.createTextRange();
  869. range.moveToElementText(x);
  870. range.select();
  871. } else if (window.getSelection) {
  872. var selection = window.getSelection();
  873. var range = document.createRange();
  874. selection.removeAllRanges();
  875. range.selectNodeContents(x);
  876. selection.addRange(range);
  877. }
  878. }
  879. // 激活码广告相关配置
  880. function getConfigByPhoneType() {
  881. return new Promise((resolve, reject) => {
  882. $.ajax({
  883. url: baseUrl + "/api/pay/v5/trialCodeConfig/getConfigByPhoneType",
  884. headers: {
  885. 'Authorization': form.token
  886. },
  887. data: {
  888. userCardId: form.userCardId,
  889. phoneType: form.mealType
  890. },
  891. type: 'get',
  892. dataType: 'json',
  893. success: function (res) {
  894. console.log(res)
  895. let obj = res.data;
  896. if (res.status === 0) {
  897. resolve(obj)
  898. } else {
  899. $.toast(res.msg, "text");
  900. }
  901. }
  902. })
  903. })
  904. }
  905. //列表
  906. function getSetmealList() {
  907. return new Promise((resolve, reject) => {
  908. $.ajax({
  909. url: baseUrl + "/api/resources/v4/freetrial/setmeal/list",
  910. headers: {
  911. 'Authorization': form.token
  912. },
  913. type: 'get',
  914. dataType: 'json',
  915. success: function (res) {
  916. if (res.status === 0) {
  917. let list = res.data;
  918. list.map((item) => {
  919. if(item.phoneType === parameters['mealType']){
  920. resolve(item)
  921. }
  922. })
  923. } else {
  924. $.toast(res.msg, "text");
  925. }
  926. }
  927. })
  928. })
  929. }
  930. //广告信息
  931. function adInit() {
  932. sourceType = parameters['sourceType'];
  933. if(sourceType == 1) {
  934. getSetmealList().then((res) => {
  935. if(res.pushFlowAdvert === 1){
  936. getAdList(15);
  937. }
  938. if(res.intervalSwitch === 1) {
  939. let time = res.intervalAdvertDuration * 60 * 1000;
  940. setInterval(() => {
  941. $('.try-use-wrap').eq(0).hide();
  942. getAdList(16);
  943. }, time);
  944. }
  945. })
  946. }else if(sourceType == 2) {
  947. getConfigByPhoneType().then((res) => {
  948. if(res.isDisconnectionTime === 1){
  949. let time = res.disconnectionTime * 60 * 1000;
  950. setTimeout(() => {
  951. disconnectionFlag = true;
  952. $('.buy-phone-wrap').eq(0).show();
  953. }, time);
  954. }
  955. if(res.isShowAd === 1){
  956. getAdList(15);
  957. }
  958. if(res.isIntervalPlayAd === 1) {
  959. let time = res.intervalPlayAdTime * 60 * 1000;
  960. setInterval(() => {
  961. $('.try-use-wrap').eq(0).hide();
  962. getAdList(16);
  963. }, time);
  964. }
  965. })
  966. }
  967. }
  968. // 广告接口
  969. function getAdList(type){
  970. adType = type;
  971. $.ajax({
  972. url: baseUrl + "/api/public/v5/advertising/getAdInfoByAdPlace",
  973. headers: {
  974. 'Authorization': form.token
  975. },
  976. data: JSON.stringify({
  977. adPlace: type,
  978. os: 0
  979. }),
  980. type: 'POST',
  981. dataType: 'json',
  982. contentType: "application/json;charset=UTF-8",
  983. success: function (res) {
  984. if (res.status === 0) {
  985. let list = res.data;
  986. let indexs = Math.floor(Math.random()*list.length);
  987. videoTime = list[indexs].forcedTime;
  988. // $('#source').src = list[0].adVideoBase.videoUrl;
  989. $("#source").attr("src", list[indexs].adVideoBase.videoUrl);//更新url
  990. $("#source").attr("autoplay", "true");//直接播放
  991. videoTimer = setInterval(() =>{
  992. if(videoTime > 0) {
  993. videoTime--;
  994. $('.time-node').eq(0).text(videoTime + 's');
  995. } else {
  996. clearInterval(videoTimer);
  997. $('.time-node').eq(0).text('');
  998. }
  999. },1000)
  1000. if (adType === 16 && sourceType == 1) { // 间隔广告和试用才上报
  1001. report(0);
  1002. }
  1003. $('.try-use-wrap').eq(0).show();
  1004. } else {
  1005. $.toast(res.msg, "text");
  1006. }
  1007. }
  1008. })
  1009. }
  1010. //间隔广告上报
  1011. function report(type) {
  1012. $.ajax({
  1013. url: baseUrl + "/api/resources/v1/trial/report",
  1014. headers: {
  1015. 'Authorization': form.token
  1016. },
  1017. data: JSON.stringify({
  1018. userCardId: form.userCardId,
  1019. reportType: type
  1020. }),
  1021. type: 'POST',
  1022. dataType: 'json',
  1023. contentType: "application/json;charset=UTF-8",
  1024. success: function (res) {}
  1025. })
  1026. }
  1027. //关闭广告
  1028. $('.time-close-wrap')[0].addEventListener('click', () => {
  1029. $('.buy-phone-wrap').eq(0).show();
  1030. })
  1031. // 点击取消
  1032. $('.cannel-btn')[0].addEventListener('click', () => {
  1033. $('.buy-phone-wrap').eq(0).hide();
  1034. if (disconnectionFlag || getDate) {//设置了断线时间,取消直接退出
  1035. systemBuriedPoint('激活码-断线-取消');
  1036. wx.miniProgram.switchTab({
  1037. url: '/pages/home/home'
  1038. })
  1039. return
  1040. }
  1041. let pointName = '';
  1042. if(sourceType == 1){
  1043. pointName = videoTime == 0 ? '免费试用-关闭-取消' : '免费试用-强制关闭-取消';
  1044. } else {
  1045. pointName = videoTime == 0 ? '激活码-关闭-取消' : '激活码-强制关闭-取消';
  1046. }
  1047. systemBuriedPoint(pointName);
  1048. if(videoTime == 0) {
  1049. if (adType === 16 && sourceType == 1) {
  1050. report(1);
  1051. }
  1052. $('.try-use-wrap').eq(0).hide();
  1053. return
  1054. }
  1055. $('.look-wrap').eq(0).show();
  1056. })
  1057. // 点击去购买
  1058. $('.go-bug')[0].addEventListener('click', () => {
  1059. let pointName = '';
  1060. if(disconnectionFlag) {
  1061. pointName = '激活码-断线-去购买';
  1062. } else if(sourceType == 1){
  1063. pointName = videoTime == 0 ? '免费试用-关闭-去购买' : '免费试用-强制关闭-去购买';
  1064. } else {
  1065. pointName = videoTime == 0 ? '激活码-关闭-去购买' : '激活码-强制关闭-去购买';
  1066. }
  1067. systemBuriedPoint(pointName);
  1068. if(getDate){
  1069. wx.miniProgram.navigateTo({
  1070. url: '/packageA/order/buy/index'
  1071. })
  1072. } else {
  1073. wx.miniProgram.navigateTo({
  1074. url: '/packageA/order/renew/index?record=' + form.userCardId
  1075. })
  1076. }
  1077. })
  1078. // 放弃
  1079. $('.cannel-ad-btn')[0].addEventListener('click', () => {
  1080. if(sourceType == 1){
  1081. systemBuriedPoint('免费试用-强制关闭-放弃');
  1082. } else {
  1083. systemBuriedPoint('激活码-强制关闭-放弃');
  1084. }
  1085. wx.miniProgram.switchTab({
  1086. url: '/pages/home/home'
  1087. })
  1088. })
  1089. // 继续观看
  1090. $('.looking')[0].addEventListener('click', () => {
  1091. $('.look-wrap').eq(0).hide();
  1092. if(sourceType == 1){
  1093. systemBuriedPoint('免费试用-强制关闭-继续观看');
  1094. } else {
  1095. systemBuriedPoint('激活码-强制关闭-继续观看');
  1096. }
  1097. })
  1098. // 埋点
  1099. function systemBuriedPoint(pointName){
  1100. $.ajax({
  1101. url: baseUrl + "/api/public/v1/systemBuriedPoint/stat",
  1102. headers: {
  1103. 'Authorization': form.token
  1104. },
  1105. type: 'post',
  1106. data:JSON.stringify({
  1107. pointName: pointName
  1108. }),
  1109. contentType:"application/json",
  1110. dataType: 'json',
  1111. success: function (res) {}
  1112. })
  1113. }
  1114. window.onbeforeunload = function () {
  1115. ws.close();
  1116. wsss.close();
  1117. }
  1118. </script>
  1119. <script type="text/javascript" src="aac.js"></script>
  1120. </body>
  1121. </html>