WXtrialInterface.html 63 KB

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