WXtrialInterface.html 60 KB

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