WXtrialInterface.html 51 KB

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