WXtrialInterface.html 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844
  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(type) {
  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. if (type === 'clear') {
  650. return
  651. }
  652. $.toast('读取剪贴板失败', 'text');
  653. },
  654. )
  655. .finally(resolve);
  656. } else {
  657. resolve();
  658. }
  659. }).then(function () {
  660. $('.box-shear-plate').empty();
  661. return $.ajax({
  662. url: baseUrl + '/api/public/v5/shear/content',
  663. headers: {
  664. Authorization: token,
  665. },
  666. type: 'get',
  667. dataType: 'json',
  668. success: function (res) {
  669. updateShearHtml(res.status === 0 ? res.data : []);
  670. $('.mask').show();
  671. initSlider();
  672. },
  673. });
  674. });
  675. });
  676. }
  677. //防止提示一秒内重复显示
  678. function stopManyClick(fn) {
  679. if (isFlag) {
  680. fn();
  681. }
  682. isFlag = false;
  683. if (timer) {
  684. clearTimeout(timer);
  685. }
  686. timer = setTimeout(() => {
  687. isFlag = true;
  688. }, 1500);
  689. }
  690. // 清空剪贴板
  691. function handleClear() {
  692. $.confirm('确定清空剪贴板?', function () {
  693. $.ajax({
  694. url:
  695. baseUrl +
  696. '/api/public/v5/shear/content' +
  697. Qs.stringify(
  698. {
  699. ids: Array.from($('.slide-wrapper')).map((v) => v.dataset.id),
  700. },
  701. { arrayFormat: 'repeat', addQueryPrefix: true },
  702. ),
  703. headers: {
  704. Authorization: token,
  705. },
  706. type: 'DELETE',
  707. dataType: 'json',
  708. success: function (res) {
  709. if (res.status === 0) {
  710. showShearPlate('clear');
  711. } else {
  712. $.toast(res.msg, 'text');
  713. }
  714. },
  715. });
  716. });
  717. }
  718. function handleCopy(content) {
  719. var cutting = {
  720. type: 'cutting',
  721. data: {
  722. str: content,
  723. },
  724. };
  725. wsss.send(JSON.stringify(cutting));
  726. }
  727. // 删除剪贴板
  728. function handleDelete(id) {
  729. $.ajax({
  730. url: baseUrl + '/api/public/v5/shear/content?ids=' + id,
  731. headers: {
  732. Authorization: token,
  733. },
  734. type: 'DELETE',
  735. dataType: 'json',
  736. success: function (res) {
  737. if (res.status === 0) {
  738. showShearPlate();
  739. } else {
  740. $.toast(res.msg, 'text');
  741. }
  742. },
  743. });
  744. }
  745. function initSlider() {
  746. //手指滑动多少距离就认为是滑成功
  747. //这个值不能太大,否则影响斜着滑动时,垂直滑动的流畅性,也不能太小,太灵敏也不好
  748. var diffXDistance = 50;
  749. //当前滑动的对象
  750. var currentObject;
  751. //上一次滑动的对象
  752. var lastObject;
  753. //是否可以左右滑动,在上下滑的时候禁止左右滑
  754. var canSlide = true;
  755. //用于记录按下的点
  756. var startPoint;
  757. $('.slide-content').css({
  758. width: $('.slide-wrapper').width(),
  759. });
  760. document.body.removeEventListener(
  761. 'touchmove',
  762. function (e) {
  763. e.preventDefault();
  764. },
  765. {
  766. passive: false,
  767. },
  768. );
  769. $('.slide-scroll')
  770. .css({
  771. width:
  772. $('.slide-wrapper').width() + $('.slide-content-button').width(),
  773. })
  774. .on('touchstart', function (e) {
  775. currentObject = this;
  776. startPoint = {
  777. x: e.originalEvent.changedTouches[0].pageX,
  778. y: e.originalEvent.changedTouches[0].pageY,
  779. };
  780. })
  781. .on('touchmove', function (e) {
  782. //如果是左右滑动,就禁止上下的滑动
  783. //如果是上下的滑动,就禁止左右滑动
  784. if (
  785. Math.abs(e.originalEvent.changedTouches[0].pageX - startPoint.x) >
  786. Math.abs(e.originalEvent.changedTouches[0].pageY - startPoint.y)
  787. ) {
  788. event.preventDefault();
  789. } else {
  790. canSlide = false;
  791. }
  792. })
  793. .on('touchend', function (e) {
  794. //如果是上下滑动,这里就直接返回了
  795. if (!canSlide) {
  796. canSlide = true;
  797. return true;
  798. }
  799. //点击除当前左滑对象之外的任意其他位置
  800. if (lastObject && currentObject != lastObject) {
  801. //右滑→
  802. $(lastObject).removeClass('animate-slide');
  803. //清空上一个左滑的对象
  804. lastObject = undefined;
  805. }
  806. var diffX = e.originalEvent.changedTouches[0].pageX - startPoint.x;
  807. if (diffX < -diffXDistance) {
  808. //左滑←
  809. $(currentObject).addClass('animate-slide');
  810. if (lastObject && lastObject != currentObject) {
  811. //右滑→
  812. $(lastObject).removeClass('animate-slide');
  813. }
  814. //记录上一个左滑的对象
  815. lastObject = currentObject;
  816. } else if (diffX >= diffXDistance) {
  817. if (currentObject == lastObject) {
  818. //右滑→
  819. $(currentObject).removeClass('animate-slide');
  820. //清空上一个左滑的对象
  821. lastObject = undefined;
  822. }
  823. }
  824. });
  825. }
  826. $('#wine').on('click', function (e) {
  827. console.log('🚀 ~ file: WXdraw.js ~ line 4 ~ e', e);
  828. $('.control-right-img').attr({
  829. 'data-id': '1',
  830. });
  831. $('.leftmains').css({
  832. right: '-4rem',
  833. });
  834. });
  835. var btnMuted = document.querySelector('#btnMuted');
  836. btnMuted &&
  837. (function () {
  838. var setHistory = function (left, top) {
  839. try {
  840. localStorage.setItem(
  841. 'muted-btn-loc',
  842. JSON.stringify({
  843. left: left,
  844. top: top,
  845. }),
  846. );
  847. } catch (ex) { }
  848. };
  849. var getHistory = function () {
  850. try {
  851. var value = localStorage.getItem('muted-btn-loc');
  852. if (!value) return null;
  853. value = JSON.parse(value);
  854. if (!value) return null;
  855. return value;
  856. } catch (ex) {
  857. return null;
  858. }
  859. };
  860. var fixLoc = function (loc) {
  861. var rect = btnMuted.getBoundingClientRect();
  862. rect = {
  863. top: rect.top,
  864. left: rect.left,
  865. width: rect.width,
  866. height: rect.height,
  867. }; // 部分低版本浏览器,该属性为只读
  868. if (loc) {
  869. rect.left = loc.left;
  870. rect.top = loc.top;
  871. }
  872. var minX = 0;
  873. var minY = 0;
  874. var docRect = document.documentElement.getBoundingClientRect();
  875. var maxY = docRect.height - rect.height;
  876. var maxX = docRect.width - rect.width;
  877. var left = rect.left;
  878. var top = rect.top;
  879. left = Math.min(left, maxX);
  880. left = Math.max(left, minX);
  881. top = Math.min(top, maxY);
  882. top = Math.max(top, minY);
  883. if (loc || top !== rect.top || left !== rect.left) {
  884. btnMuted.style.cssText +=
  885. 'left:' + left + 'px;top:' + top + 'px;';
  886. }
  887. };
  888. window.addEventListener('resize', function () {
  889. fixLoc();
  890. });
  891. var touchPoint = {
  892. pageY: 0,
  893. pageX: 0,
  894. };
  895. var currentLoc = {
  896. top: 0,
  897. left: 0,
  898. curTop: 0,
  899. curLeft: 0,
  900. };
  901. var toMove = false;
  902. var touchmove = function (e) {
  903. e.preventDefault();
  904. var point = e.changedTouches[0];
  905. var top = -touchPoint.pageY + point.pageY;
  906. var left = -touchPoint.pageX + point.pageX;
  907. if (toMove) {
  908. top += currentLoc.top;
  909. left += currentLoc.left;
  910. currentLoc.curLeft = left;
  911. currentLoc.curTop = top;
  912. btnMuted.style.cssText +=
  913. 'left:' + left + 'px;top:' + top + 'px;';
  914. } else {
  915. if (Math.abs(top) >= 5 || Math.abs(left) >= 5) {
  916. toMove = true;
  917. }
  918. }
  919. };
  920. var touchend = function () {
  921. window.removeEventListener('touchmove', touchmove, {
  922. passive: false,
  923. });
  924. window.removeEventListener('touchend', touchend, {
  925. passive: false,
  926. });
  927. if (toMove) {
  928. setHistory(currentLoc.curLeft, currentLoc.curTop);
  929. fixLoc();
  930. } else {
  931. //按点击处理
  932. var set = $('.control-right-img').attr('data-id');
  933. if (set == '1') {
  934. $('.control-right-img').attr({
  935. 'data-id': '2',
  936. });
  937. $('.leftmains').css({
  938. right: '0rem',
  939. });
  940. } else {
  941. $('.control-right-img').attr({
  942. 'data-id': '1',
  943. });
  944. $('.leftmains').css({
  945. right: '-4rem',
  946. });
  947. }
  948. }
  949. };
  950. btnMuted.addEventListener(
  951. 'touchstart',
  952. function (e) {
  953. e.preventDefault();
  954. toMove = false;
  955. var point = e.changedTouches[0];
  956. touchPoint.pageX = point.pageX;
  957. touchPoint.pageY = point.pageY;
  958. var rect = e.target.getBoundingClientRect();
  959. currentLoc.top = rect.top;
  960. currentLoc.left = rect.left;
  961. window.addEventListener('touchmove', touchmove, {
  962. passive: false,
  963. });
  964. window.addEventListener('touchend', touchend, {
  965. passive: false,
  966. });
  967. },
  968. {
  969. passive: false,
  970. },
  971. );
  972. var history = getHistory();
  973. if (history) {
  974. fixLoc(history);
  975. }
  976. btnMuted.classList.remove('hide');
  977. })();
  978. function handleClose() {
  979. $('.mask').hide();
  980. }
  981. var decodeCount = 1;
  982. var isFinish = false;
  983. var player = new PCMPlayer({
  984. encoding: '16bitInt',
  985. channels: 2,
  986. sampleRate: 44100,
  987. flushingTime: 22,
  988. debug: false,
  989. });
  990. Module = {};
  991. Module.onRuntimeInitialized = function () {
  992. isFinish = true;
  993. };
  994. function decodeAAC(data) {
  995. var retPtr = Module._malloc(4 * 5 * 1024); //接收的数据
  996. var inputPtr = Module._malloc(4 * data.length); //输入数据
  997. for (var i = 0; i < data.length; i++) {
  998. Module.HEAPU8[inputPtr + i] = data[i]; //转换为堆数据
  999. }
  1000. var pcmLen = Module._feedData(retPtr, inputPtr, data.length);
  1001. if (pcmLen >= 0) {
  1002. var pcmData = new Uint8Array(pcmLen);
  1003. for (var i = 0; i < pcmLen; i++) {
  1004. pcmData[i] = Module.HEAPU8[retPtr + i];
  1005. }
  1006. player.feed(pcmData);
  1007. }
  1008. decodeCount++;
  1009. Module._free(inputPtr);
  1010. Module._free(retPtr);
  1011. }
  1012. var decodeWoker = new Worker('decoder.js');
  1013. var myVideo = document.getElementById('playCanvas');
  1014. var logicWidth = 720;
  1015. var logicHeight = 1280;
  1016. decodeWoker.onmessage = function (event) {
  1017. var objData = event.data;
  1018. // console.log("🚀 ~ file: WXtrialInterface.html ~ line 806 ~ objData", objData)
  1019. switch (objData.cmd) {
  1020. case 0:
  1021. break;
  1022. case 1:
  1023. // console.log(objData);
  1024. if (logicWidth != objData.width || logicHeight != objData.height) {
  1025. logicWidth = objData.width;
  1026. logicHeight = objData.height;
  1027. }
  1028. // logicWidth = 375
  1029. // logicHeight = 812
  1030. webglPlayer.renderFrame(
  1031. objData.data,
  1032. logicWidth,
  1033. logicHeight,
  1034. logicWidth * logicHeight,
  1035. (logicWidth / 2) * (logicHeight / 2),
  1036. );
  1037. $('.weui-mask_transparent').hide();
  1038. $('.weui-toast').hide();
  1039. $('.loading').hide();
  1040. break;
  1041. case 5:
  1042. var buffer = RequestIFrame();
  1043. webSocketWorker.postMessage(buffer);
  1044. }
  1045. };
  1046. var isFinish = false;
  1047. var webglPlayer = new WebGLPlayer(myVideo, {
  1048. preserveDrawingBuffer: false,
  1049. });
  1050. function GetRequest() {
  1051. var url = location.search; // 获取url中"?"符后的字串
  1052. var obj = new Object();
  1053. if (url.indexOf('?') != -1) {
  1054. var str = url.substr(1);
  1055. strs = str.split('&');
  1056. for (var i = 0; i < strs.length; i++) {
  1057. obj[strs[i].split('=')[0]] = strs[i].split('=')[1];
  1058. }
  1059. }
  1060. return obj;
  1061. }
  1062. function doConnectBusiness() {
  1063. var webSocketWorker = new Worker(
  1064. 'websocket.js?socketURL=' +
  1065. encodeURIComponent(socketURL) +
  1066. '&cardToken=' +
  1067. encodeURIComponent(cardToken),
  1068. );
  1069. window.webSocketWorker = webSocketWorker;
  1070. webSocketWorker.onmessage = function (event) {
  1071. var input = event.data;
  1072. if (input[0] == 0xff && isAudioPlay) {
  1073. decodeAAC(input);
  1074. }
  1075. if (
  1076. input[0] == 0 &&
  1077. input[1] == 0 &&
  1078. input[2] == 0 &&
  1079. input[3] == 1
  1080. ) {
  1081. var cmd = {
  1082. type: 'rawData',
  1083. data: event.data,
  1084. };
  1085. decodeWoker.postMessage(cmd);
  1086. }
  1087. if (input[0] == 0x68) {
  1088. if (input[23] == 0x5c) {
  1089. if (CheckVerifyCode(input)) {
  1090. webSocketWorker.postMessage(ConfigChannel('RK3923C1201900139'));
  1091. var checkBuffer = GetScreenState();
  1092. webSocketWorker.postMessage(checkBuffer);
  1093. } else {
  1094. connect('update');
  1095. }
  1096. }
  1097. if (input[23] == 0x05) {
  1098. //横竖屏标识
  1099. if (input[28] == 0x01 && input[29] == 0x01) {
  1100. var state = CheckScreenDirection(input.slice(24, 24 + 8));
  1101. if (state == 1) {
  1102. console.log('安卓卡此时竖屏');
  1103. //竖屏处理
  1104. resolving = 1;
  1105. // $('#playCanvas').removeClass('horizontal').addClass('vertical');
  1106. } else {
  1107. console.log('安卓卡此时横屏');
  1108. //横屏处理
  1109. resolving = 0;
  1110. // $('#playCanvas').removeClass('vertical').addClass('horizontal');
  1111. }
  1112. }
  1113. // window.phoneSizeList = window.phoneSizeListBack.map(function (
  1114. // item,
  1115. // ) {
  1116. // return resolving
  1117. // ? item
  1118. // : Object.assign({}, item, {
  1119. // width: item.height,
  1120. // height: item.width,
  1121. // });
  1122. // });
  1123. // wsss.send(
  1124. // JSON.stringify({
  1125. // type: 'getPhoneSize',
  1126. // }),
  1127. // );
  1128. // 横竖屏变更时获取分辨率要延迟,不然会获取到变更前的分辨率
  1129. // setTimeout(function () {
  1130. // wsss.send(
  1131. // JSON.stringify({
  1132. // type: 'getPhoneSize',
  1133. // }),
  1134. // );
  1135. // }, 500);
  1136. }
  1137. if (input[23] == 0x0b) {
  1138. console.log('多端登陆');
  1139. }
  1140. }
  1141. if (event.data === 'close') {
  1142. $.toast('画面异常,请重新进入', 'text');
  1143. setTimeout(() => {
  1144. decodeWoker.postMessage('close');
  1145. decodeWoker.terminate();
  1146. quit();
  1147. }, 3000);
  1148. }
  1149. };
  1150. }
  1151. // 激活码广告相关配置
  1152. function getConfigByPhoneType() {
  1153. return new Promise((resolve, reject) => {
  1154. $.ajax({
  1155. url: baseUrl + '/api/pay/v5/trialCodeConfig/getConfigByPhoneType',
  1156. headers: {
  1157. Authorization: token,
  1158. },
  1159. data: {
  1160. userCardId: userCardId,
  1161. phoneType: mealType,
  1162. },
  1163. type: 'get',
  1164. dataType: 'json',
  1165. success: function (res) {
  1166. console.log(res);
  1167. let obj = res.data;
  1168. if (res.status === 0) {
  1169. resolve(obj);
  1170. } else {
  1171. $.toast(res.msg, 'text');
  1172. }
  1173. },
  1174. });
  1175. });
  1176. }
  1177. //列表
  1178. function getSetmealList() {
  1179. return new Promise((resolve, reject) => {
  1180. $.ajax({
  1181. url: baseUrl + '/api/resources/v4/freetrial/setmeal/list',
  1182. headers: {
  1183. Authorization: token,
  1184. },
  1185. type: 'get',
  1186. dataType: 'json',
  1187. success: function (res) {
  1188. if (res.status === 0) {
  1189. let list = res.data;
  1190. list.map((item) => {
  1191. if (item.phoneType === mealType) {
  1192. resolve(item);
  1193. }
  1194. });
  1195. } else {
  1196. $.toast(res.msg, 'text');
  1197. }
  1198. },
  1199. });
  1200. });
  1201. }
  1202. //广告信息
  1203. var adData = null; // 广告数据
  1204. var adLastTime = 0; // 广告时间
  1205. var intervalTime = 0; // 间隔时间
  1206. // let adType = 0;
  1207. console.log(
  1208. '🚀 ~ file: WXtrialInterface.html ~ line 973 ~ sourceType',
  1209. sourceType,
  1210. );
  1211. // 拉取广告数据
  1212. function getAD() {
  1213. return $.ajax({
  1214. url: baseUrl + '/api/public/v5/advertising/getAdInfoByAdPlace',
  1215. headers: {
  1216. Authorization: token,
  1217. },
  1218. data: JSON.stringify({
  1219. adPlace: adType,
  1220. os: 0,
  1221. }),
  1222. type: 'POST',
  1223. dataType: 'json',
  1224. contentType: 'application/json;charset=UTF-8',
  1225. }).then(function (res) {
  1226. if (res.status === 0) {
  1227. var list = res.data.filter(
  1228. (v) => v.adType === 1 && !!v.adVideoBase.videoUrl,
  1229. );
  1230. adData = list[Math.floor(Math.random() * list.length)];
  1231. console.log(
  1232. '🚀 ~ file: WXtrialInterface.html ~ line 990 ~ getAD ~ adData',
  1233. adData,
  1234. );
  1235. return adData;
  1236. } else {
  1237. return Promise.reject(new Error(res.msg));
  1238. }
  1239. });
  1240. }
  1241. // 播放广告
  1242. function playAD() {
  1243. var nowTime = Date.now();
  1244. if (
  1245. adData &&
  1246. // [1, 2].includes(sourceType) &&
  1247. $('.try-use-wrap').eq(0).is(':hidden') &&
  1248. nowTime > adLastTime + intervalTime
  1249. ) {
  1250. $('#source').attr('src', adData.adVideoBase.videoUrl);
  1251. $('.try-use-wrap').eq(0).show();
  1252. $('#source')[0].play();
  1253. videoTime = adData.forcedTime;
  1254. adData = null;
  1255. adLastTime = nowTime;
  1256. videoTimer = setInterval(() => {
  1257. if (videoTime > 0) {
  1258. videoTime--;
  1259. $('.time-node')
  1260. .eq(0)
  1261. .text(videoTime + 's');
  1262. } else {
  1263. clearInterval(videoTimer);
  1264. $('.time-node').eq(0).text('');
  1265. }
  1266. }, 1000);
  1267. if (intervalTime > 0) {
  1268. // 间隔广告拉取下一次广告数据
  1269. adType = 16;
  1270. getAD();
  1271. }
  1272. if (adType === 16 && sourceType == 1) {
  1273. // 间隔广告和试用才上报
  1274. report(0);
  1275. }
  1276. }
  1277. }
  1278. var residueTimer = null;
  1279. // 获取云机剩余时长
  1280. function getResidueTime() {
  1281. if (sourceType !== 5) {
  1282. return
  1283. }
  1284. return $.ajax({
  1285. url: baseUrl + `/api/resources/yearMember/getResidueTime?userCardId=${userCardId}`,
  1286. headers: {
  1287. Authorization: token,
  1288. },
  1289. type: 'get',
  1290. dataType: 'json',
  1291. contentType: 'application/json;charset=UTF-8',
  1292. }).then(function (res) {
  1293. if (res.status === 0) {
  1294. let time = res.data;
  1295. residueTimer = setInterval(() => {
  1296. if (time > 0) {
  1297. time--;
  1298. $('.countdown-time').text(residueTimeStamp(time));
  1299. } else {
  1300. clearInterval(residueTimer);
  1301. downline();
  1302. }
  1303. }, 1000)
  1304. } else {
  1305. return Promise.reject(new Error(res.msg));
  1306. }
  1307. });
  1308. }
  1309. // 秒转化为时分秒
  1310. function getResultTime(time) {
  1311. let theTime = parseInt(time);// 秒
  1312. let theTime1 = 0;// 分
  1313. let theTime2 = 0;// 小时
  1314. if(theTime > 60) {
  1315. theTime1 = parseInt(theTime/60);
  1316. theTime = parseInt(theTime%60);
  1317. if(theTime1 > 60) {
  1318. theTime2 = parseInt(theTime1/60);
  1319. theTime1 = parseInt(theTime1%60);
  1320. }
  1321. }
  1322. let result = '' + parseInt(theTime);
  1323. if(theTime1 > 0) {
  1324. result = '' + parseInt(theTime1) + ':' + result;
  1325. }
  1326. if(theTime2 > 0) {
  1327. result = '' + parseInt(theTime2) + ':' + result;
  1328. }
  1329. return result;
  1330. }
  1331. // 推荐列表
  1332. function getRecommend() {
  1333. return $.ajax({
  1334. url: baseUrl + `/api/public/v1/market/get/recommend?userCardId=${userCardId}`,
  1335. headers: {
  1336. Authorization: token,
  1337. },
  1338. type: 'get',
  1339. dataType: 'json',
  1340. contentType: 'application/json;charset=UTF-8',
  1341. }).then(function (res) {
  1342. if (res.status === 0) {
  1343. $('.apply-wrap').eq(0).show();
  1344. let list = res.data;
  1345. let result = '';
  1346. list.map(item => {
  1347. item.installNum = `有${item.installNum}人下载`
  1348. result += $('#apply').text().replace(/{{(.*?)}}/g, function(node, key) {
  1349. return item[key];
  1350. })
  1351. })
  1352. $('.apply-list').eq(0).append(result)
  1353. } else {
  1354. return Promise.reject(new Error(res.msg));
  1355. }
  1356. });
  1357. }
  1358. //点击了换一批
  1359. $('.apply-list-change')[0].addEventListener('click',() => {
  1360. $('.apply-list').eq(0).empty();
  1361. getRecommend();
  1362. })
  1363. //点击了关闭按钮
  1364. $('.apply-close')[0].addEventListener('click',() => {
  1365. localStorage.setItem('isShowRecommend', true);
  1366. $('.apply-wrap').eq(0).hide();
  1367. })
  1368. // 点击下载按钮
  1369. $('.apply-wrap')[0].addEventListener('click',(e)=>{
  1370. let id = e.target.dataset.id;
  1371. let downloadUrl = e.target.dataset.url;
  1372. let className = e.target.className;
  1373. if(className === 'apply-down-btn'){
  1374. var pings2 = {
  1375. type: 'downAndInstallApk',
  1376. data: {
  1377. apkUrl: downloadUrl,
  1378. taskUid: id
  1379. },
  1380. };
  1381. wsss.send(JSON.stringify(pings2));
  1382. }
  1383. })
  1384. // 点击了我知道了
  1385. $('.countdown-btn')[0].addEventListener('click',() => {
  1386. $('.countdown-wrap').eq(0).hide();
  1387. clearInterval(residueTimer);
  1388. getRecommend();
  1389. })
  1390. // 点击了续时长
  1391. $('.time-lang-btn')[0].addEventListener('click',() => {
  1392. $('.time-lang-wrap').eq(0).hide();
  1393. if (window.__wxjs_environment === 'miniprogram') {
  1394. wx.miniProgram.navigateTo({
  1395. url:`/packageA/order/renew/index?record=` + userCardId
  1396. });
  1397. } else {
  1398. uni.webView.navigateTo({
  1399. url: '/pages/order/renew?record=' + userCardId
  1400. })
  1401. }
  1402. })
  1403. /**
  1404. * 初始化广告
  1405. * 因移动端video无法自动播放,play()方法不能异步调用。
  1406. * 解决方案,初始化时预先请求广告数据,在用户对云手机touchmove事件中去播放广告并请求下一次广告数据。
  1407. */
  1408. function initAD() {
  1409. console.log(
  1410. '🚀 ~ file: WXtrialInterface.html ~ line 1052 ~ initAD ~ sourceType',
  1411. sourceType,
  1412. );
  1413. (function () {
  1414. switch (sourceType) {
  1415. case 1: {
  1416. return getSetmealList().then(function (res) {
  1417. intervalTime =
  1418. res.intervalSwitch === 1
  1419. ? res.intervalAdvertDuration * 1000 * 60
  1420. : 0;
  1421. if (res.pushFlowAdvert === 1) {
  1422. adType = 15;
  1423. adTime = 0;
  1424. } else if (intervalTime > 0) {
  1425. adType = 16;
  1426. adTime = date.now();
  1427. }
  1428. });
  1429. }
  1430. case 2: {
  1431. return getConfigByPhoneType().then(function (res) {
  1432. if (res.isDisconnectionTime === 1) {
  1433. var time = res.disconnectionTime * 60 * 1000;
  1434. setTimeout(() => {
  1435. disconnectionFlag = true;
  1436. $('.buy-phone-wrap').eq(0).show();
  1437. }, time);
  1438. }
  1439. intervalTime =
  1440. res.isIntervalPlayAd === 1
  1441. ? res.intervalPlayAdTime * 1000 * 60
  1442. : 0;
  1443. if (res.isShowAd === 1) {
  1444. adType = 15;
  1445. adTime = 0;
  1446. } else if (intervalTime > 0) {
  1447. adType = 16;
  1448. adTime = date.now();
  1449. }
  1450. });
  1451. }
  1452. default: {
  1453. return Promise.reject();
  1454. }
  1455. }
  1456. })().then(function () {
  1457. console.log(adType);
  1458. this.$('#playCanvas').on('touchstart', playAD);
  1459. // this.$('#playCanvas').on('touchmove', playAD);
  1460. getAD();
  1461. });
  1462. }
  1463. // 观看广告次数上报1
  1464. function reportFrequency() {
  1465. $.ajax({
  1466. url: baseUrl + '/api/resoures/v1/trial/reportFrequency/' + userCardId,
  1467. headers: {
  1468. Authorization: token,
  1469. },
  1470. type: 'post',
  1471. contentType: 'application/json',
  1472. dataType: 'json',
  1473. success: function (res) { },
  1474. });
  1475. }
  1476. //间隔广告上报
  1477. function report(type) {
  1478. $.ajax({
  1479. url: baseUrl + '/api/resources/v1/trial/report',
  1480. headers: {
  1481. Authorization: token,
  1482. },
  1483. data: JSON.stringify({
  1484. userCardId: userCardId,
  1485. reportType: type,
  1486. }),
  1487. type: 'POST',
  1488. dataType: 'json',
  1489. contentType: 'application/json;charset=UTF-8',
  1490. success: function (res) { },
  1491. });
  1492. }
  1493. //关闭广告
  1494. $('.time-close-wrap')[0].addEventListener('click', () => {
  1495. if (videoTime == 0) {
  1496. reportFrequency();
  1497. }
  1498. $('.buy-phone-wrap').eq(0).show();
  1499. });
  1500. // 点击取消
  1501. $('.cannel-btn')[0].addEventListener('click', () => {
  1502. $('.buy-phone-wrap').eq(0).hide();
  1503. if (disconnectionFlag || getDate) {
  1504. //设置了断线时间,取消直接退出
  1505. systemBuriedPoint('激活码-断线-取消');
  1506. quit();
  1507. return;
  1508. }
  1509. let pointName = '';
  1510. if (sourceType == 1) {
  1511. pointName =
  1512. videoTime == 0 ? '免费试用-关闭-取消' : '免费试用-强制关闭-取消';
  1513. } else {
  1514. pointName =
  1515. videoTime == 0 ? '激活码-关闭-取消' : '激活码-强制关闭-取消';
  1516. }
  1517. systemBuriedPoint(pointName);
  1518. if (videoTime == 0) {
  1519. if (adType === 16 && sourceType == 1) {
  1520. report(1);
  1521. }
  1522. $('.try-use-wrap').eq(0).hide();
  1523. $('#source')[0].pause();
  1524. return;
  1525. }
  1526. $('.look-wrap').eq(0).show();
  1527. });
  1528. // 点击去购买
  1529. $('.go-bug')[0].addEventListener('click', () => {
  1530. let pointName = '';
  1531. if (disconnectionFlag) {
  1532. pointName = '激活码-断线-去购买';
  1533. } else if (sourceType == 1) {
  1534. pointName =
  1535. videoTime == 0
  1536. ? '免费试用-关闭-去购买'
  1537. : '免费试用-强制关闭-去购买';
  1538. } else {
  1539. pointName =
  1540. videoTime == 0 ? '激活码-关闭-去购买' : '激活码-强制关闭-去购买';
  1541. }
  1542. systemBuriedPoint(pointName);
  1543. if (getDate) {
  1544. if (window.__wxjs_environment === 'miniprogram') {
  1545. wx.miniProgram.navigateTo({
  1546. url: '/packageA/order/buy/index?buyType=试用界面购买',
  1547. });
  1548. } else {
  1549. uni.webView.navigateTo({
  1550. url: '/pages/order/order',
  1551. });
  1552. }
  1553. } else {
  1554. if (window.__wxjs_environment === 'miniprogram') {
  1555. wx.miniProgram.navigateTo({
  1556. url:
  1557. `/packageA/order/renew/index?buyType=${sourceType == 1
  1558. ? '试用弹窗购买按钮进入-普通试用'
  1559. : '试用弹窗购买按钮进入-激活码试用'
  1560. }&record=` + userCardId,
  1561. });
  1562. } else {
  1563. uni.webView.navigateTo({
  1564. url: '/pages/order/order',
  1565. });
  1566. }
  1567. }
  1568. });
  1569. window.onbeforeunload = function () {
  1570. wsss.close();
  1571. decodeWoker.postMessage('close');
  1572. decodeWoker.terminate();
  1573. };
  1574. // 埋点
  1575. function systemBuriedPoint(pointName) {
  1576. $.ajax({
  1577. url: baseUrl + '/api/public/v1/systemBuriedPoint/stat',
  1578. headers: {
  1579. Authorization: token,
  1580. },
  1581. type: 'post',
  1582. data: JSON.stringify({
  1583. pointName: pointName,
  1584. }),
  1585. contentType: 'application/json',
  1586. dataType: 'json',
  1587. success: function (res) { },
  1588. });
  1589. }
  1590. function quit() {
  1591. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  1592. tt.miniProgram.switchTab({
  1593. url: '/pages/home/home',
  1594. });
  1595. } else if (window.__wxjs_environment === 'miniprogram') {
  1596. wx.miniProgram.switchTab({
  1597. url: '/pages/home/home',
  1598. });
  1599. } else {
  1600. uni.webView.navigateBack({
  1601. delta: 1,
  1602. });
  1603. }
  1604. }
  1605. function updatePhoneSizeListHtml() {
  1606. const templatePhoneSizeItem = doT.template(
  1607. $('#template-phone-size-item').html().replace(/&amp;/g, '&'),
  1608. );
  1609. // console.log({
  1610. // list: window.phoneSizeList,
  1611. // active: window.activePhoneSize,
  1612. // resolving,
  1613. // });
  1614. const phoneSizeListItemsHtml = templatePhoneSizeItem({
  1615. list: window.phoneSizeList,
  1616. active: window.activePhoneSize,
  1617. resolving,
  1618. });
  1619. $('#phone-size-list').html(phoneSizeListItemsHtml);
  1620. }
  1621. $('#open-set-phone-size-dialog-btn').on('click', async function (e) {
  1622. !window.phoneSizeList.length && (await getPhoneSizeList());
  1623. window.activePhoneSize = window.currentPhoneSize;
  1624. updatePhoneSizeListHtml();
  1625. $('#set-phone-size-dialog').addClass('show');
  1626. });
  1627. // $('#set-phone-size-dialog').addClass('show');
  1628. $('.dialog .dialog-mask')
  1629. .add('.dialog .dialog-btn.cancel')
  1630. .on('click', function (e) {
  1631. $(e.currentTarget).parents('.dialog').removeClass('show');
  1632. });
  1633. // 分辨率列表
  1634. window.phoneSizeList = [];
  1635. // 当前生效的分辨率
  1636. // 选中的分辨率
  1637. // window.activePhoneSize = window.currentPhoneSize;
  1638. async function getPhoneSizeList() {
  1639. const response = await $.ajax({
  1640. url:
  1641. baseUrl + '/api/resources/v5/machine/resolution/getResolvingPower',
  1642. headers: {
  1643. Authorization: token,
  1644. },
  1645. type: 'get',
  1646. dataType: 'json',
  1647. data: {
  1648. userCardId,
  1649. },
  1650. });
  1651. const phoneSizeList = response.data.map(function (v) {
  1652. return {
  1653. id: v.id,
  1654. dpi: v.dpi,
  1655. width: v.width,
  1656. height: v.high,
  1657. };
  1658. });
  1659. window.phoneSizeList = phoneSizeList;
  1660. // 关联上当前云机分辨率
  1661. const currentPhoneSize = phoneSizeList.find(function (v) {
  1662. return (
  1663. window.currentPhoneSize &&
  1664. v.width === window.currentPhoneSize.width &&
  1665. v.height === window.currentPhoneSize.height &&
  1666. v.dpi === window.currentPhoneSize.dpi
  1667. );
  1668. });
  1669. window.currentPhoneSize = currentPhoneSize || window.currentPhoneSize;
  1670. }
  1671. /*
  1672. getPhoneSizeList().then(function (phoneSizeList) {
  1673. window.phoneSizeList = phoneSizeList;
  1674. // window.phoneSizeListBack = phoneSizeList; // 备份下数据,用户横竖切换时。
  1675. const currentPhoneSize = window.phoneSizeList.find(function (v) {
  1676. return (
  1677. window.currentPhoneSize &&
  1678. v.width === window.currentPhoneSize.width &&
  1679. v.height === window.currentPhoneSize.height &&
  1680. v.dpi === window.currentPhoneSize.dpi
  1681. );
  1682. });
  1683. window.currentPhoneSize = currentPhoneSize || window.currentPhoneSize;
  1684. // return updatePhoneSizeListHtml();
  1685. });
  1686. */
  1687. // const phoneSizeListSwiper = new Swiper('#phone-size-list-swiper', {
  1688. // direction: 'vertical',
  1689. // slidesPerView: 'auto',
  1690. // loop: false,
  1691. // centeredSlides: true,
  1692. // });
  1693. let lastSetPhone = 0;
  1694. function setPhoneSize(config) {
  1695. if (config.id === currentPhoneSize.id) {
  1696. return;
  1697. }
  1698. if (Date.now() <= lastSetPhone + 1000 * 5) {
  1699. throw new Error('请勿频繁操作');
  1700. }
  1701. lastSetPhone = Date.now();
  1702. // config = Object.assign({}, config, {
  1703. // width: config.width,
  1704. // height: config.height,
  1705. // });
  1706. // 修改云机分辨率
  1707. wsss.send(
  1708. JSON.stringify({
  1709. type: 'setPhoneSize',
  1710. data: {
  1711. id: config.id,
  1712. width: config.width,
  1713. height: config.height,
  1714. dpi: config.dpi,
  1715. },
  1716. }),
  1717. );
  1718. // XXX: 去除了,改为中台发送
  1719. // 通知其他在线端
  1720. // wsss.send(
  1721. // JSON.stringify({
  1722. // type: 'forwardMsg',
  1723. // data: {
  1724. // code: 'phoneSizeChange',
  1725. // id: config.id,
  1726. // width: config.width,
  1727. // height: config.height,
  1728. // dpi: config.dpi,
  1729. // desc: '分辨率修改', // 可选
  1730. // },
  1731. // }),
  1732. // );
  1733. // 上报分辨率
  1734. window.currentPhoneSize = config;
  1735. }
  1736. // wsss.addEventListener('message', function (event) {
  1737. // console.log(
  1738. // '🚀 ~ file: WXtrialInterface.html ~ line 1476 ~ event',
  1739. // event,
  1740. // );
  1741. // });
  1742. $('#phone-size-list').on('click', '.phone-size-item', function (e) {
  1743. const data = $(e.currentTarget).data();
  1744. // console.log(
  1745. // '🚀 ~ file: WXtrialInterface.html ~ line 1494 ~ data',
  1746. // data,
  1747. // );
  1748. window.activePhoneSize = data;
  1749. updatePhoneSizeListHtml();
  1750. // setPhoneSize(data.width, data.height);
  1751. });
  1752. $('#set-phone-size-dialog .dialog-btn.confirm').on('click', function (e) {
  1753. try {
  1754. setPhoneSize(window.activePhoneSize);
  1755. $('#set-phone-size-dialog').removeClass('show');
  1756. } catch (error) {
  1757. $.toast(error.message, 'text');
  1758. }
  1759. });
  1760. </script>
  1761. <script type="text/javascript" src="WXdraw.js"></script>
  1762. <script type="text/javascript" src="aac.js"></script>
  1763. <script type="text/javascript" src="./timer.js"></script>
  1764. </body>
  1765. </html>