WXtrialInterface.html 64 KB

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