WXtrialInterface.html 61 KB

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