WXtrialInterface.html 64 KB

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