WXtrialInterface.html 63 KB

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