WXtrialInterface.html 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577
  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. }
  421. } else if (res.status === 5200) {
  422. if (timeInterval > 7) {
  423. $.toast('网络异常,请稍后重试', 'text');
  424. timerInterval = clearTimeout()
  425. return
  426. }
  427. timerInterval = setTimeout(() => {
  428. connect(type);
  429. timeInterval += 1;
  430. }, 3000)
  431. } else {
  432. $.toast('画面异常,请重新进入', 'text');
  433. clearInterval(intervaler);
  434. quit();
  435. ws.close();
  436. wsss.close();
  437. }
  438. },
  439. });
  440. }
  441. var jmuxer = new JMuxer({
  442. node: 'playerVideo',
  443. flushingTime: 33,
  444. fps: 30,
  445. mode: 'video',
  446. debug: false,
  447. });
  448. window.onload = function () {
  449. var myPlay = document.getElementById('wine');
  450. myPlay.onkeydown = function (event) {
  451. ExexuteKeyDown(e.keyCode);
  452. };
  453. };
  454. var ws,
  455. errorTime = 0;
  456. // 节流
  457. // 设置一个标志
  458. function throttle(fn, delay) {
  459. let flag = true;
  460. errorTime += delay;
  461. return () => {
  462. if (!flag) return;
  463. flag = false;
  464. timer = setTimeout(() => {
  465. fn();
  466. flag = true;
  467. }, delay);
  468. };
  469. }
  470. var intervaler;
  471. function doConnectBusiness() {
  472. ws = new WebSocket(socketURL);
  473. ws.binaryType = 'arraybuffer';
  474. intervaler = setInterval(() => {
  475. if (ws.readyState === 1) {
  476. ws.send('ping');
  477. } else {
  478. clearInterval(intervaler);
  479. $.toast('画面异常,请重新进入', 'text');
  480. quit();
  481. }
  482. }, 3000);
  483. ws.addEventListener('open', function (event) {
  484. // sn只要长度满足17位随机数,不需要从后台获取
  485. var verifyBuffer = VerifyCode('RK3923C1201900139', cardToken);
  486. console.log('鉴权报文:' + PrintArry(verifyBuffer));
  487. ws.send(verifyBuffer);
  488. });
  489. ws.addEventListener('error', function (event) {
  490. ws.close();
  491. clearInterval(intervaler);
  492. throttle(doConnectBusiness, 100);
  493. if (errorTime > 1000) {
  494. $.toast('画面异常,请重新进入', 'text');
  495. wsss.close();
  496. quit();
  497. }
  498. });
  499. ws.addEventListener('message', function (event) {
  500. var data = ParseProto(event.data); //JAVA服务器转发
  501. if (isAudioPlay) {
  502. $('.weui-mask_transparent').hide();
  503. $('.weui-toast').hide();
  504. $('.loading').hide();
  505. }
  506. var input = new Uint8Array(event.data);
  507. if (data.audio != null && isAudioPlay) {
  508. //喂音频
  509. if (input[0] == 0xff) {
  510. if (isFinish) {
  511. decodeAAC(input);
  512. }
  513. }
  514. }
  515. if (
  516. data.frameType != undefined &&
  517. data.frameType != 1 &&
  518. data.frameType != 6
  519. ) {
  520. if (data.frameType == 7) {
  521. let info = spsParser(data.video);
  522. if (
  523. info.width != myVideo.videoWidth &&
  524. info.height != myVideo.videoHeight
  525. ) {
  526. if (myVideo.videoWidth == 0) {
  527. console.log(
  528. 'SPS计算得到宽 %d, 高 %d, 控件宽 %d, %d',
  529. info.width,
  530. info.height,
  531. myVideo.videoWidth,
  532. myVideo.videoHeight,
  533. );
  534. }
  535. }
  536. }
  537. }
  538. if (data.video != null) {
  539. //喂视频
  540. if (data.frameType == 0x05 && isVisuable) {
  541. isFeed = true;
  542. }
  543. if (data.frameType == 7 || data.frameType == 8) {
  544. isFeed = true;
  545. isAudioPlay = true;
  546. }
  547. if (isFeed) {
  548. jmuxer.feed(data);
  549. }
  550. }
  551. });
  552. }
  553. var hidden, visibilityChange;
  554. if (typeof document.hidden !== 'undefined') {
  555. // Opera 12.10 and Firefox 18 and later support
  556. hidden = 'hidden';
  557. visibilityChange = 'visibilitychange';
  558. } else if (typeof document.msHidden !== 'undefined') {
  559. hidden = 'msHidden';
  560. visibilityChange = 'msvisibilitychange';
  561. } else if (typeof document.webkitHidden !== 'undefined') {
  562. hidden = 'webkitHidden';
  563. visibilityChange = 'webkitvisibilitychange';
  564. }
  565. // 处理页面可见属性的改变
  566. document.addEventListener(
  567. 'visibilitychange',
  568. function () {
  569. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  570. visibilitychange();
  571. } else if (window.__wxjs_environment === 'miniprogram') {
  572. visibilitychange();
  573. } else {
  574. if (document[hidden]) {
  575. ws.close();
  576. wsss.close();
  577. uni.webView.navigateBack({
  578. delta: 1
  579. });
  580. }
  581. }
  582. },
  583. false,
  584. );
  585. function visibilitychange() {
  586. if (document.visibilityState == 'visible') {
  587. var buffer = RequestIFrame();
  588. ws.send(buffer);
  589. isVisuable = true;
  590. } else {
  591. isVisuable = false;
  592. isFeed = false;
  593. myVideo.pause();
  594. }
  595. }
  596. myVideo.addEventListener('pause', function () {
  597. isFeed = false;
  598. });
  599. var decodeCount = 1;
  600. var player = new PCMPlayer({
  601. encoding: '16bitInt',
  602. channels: 2,
  603. sampleRate: 44100,
  604. flushingTime: 22,
  605. debug: false,
  606. });
  607. function handleClose() {
  608. $('.mask').hide();
  609. }
  610. function decodeAAC(data) {
  611. var retPtr = Module._malloc(4 * 5 * 1024); // 接收的数据
  612. var inputPtr = Module._malloc(4 * data.length); // 输入数据
  613. for (var i = 0; i < data.length; i++) {
  614. Module.HEAPU8[inputPtr + i] = data[i]; //转换为堆数据
  615. }
  616. var pcmLen = Module._feedData(retPtr, inputPtr, data.length);
  617. if (pcmLen >= 0) {
  618. var pcmData = new Uint8Array(pcmLen);
  619. for (var i = 0; i < pcmLen; i++) {
  620. pcmData[i] = Module.HEAPU8[retPtr + i];
  621. }
  622. player.feed(pcmData);
  623. }
  624. decodeCount++;
  625. Module._free(inputPtr);
  626. Module._free(retPtr);
  627. }
  628. //解协议
  629. function ParseProto(data) {
  630. var input = new Uint8Array(data),
  631. duration,
  632. video,
  633. frameType,
  634. audio;
  635. if (input[0] == 0 && input[1] == 0 && input[2] == 0 && input[3] == 1) {
  636. video = input;
  637. duration = 24;
  638. var nalType = input[4] & 0x1f;
  639. frameType = nalType;
  640. if (!isFeed) {
  641. if (nalType == 0x05 && isVisuable) {
  642. isFeed = true;
  643. }
  644. }
  645. } else if (input[0] == 0xff) {
  646. audio = input;
  647. duration = 24;
  648. } else if (input[0] == 0x68) {
  649. if (input[23] == 0x5c) {
  650. console.log('收到消息:' + PrintArry(input));
  651. if (CheckVerifyCode(input)) {
  652. ws.send(ConfigChannel('RK3923C1201900139'));
  653. var checkBuffer = GetScreenState();
  654. ws.send(checkBuffer);
  655. } else {
  656. connect('update');
  657. }
  658. }
  659. if (input[23] == 0x05) {
  660. //横竖屏标识
  661. var state = CheckScreenDirection(input.slice(24, 24 + 8));
  662. if (state == 1) {
  663. console.log('安卓卡此时竖屏');
  664. //竖屏处理
  665. resolving = 1;
  666. } else {
  667. console.log('安卓卡此时横屏');
  668. //横屏处理
  669. resolving = 0;
  670. }
  671. }
  672. if (input[23] == 0x0b) {
  673. //多端登录处理, 数据从索引24开始取, input 是接收到的原始数据
  674. var jsonobj = checkMultiLoginInfo(input);
  675. }
  676. }
  677. return {
  678. audio: audio,
  679. video: video,
  680. duration: duration,
  681. frameType: frameType,
  682. };
  683. }
  684. function GetRequest() {
  685. var url = location.search; // 获取url中"?"符后的字串
  686. var obj = new Object();
  687. if (url.indexOf('?') != -1) {
  688. var str = url.substr(1);
  689. strs = str.split('&');
  690. for (var i = 0; i < strs.length; i++) {
  691. obj[strs[i].split('=')[0]] = strs[i].split('=')[1];
  692. }
  693. }
  694. return obj;
  695. }
  696. function Back() {
  697. ExexuteKeyDown(4);
  698. window.event.returnValue = false;
  699. return false;
  700. }
  701. function array_unique(arr) {
  702. return arr.filter(function (e, i) {
  703. return arr.indexOf(e) === i;
  704. });
  705. }
  706. var cutList = [];
  707. let timer,
  708. isFlag = true;
  709. function showShearPlate() {
  710. if (!isControl) {
  711. return;
  712. }
  713. stopManyClick(() => {
  714. new Promise((resolve, reject) => {
  715. if (window.navigator.clipboard) {
  716. window.navigator.clipboard
  717. .readText()
  718. .then(
  719. function (content) {
  720. return $.ajax({
  721. url: baseUrl + '/api/public/v5/shear/content',
  722. type: 'post',
  723. dataType: 'json',
  724. data: JSON.stringify({
  725. content: content,
  726. }),
  727. headers: {
  728. 'content-Type': 'application/json',
  729. Authorization: token,
  730. },
  731. });
  732. },
  733. function (err) {
  734. $.toast('读取剪贴板失败', 'text');
  735. },
  736. )
  737. .finally(resolve);
  738. } else {
  739. resolve();
  740. }
  741. }).then(function () {
  742. $('.box-shear-plate').empty();
  743. $.ajax({
  744. url: baseUrl + '/api/public/v5/shear/content',
  745. headers: {
  746. Authorization: token,
  747. },
  748. type: 'get',
  749. dataType: 'json',
  750. success: function (res) {
  751. if (res.status === 0) {
  752. if (res.data.length) {
  753. cutList = array_unique(res.data);
  754. var str =
  755. '<div class="title">剪贴板<div onclick="handleClear()" class="btn-clear">清空</div></div><div class="slide-wrapper-content">';
  756. cutList.forEach(function (item) {
  757. str +=
  758. "<div class='slide-wrapper'><div class='slide-scroll animate-slide-start'><div class='slide-content'><div onclick='handleCopy(\"" +
  759. item.content +
  760. '")\'>' +
  761. item.content +
  762. "</div></div><div class='slide-content-button'><button onclick='handleDelete(" +
  763. item.id +
  764. ")'>删除</button></div></div></div>";
  765. });
  766. str += '</div>';
  767. $('.box-shear-plate').append(str);
  768. } else {
  769. $('.box-shear-plate').append(
  770. '<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>',
  771. );
  772. }
  773. $('.mask').show();
  774. initSlider();
  775. } else {
  776. $('.box-shear-plate').append(
  777. '<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>',
  778. );
  779. $('.mask').show();
  780. }
  781. },
  782. });
  783. });
  784. });
  785. }
  786. //防止提示一秒内重复显示
  787. function stopManyClick(fn) {
  788. if (isFlag) {
  789. fn();
  790. }
  791. isFlag = false;
  792. if (timer) {
  793. clearTimeout(timer);
  794. }
  795. timer = setTimeout(() => {
  796. isFlag = true;
  797. }, 1500);
  798. }
  799. // 清空剪贴板
  800. function handleClear() {
  801. var ids = '';
  802. cutList.forEach(function (item) {
  803. ids += 'ids=' + item.id + '&';
  804. });
  805. ids = ids.substring(0, ids.lastIndexOf('&'));
  806. $.confirm('确定清空剪贴板?', function () {
  807. $.ajax({
  808. url: baseUrl + '/api/public/v5/shear/content?' + ids,
  809. headers: {
  810. Authorization: token,
  811. },
  812. type: 'DELETE',
  813. dataType: 'json',
  814. success: function (res) {
  815. if (res.status === 0) {
  816. showShearPlate();
  817. } else {
  818. $.toast(res.msg, 'text');
  819. }
  820. },
  821. });
  822. });
  823. }
  824. function handleCopy(content) {
  825. var cutting = {
  826. type: 'cutting',
  827. data: {
  828. str: content,
  829. },
  830. };
  831. wsss.send(JSON.stringify(cutting));
  832. }
  833. // 删除剪贴板
  834. function handleDelete(id) {
  835. $.ajax({
  836. url: baseUrl + '/api/public/v5/shear/content?ids=' + id,
  837. headers: {
  838. Authorization: token,
  839. },
  840. type: 'DELETE',
  841. dataType: 'json',
  842. success: function (res) {
  843. if (res.status === 0) {
  844. showShearPlate();
  845. } else {
  846. $.toast(res.msg, 'text');
  847. }
  848. },
  849. });
  850. }
  851. function initSlider() {
  852. //手指滑动多少距离就认为是滑成功
  853. //这个值不能太大,否则影响斜着滑动时,垂直滑动的流畅性,也不能太小,太灵敏也不好
  854. var diffXDistance = 50;
  855. //当前滑动的对象
  856. var currentObject;
  857. //上一次滑动的对象
  858. var lastObject;
  859. //是否可以左右滑动,在上下滑的时候禁止左右滑
  860. var canSlide = true;
  861. //用于记录按下的点
  862. var startPoint;
  863. $('.slide-content').css({
  864. width: $('.slide-wrapper').width(),
  865. });
  866. document.body.removeEventListener(
  867. 'touchmove',
  868. function (e) {
  869. e.preventDefault();
  870. },
  871. {
  872. passive: false,
  873. },
  874. );
  875. $('.slide-scroll')
  876. .css({
  877. width:
  878. $('.slide-wrapper').width() + $('.slide-content-button').width(),
  879. })
  880. .on('touchstart', function (e) {
  881. currentObject = this;
  882. startPoint = {
  883. x: e.originalEvent.changedTouches[0].pageX,
  884. y: e.originalEvent.changedTouches[0].pageY,
  885. };
  886. })
  887. .on('touchmove', function (e) {
  888. //如果是左右滑动,就禁止上下的滑动
  889. //如果是上下的滑动,就禁止左右滑动
  890. if (
  891. Math.abs(e.originalEvent.changedTouches[0].pageX - startPoint.x) >
  892. Math.abs(e.originalEvent.changedTouches[0].pageY - startPoint.y)
  893. ) {
  894. event.preventDefault();
  895. } else {
  896. canSlide = false;
  897. }
  898. })
  899. .on('touchend', function (e) {
  900. //如果是上下滑动,这里就直接返回了
  901. if (!canSlide) {
  902. canSlide = true;
  903. return true;
  904. }
  905. //点击除当前左滑对象之外的任意其他位置
  906. if (lastObject && currentObject != lastObject) {
  907. //右滑→
  908. $(lastObject).removeClass('animate-slide');
  909. //清空上一个左滑的对象
  910. lastObject = undefined;
  911. }
  912. var diffX = e.originalEvent.changedTouches[0].pageX - startPoint.x;
  913. if (diffX < -diffXDistance) {
  914. //左滑←
  915. $(currentObject).addClass('animate-slide');
  916. if (lastObject && lastObject != currentObject) {
  917. //右滑→
  918. $(lastObject).removeClass('animate-slide');
  919. }
  920. //记录上一个左滑的对象
  921. lastObject = currentObject;
  922. } else if (diffX >= diffXDistance) {
  923. if (currentObject == lastObject) {
  924. //右滑→
  925. $(currentObject).removeClass('animate-slide');
  926. //清空上一个左滑的对象
  927. lastObject = undefined;
  928. }
  929. }
  930. });
  931. }
  932. var btnMuted = document.querySelector('#btnMuted');
  933. btnMuted &&
  934. (function () {
  935. var setHistory = function (left, top) {
  936. try {
  937. localStorage.setItem(
  938. 'muted-btn-loc',
  939. JSON.stringify({
  940. left: left,
  941. top: top,
  942. }),
  943. );
  944. } catch (ex) {}
  945. };
  946. var getHistory = function () {
  947. try {
  948. var value = localStorage.getItem('muted-btn-loc');
  949. if (!value) return null;
  950. value = JSON.parse(value);
  951. if (!value) return null;
  952. return value;
  953. } catch (ex) {
  954. return null;
  955. }
  956. };
  957. var fixLoc = function (loc) {
  958. var rect = btnMuted.getBoundingClientRect();
  959. rect = {
  960. top: rect.top,
  961. left: rect.left,
  962. width: rect.width,
  963. height: rect.height,
  964. }; //部分低版本浏览器,该属性为只读
  965. if (loc) {
  966. rect.left = loc.left;
  967. rect.top = loc.top;
  968. }
  969. var minX = 0;
  970. var minY = 0;
  971. var docRect = document.documentElement.getBoundingClientRect();
  972. var maxY = docRect.height - rect.height;
  973. var maxX = docRect.width - rect.width;
  974. var left = rect.left;
  975. var top = rect.top;
  976. left = Math.min(left, maxX);
  977. left = Math.max(left, minX);
  978. top = Math.min(top, maxY);
  979. top = Math.max(top, minY);
  980. if (loc || top !== rect.top || left !== rect.left) {
  981. btnMuted.style.cssText +=
  982. 'left:' + left + 'px;top:' + top + 'px;';
  983. }
  984. };
  985. window.addEventListener('resize', function () {
  986. fixLoc();
  987. });
  988. var touchPoint = {
  989. pageY: 0,
  990. pageX: 0,
  991. };
  992. var currentLoc = {
  993. top: 0,
  994. left: 0,
  995. curTop: 0,
  996. curLeft: 0,
  997. };
  998. var toMove = false;
  999. var touchmove = function (e) {
  1000. e.preventDefault();
  1001. var point = e.changedTouches[0];
  1002. var top = -touchPoint.pageY + point.pageY;
  1003. var left = -touchPoint.pageX + point.pageX;
  1004. if (toMove) {
  1005. top += currentLoc.top;
  1006. left += currentLoc.left;
  1007. currentLoc.curLeft = left;
  1008. currentLoc.curTop = top;
  1009. btnMuted.style.cssText +=
  1010. 'left:' + left + 'px;top:' + top + 'px;';
  1011. } else {
  1012. if (Math.abs(top) >= 5 || Math.abs(left) >= 5) {
  1013. toMove = true;
  1014. }
  1015. }
  1016. };
  1017. var touchend = function () {
  1018. window.removeEventListener('touchmove', touchmove, {
  1019. passive: false,
  1020. });
  1021. window.removeEventListener('touchend', touchend, {
  1022. passive: false,
  1023. });
  1024. if (toMove) {
  1025. setHistory(currentLoc.curLeft, currentLoc.curTop);
  1026. fixLoc();
  1027. } else {
  1028. //按点击处理
  1029. var set = $('.control-right-img').attr('data-id');
  1030. if (set == '1') {
  1031. $('.control-right-img').attr({
  1032. 'data-id': '2',
  1033. });
  1034. $('.leftmains').css({
  1035. right: '0rem',
  1036. });
  1037. } else {
  1038. $('.control-right-img').attr({
  1039. 'data-id': '1',
  1040. });
  1041. $('.leftmains').css({
  1042. right: '-4rem',
  1043. });
  1044. }
  1045. }
  1046. };
  1047. btnMuted.addEventListener(
  1048. 'touchstart',
  1049. function (e) {
  1050. e.preventDefault();
  1051. toMove = false;
  1052. var point = e.changedTouches[0];
  1053. touchPoint.pageX = point.pageX;
  1054. touchPoint.pageY = point.pageY;
  1055. var rect = e.target.getBoundingClientRect();
  1056. currentLoc.top = rect.top;
  1057. currentLoc.left = rect.left;
  1058. window.addEventListener('touchmove', touchmove, {
  1059. passive: false,
  1060. });
  1061. window.addEventListener('touchend', touchend, {
  1062. passive: false,
  1063. });
  1064. },
  1065. {
  1066. passive: false,
  1067. },
  1068. );
  1069. var history = getHistory();
  1070. if (history) {
  1071. fixLoc(history);
  1072. }
  1073. btnMuted.classList.remove('hide');
  1074. })();
  1075. $('#upload').on('click', function () {
  1076. clearInterval(intervaler);
  1077. quit();
  1078. ws.close();
  1079. wsss.close();
  1080. });
  1081. function selectText(x) {
  1082. if (document.selection) {
  1083. var range = document.body.createTextRange();
  1084. range.moveToElementText(x);
  1085. range.select();
  1086. } else if (window.getSelection) {
  1087. var selection = window.getSelection();
  1088. var range = document.createRange();
  1089. selection.removeAllRanges();
  1090. range.selectNodeContents(x);
  1091. selection.addRange(range);
  1092. }
  1093. }
  1094. // 激活码广告相关配置
  1095. function getConfigByPhoneType() {
  1096. return new Promise((resolve, reject) => {
  1097. $.ajax({
  1098. url: baseUrl + '/api/pay/v5/trialCodeConfig/getConfigByPhoneType',
  1099. headers: {
  1100. Authorization: token,
  1101. },
  1102. data: {
  1103. userCardId: userCardId,
  1104. phoneType: mealType,
  1105. },
  1106. type: 'get',
  1107. dataType: 'json',
  1108. success: function (res) {
  1109. let obj = res.data;
  1110. if (res.status === 0) {
  1111. resolve(obj);
  1112. } else {
  1113. $.toast(res.msg, 'text');
  1114. }
  1115. },
  1116. });
  1117. });
  1118. }
  1119. //列表
  1120. function getSetmealList() {
  1121. return new Promise((resolve, reject) => {
  1122. $.ajax({
  1123. url: baseUrl + '/api/resources/v4/freetrial/setmeal/list',
  1124. headers: {
  1125. Authorization: token,
  1126. },
  1127. type: 'get',
  1128. dataType: 'json',
  1129. success: function (res) {
  1130. if (res.status === 0) {
  1131. let list = res.data;
  1132. list.map((item) => {
  1133. if (item.phoneType === parameters['mealType']) {
  1134. resolve(item);
  1135. }
  1136. });
  1137. } else {
  1138. $.toast(res.msg, 'text');
  1139. }
  1140. },
  1141. });
  1142. });
  1143. }
  1144. //广告信息
  1145. var adData = null; // 广告数据
  1146. var adLastTime = 0; // 广告时间
  1147. var intervalTime = 0; // 间隔时间
  1148. // let adType = 0;
  1149. console.log(
  1150. '🚀 ~ file: WXtrialInterface.html ~ line 973 ~ sourceType',
  1151. sourceType,
  1152. );
  1153. // 拉取广告数据
  1154. function getAD() {
  1155. return $.ajax({
  1156. url: baseUrl + '/api/public/v5/advertising/getAdInfoByAdPlace',
  1157. headers: {
  1158. Authorization: token,
  1159. },
  1160. data: JSON.stringify({
  1161. adPlace: adType,
  1162. os: 0,
  1163. }),
  1164. type: 'POST',
  1165. dataType: 'json',
  1166. contentType: 'application/json;charset=UTF-8',
  1167. }).then(function (res) {
  1168. if (res.status === 0) {
  1169. var list = res.data.filter(
  1170. (v) => v.adType === 1 && !!v.adVideoBase.videoUrl,
  1171. );
  1172. adData = list[Math.floor(Math.random() * list.length)];
  1173. console.log(
  1174. '🚀 ~ file: WXtrialInterface.html ~ line 990 ~ getAD ~ adData',
  1175. adData,
  1176. );
  1177. return adData;
  1178. } else {
  1179. return Promise.reject(new Error(res.msg));
  1180. }
  1181. });
  1182. }
  1183. // 播放广告
  1184. function playAD() {
  1185. var nowTime = Date.now();
  1186. if (
  1187. adData &&
  1188. // [1, 2].includes(sourceType) &&
  1189. $('.try-use-wrap').eq(0).is(':hidden') &&
  1190. nowTime > adLastTime + intervalTime
  1191. ) {
  1192. $('#source').attr('src', adData.adVideoBase.videoUrl);
  1193. $('.try-use-wrap').eq(0).show();
  1194. $('#source')[0].play();
  1195. videoTime = adData.forcedTime;
  1196. adData = null;
  1197. adLastTime = nowTime;
  1198. videoTimer = setInterval(() => {
  1199. if (videoTime > 0) {
  1200. videoTime--;
  1201. $('.time-node')
  1202. .eq(0)
  1203. .text(videoTime + 's');
  1204. } else {
  1205. clearInterval(videoTimer);
  1206. $('.time-node').eq(0).text('');
  1207. }
  1208. }, 1000);
  1209. if (intervalTime > 0) {
  1210. // 间隔广告拉取下一次广告数据
  1211. adType = 16;
  1212. getAD();
  1213. }
  1214. if (adType === 16 && sourceType == 1) {
  1215. // 间隔广告和试用才上报
  1216. report(0);
  1217. }
  1218. }
  1219. }
  1220. /**
  1221. * 初始化广告
  1222. * 因移动端video无法自动播放,play()方法不能异步调用。
  1223. * 解决方案,初始化时预先请求广告数据,在用户对云手机touchmove事件中去播放广告并请求下一次广告数据。
  1224. */
  1225. function initAD() {
  1226. console.log(
  1227. '🚀 ~ file: WXtrialInterface.html ~ line 1052 ~ initAD ~ sourceType',
  1228. sourceType,
  1229. );
  1230. (function () {
  1231. switch (sourceType) {
  1232. case 1: {
  1233. return getSetmealList().then(function (res) {
  1234. intervalTime =
  1235. res.intervalSwitch === 1
  1236. ? res.intervalAdvertDuration * 1000 * 60
  1237. : 0;
  1238. if (res.pushFlowAdvert === 1) {
  1239. adType = 15;
  1240. adTime = 0;
  1241. } else if (intervalTime > 0) {
  1242. adType = 16;
  1243. adTime = date.now();
  1244. }
  1245. });
  1246. }
  1247. case 2: {
  1248. return getConfigByPhoneType().then(function (res) {
  1249. if (res.isDisconnectionTime === 1) {
  1250. var time = res.disconnectionTime * 60 * 1000;
  1251. setTimeout(() => {
  1252. disconnectionFlag = true;
  1253. $('.buy-phone-wrap').eq(0).show();
  1254. }, time);
  1255. }
  1256. intervalTime =
  1257. res.isIntervalPlayAd === 1
  1258. ? res.intervalPlayAdTime * 1000 * 60
  1259. : 0;
  1260. if (res.isShowAd === 1) {
  1261. adType = 15;
  1262. adTime = 0;
  1263. } else if (intervalTime > 0) {
  1264. adType = 16;
  1265. adTime = date.now();
  1266. }
  1267. });
  1268. }
  1269. default: {
  1270. return Promise.reject();
  1271. }
  1272. }
  1273. })().then(function () {
  1274. console.log(adType);
  1275. this.$('#wine').on('touchstart', playAD);
  1276. getAD();
  1277. });
  1278. }
  1279. //广告信息
  1280. // function adInit() {
  1281. // sourceType = parameters['sourceType'];
  1282. // if (sourceType == 1) {
  1283. // getSetmealList().then((res) => {
  1284. // if (res.pushFlowAdvert === 1) {
  1285. // getAdList(15);
  1286. // }
  1287. // if (res.intervalSwitch === 1) {
  1288. // let time = res.intervalAdvertDuration * 60 * 1000;
  1289. // setInterval(() => {
  1290. // $('.try-use-wrap').eq(0).hide();
  1291. // getAdList(16);
  1292. // }, time);
  1293. // }
  1294. // })
  1295. // } else if (sourceType == 2) {
  1296. // getConfigByPhoneType().then((res) => {
  1297. // if (res.isDisconnectionTime === 1) {
  1298. // let time = res.disconnectionTime * 60 * 1000;
  1299. // setTimeout(() => {
  1300. // disconnectionFlag = true;
  1301. // $('.buy-phone-wrap').eq(0).show();
  1302. // }, time);
  1303. // }
  1304. // if (res.isShowAd === 1) {
  1305. // getAdList(15);
  1306. // }
  1307. // if (res.isIntervalPlayAd === 1) {
  1308. // let time = res.intervalPlayAdTime * 60 * 1000;
  1309. // setInterval(() => {
  1310. // $('.try-use-wrap').eq(0).hide();
  1311. // getAdList(16);
  1312. // }, time);
  1313. // }
  1314. // })
  1315. // }
  1316. // }
  1317. // 广告接口
  1318. // function getAdList(type) {
  1319. // adType = type;
  1320. // $.ajax({
  1321. // url: baseUrl + '/api/public/v5/advertising/getAdInfoByAdPlace',
  1322. // headers: {
  1323. // Authorization: form.token,
  1324. // },
  1325. // data: JSON.stringify({
  1326. // adPlace: type,
  1327. // os: 0,
  1328. // }),
  1329. // type: 'POST',
  1330. // dataType: 'json',
  1331. // contentType: 'application/json;charset=UTF-8',
  1332. // success: function (res) {
  1333. // if (res.status === 0) {
  1334. // let list = res.data;
  1335. // let indexs = Math.floor(Math.random() * list.length);
  1336. // videoTime = list[indexs].forcedTime;
  1337. // // $('#source').src = list[0].adVideoBase.videoUrl;
  1338. // $('#source').attr('src', list[indexs].adVideoBase.videoUrl); //更新url
  1339. // $('#source').attr('autoplay', 'true'); //直接播放
  1340. // videoTimer = setInterval(() => {
  1341. // if (videoTime > 0) {
  1342. // videoTime--;
  1343. // $('.time-node')
  1344. // .eq(0)
  1345. // .text(videoTime + 's');
  1346. // } else {
  1347. // clearInterval(videoTimer);
  1348. // $('.time-node').eq(0).text('');
  1349. // }
  1350. // }, 1000);
  1351. // if (adType === 16 && sourceType == 1) {
  1352. // // 间隔广告和试用才上报
  1353. // report(0);
  1354. // }
  1355. // $('.try-use-wrap').eq(0).show();
  1356. // } else {
  1357. // $.toast(res.msg, 'text');
  1358. // }
  1359. // },
  1360. // });
  1361. // }
  1362. //间隔广告上报
  1363. function report(type) {
  1364. $.ajax({
  1365. url: baseUrl + '/api/resources/v1/trial/report',
  1366. headers: {
  1367. Authorization: token,
  1368. },
  1369. data: JSON.stringify({
  1370. userCardId: userCardId,
  1371. reportType: type,
  1372. }),
  1373. type: 'POST',
  1374. dataType: 'json',
  1375. contentType: 'application/json;charset=UTF-8',
  1376. success: function (res) {},
  1377. });
  1378. }
  1379. // 观看广告次数上报
  1380. function reportFrequency() {
  1381. $.ajax({
  1382. url: baseUrl + '/api/resoures/v1/trial/reportFrequency/' + form.userCardId,
  1383. headers: {
  1384. Authorization: form.token
  1385. },
  1386. type: 'post',
  1387. contentType: 'application/json',
  1388. dataType: 'json',
  1389. success: function (res) {},
  1390. });
  1391. }
  1392. //关闭广告
  1393. $('.time-close-wrap')[0].addEventListener('click', () => {
  1394. if(videoTime == 0) {
  1395. reportFrequency()
  1396. }
  1397. $('.buy-phone-wrap').eq(0).show();
  1398. });
  1399. // 点击取消
  1400. $('.cannel-btn')[0].addEventListener('click', () => {
  1401. $('.buy-phone-wrap').eq(0).hide();
  1402. if (disconnectionFlag || getDate) {
  1403. //设置了断线时间,取消直接退出
  1404. systemBuriedPoint('激活码-断线-取消');
  1405. quit();
  1406. return;
  1407. }
  1408. let pointName = '';
  1409. if (sourceType == 1) {
  1410. pointName =
  1411. videoTime == 0 ? '免费试用-关闭-取消' : '免费试用-强制关闭-取消';
  1412. } else {
  1413. pointName =
  1414. videoTime == 0 ? '激活码-关闭-取消' : '激活码-强制关闭-取消';
  1415. }
  1416. systemBuriedPoint(pointName);
  1417. if (videoTime == 0) {
  1418. if (adType === 16 && sourceType == 1) {
  1419. report(1);
  1420. }
  1421. $('.try-use-wrap').eq(0).hide();
  1422. $('#source')[0].pause();
  1423. return;
  1424. }
  1425. $('.look-wrap').eq(0).show();
  1426. });
  1427. // 点击去购买
  1428. $('.go-bug')[0].addEventListener('click', () => {
  1429. let pointName = '';
  1430. if (disconnectionFlag) {
  1431. pointName = '激活码-断线-去购买';
  1432. } else if (sourceType == 1) {
  1433. pointName =
  1434. videoTime == 0
  1435. ? '免费试用-关闭-去购买'
  1436. : '免费试用-强制关闭-去购买';
  1437. } else {
  1438. pointName =
  1439. videoTime == 0 ? '激活码-关闭-去购买' : '激活码-强制关闭-去购买';
  1440. }
  1441. systemBuriedPoint(pointName);
  1442. if (getDate) {
  1443. wx.miniProgram.navigateTo({
  1444. url: '/packageA/order/buy/index?buyType=试用界面购买',
  1445. });
  1446. } else {
  1447. // 过期续费按钮进入
  1448. wx.miniProgram.navigateTo({
  1449. url:
  1450. `/packageA/order/renew/index?buyType=${
  1451. sourceType == 1
  1452. ? '试用弹窗购买按钮进入-普通试用'
  1453. : '试用弹窗购买按钮进入-激活码试用'
  1454. }&record=` + userCardId,
  1455. });
  1456. }
  1457. });
  1458. // 放弃
  1459. $('.cannel-ad-btn')[0].addEventListener('click', () => {
  1460. if (sourceType == 1) {
  1461. systemBuriedPoint('免费试用-强制关闭-放弃');
  1462. } else {
  1463. systemBuriedPoint('激活码-强制关闭-放弃');
  1464. }
  1465. quit();
  1466. });
  1467. // 继续观看
  1468. $('.looking')[0].addEventListener('click', () => {
  1469. $('.look-wrap').eq(0).hide();
  1470. if (sourceType == 1) {
  1471. systemBuriedPoint('免费试用-强制关闭-继续观看');
  1472. } else {
  1473. systemBuriedPoint('激活码-强制关闭-继续观看');
  1474. }
  1475. });
  1476. // 埋点
  1477. function systemBuriedPoint(pointName) {
  1478. $.ajax({
  1479. url: baseUrl + '/api/public/v1/systemBuriedPoint/stat',
  1480. headers: {
  1481. Authorization: token,
  1482. },
  1483. type: 'post',
  1484. data: JSON.stringify({
  1485. pointName: pointName,
  1486. }),
  1487. contentType: 'application/json',
  1488. dataType: 'json',
  1489. success: function (res) {},
  1490. });
  1491. }
  1492. function quit() {
  1493. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  1494. tt.miniProgram.switchTab({
  1495. url: '/pages/home/home',
  1496. });
  1497. } else if (window.__wxjs_environment === 'miniprogram') {
  1498. wx.miniProgram.switchTab({
  1499. url: '/pages/home/home',
  1500. });
  1501. } else {
  1502. uni.webView.navigateBack({
  1503. delta: 1
  1504. });
  1505. }
  1506. }
  1507. window.onbeforeunload = function () {
  1508. ws.close();
  1509. wsss.close();
  1510. };
  1511. </script>
  1512. <script type="text/javascript" src="WXdraw.js"></script>
  1513. <script type="text/javascript" src="aac.js"></script>
  1514. </body>
  1515. </html>