WXtrialInterface.html 56 KB

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