WXtrialInterface.html 51 KB

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