WXtrialInterface.html 58 KB

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