WXtrialInterface.html 71 KB

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