WXtrialInterface.html 61 KB

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