WXtrialInterface.html 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589
  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
  10. name="viewport"
  11. content="width=device-width, initial-scale=1, user-scalable=no"
  12. />
  13. <meta name="apple-mobile-web-app-capable" content="yes" />
  14. <!-- 删除苹果默认的工具栏和菜单栏 -->
  15. <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  16. <!-- 设置苹果工具栏颜? -->
  17. <meta name="format-detection" content="telphone=no, email=no" />
  18. <!-- 忽略页面中的数字识别为电话,忽略email识别 -->
  19. <!-- 启用360浏览器的极速模?(webkit) -->
  20. <meta name="renderer" content="webkit" />
  21. <!-- 针对手持设备优化,主要是针对一些老的不识别viewport的浏览器,比如黑? -->
  22. <meta name="HandheldFriendly" content="true" />
  23. <!-- 微软的老式浏览? -->
  24. <meta name="MobileOptimized" content="320" />
  25. <!-- 不能旋转,问题出在这 -->
  26. <!-- UC强制全屏 -->
  27. <meta name="full-screen" content="yes" />
  28. <!-- QQ强制全屏 -->
  29. <meta name="x5-fullscreen" content="true" />
  30. <!-- UC应用模式 -->
  31. <meta name="browsermode" content="application" />
  32. <!-- QQ应用模式 -->
  33. <meta name="x5-page-mode" content="app" />
  34. <!-- windows phone 点击无高? -->
  35. <meta name="msapplication-tap-highlight" content="no" />
  36. <link rel="stylesheet" type="text/css" href="css/WXtrialInterface.css" />
  37. <link
  38. rel="stylesheet"
  39. href="https://cdn.bootcss.com/weui/1.1.3/style/weui.min.css"
  40. />
  41. <link
  42. rel="stylesheet"
  43. href="https://cdn.bootcss.com/jquery-weui/1.2.1/css/jquery-weui.min.css"
  44. />
  45. </head>
  46. <body class="scroll h-player" style="overscroll-behavior: contain">
  47. <div class="container" id="player">
  48. <div class="muted" id="btnMuted">
  49. <div class="control-right-img" data-id="1">
  50. <img src="../static/img/xuanfu_icon.png" />
  51. </div>
  52. </div>
  53. <div id="wine">
  54. <video
  55. id="playerVideo"
  56. x5-video-orientation="landscape"
  57. playsinline="true"
  58. autoplay="true"
  59. webkit-playsinline="true"
  60. x5-playsinline="true"
  61. x5-video-player-type="h5"
  62. x5-video-player-fullscreen="false"
  63. style="
  64. pointer-events: none;
  65. object-fit: fill;
  66. width: 100%;
  67. height: 100%;
  68. "
  69. ></video>
  70. <div id="box"></div>
  71. <audio
  72. preload="auto"
  73. autoplay
  74. controls
  75. poster="images/loader-thumb.jpg"
  76. id="audioPlayer"
  77. style="position: absolute; top: 0; width: 0; height: 0"
  78. ></audio>
  79. </div>
  80. <div class="leftmains">
  81. <div class="PictureQualityMain">
  82. <div class="PictureQuality" data-id="4">高清</div>
  83. <div class="PictureQuality avit" data-id="3">标清</div>
  84. <div class="PictureQuality" data-id="2">极速</div>
  85. </div>
  86. <div class="operation">
  87. <div class="upload" id="showsuss" data-text="uploads">
  88. <img src="../static/img/wx/shangchuan_icon.png" />
  89. <div>上传</div>
  90. </div>
  91. <div class="upload" onclick="showShearPlate()" data-text="Shearplate">
  92. <img src="../static/img/wx/jianqieban_icon.png" />
  93. <div>剪贴板</div>
  94. </div>
  95. <div class="upload" id="upload" data-text="Signout">
  96. <img src="../static/img/wx/tuichu_icon.png" />
  97. <div>退出</div>
  98. </div>
  99. </div>
  100. </div>
  101. <div class="bottommains">
  102. <div class="botmat1">
  103. <div class="botmat1img" data-text="gengduo">
  104. <img src="../static/img/wx/gengduo_icon.png" />
  105. </div>
  106. </div>
  107. <div class="botmat1">
  108. <div class="botmat1img" data-text="home">
  109. <img src="../static/img/wx/home_icon.png" />
  110. </div>
  111. </div>
  112. <div class="botmat1">
  113. <div class="botmat1img" data-text="return">
  114. <img src="../static/img/wx/fanhui_icon.png" />
  115. </div>
  116. </div>
  117. </div>
  118. <img class="loading loading_sceen_pic" />
  119. </div>
  120. <div class="mask">
  121. <div class="box-shear-plate"></div>
  122. <img
  123. class="close"
  124. onclick="handleClose()"
  125. src="img/guanbi_icon@2x.png"
  126. alt=""
  127. />
  128. </div>
  129. <div class="weui-mask_transparent"></div>
  130. <div class="weui-toast weui_loading_toast weui-toast--visible">
  131. <div class="weui_loading">
  132. <i class="weui-loading weui-icon_toast"></i>
  133. </div>
  134. <p class="weui-toast_content">数据加载中</p>
  135. </div>
  136. <div class="try-use-wrap">
  137. <div class="try-use-container">
  138. <video
  139. width="100%"
  140. height="100%"
  141. id="source"
  142. autoplay="autoplay"
  143. loop="loop"
  144. webkit-playsinline="true"
  145. playsinline="true"
  146. x5-video-player-type="h5-page"
  147. >
  148. 您的浏览器不支持 video 标签。
  149. </video>
  150. <div class="time-close-wrap"><span class="time-node"></span> 关闭</div>
  151. </div>
  152. </div>
  153. <div class="buy-phone-wrap">
  154. <div class="bug-wrap">
  155. <div class="bug-title">获得极致体验服务请购买云手机</div>
  156. <div class="btn-list">
  157. <div class="btn cannel-btn">取消</div>
  158. <div class="btn go-bug">去购买</div>
  159. </div>
  160. </div>
  161. </div>
  162. <div class="look-wrap">
  163. <div class="bug-wrap">
  164. <div class="bug-title">关闭广告会退出云手机是否继续观看</div>
  165. <div class="btn-list">
  166. <div class="btn cannel-btn cannel-ad-btn">放弃</div>
  167. <div class="btn go-bug looking">继续观看</div>
  168. </div>
  169. </div>
  170. </div>
  171. <body oncontextmenu="Back()"></body>
  172. <script
  173. type="text/javascript"
  174. src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"
  175. ></script>
  176. <script src="https://lf1-cdn-tos.bytegoofy.com/goofy/developer/jssdk/jssdk-1.0.3.js"></script>
  177. <script
  178. type="text/javascript"
  179. src="../static/js/jquery-1.11.0.min.js"
  180. ></script>
  181. <script type="text/javascript" src="helper.js"></script>
  182. <script type="text/javascript" src="pcm-player.js"></script>
  183. <script
  184. type="text/javascript"
  185. src="https://cdn.bootcss.com/vConsole/3.2.0/vconsole.min.js"
  186. ></script>
  187. <script src="https://cdn.bootcss.com/jquery-weui/1.2.1/js/jquery-weui.min.js"></script>
  188. <script type="text/javascript" src="jmuxer.js"></script>
  189. <script type="text/javascript" src="spsParser.js"></script>
  190. <script
  191. type="text/javascript"
  192. src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js"
  193. ></script>
  194. <script>
  195. var url = window.location.href;
  196. url = url.split('/');
  197. var baseUrl = url[0] + '//' + url[2];
  198. var parameters = GetRequest();
  199. var token = parameters['token'];
  200. var userCardId = parameters['userCardId'];
  201. var mealType = parameters['mealType'];
  202. var videoTimer = null,
  203. videoTime = 0,
  204. adType = 0,
  205. sourceType = isNaN(parameters['sourceType'])
  206. ? 0
  207. : +parameters['sourceType'],
  208. disconnectionFlag = false,
  209. getDate = false;
  210. var isDev =
  211. /^192\.168\./.test(location.host) ||
  212. /^127\.0\.0\.1/.test(location.host) ||
  213. /^localhost/.test(location.host);
  214. if (isDev) {
  215. baseUrl = 'http://gntest.phone.androidscloud.com:1280';
  216. sourceType = 2;
  217. }
  218. if (parameters['mealType'] === 'VIP') {
  219. $('.loading_sceen_pic').attr('src', '../static/img/home_bg_VIP.png');
  220. } else if (parameters['mealType'] === 'SVIP') {
  221. $('.loading_sceen_pic').attr('src', '../static/img/home_bg_SVIP.png');
  222. } else if (parameters['mealType'] === 'STAR') {
  223. $('.loading_sceen_pic').attr('src', '../static/img/home_bg_STAR.png');
  224. } else if (parameters['mealType'] === 'STARPRO') {
  225. $('.loading_sceen_pic').attr('src', '../static/img/home_bg_PRO.png');
  226. }
  227. initAD();
  228. let dbName = parameters['username'],
  229. version = 1,
  230. storeName = 'usercard';
  231. let indexedDB = window.indexedDB;
  232. let db, socketURL, cUrl, cardToken, resolvingPower;
  233. const request = indexedDB.open(dbName, version);
  234. request.onsuccess = function (event) {
  235. db = event.target.result; // 数据库对象
  236. console.log('数据库打开成功');
  237. };
  238. request.onerror = function (event) {
  239. console.log('数据库打开报错');
  240. };
  241. request.onupgradeneeded = function (event) {
  242. // 数据库创建或升级的时候会触发
  243. console.log('onupgradeneeded');
  244. db = event.target.result; // 数据库对象
  245. let objectStore;
  246. if (!db.objectStoreNames.contains(storeName)) {
  247. objectStore = db.createObjectStore(storeName, { keyPath: 'id' }); // 创建表
  248. }
  249. };
  250. // 添加数据
  251. function addData(db, storeName, data) {
  252. let request = db
  253. .transaction([storeName], 'readwrite') // 事务对象 指定表格名称和操作模式("只读"或"读写")
  254. .objectStore(storeName) // 仓库对象
  255. .add(data);
  256. request.onsuccess = function (event) {
  257. console.log('数据写入成功');
  258. };
  259. request.onerror = function (event) {
  260. console.log('数据写入失败');
  261. throw new Error(event.target.error);
  262. };
  263. }
  264. // 根据id获取数据
  265. function getDataByKey(db, storeName, key) {
  266. let transaction = db.transaction([storeName]); // 事务
  267. let objectStore = transaction.objectStore(storeName); // 仓库对象
  268. let request = objectStore.get(key);
  269. request.onerror = function (event) {
  270. connect('add');
  271. };
  272. request.onsuccess = function (event) {
  273. console.log('主键查询结果: ', request.result);
  274. if (request.result) {
  275. socketURL = request.result.socketURL;
  276. cUrl = request.result.cUrl;
  277. cardToken = request.result.cardToken;
  278. resolvingPower = request.result.resolvingPower;
  279. doConnectBusiness();
  280. doConnectDirectives();
  281. } else {
  282. connect('add');
  283. }
  284. };
  285. }
  286. // 根据id修改数
  287. function updateDB(db, storeName, data) {
  288. let request = db
  289. .transaction([storeName], 'readwrite') // 事务对象
  290. .objectStore(storeName) // 仓库对象
  291. .put(data);
  292. request.onsuccess = function () {
  293. console.log('数据更新成功');
  294. };
  295. request.onerror = function () {
  296. console.log('数据更新失败');
  297. };
  298. }
  299. // 由于打开indexDB是异步的加个定时器避免 db对象还没获取到值导致 报错
  300. setTimeout(() => {
  301. getDataByKey(db, storeName, userCardId);
  302. }, 1000);
  303. var isAudioPlay = false;
  304. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  305. var video = document.getElementById('playerVideo');
  306. video.play();
  307. setTimeout(() => {
  308. // 抖音环境需要设置延时,不然会有video默认图显示
  309. $.alert({
  310. title: '提示',
  311. text: '开始使用云手机',
  312. onOK: function () {
  313. setTimeout(() => {
  314. isAudioPlay = true;
  315. }, 1000);
  316. },
  317. });
  318. }, 1000);
  319. } else {
  320. $.alert({
  321. title: '提示',
  322. text: '开始使用云手机',
  323. onOK: function () {
  324. var video = document.getElementById('playerVideo');
  325. video.play();
  326. isAudioPlay = true;
  327. },
  328. });
  329. }
  330. //云机倒计时
  331. let validTime = parameters['validTime'] || 10000;
  332. if (validTime > 32000) {
  333. validTime = 32000;
  334. }
  335. let detailTime = validTime * 60 * 1000;
  336. setTimeout(() => {
  337. $('.bug-title').eq(0).text('尊敬的用户您的云手机试用时间已到期');
  338. getDate = true;
  339. $('.buy-phone-wrap').eq(0).show();
  340. }, detailTime);
  341. var topwinHeight = window.screen.height - window.innerHeight + 30; //计算title top 头部
  342. $('#wine').css({
  343. width: window.screen.width,
  344. height: window.screen.height - topwinHeight - 20,
  345. position: 'absolute',
  346. });
  347. $('.loading').css({
  348. width: window.screen.width,
  349. height: window.screen.height - topwinHeight - 20,
  350. });
  351. var winese = document.createElement('wine');
  352. wine.style.top = '-' + winese + 'px';
  353. var isVisuable = true;
  354. var isFeed = true;
  355. var isFinish = false;
  356. var myVideo = document.getElementById('playerVideo');
  357. Module = {};
  358. Module.onRuntimeInitialized = function () {
  359. isFinish = true;
  360. };
  361. var timerInterval = null, timeInterval = 0;
  362. function connect(type) {
  363. $.ajax({
  364. url: baseUrl + '/api/resources/user/cloud/connect',
  365. type: 'post',
  366. data: JSON.stringify({
  367. userCardId: Number(userCardId),
  368. }),
  369. headers: {
  370. 'content-Type': 'application/json',
  371. Authorization: token,
  372. },
  373. dataType: 'json',
  374. async: false,
  375. success: function (res) {
  376. if (res.status === 0) {
  377. if (timerInterval) {
  378. timerInterval = clearTimeout();
  379. }
  380. if (res.data.internetHttps) {
  381. socketURL =
  382. 'wss://' +
  383. res.data.internetHttps +
  384. '/plugflow?cardIp=' +
  385. res.data.localIp +
  386. '&token=' +
  387. res.data.cardToken +
  388. '&type=business';
  389. cUrl =
  390. 'wss://' +
  391. res.data.internetHttps +
  392. '/businessChannel?cardIp=' +
  393. res.data.localIp +
  394. '&token=' +
  395. res.data.cardToken +
  396. '&type=directives';
  397. cardToken = res.data.cardToken;
  398. resolvingPower = res.data.resolvingPower;
  399. doConnectBusiness();
  400. doConnectDirectives();
  401. if (type === 'add') {
  402. addData(db, storeName, {
  403. id: userCardId,
  404. socketURL: socketURL,
  405. cUrl: cUrl,
  406. cardToken: res.data.cardToken,
  407. resolvingPower: res.data.resolvingPower,
  408. });
  409. } else {
  410. updateDB(db, storeName, {
  411. id: userCardId,
  412. socketURL: socketURL,
  413. cUrl: cUrl,
  414. cardToken: res.data.cardToken,
  415. resolvingPower: res.data.resolvingPower,
  416. });
  417. }
  418. } else {
  419. $.toast('网络异常,请稍后重试', 'text');
  420. setTimeout(() => {
  421. clearInterval(intervaler);
  422. quit();
  423. }, 3000);
  424. }
  425. } else if (res.status === 5200) {
  426. if (timeInterval > 7) {
  427. $.toast('网络异常,请稍后重试', 'text');
  428. setTimeout(() => {
  429. clearInterval(intervaler);
  430. quit();
  431. }, 3000);
  432. timerInterval = clearTimeout()
  433. return
  434. }
  435. timerInterval = setTimeout(() => {
  436. connect(type);
  437. timeInterval += 1;
  438. }, 3000)
  439. } else {
  440. $.toast('画面异常,请重新进入', 'text');
  441. setTimeout(() => {
  442. clearInterval(intervaler);
  443. quit();
  444. }, 3000);
  445. }
  446. },
  447. });
  448. }
  449. var jmuxer = new JMuxer({
  450. node: 'playerVideo',
  451. flushingTime: 33,
  452. fps: 30,
  453. mode: 'video',
  454. debug: false,
  455. });
  456. window.onload = function () {
  457. var myPlay = document.getElementById('wine');
  458. myPlay.onkeydown = function (event) {
  459. ExexuteKeyDown(e.keyCode);
  460. };
  461. };
  462. var ws,
  463. errorTime = 0;
  464. // 节流
  465. // 设置一个标志
  466. function throttle(fn, delay) {
  467. let flag = true;
  468. errorTime += delay;
  469. return () => {
  470. if (!flag) return;
  471. flag = false;
  472. timer = setTimeout(() => {
  473. fn();
  474. flag = true;
  475. }, delay);
  476. };
  477. }
  478. var intervaler;
  479. function doConnectBusiness() {
  480. ws = new WebSocket(socketURL);
  481. ws.binaryType = 'arraybuffer';
  482. intervaler = setInterval(() => {
  483. if (ws.readyState === 1) {
  484. ws.send('ping');
  485. } else {
  486. clearInterval(intervaler);
  487. $.toast('画面异常,请重新进入', 'text');
  488. setTimeout(() => {
  489. quit();
  490. }, 3000)
  491. }
  492. }, 3000);
  493. ws.addEventListener('open', function (event) {
  494. // sn只要长度满足17位随机数,不需要从后台获取
  495. var verifyBuffer = VerifyCode('RK3923C1201900139', cardToken);
  496. console.log('鉴权报文:' + PrintArry(verifyBuffer));
  497. ws.send(verifyBuffer);
  498. });
  499. ws.addEventListener('error', function (event) {
  500. ws.close();
  501. clearInterval(intervaler);
  502. throttle(doConnectBusiness, 100);
  503. if (errorTime > 1000) {
  504. $.toast('画面异常,请重新进入', 'text');
  505. setTimeout(() => {
  506. wsss.close();
  507. quit();
  508. }, 3000)
  509. }
  510. });
  511. ws.addEventListener('message', function (event) {
  512. var data = ParseProto(event.data); //JAVA服务器转发
  513. if (isAudioPlay) {
  514. $('.weui-mask_transparent').hide();
  515. $('.weui-toast').hide();
  516. $('.loading').hide();
  517. }
  518. var input = new Uint8Array(event.data);
  519. if (data.audio != null && isAudioPlay) {
  520. //喂音频
  521. if (input[0] == 0xff) {
  522. if (isFinish) {
  523. decodeAAC(input);
  524. }
  525. }
  526. }
  527. if (
  528. data.frameType != undefined &&
  529. data.frameType != 1 &&
  530. data.frameType != 6
  531. ) {
  532. if (data.frameType == 7) {
  533. let info = spsParser(data.video);
  534. if (
  535. info.width != myVideo.videoWidth &&
  536. info.height != myVideo.videoHeight
  537. ) {
  538. if (myVideo.videoWidth == 0) {
  539. console.log(
  540. 'SPS计算得到宽 %d, 高 %d, 控件宽 %d, %d',
  541. info.width,
  542. info.height,
  543. myVideo.videoWidth,
  544. myVideo.videoHeight,
  545. );
  546. }
  547. }
  548. }
  549. }
  550. if (data.video != null) {
  551. //喂视频
  552. if (data.frameType == 0x05 && isVisuable) {
  553. isFeed = true;
  554. }
  555. if (data.frameType == 7 || data.frameType == 8) {
  556. isFeed = true;
  557. isAudioPlay = true;
  558. }
  559. if (isFeed) {
  560. jmuxer.feed(data);
  561. }
  562. }
  563. });
  564. }
  565. var hidden, visibilityChange;
  566. if (typeof document.hidden !== 'undefined') {
  567. // Opera 12.10 and Firefox 18 and later support
  568. hidden = 'hidden';
  569. visibilityChange = 'visibilitychange';
  570. } else if (typeof document.msHidden !== 'undefined') {
  571. hidden = 'msHidden';
  572. visibilityChange = 'msvisibilitychange';
  573. } else if (typeof document.webkitHidden !== 'undefined') {
  574. hidden = 'webkitHidden';
  575. visibilityChange = 'webkitvisibilitychange';
  576. }
  577. // 处理页面可见属性的改变
  578. document.addEventListener(
  579. 'visibilitychange',
  580. function () {
  581. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  582. visibilitychange();
  583. } else if (window.__wxjs_environment === 'miniprogram') {
  584. visibilitychange();
  585. } else {
  586. if (document[hidden]) {
  587. ws.close();
  588. wsss.close();
  589. uni.webView.navigateBack({
  590. delta: 1
  591. });
  592. }
  593. }
  594. },
  595. false,
  596. );
  597. function visibilitychange() {
  598. if (document.visibilityState == 'visible') {
  599. var buffer = RequestIFrame();
  600. ws.send(buffer);
  601. isVisuable = true;
  602. } else {
  603. isVisuable = false;
  604. isFeed = false;
  605. myVideo.pause();
  606. }
  607. }
  608. myVideo.addEventListener('pause', function () {
  609. isFeed = false;
  610. });
  611. var decodeCount = 1;
  612. var player = new PCMPlayer({
  613. encoding: '16bitInt',
  614. channels: 2,
  615. sampleRate: 44100,
  616. flushingTime: 22,
  617. debug: false,
  618. });
  619. function handleClose() {
  620. $('.mask').hide();
  621. }
  622. function decodeAAC(data) {
  623. var retPtr = Module._malloc(4 * 5 * 1024); // 接收的数据
  624. var inputPtr = Module._malloc(4 * data.length); // 输入数据
  625. for (var i = 0; i < data.length; i++) {
  626. Module.HEAPU8[inputPtr + i] = data[i]; //转换为堆数据
  627. }
  628. var pcmLen = Module._feedData(retPtr, inputPtr, data.length);
  629. if (pcmLen >= 0) {
  630. var pcmData = new Uint8Array(pcmLen);
  631. for (var i = 0; i < pcmLen; i++) {
  632. pcmData[i] = Module.HEAPU8[retPtr + i];
  633. }
  634. player.feed(pcmData);
  635. }
  636. decodeCount++;
  637. Module._free(inputPtr);
  638. Module._free(retPtr);
  639. }
  640. //解协议
  641. function ParseProto(data) {
  642. var input = new Uint8Array(data),
  643. duration,
  644. video,
  645. frameType,
  646. audio;
  647. if (input[0] == 0 && input[1] == 0 && input[2] == 0 && input[3] == 1) {
  648. video = input;
  649. duration = 24;
  650. var nalType = input[4] & 0x1f;
  651. frameType = nalType;
  652. if (!isFeed) {
  653. if (nalType == 0x05 && isVisuable) {
  654. isFeed = true;
  655. }
  656. }
  657. } else if (input[0] == 0xff) {
  658. audio = input;
  659. duration = 24;
  660. } else if (input[0] == 0x68) {
  661. if (input[23] == 0x5c) {
  662. console.log('收到消息:' + PrintArry(input));
  663. if (CheckVerifyCode(input)) {
  664. ws.send(ConfigChannel('RK3923C1201900139'));
  665. var checkBuffer = GetScreenState();
  666. ws.send(checkBuffer);
  667. } else {
  668. connect('update');
  669. }
  670. }
  671. if (input[23] == 0x05) {
  672. //横竖屏标识
  673. var state = CheckScreenDirection(input.slice(24, 24 + 8));
  674. if (state == 1) {
  675. console.log('安卓卡此时竖屏');
  676. //竖屏处理
  677. resolving = 1;
  678. } else {
  679. console.log('安卓卡此时横屏');
  680. //横屏处理
  681. resolving = 0;
  682. }
  683. }
  684. if (input[23] == 0x0b) {
  685. //多端登录处理, 数据从索引24开始取, input 是接收到的原始数据
  686. var jsonobj = checkMultiLoginInfo(input);
  687. }
  688. }
  689. return {
  690. audio: audio,
  691. video: video,
  692. duration: duration,
  693. frameType: frameType,
  694. };
  695. }
  696. function GetRequest() {
  697. var url = location.search; // 获取url中"?"符后的字串
  698. var obj = new Object();
  699. if (url.indexOf('?') != -1) {
  700. var str = url.substr(1);
  701. strs = str.split('&');
  702. for (var i = 0; i < strs.length; i++) {
  703. obj[strs[i].split('=')[0]] = strs[i].split('=')[1];
  704. }
  705. }
  706. return obj;
  707. }
  708. function Back() {
  709. ExexuteKeyDown(4);
  710. window.event.returnValue = false;
  711. return false;
  712. }
  713. function array_unique(arr) {
  714. return arr.filter(function (e, i) {
  715. return arr.indexOf(e) === i;
  716. });
  717. }
  718. var cutList = [];
  719. let timer,
  720. isFlag = true;
  721. function showShearPlate() {
  722. if (!isControl) {
  723. return;
  724. }
  725. stopManyClick(() => {
  726. new Promise((resolve, reject) => {
  727. if (window.navigator.clipboard) {
  728. window.navigator.clipboard
  729. .readText()
  730. .then(
  731. function (content) {
  732. return $.ajax({
  733. url: baseUrl + '/api/public/v5/shear/content',
  734. type: 'post',
  735. dataType: 'json',
  736. data: JSON.stringify({
  737. content: content,
  738. }),
  739. headers: {
  740. 'content-Type': 'application/json',
  741. Authorization: token,
  742. },
  743. });
  744. },
  745. function (err) {
  746. $.toast('读取剪贴板失败', 'text');
  747. },
  748. )
  749. .finally(resolve);
  750. } else {
  751. resolve();
  752. }
  753. }).then(function () {
  754. $('.box-shear-plate').empty();
  755. $.ajax({
  756. url: baseUrl + '/api/public/v5/shear/content',
  757. headers: {
  758. Authorization: token,
  759. },
  760. type: 'get',
  761. dataType: 'json',
  762. success: function (res) {
  763. if (res.status === 0) {
  764. if (res.data.length) {
  765. cutList = array_unique(res.data);
  766. var str =
  767. '<div class="title">剪贴板<div onclick="handleClear()" class="btn-clear">清空</div></div><div class="slide-wrapper-content">';
  768. cutList.forEach(function (item) {
  769. str +=
  770. "<div class='slide-wrapper'><div class='slide-scroll animate-slide-start'><div class='slide-content'><div onclick='handleCopy(\"" +
  771. item.content +
  772. '")\'>' +
  773. item.content +
  774. "</div></div><div class='slide-content-button'><button onclick='handleDelete(" +
  775. item.id +
  776. ")'>删除</button></div></div></div>";
  777. });
  778. str += '</div>';
  779. $('.box-shear-plate').append(str);
  780. } else {
  781. $('.box-shear-plate').append(
  782. '<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>',
  783. );
  784. }
  785. $('.mask').show();
  786. initSlider();
  787. } else {
  788. $('.box-shear-plate').append(
  789. '<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>',
  790. );
  791. $('.mask').show();
  792. }
  793. },
  794. });
  795. });
  796. });
  797. }
  798. //防止提示一秒内重复显示
  799. function stopManyClick(fn) {
  800. if (isFlag) {
  801. fn();
  802. }
  803. isFlag = false;
  804. if (timer) {
  805. clearTimeout(timer);
  806. }
  807. timer = setTimeout(() => {
  808. isFlag = true;
  809. }, 1500);
  810. }
  811. // 清空剪贴板
  812. function handleClear() {
  813. var ids = '';
  814. cutList.forEach(function (item) {
  815. ids += 'ids=' + item.id + '&';
  816. });
  817. ids = ids.substring(0, ids.lastIndexOf('&'));
  818. $.confirm('确定清空剪贴板?', function () {
  819. $.ajax({
  820. url: baseUrl + '/api/public/v5/shear/content?' + ids,
  821. headers: {
  822. Authorization: token,
  823. },
  824. type: 'DELETE',
  825. dataType: 'json',
  826. success: function (res) {
  827. if (res.status === 0) {
  828. showShearPlate();
  829. } else {
  830. $.toast(res.msg, 'text');
  831. }
  832. },
  833. });
  834. });
  835. }
  836. function handleCopy(content) {
  837. var cutting = {
  838. type: 'cutting',
  839. data: {
  840. str: content,
  841. },
  842. };
  843. wsss.send(JSON.stringify(cutting));
  844. }
  845. // 删除剪贴板
  846. function handleDelete(id) {
  847. $.ajax({
  848. url: baseUrl + '/api/public/v5/shear/content?ids=' + id,
  849. headers: {
  850. Authorization: token,
  851. },
  852. type: 'DELETE',
  853. dataType: 'json',
  854. success: function (res) {
  855. if (res.status === 0) {
  856. showShearPlate();
  857. } else {
  858. $.toast(res.msg, 'text');
  859. }
  860. },
  861. });
  862. }
  863. function initSlider() {
  864. //手指滑动多少距离就认为是滑成功
  865. //这个值不能太大,否则影响斜着滑动时,垂直滑动的流畅性,也不能太小,太灵敏也不好
  866. var diffXDistance = 50;
  867. //当前滑动的对象
  868. var currentObject;
  869. //上一次滑动的对象
  870. var lastObject;
  871. //是否可以左右滑动,在上下滑的时候禁止左右滑
  872. var canSlide = true;
  873. //用于记录按下的点
  874. var startPoint;
  875. $('.slide-content').css({
  876. width: $('.slide-wrapper').width(),
  877. });
  878. document.body.removeEventListener(
  879. 'touchmove',
  880. function (e) {
  881. e.preventDefault();
  882. },
  883. {
  884. passive: false,
  885. },
  886. );
  887. $('.slide-scroll')
  888. .css({
  889. width:
  890. $('.slide-wrapper').width() + $('.slide-content-button').width(),
  891. })
  892. .on('touchstart', function (e) {
  893. currentObject = this;
  894. startPoint = {
  895. x: e.originalEvent.changedTouches[0].pageX,
  896. y: e.originalEvent.changedTouches[0].pageY,
  897. };
  898. })
  899. .on('touchmove', function (e) {
  900. //如果是左右滑动,就禁止上下的滑动
  901. //如果是上下的滑动,就禁止左右滑动
  902. if (
  903. Math.abs(e.originalEvent.changedTouches[0].pageX - startPoint.x) >
  904. Math.abs(e.originalEvent.changedTouches[0].pageY - startPoint.y)
  905. ) {
  906. event.preventDefault();
  907. } else {
  908. canSlide = false;
  909. }
  910. })
  911. .on('touchend', function (e) {
  912. //如果是上下滑动,这里就直接返回了
  913. if (!canSlide) {
  914. canSlide = true;
  915. return true;
  916. }
  917. //点击除当前左滑对象之外的任意其他位置
  918. if (lastObject && currentObject != lastObject) {
  919. //右滑→
  920. $(lastObject).removeClass('animate-slide');
  921. //清空上一个左滑的对象
  922. lastObject = undefined;
  923. }
  924. var diffX = e.originalEvent.changedTouches[0].pageX - startPoint.x;
  925. if (diffX < -diffXDistance) {
  926. //左滑←
  927. $(currentObject).addClass('animate-slide');
  928. if (lastObject && lastObject != currentObject) {
  929. //右滑→
  930. $(lastObject).removeClass('animate-slide');
  931. }
  932. //记录上一个左滑的对象
  933. lastObject = currentObject;
  934. } else if (diffX >= diffXDistance) {
  935. if (currentObject == lastObject) {
  936. //右滑→
  937. $(currentObject).removeClass('animate-slide');
  938. //清空上一个左滑的对象
  939. lastObject = undefined;
  940. }
  941. }
  942. });
  943. }
  944. var btnMuted = document.querySelector('#btnMuted');
  945. btnMuted &&
  946. (function () {
  947. var setHistory = function (left, top) {
  948. try {
  949. localStorage.setItem(
  950. 'muted-btn-loc',
  951. JSON.stringify({
  952. left: left,
  953. top: top,
  954. }),
  955. );
  956. } catch (ex) {}
  957. };
  958. var getHistory = function () {
  959. try {
  960. var value = localStorage.getItem('muted-btn-loc');
  961. if (!value) return null;
  962. value = JSON.parse(value);
  963. if (!value) return null;
  964. return value;
  965. } catch (ex) {
  966. return null;
  967. }
  968. };
  969. var fixLoc = function (loc) {
  970. var rect = btnMuted.getBoundingClientRect();
  971. rect = {
  972. top: rect.top,
  973. left: rect.left,
  974. width: rect.width,
  975. height: rect.height,
  976. }; //部分低版本浏览器,该属性为只读
  977. if (loc) {
  978. rect.left = loc.left;
  979. rect.top = loc.top;
  980. }
  981. var minX = 0;
  982. var minY = 0;
  983. var docRect = document.documentElement.getBoundingClientRect();
  984. var maxY = docRect.height - rect.height;
  985. var maxX = docRect.width - rect.width;
  986. var left = rect.left;
  987. var top = rect.top;
  988. left = Math.min(left, maxX);
  989. left = Math.max(left, minX);
  990. top = Math.min(top, maxY);
  991. top = Math.max(top, minY);
  992. if (loc || top !== rect.top || left !== rect.left) {
  993. btnMuted.style.cssText +=
  994. 'left:' + left + 'px;top:' + top + 'px;';
  995. }
  996. };
  997. window.addEventListener('resize', function () {
  998. fixLoc();
  999. });
  1000. var touchPoint = {
  1001. pageY: 0,
  1002. pageX: 0,
  1003. };
  1004. var currentLoc = {
  1005. top: 0,
  1006. left: 0,
  1007. curTop: 0,
  1008. curLeft: 0,
  1009. };
  1010. var toMove = false;
  1011. var touchmove = function (e) {
  1012. e.preventDefault();
  1013. var point = e.changedTouches[0];
  1014. var top = -touchPoint.pageY + point.pageY;
  1015. var left = -touchPoint.pageX + point.pageX;
  1016. if (toMove) {
  1017. top += currentLoc.top;
  1018. left += currentLoc.left;
  1019. currentLoc.curLeft = left;
  1020. currentLoc.curTop = top;
  1021. btnMuted.style.cssText +=
  1022. 'left:' + left + 'px;top:' + top + 'px;';
  1023. } else {
  1024. if (Math.abs(top) >= 5 || Math.abs(left) >= 5) {
  1025. toMove = true;
  1026. }
  1027. }
  1028. };
  1029. var touchend = function () {
  1030. window.removeEventListener('touchmove', touchmove, {
  1031. passive: false,
  1032. });
  1033. window.removeEventListener('touchend', touchend, {
  1034. passive: false,
  1035. });
  1036. if (toMove) {
  1037. setHistory(currentLoc.curLeft, currentLoc.curTop);
  1038. fixLoc();
  1039. } else {
  1040. //按点击处理
  1041. var set = $('.control-right-img').attr('data-id');
  1042. if (set == '1') {
  1043. $('.control-right-img').attr({
  1044. 'data-id': '2',
  1045. });
  1046. $('.leftmains').css({
  1047. right: '0rem',
  1048. });
  1049. } else {
  1050. $('.control-right-img').attr({
  1051. 'data-id': '1',
  1052. });
  1053. $('.leftmains').css({
  1054. right: '-4rem',
  1055. });
  1056. }
  1057. }
  1058. };
  1059. btnMuted.addEventListener(
  1060. 'touchstart',
  1061. function (e) {
  1062. e.preventDefault();
  1063. toMove = false;
  1064. var point = e.changedTouches[0];
  1065. touchPoint.pageX = point.pageX;
  1066. touchPoint.pageY = point.pageY;
  1067. var rect = e.target.getBoundingClientRect();
  1068. currentLoc.top = rect.top;
  1069. currentLoc.left = rect.left;
  1070. window.addEventListener('touchmove', touchmove, {
  1071. passive: false,
  1072. });
  1073. window.addEventListener('touchend', touchend, {
  1074. passive: false,
  1075. });
  1076. },
  1077. {
  1078. passive: false,
  1079. },
  1080. );
  1081. var history = getHistory();
  1082. if (history) {
  1083. fixLoc(history);
  1084. }
  1085. btnMuted.classList.remove('hide');
  1086. })();
  1087. $('#upload').on('click', function () {
  1088. clearInterval(intervaler);
  1089. quit();
  1090. ws.close();
  1091. wsss.close();
  1092. });
  1093. function selectText(x) {
  1094. if (document.selection) {
  1095. var range = document.body.createTextRange();
  1096. range.moveToElementText(x);
  1097. range.select();
  1098. } else if (window.getSelection) {
  1099. var selection = window.getSelection();
  1100. var range = document.createRange();
  1101. selection.removeAllRanges();
  1102. range.selectNodeContents(x);
  1103. selection.addRange(range);
  1104. }
  1105. }
  1106. // 激活码广告相关配置
  1107. function getConfigByPhoneType() {
  1108. return new Promise((resolve, reject) => {
  1109. $.ajax({
  1110. url: baseUrl + '/api/pay/v5/trialCodeConfig/getConfigByPhoneType',
  1111. headers: {
  1112. Authorization: token,
  1113. },
  1114. data: {
  1115. userCardId: userCardId,
  1116. phoneType: mealType,
  1117. },
  1118. type: 'get',
  1119. dataType: 'json',
  1120. success: function (res) {
  1121. let obj = res.data;
  1122. if (res.status === 0) {
  1123. resolve(obj);
  1124. } else {
  1125. $.toast(res.msg, 'text');
  1126. }
  1127. },
  1128. });
  1129. });
  1130. }
  1131. //列表
  1132. function getSetmealList() {
  1133. return new Promise((resolve, reject) => {
  1134. $.ajax({
  1135. url: baseUrl + '/api/resources/v4/freetrial/setmeal/list',
  1136. headers: {
  1137. Authorization: token,
  1138. },
  1139. type: 'get',
  1140. dataType: 'json',
  1141. success: function (res) {
  1142. if (res.status === 0) {
  1143. let list = res.data;
  1144. list.map((item) => {
  1145. if (item.phoneType === parameters['mealType']) {
  1146. resolve(item);
  1147. }
  1148. });
  1149. } else {
  1150. $.toast(res.msg, 'text');
  1151. }
  1152. },
  1153. });
  1154. });
  1155. }
  1156. //广告信息
  1157. var adData = null; // 广告数据
  1158. var adLastTime = 0; // 广告时间
  1159. var intervalTime = 0; // 间隔时间
  1160. // let adType = 0;
  1161. console.log(
  1162. '🚀 ~ file: WXtrialInterface.html ~ line 973 ~ sourceType',
  1163. sourceType,
  1164. );
  1165. // 拉取广告数据
  1166. function getAD() {
  1167. return $.ajax({
  1168. url: baseUrl + '/api/public/v5/advertising/getAdInfoByAdPlace',
  1169. headers: {
  1170. Authorization: token,
  1171. },
  1172. data: JSON.stringify({
  1173. adPlace: adType,
  1174. os: 0,
  1175. }),
  1176. type: 'POST',
  1177. dataType: 'json',
  1178. contentType: 'application/json;charset=UTF-8',
  1179. }).then(function (res) {
  1180. if (res.status === 0) {
  1181. var list = res.data.filter(
  1182. (v) => v.adType === 1 && !!v.adVideoBase.videoUrl,
  1183. );
  1184. adData = list[Math.floor(Math.random() * list.length)];
  1185. console.log(
  1186. '🚀 ~ file: WXtrialInterface.html ~ line 990 ~ getAD ~ adData',
  1187. adData,
  1188. );
  1189. return adData;
  1190. } else {
  1191. return Promise.reject(new Error(res.msg));
  1192. }
  1193. });
  1194. }
  1195. // 播放广告
  1196. function playAD() {
  1197. var nowTime = Date.now();
  1198. if (
  1199. adData &&
  1200. // [1, 2].includes(sourceType) &&
  1201. $('.try-use-wrap').eq(0).is(':hidden') &&
  1202. nowTime > adLastTime + intervalTime
  1203. ) {
  1204. $('#source').attr('src', adData.adVideoBase.videoUrl);
  1205. $('.try-use-wrap').eq(0).show();
  1206. $('#source')[0].play();
  1207. videoTime = adData.forcedTime;
  1208. adData = null;
  1209. adLastTime = nowTime;
  1210. videoTimer = setInterval(() => {
  1211. if (videoTime > 0) {
  1212. videoTime--;
  1213. $('.time-node')
  1214. .eq(0)
  1215. .text(videoTime + 's');
  1216. } else {
  1217. clearInterval(videoTimer);
  1218. $('.time-node').eq(0).text('');
  1219. }
  1220. }, 1000);
  1221. if (intervalTime > 0) {
  1222. // 间隔广告拉取下一次广告数据
  1223. adType = 16;
  1224. getAD();
  1225. }
  1226. if (adType === 16 && sourceType == 1) {
  1227. // 间隔广告和试用才上报
  1228. report(0);
  1229. }
  1230. }
  1231. }
  1232. /**
  1233. * 初始化广告
  1234. * 因移动端video无法自动播放,play()方法不能异步调用。
  1235. * 解决方案,初始化时预先请求广告数据,在用户对云手机touchmove事件中去播放广告并请求下一次广告数据。
  1236. */
  1237. function initAD() {
  1238. console.log(
  1239. '🚀 ~ file: WXtrialInterface.html ~ line 1052 ~ initAD ~ sourceType',
  1240. sourceType,
  1241. );
  1242. (function () {
  1243. switch (sourceType) {
  1244. case 1: {
  1245. return getSetmealList().then(function (res) {
  1246. intervalTime =
  1247. res.intervalSwitch === 1
  1248. ? res.intervalAdvertDuration * 1000 * 60
  1249. : 0;
  1250. if (res.pushFlowAdvert === 1) {
  1251. adType = 15;
  1252. adTime = 0;
  1253. } else if (intervalTime > 0) {
  1254. adType = 16;
  1255. adTime = date.now();
  1256. }
  1257. });
  1258. }
  1259. case 2: {
  1260. return getConfigByPhoneType().then(function (res) {
  1261. if (res.isDisconnectionTime === 1) {
  1262. var time = res.disconnectionTime * 60 * 1000;
  1263. setTimeout(() => {
  1264. disconnectionFlag = true;
  1265. $('.buy-phone-wrap').eq(0).show();
  1266. }, time);
  1267. }
  1268. intervalTime =
  1269. res.isIntervalPlayAd === 1
  1270. ? res.intervalPlayAdTime * 1000 * 60
  1271. : 0;
  1272. if (res.isShowAd === 1) {
  1273. adType = 15;
  1274. adTime = 0;
  1275. } else if (intervalTime > 0) {
  1276. adType = 16;
  1277. adTime = date.now();
  1278. }
  1279. });
  1280. }
  1281. default: {
  1282. return Promise.reject();
  1283. }
  1284. }
  1285. })().then(function () {
  1286. console.log(adType);
  1287. this.$('#wine').on('touchstart', playAD);
  1288. getAD();
  1289. });
  1290. }
  1291. //广告信息
  1292. // function adInit() {
  1293. // sourceType = parameters['sourceType'];
  1294. // if (sourceType == 1) {
  1295. // getSetmealList().then((res) => {
  1296. // if (res.pushFlowAdvert === 1) {
  1297. // getAdList(15);
  1298. // }
  1299. // if (res.intervalSwitch === 1) {
  1300. // let time = res.intervalAdvertDuration * 60 * 1000;
  1301. // setInterval(() => {
  1302. // $('.try-use-wrap').eq(0).hide();
  1303. // getAdList(16);
  1304. // }, time);
  1305. // }
  1306. // })
  1307. // } else if (sourceType == 2) {
  1308. // getConfigByPhoneType().then((res) => {
  1309. // if (res.isDisconnectionTime === 1) {
  1310. // let time = res.disconnectionTime * 60 * 1000;
  1311. // setTimeout(() => {
  1312. // disconnectionFlag = true;
  1313. // $('.buy-phone-wrap').eq(0).show();
  1314. // }, time);
  1315. // }
  1316. // if (res.isShowAd === 1) {
  1317. // getAdList(15);
  1318. // }
  1319. // if (res.isIntervalPlayAd === 1) {
  1320. // let time = res.intervalPlayAdTime * 60 * 1000;
  1321. // setInterval(() => {
  1322. // $('.try-use-wrap').eq(0).hide();
  1323. // getAdList(16);
  1324. // }, time);
  1325. // }
  1326. // })
  1327. // }
  1328. // }
  1329. // 广告接口
  1330. // function getAdList(type) {
  1331. // adType = type;
  1332. // $.ajax({
  1333. // url: baseUrl + '/api/public/v5/advertising/getAdInfoByAdPlace',
  1334. // headers: {
  1335. // Authorization: form.token,
  1336. // },
  1337. // data: JSON.stringify({
  1338. // adPlace: type,
  1339. // os: 0,
  1340. // }),
  1341. // type: 'POST',
  1342. // dataType: 'json',
  1343. // contentType: 'application/json;charset=UTF-8',
  1344. // success: function (res) {
  1345. // if (res.status === 0) {
  1346. // let list = res.data;
  1347. // let indexs = Math.floor(Math.random() * list.length);
  1348. // videoTime = list[indexs].forcedTime;
  1349. // // $('#source').src = list[0].adVideoBase.videoUrl;
  1350. // $('#source').attr('src', list[indexs].adVideoBase.videoUrl); //更新url
  1351. // $('#source').attr('autoplay', 'true'); //直接播放
  1352. // videoTimer = setInterval(() => {
  1353. // if (videoTime > 0) {
  1354. // videoTime--;
  1355. // $('.time-node')
  1356. // .eq(0)
  1357. // .text(videoTime + 's');
  1358. // } else {
  1359. // clearInterval(videoTimer);
  1360. // $('.time-node').eq(0).text('');
  1361. // }
  1362. // }, 1000);
  1363. // if (adType === 16 && sourceType == 1) {
  1364. // // 间隔广告和试用才上报
  1365. // report(0);
  1366. // }
  1367. // $('.try-use-wrap').eq(0).show();
  1368. // } else {
  1369. // $.toast(res.msg, 'text');
  1370. // }
  1371. // },
  1372. // });
  1373. // }
  1374. //间隔广告上报
  1375. function report(type) {
  1376. $.ajax({
  1377. url: baseUrl + '/api/resources/v1/trial/report',
  1378. headers: {
  1379. Authorization: token,
  1380. },
  1381. data: JSON.stringify({
  1382. userCardId: userCardId,
  1383. reportType: type,
  1384. }),
  1385. type: 'POST',
  1386. dataType: 'json',
  1387. contentType: 'application/json;charset=UTF-8',
  1388. success: function (res) {},
  1389. });
  1390. }
  1391. // 观看广告次数上报
  1392. function reportFrequency() {
  1393. $.ajax({
  1394. url: baseUrl + '/api/resoures/v1/trial/reportFrequency/' + form.userCardId,
  1395. headers: {
  1396. Authorization: form.token
  1397. },
  1398. type: 'post',
  1399. contentType: 'application/json',
  1400. dataType: 'json',
  1401. success: function (res) {},
  1402. });
  1403. }
  1404. //关闭广告
  1405. $('.time-close-wrap')[0].addEventListener('click', () => {
  1406. if(videoTime == 0) {
  1407. reportFrequency()
  1408. }
  1409. $('.buy-phone-wrap').eq(0).show();
  1410. });
  1411. // 点击取消
  1412. $('.cannel-btn')[0].addEventListener('click', () => {
  1413. $('.buy-phone-wrap').eq(0).hide();
  1414. if (disconnectionFlag || getDate) {
  1415. //设置了断线时间,取消直接退出
  1416. systemBuriedPoint('激活码-断线-取消');
  1417. quit();
  1418. return;
  1419. }
  1420. let pointName = '';
  1421. if (sourceType == 1) {
  1422. pointName =
  1423. videoTime == 0 ? '免费试用-关闭-取消' : '免费试用-强制关闭-取消';
  1424. } else {
  1425. pointName =
  1426. videoTime == 0 ? '激活码-关闭-取消' : '激活码-强制关闭-取消';
  1427. }
  1428. systemBuriedPoint(pointName);
  1429. if (videoTime == 0) {
  1430. if (adType === 16 && sourceType == 1) {
  1431. report(1);
  1432. }
  1433. $('.try-use-wrap').eq(0).hide();
  1434. $('#source')[0].pause();
  1435. return;
  1436. }
  1437. $('.look-wrap').eq(0).show();
  1438. });
  1439. // 点击去购买
  1440. $('.go-bug')[0].addEventListener('click', () => {
  1441. let pointName = '';
  1442. if (disconnectionFlag) {
  1443. pointName = '激活码-断线-去购买';
  1444. } else if (sourceType == 1) {
  1445. pointName =
  1446. videoTime == 0
  1447. ? '免费试用-关闭-去购买'
  1448. : '免费试用-强制关闭-去购买';
  1449. } else {
  1450. pointName =
  1451. videoTime == 0 ? '激活码-关闭-去购买' : '激活码-强制关闭-去购买';
  1452. }
  1453. systemBuriedPoint(pointName);
  1454. if (getDate) {
  1455. wx.miniProgram.navigateTo({
  1456. url: '/packageA/order/buy/index?buyType=试用界面购买',
  1457. });
  1458. } else {
  1459. // 过期续费按钮进入
  1460. wx.miniProgram.navigateTo({
  1461. url:
  1462. `/packageA/order/renew/index?buyType=${
  1463. sourceType == 1
  1464. ? '试用弹窗购买按钮进入-普通试用'
  1465. : '试用弹窗购买按钮进入-激活码试用'
  1466. }&record=` + userCardId,
  1467. });
  1468. }
  1469. });
  1470. // 放弃
  1471. $('.cannel-ad-btn')[0].addEventListener('click', () => {
  1472. if (sourceType == 1) {
  1473. systemBuriedPoint('免费试用-强制关闭-放弃');
  1474. } else {
  1475. systemBuriedPoint('激活码-强制关闭-放弃');
  1476. }
  1477. quit();
  1478. });
  1479. // 继续观看
  1480. $('.looking')[0].addEventListener('click', () => {
  1481. $('.look-wrap').eq(0).hide();
  1482. if (sourceType == 1) {
  1483. systemBuriedPoint('免费试用-强制关闭-继续观看');
  1484. } else {
  1485. systemBuriedPoint('激活码-强制关闭-继续观看');
  1486. }
  1487. });
  1488. // 埋点
  1489. function systemBuriedPoint(pointName) {
  1490. $.ajax({
  1491. url: baseUrl + '/api/public/v1/systemBuriedPoint/stat',
  1492. headers: {
  1493. Authorization: token,
  1494. },
  1495. type: 'post',
  1496. data: JSON.stringify({
  1497. pointName: pointName,
  1498. }),
  1499. contentType: 'application/json',
  1500. dataType: 'json',
  1501. success: function (res) {},
  1502. });
  1503. }
  1504. function quit() {
  1505. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  1506. tt.miniProgram.switchTab({
  1507. url: '/pages/home/home',
  1508. });
  1509. } else if (window.__wxjs_environment === 'miniprogram') {
  1510. wx.miniProgram.switchTab({
  1511. url: '/pages/home/home',
  1512. });
  1513. } else {
  1514. uni.webView.navigateBack({
  1515. delta: 1
  1516. });
  1517. }
  1518. }
  1519. window.onbeforeunload = function () {
  1520. ws.close();
  1521. wsss.close();
  1522. };
  1523. </script>
  1524. <script type="text/javascript" src="WXdraw.js"></script>
  1525. <script type="text/javascript" src="aac.js"></script>
  1526. </body>
  1527. </html>