WXtrialInterface.html 70 KB

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