WXtrialInterface.html 69 KB

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