WXtrialInterface.html 63 KB

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