WXtrialInterface.html 58 KB

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