WXtrialInterface.html 64 KB

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