WXtrialInterface.html 38 KB

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