WXtrialInterface.html 61 KB

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