WXtrialInterface.html 63 KB

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