WXtrialInterface.html 65 KB

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