WXtrialInterface.html 69 KB

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