WXtrialInterface.html 58 KB

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