WXtrialInterface.html 53 KB

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