WXtrialInterface.html 63 KB

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