WXtrialInterface.html 71 KB

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