WXtrialInterface.html 61 KB

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