WXtrialInterface.html 64 KB

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