WXtrialInterface.html 64 KB

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