WXtrialInterface.html 54 KB

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