WXtrialInterface.html 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082
  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. }
  1830. function updatePhoneSizeListHtml() {
  1831. const templatePhoneSizeItem = doT.template(
  1832. $('#template-phone-size-item').html().replace(/&amp;/g, '&'),
  1833. );
  1834. // console.log({
  1835. // list: window.phoneSizeList,
  1836. // active: window.activePhoneSize,
  1837. // resolving,
  1838. // });
  1839. const phoneSizeListItemsHtml = templatePhoneSizeItem({
  1840. list: window.phoneSizeList,
  1841. active: window.activePhoneSize,
  1842. resolving,
  1843. });
  1844. $('#phone-size-list').html(phoneSizeListItemsHtml);
  1845. }
  1846. $('#open-set-phone-size-dialog-btn').on('click', async function (e) {
  1847. !window.phoneSizeList.length && (await getPhoneSizeList());
  1848. window.activePhoneSize = window.currentPhoneSize;
  1849. updatePhoneSizeListHtml();
  1850. $('#set-phone-size-dialog').addClass('show');
  1851. });
  1852. // $('#set-phone-size-dialog').addClass('show');
  1853. $('.dialog .dialog-mask')
  1854. .add('.dialog .dialog-btn.cancel')
  1855. .on('click', function (e) {
  1856. $(e.currentTarget).parents('.dialog').removeClass('show');
  1857. });
  1858. // 分辨率列表
  1859. window.phoneSizeList = [];
  1860. // 当前生效的分辨率
  1861. // 选中的分辨率
  1862. // window.activePhoneSize = window.currentPhoneSize;
  1863. async function getPhoneSizeList() {
  1864. const response = await $.ajax({
  1865. url:
  1866. baseUrl + '/api/resources/v5/machine/resolution/getResolvingPower',
  1867. headers: {
  1868. Authorization: token,
  1869. },
  1870. type: 'get',
  1871. dataType: 'json',
  1872. data: {
  1873. userCardId,
  1874. },
  1875. });
  1876. const phoneSizeList = response.data.map(function (v) {
  1877. return {
  1878. id: v.id,
  1879. dpi: v.dpi,
  1880. width: v.width,
  1881. height: v.high,
  1882. };
  1883. });
  1884. window.phoneSizeList = phoneSizeList;
  1885. // 关联上当前云机分辨率
  1886. const currentPhoneSize = phoneSizeList.find(function (v) {
  1887. return (
  1888. window.currentPhoneSize &&
  1889. v.width === window.currentPhoneSize.width &&
  1890. v.height === window.currentPhoneSize.height &&
  1891. v.dpi === window.currentPhoneSize.dpi
  1892. );
  1893. });
  1894. window.currentPhoneSize = currentPhoneSize || window.currentPhoneSize;
  1895. }
  1896. /*
  1897. getPhoneSizeList().then(function (phoneSizeList) {
  1898. window.phoneSizeList = phoneSizeList;
  1899. // window.phoneSizeListBack = phoneSizeList; // 备份下数据,用户横竖切换时。
  1900. const currentPhoneSize = window.phoneSizeList.find(function (v) {
  1901. return (
  1902. window.currentPhoneSize &&
  1903. v.width === window.currentPhoneSize.width &&
  1904. v.height === window.currentPhoneSize.height &&
  1905. v.dpi === window.currentPhoneSize.dpi
  1906. );
  1907. });
  1908. window.currentPhoneSize = currentPhoneSize || window.currentPhoneSize;
  1909. // return updatePhoneSizeListHtml();
  1910. });
  1911. */
  1912. // const phoneSizeListSwiper = new Swiper('#phone-size-list-swiper', {
  1913. // direction: 'vertical',
  1914. // slidesPerView: 'auto',
  1915. // loop: false,
  1916. // centeredSlides: true,
  1917. // });
  1918. let lastSetPhone = 0;
  1919. function setPhoneSize(config) {
  1920. if (config.id === currentPhoneSize.id) {
  1921. return;
  1922. }
  1923. if (Date.now() <= lastSetPhone + 1000 * 5) {
  1924. throw new Error('请勿频繁操作');
  1925. }
  1926. lastSetPhone = Date.now();
  1927. // config = Object.assign({}, config, {
  1928. // width: config.width,
  1929. // height: config.height,
  1930. // });
  1931. // 修改云机分辨率
  1932. wsss.send(
  1933. JSON.stringify({
  1934. type: 'setPhoneSize',
  1935. data: {
  1936. id: config.id,
  1937. width: config.width,
  1938. height: config.height,
  1939. dpi: config.dpi,
  1940. },
  1941. }),
  1942. );
  1943. // XXX: 去除了,改为中台发送
  1944. // 通知其他在线端
  1945. // wsss.send(
  1946. // JSON.stringify({
  1947. // type: 'forwardMsg',
  1948. // data: {
  1949. // code: 'phoneSizeChange',
  1950. // id: config.id,
  1951. // width: config.width,
  1952. // height: config.height,
  1953. // dpi: config.dpi,
  1954. // desc: '分辨率修改', // 可选
  1955. // },
  1956. // }),
  1957. // );
  1958. // 上报分辨率
  1959. window.currentPhoneSize = config;
  1960. }
  1961. // wsss.addEventListener('message', function (event) {
  1962. // console.log(
  1963. // '🚀 ~ file: WXtrialInterface.html ~ line 1476 ~ event',
  1964. // event,
  1965. // );
  1966. // });
  1967. $('#phone-size-list').on('click', '.phone-size-item', function (e) {
  1968. const data = $(e.currentTarget).data();
  1969. // console.log(
  1970. // '🚀 ~ file: WXtrialInterface.html ~ line 1494 ~ data',
  1971. // data,
  1972. // );
  1973. window.activePhoneSize = data;
  1974. updatePhoneSizeListHtml();
  1975. // setPhoneSize(data.width, data.height);
  1976. });
  1977. $('#set-phone-size-dialog .dialog-btn.confirm').on('click', function (e) {
  1978. try {
  1979. setPhoneSize(window.activePhoneSize);
  1980. $('#set-phone-size-dialog').removeClass('show');
  1981. } catch (error) {
  1982. $.toast(error.message, 'text');
  1983. }
  1984. });
  1985. </script>
  1986. <script type="text/javascript" src="WXdraw.js"></script>
  1987. <script type="text/javascript" src="aac.js"></script>
  1988. <script type="text/javascript" src="./timer.js"></script>
  1989. </body>
  1990. </html>