WXtrialInterface.html 59 KB

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