WXtrialInterface.html 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950
  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(connectStatus==1) {
  487. getResidueTime();
  488. }
  489. if (timerInterval) {
  490. timerInterval = clearTimeout();
  491. }
  492. if (res.data.internetHttps) {
  493. socketURL =
  494. 'wss://' +
  495. res.data.internetHttps +
  496. '/plugflow?cardIp=' +
  497. res.data.localIp +
  498. '&token=' +
  499. res.data.cardToken +
  500. '&type=business';
  501. cUrl =
  502. 'wss://' +
  503. res.data.internetHttps +
  504. '/businessChannel?cardIp=' +
  505. res.data.localIp +
  506. '&token=' +
  507. res.data.cardToken +
  508. '&type=directives';
  509. cardToken = res.data.cardToken;
  510. resolvingPower = res.data.resolvingPower;
  511. doConnectBusiness();
  512. doConnectDirectives();
  513. if (type === 'add') {
  514. addData(db, storeName, {
  515. id: userCardId,
  516. socketURL: socketURL,
  517. cUrl: cUrl,
  518. cardToken: res.data.cardToken,
  519. resolvingPower: res.data.resolvingPower,
  520. width: res.data.width,
  521. height: res.data.high,
  522. dpi: res.data.dpi,
  523. });
  524. } else {
  525. updateDB(db, storeName, {
  526. id: userCardId,
  527. socketURL: socketURL,
  528. cUrl: cUrl,
  529. cardToken: res.data.cardToken,
  530. resolvingPower: res.data.resolvingPower,
  531. width: res.data.width,
  532. height: res.data.high,
  533. dpi: res.data.dpi,
  534. });
  535. }
  536. const data = window.phoneSizeList.find(function (v) {
  537. return (
  538. v.width === res.data.width &&
  539. v.height === res.data.height &&
  540. v.dpi === res.data.dpi
  541. );
  542. });
  543. window.currentPhoneSize = data || {
  544. width: res.data.width,
  545. height: res.data.height,
  546. dpi: res.data.dpi,
  547. };
  548. } else {
  549. $.toast('网络异常,请稍后重试', 'text');
  550. setTimeout(() => {
  551. clearInterval(intervaler);
  552. quit();
  553. }, 3000);
  554. }
  555. return;
  556. }
  557. if (res.status === 5200) {
  558. if (timeInterval > 7) {
  559. $.toast('网络异常,请稍后重试', 'text');
  560. timerInterval = clearTimeout();
  561. setTimeout(() => {
  562. quit();
  563. }, 3000);
  564. return;
  565. }
  566. timerInterval = setTimeout(() => {
  567. connect(type);
  568. timeInterval += 1;
  569. }, 3000);
  570. return;
  571. }
  572. if (res.status === 5220) {
  573. $.toast('云手机正在一键修复中', 'text');
  574. setTimeout(() => {
  575. quit();
  576. }, 3000);
  577. return;
  578. }
  579. if (res.status === 5203) {
  580. $.toast('正在排队中,请稍等', 'text');
  581. setTimeout(() => {
  582. quit();
  583. }, 3000);
  584. return;
  585. }
  586. if (res.status === 5204) {
  587. $.toast('云机异常,正在为你重新分配云机', 'text');
  588. setTimeout(() => {
  589. quit();
  590. }, 3000);
  591. return;
  592. }
  593. $('#countView').hide();
  594. $('.countdown-wrap').hide();
  595. //downline();
  596. $.toast('画面异常,请重新进入', 'text');
  597. setTimeout(() => {
  598. quit();
  599. }, 3000);
  600. },
  601. });
  602. }
  603. initAD();
  604. var isShowCountdown = +parameters['isShowCountdown'], isShowRule = +parameters['isShowRule'];
  605. $.alert({
  606. title: '提示',
  607. text: '开始使用云手机',
  608. onOK: function () {
  609. isAudioPlay = true;
  610. if (isShowCountdown) {
  611. $('#countView').eq(0).show();
  612. }
  613. if (isShowRule) {
  614. $('.countdown-wrap').eq(0).show();
  615. }
  616. //getResidueTime();
  617. },
  618. });
  619. //云机倒计时
  620. let validTime = parameters['validTime'] || 10000;
  621. if (validTime > 32000) {
  622. validTime = 32000;
  623. }
  624. let detailTime = validTime * 60 * 1000;
  625. setTimeout(() => {
  626. $('.bug-title').eq(0).text('尊敬的用户您的云手机试用时间已到期');
  627. getDate = true;
  628. $('.buy-phone-wrap').eq(0).show();
  629. }, detailTime);
  630. var orientation = 0; //0 竖屏,1横屏
  631. function array_unique(arr) {
  632. return arr.filter(function (e, i) {
  633. return arr.indexOf(e) === i;
  634. });
  635. }
  636. var cutList = [];
  637. let timer,
  638. isFlag = true;
  639. const shearTemplate = doT.template(
  640. $('#template-shear').html().replace(/&amp;/g, '&'),
  641. );
  642. function updateShearHtml(list) {
  643. $('.box-shear-plate').html(shearTemplate(list));
  644. }
  645. // 对字符串进行html转义
  646. function encodeHtml(content) {
  647. return [
  648. ['<', '&lt;'],
  649. ['>', '&gt;'],
  650. ['&', '&amp;'],
  651. ['"', '&quot;'],
  652. ].reduce(function (previousValue, currentValue) {
  653. return previousValue.replace(
  654. new RegExp(currentValue[0], 'g'),
  655. currentValue[1],
  656. );
  657. }, content);
  658. }
  659. $('.box-shear-plate').on('click', '.slide-content', function (e) {
  660. handleCopy(e.currentTarget.dataset.content);
  661. });
  662. $('.box-shear-plate').on('click', '.btn-clear', function (e) {
  663. handleClear();
  664. });
  665. $('.box-shear-plate').on('click', '.slide-content-button', function (e) {
  666. handleDelete(e.currentTarget.dataset.id);
  667. });
  668. function showShearPlate(type) {
  669. if (!isControl) {
  670. return;
  671. }
  672. stopManyClick(function () {
  673. new Promise((resolve, reject) => {
  674. if (window.navigator.clipboard) {
  675. window.navigator.clipboard
  676. .readText()
  677. .then(
  678. function (content) {
  679. return $.ajax({
  680. url: baseUrl + '/api/public/v5/shear/content',
  681. type: 'post',
  682. dataType: 'json',
  683. data: JSON.stringify({
  684. content: content,
  685. }),
  686. headers: {
  687. 'content-Type': 'application/json',
  688. Authorization: token,
  689. },
  690. });
  691. },
  692. function (err) {
  693. if (type === 'clear') {
  694. return
  695. }
  696. $.toast('读取剪贴板失败', 'text');
  697. },
  698. )
  699. .finally(resolve);
  700. } else {
  701. resolve();
  702. }
  703. }).then(function () {
  704. $('.box-shear-plate').empty();
  705. return $.ajax({
  706. url: baseUrl + '/api/public/v5/shear/content',
  707. headers: {
  708. Authorization: token,
  709. },
  710. type: 'get',
  711. dataType: 'json',
  712. success: function (res) {
  713. updateShearHtml(res.status === 0 ? res.data : []);
  714. $('.mask').show();
  715. initSlider();
  716. },
  717. });
  718. });
  719. });
  720. }
  721. //防止提示一秒内重复显示
  722. function stopManyClick(fn) {
  723. if (isFlag) {
  724. fn();
  725. }
  726. isFlag = false;
  727. if (timer) {
  728. clearTimeout(timer);
  729. }
  730. timer = setTimeout(() => {
  731. isFlag = true;
  732. }, 1500);
  733. }
  734. // 清空剪贴板
  735. function handleClear() {
  736. $.confirm('确定清空剪贴板?', function () {
  737. $.ajax({
  738. url:
  739. baseUrl +
  740. '/api/public/v5/shear/content' +
  741. Qs.stringify(
  742. {
  743. ids: Array.from($('.slide-wrapper')).map((v) => v.dataset.id),
  744. },
  745. { arrayFormat: 'repeat', addQueryPrefix: true },
  746. ),
  747. headers: {
  748. Authorization: token,
  749. },
  750. type: 'DELETE',
  751. dataType: 'json',
  752. success: function (res) {
  753. if (res.status === 0) {
  754. showShearPlate('clear');
  755. } else {
  756. $.toast(res.msg, 'text');
  757. }
  758. },
  759. });
  760. });
  761. }
  762. function handleCopy(content) {
  763. var cutting = {
  764. type: 'cutting',
  765. data: {
  766. str: content,
  767. },
  768. };
  769. wsss.send(JSON.stringify(cutting));
  770. }
  771. // 删除剪贴板
  772. function handleDelete(id) {
  773. $.ajax({
  774. url: baseUrl + '/api/public/v5/shear/content?ids=' + id,
  775. headers: {
  776. Authorization: token,
  777. },
  778. type: 'DELETE',
  779. dataType: 'json',
  780. success: function (res) {
  781. if (res.status === 0) {
  782. showShearPlate();
  783. } else {
  784. $.toast(res.msg, 'text');
  785. }
  786. },
  787. });
  788. }
  789. function initSlider() {
  790. //手指滑动多少距离就认为是滑成功
  791. //这个值不能太大,否则影响斜着滑动时,垂直滑动的流畅性,也不能太小,太灵敏也不好
  792. var diffXDistance = 50;
  793. //当前滑动的对象
  794. var currentObject;
  795. //上一次滑动的对象
  796. var lastObject;
  797. //是否可以左右滑动,在上下滑的时候禁止左右滑
  798. var canSlide = true;
  799. //用于记录按下的点
  800. var startPoint;
  801. $('.slide-content').css({
  802. width: $('.slide-wrapper').width(),
  803. });
  804. document.body.removeEventListener(
  805. 'touchmove',
  806. function (e) {
  807. e.preventDefault();
  808. },
  809. {
  810. passive: false,
  811. },
  812. );
  813. $('.slide-scroll')
  814. .css({
  815. width:
  816. $('.slide-wrapper').width() + $('.slide-content-button').width(),
  817. })
  818. .on('touchstart', function (e) {
  819. currentObject = this;
  820. startPoint = {
  821. x: e.originalEvent.changedTouches[0].pageX,
  822. y: e.originalEvent.changedTouches[0].pageY,
  823. };
  824. })
  825. .on('touchmove', function (e) {
  826. //如果是左右滑动,就禁止上下的滑动
  827. //如果是上下的滑动,就禁止左右滑动
  828. if (
  829. Math.abs(e.originalEvent.changedTouches[0].pageX - startPoint.x) >
  830. Math.abs(e.originalEvent.changedTouches[0].pageY - startPoint.y)
  831. ) {
  832. event.preventDefault();
  833. } else {
  834. canSlide = false;
  835. }
  836. })
  837. .on('touchend', function (e) {
  838. //如果是上下滑动,这里就直接返回了
  839. if (!canSlide) {
  840. canSlide = true;
  841. return true;
  842. }
  843. //点击除当前左滑对象之外的任意其他位置
  844. if (lastObject && currentObject != lastObject) {
  845. //右滑→
  846. $(lastObject).removeClass('animate-slide');
  847. //清空上一个左滑的对象
  848. lastObject = undefined;
  849. }
  850. var diffX = e.originalEvent.changedTouches[0].pageX - startPoint.x;
  851. if (diffX < -diffXDistance) {
  852. //左滑←
  853. $(currentObject).addClass('animate-slide');
  854. if (lastObject && lastObject != currentObject) {
  855. //右滑→
  856. $(lastObject).removeClass('animate-slide');
  857. }
  858. //记录上一个左滑的对象
  859. lastObject = currentObject;
  860. } else if (diffX >= diffXDistance) {
  861. if (currentObject == lastObject) {
  862. //右滑→
  863. $(currentObject).removeClass('animate-slide');
  864. //清空上一个左滑的对象
  865. lastObject = undefined;
  866. }
  867. }
  868. });
  869. }
  870. $('#wine').on('click', function (e) {
  871. console.log('🚀 ~ file: WXdraw.js ~ line 4 ~ e', e);
  872. $('.control-right-img').attr({
  873. 'data-id': '1',
  874. });
  875. $('.leftmains').css({
  876. right: '-4rem',
  877. });
  878. });
  879. var btnMuted = document.querySelector('#btnMuted');
  880. btnMuted &&
  881. (function () {
  882. var setHistory = function (left, top) {
  883. try {
  884. localStorage.setItem(
  885. 'muted-btn-loc',
  886. JSON.stringify({
  887. left: left,
  888. top: top,
  889. }),
  890. );
  891. } catch (ex) { }
  892. };
  893. var getHistory = function () {
  894. try {
  895. var value = localStorage.getItem('muted-btn-loc');
  896. if (!value) return null;
  897. value = JSON.parse(value);
  898. if (!value) return null;
  899. return value;
  900. } catch (ex) {
  901. return null;
  902. }
  903. };
  904. var fixLoc = function (loc) {
  905. var rect = btnMuted.getBoundingClientRect();
  906. rect = {
  907. top: rect.top,
  908. left: rect.left,
  909. width: rect.width,
  910. height: rect.height,
  911. }; // 部分低版本浏览器,该属性为只读
  912. if (loc) {
  913. rect.left = loc.left;
  914. rect.top = loc.top;
  915. }
  916. var minX = 0;
  917. var minY = 0;
  918. var docRect = document.documentElement.getBoundingClientRect();
  919. var maxY = docRect.height - rect.height;
  920. var maxX = docRect.width - rect.width;
  921. var left = rect.left;
  922. var top = rect.top;
  923. left = Math.min(left, maxX);
  924. left = Math.max(left, minX);
  925. top = Math.min(top, maxY);
  926. top = Math.max(top, minY);
  927. if (loc || top !== rect.top || left !== rect.left) {
  928. btnMuted.style.cssText +=
  929. 'left:' + left + 'px;top:' + top + 'px;';
  930. }
  931. };
  932. window.addEventListener('resize', function () {
  933. fixLoc();
  934. });
  935. var touchPoint = {
  936. pageY: 0,
  937. pageX: 0,
  938. };
  939. var currentLoc = {
  940. top: 0,
  941. left: 0,
  942. curTop: 0,
  943. curLeft: 0,
  944. };
  945. var toMove = false;
  946. var touchmove = function (e) {
  947. e.preventDefault();
  948. var point = e.changedTouches[0];
  949. var top = -touchPoint.pageY + point.pageY;
  950. var left = -touchPoint.pageX + point.pageX;
  951. if (toMove) {
  952. top += currentLoc.top;
  953. left += currentLoc.left;
  954. currentLoc.curLeft = left;
  955. currentLoc.curTop = top;
  956. btnMuted.style.cssText +=
  957. 'left:' + left + 'px;top:' + top + 'px;';
  958. } else {
  959. if (Math.abs(top) >= 5 || Math.abs(left) >= 5) {
  960. toMove = true;
  961. }
  962. }
  963. };
  964. var touchend = function () {
  965. window.removeEventListener('touchmove', touchmove, {
  966. passive: false,
  967. });
  968. window.removeEventListener('touchend', touchend, {
  969. passive: false,
  970. });
  971. if (toMove) {
  972. setHistory(currentLoc.curLeft, currentLoc.curTop);
  973. fixLoc();
  974. } else {
  975. //按点击处理
  976. var set = $('.control-right-img').attr('data-id');
  977. if (set == '1') {
  978. $('.control-right-img').attr({
  979. 'data-id': '2',
  980. });
  981. $('.leftmains').css({
  982. right: '0rem',
  983. });
  984. } else {
  985. $('.control-right-img').attr({
  986. 'data-id': '1',
  987. });
  988. $('.leftmains').css({
  989. right: '-4rem',
  990. });
  991. }
  992. }
  993. };
  994. btnMuted.addEventListener(
  995. 'touchstart',
  996. function (e) {
  997. e.preventDefault();
  998. toMove = false;
  999. var point = e.changedTouches[0];
  1000. touchPoint.pageX = point.pageX;
  1001. touchPoint.pageY = point.pageY;
  1002. var rect = e.target.getBoundingClientRect();
  1003. currentLoc.top = rect.top;
  1004. currentLoc.left = rect.left;
  1005. window.addEventListener('touchmove', touchmove, {
  1006. passive: false,
  1007. });
  1008. window.addEventListener('touchend', touchend, {
  1009. passive: false,
  1010. });
  1011. },
  1012. {
  1013. passive: false,
  1014. },
  1015. );
  1016. var history = getHistory();
  1017. if (history) {
  1018. fixLoc(history);
  1019. }
  1020. btnMuted.classList.remove('hide');
  1021. })();
  1022. function handleClose() {
  1023. $('.mask').hide();
  1024. }
  1025. var decodeCount = 1;
  1026. var isFinish = false;
  1027. var player = new PCMPlayer({
  1028. encoding: '16bitInt',
  1029. channels: 2,
  1030. sampleRate: 44100,
  1031. flushingTime: 22,
  1032. debug: false,
  1033. });
  1034. Module = {};
  1035. Module.onRuntimeInitialized = function () {
  1036. isFinish = true;
  1037. };
  1038. function decodeAAC(data) {
  1039. var retPtr = Module._malloc(4 * 5 * 1024); //接收的数据
  1040. var inputPtr = Module._malloc(4 * data.length); //输入数据
  1041. for (var i = 0; i < data.length; i++) {
  1042. Module.HEAPU8[inputPtr + i] = data[i]; //转换为堆数据
  1043. }
  1044. var pcmLen = Module._feedData(retPtr, inputPtr, data.length);
  1045. if (pcmLen >= 0) {
  1046. var pcmData = new Uint8Array(pcmLen);
  1047. for (var i = 0; i < pcmLen; i++) {
  1048. pcmData[i] = Module.HEAPU8[retPtr + i];
  1049. }
  1050. player.feed(pcmData);
  1051. }
  1052. decodeCount++;
  1053. Module._free(inputPtr);
  1054. Module._free(retPtr);
  1055. }
  1056. var decodeWoker = new Worker('decoder.js');
  1057. var myVideo = document.getElementById('playCanvas');
  1058. var logicWidth = 720;
  1059. var logicHeight = 1280;
  1060. decodeWoker.onmessage = function (event) {
  1061. var objData = event.data;
  1062. // console.log("🚀 ~ file: WXtrialInterface.html ~ line 806 ~ objData", objData)
  1063. switch (objData.cmd) {
  1064. case 0:
  1065. break;
  1066. case 1:
  1067. // console.log(objData);
  1068. if (logicWidth != objData.width || logicHeight != objData.height) {
  1069. logicWidth = objData.width;
  1070. logicHeight = objData.height;
  1071. }
  1072. // logicWidth = 375
  1073. // logicHeight = 812
  1074. webglPlayer.renderFrame(
  1075. objData.data,
  1076. logicWidth,
  1077. logicHeight,
  1078. logicWidth * logicHeight,
  1079. (logicWidth / 2) * (logicHeight / 2),
  1080. );
  1081. $('.weui-mask_transparent').hide();
  1082. $('.weui-toast').hide();
  1083. $('.loading').hide();
  1084. break;
  1085. case 5:
  1086. var buffer = RequestIFrame();
  1087. webSocketWorker.postMessage(buffer);
  1088. }
  1089. };
  1090. var isFinish = false;
  1091. var webglPlayer = new WebGLPlayer(myVideo, {
  1092. preserveDrawingBuffer: false,
  1093. });
  1094. function GetRequest() {
  1095. var url = location.search; // 获取url中"?"符后的字串
  1096. var obj = new Object();
  1097. if (url.indexOf('?') != -1) {
  1098. var str = url.substr(1);
  1099. strs = str.split('&');
  1100. for (var i = 0; i < strs.length; i++) {
  1101. obj[strs[i].split('=')[0]] = strs[i].split('=')[1];
  1102. }
  1103. }
  1104. return obj;
  1105. }
  1106. var webSocketWorker;
  1107. /*
  1108. var webSocketWorker;
  1109. var intervalId;
  1110. let num = 0;
  1111. //心跳
  1112. function sendHeartbeat() {
  1113. // console.log(intervalId, 'intervalId') webSocketWorker.readyState === WebSocket.OPEN &&
  1114. if (wsss.readyState === WebSocket.OPEN) {
  1115. console.log('connection is ok');
  1116. num = 0;
  1117. //webSocketWorker.send('ping');
  1118. wsss.send('ping')
  1119. } else {
  1120. //clearInterval(intervalId)
  1121. console.error('connection is not open '+num);
  1122. if(num == 20) {
  1123. console.log('num == 20')
  1124. return;
  1125. }
  1126. num++
  1127. connect("add")
  1128. }
  1129. }
  1130. */
  1131. function doConnectBusiness() {
  1132. webSocketWorker = new Worker(
  1133. 'websocket.js?socketURL=' +
  1134. encodeURIComponent(socketURL) +
  1135. '&cardToken=' +
  1136. encodeURIComponent(cardToken),
  1137. );
  1138. window.webSocketWorker = webSocketWorker;
  1139. /*
  1140. if(intervalId){
  1141. clearInterval(intervalId)
  1142. }
  1143. intervalId = setInterval(()=> {
  1144. sendHeartbeat()
  1145. },5000)
  1146. */
  1147. webSocketWorker.onmessage = function (event) {
  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>