WXtrialInterface.html 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561
  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,
  411. timeInterval = 0;
  412. function connect(type) {
  413. $.ajax({
  414. url: baseUrl + '/api/resources/user/cloud/connect',
  415. type: 'post',
  416. data: JSON.stringify({
  417. userCardId: Number(userCardId),
  418. }),
  419. headers: {
  420. 'content-Type': 'application/json',
  421. Authorization: token,
  422. },
  423. dataType: 'json',
  424. async: false,
  425. success: function (res) {
  426. if (res.status === 0) {
  427. if (timerInterval) {
  428. timerInterval = clearTimeout();
  429. }
  430. if (res.data.internetHttps) {
  431. socketURL =
  432. 'wss://' +
  433. res.data.internetHttps +
  434. '/plugflow?cardIp=' +
  435. res.data.localIp +
  436. '&token=' +
  437. res.data.cardToken +
  438. '&type=business';
  439. cUrl =
  440. 'wss://' +
  441. res.data.internetHttps +
  442. '/businessChannel?cardIp=' +
  443. res.data.localIp +
  444. '&token=' +
  445. res.data.cardToken +
  446. '&type=directives';
  447. cardToken = res.data.cardToken;
  448. resolvingPower = res.data.resolvingPower;
  449. doConnectBusiness();
  450. doConnectDirectives();
  451. if (type === 'add') {
  452. addData(db, storeName, {
  453. id: userCardId,
  454. socketURL: socketURL,
  455. cUrl: cUrl,
  456. cardToken: res.data.cardToken,
  457. resolvingPower: res.data.resolvingPower,
  458. });
  459. } else {
  460. updateDB(db, storeName, {
  461. id: userCardId,
  462. socketURL: socketURL,
  463. cUrl: cUrl,
  464. cardToken: res.data.cardToken,
  465. resolvingPower: res.data.resolvingPower,
  466. });
  467. }
  468. } else {
  469. $.toast('网络异常,请稍后重试', 'text');
  470. setTimeout(() => {
  471. clearInterval(intervaler);
  472. quit();
  473. }, 3000);
  474. }
  475. } else if (res.status === 5200) {
  476. if (timeInterval > 7) {
  477. $.toast('网络异常,请稍后重试', 'text');
  478. timerInterval = clearTimeout();
  479. setTimeout(() => {
  480. quit();
  481. }, 3000);
  482. return;
  483. }
  484. timerInterval = setTimeout(() => {
  485. connect(type);
  486. timeInterval += 1;
  487. }, 3000);
  488. } else {
  489. $.toast('画面异常,请重新进入', 'text');
  490. setTimeout(() => {
  491. quit();
  492. }, 3000);
  493. }
  494. },
  495. });
  496. }
  497. initAD();
  498. $.alert({
  499. title: '提示',
  500. text: '开始使用云手机',
  501. onOK: function () {
  502. isAudioPlay = true;
  503. },
  504. });
  505. //云机倒计时
  506. let validTime = parameters['validTime'] || 10000;
  507. if (validTime > 32000) {
  508. validTime = 32000;
  509. }
  510. let detailTime = validTime * 60 * 1000;
  511. setTimeout(() => {
  512. $('.bug-title').eq(0).text('尊敬的用户您的云手机试用时间已到期');
  513. getDate = true;
  514. $('.buy-phone-wrap').eq(0).show();
  515. }, detailTime);
  516. var orientation = 0; //0 竖屏,1横屏
  517. function array_unique(arr) {
  518. return arr.filter(function (e, i) {
  519. return arr.indexOf(e) === i;
  520. });
  521. }
  522. var cutList = [];
  523. let timer,
  524. isFlag = true;
  525. function showShearPlate() {
  526. stopManyClick(function () {
  527. new Promise((resolve, reject) => {
  528. if (window.navigator.clipboard) {
  529. window.navigator.clipboard
  530. .readText()
  531. .then(
  532. function (content) {
  533. return $.ajax({
  534. url: baseUrl + '/api/public/v5/shear/content',
  535. type: 'post',
  536. dataType: 'json',
  537. data: JSON.stringify({
  538. content: content,
  539. }),
  540. headers: {
  541. 'content-Type': 'application/json',
  542. Authorization: token,
  543. },
  544. });
  545. },
  546. function (err) {
  547. $.toast('读取剪贴板失败', 'text');
  548. },
  549. )
  550. .finally(resolve);
  551. } else {
  552. resolve();
  553. }
  554. }).then(function () {
  555. $('.box-shear-plate').empty();
  556. return $.ajax({
  557. url: baseUrl + '/api/public/v5/shear/content',
  558. headers: {
  559. Authorization: token,
  560. },
  561. type: 'get',
  562. dataType: 'json',
  563. success: function (res) {
  564. if (res.status === 0) {
  565. if (res.data.length) {
  566. cutList = array_unique(res.data);
  567. var str =
  568. '<div class="title">剪贴板<div onclick="handleClear()" class="btn-clear">清空</div></div><div class="slide-wrapper-content">';
  569. cutList.forEach(function (item) {
  570. str +=
  571. "<div class='slide-wrapper'><div class='slide-scroll animate-slide-start'><div class='slide-content'><div onclick='handleCopy(\"" +
  572. item.content +
  573. '")\'>' +
  574. item.content +
  575. "</div></div><div class='slide-content-button'><button onclick='handleDelete(" +
  576. item.id +
  577. ")'>删除</button></div></div></div>";
  578. });
  579. str += '</div>';
  580. $('.box-shear-plate').append(str);
  581. } else {
  582. $('.box-shear-plate').append(
  583. '<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>',
  584. );
  585. }
  586. $('.mask').show();
  587. initSlider();
  588. } else {
  589. $('.box-shear-plate').append(
  590. '<img class="empty" src="img/jianqieban_pic@2x.png" alt="" /><div class="empty-txt">剪贴板为空</div>',
  591. );
  592. $('.mask').show();
  593. }
  594. },
  595. });
  596. });
  597. });
  598. }
  599. //防止提示一秒内重复显示
  600. function stopManyClick(fn) {
  601. if (isFlag) {
  602. fn();
  603. }
  604. isFlag = false;
  605. if (timer) {
  606. clearTimeout(timer);
  607. }
  608. timer = setTimeout(() => {
  609. isFlag = true;
  610. }, 1500);
  611. }
  612. // 清空剪贴板
  613. function handleClear() {
  614. var ids = '';
  615. cutList.forEach(function (item) {
  616. ids += 'ids=' + item.id + '&';
  617. });
  618. ids = ids.substring(0, ids.lastIndexOf('&'));
  619. $.confirm('确定清空剪贴板?', function () {
  620. $.ajax({
  621. url: baseUrl + '/api/public/v5/shear/content?' + ids,
  622. headers: {
  623. Authorization: token,
  624. },
  625. type: 'DELETE',
  626. dataType: 'json',
  627. success: function (res) {
  628. if (res.status === 0) {
  629. showShearPlate();
  630. } else {
  631. $.toast(res.msg, 'text');
  632. }
  633. },
  634. });
  635. });
  636. }
  637. function handleCopy(content) {
  638. var cutting = {
  639. type: 'cutting',
  640. data: {
  641. str: content,
  642. },
  643. };
  644. wsss.send(JSON.stringify(cutting));
  645. }
  646. // 删除剪贴板
  647. function handleDelete(id) {
  648. $.ajax({
  649. url: baseUrl + '/api/public/v5/shear/content?ids=' + id,
  650. headers: {
  651. Authorization: token,
  652. },
  653. type: 'DELETE',
  654. dataType: 'json',
  655. success: function (res) {
  656. if (res.status === 0) {
  657. showShearPlate();
  658. } else {
  659. $.toast(res.msg, 'text');
  660. }
  661. },
  662. });
  663. }
  664. function initSlider() {
  665. //手指滑动多少距离就认为是滑成功
  666. //这个值不能太大,否则影响斜着滑动时,垂直滑动的流畅性,也不能太小,太灵敏也不好
  667. var diffXDistance = 50;
  668. //当前滑动的对象
  669. var currentObject;
  670. //上一次滑动的对象
  671. var lastObject;
  672. //是否可以左右滑动,在上下滑的时候禁止左右滑
  673. var canSlide = true;
  674. //用于记录按下的点
  675. var startPoint;
  676. $('.slide-content').css({
  677. width: $('.slide-wrapper').width(),
  678. });
  679. document.body.removeEventListener(
  680. 'touchmove',
  681. function (e) {
  682. e.preventDefault();
  683. },
  684. {
  685. passive: false,
  686. },
  687. );
  688. $('.slide-scroll')
  689. .css({
  690. width:
  691. $('.slide-wrapper').width() + $('.slide-content-button').width(),
  692. })
  693. .on('touchstart', function (e) {
  694. currentObject = this;
  695. startPoint = {
  696. x: e.originalEvent.changedTouches[0].pageX,
  697. y: e.originalEvent.changedTouches[0].pageY,
  698. };
  699. })
  700. .on('touchmove', function (e) {
  701. //如果是左右滑动,就禁止上下的滑动
  702. //如果是上下的滑动,就禁止左右滑动
  703. if (
  704. Math.abs(e.originalEvent.changedTouches[0].pageX - startPoint.x) >
  705. Math.abs(e.originalEvent.changedTouches[0].pageY - startPoint.y)
  706. ) {
  707. event.preventDefault();
  708. } else {
  709. canSlide = false;
  710. }
  711. })
  712. .on('touchend', function (e) {
  713. //如果是上下滑动,这里就直接返回了
  714. if (!canSlide) {
  715. canSlide = true;
  716. return true;
  717. }
  718. //点击除当前左滑对象之外的任意其他位置
  719. if (lastObject && currentObject != lastObject) {
  720. //右滑→
  721. $(lastObject).removeClass('animate-slide');
  722. //清空上一个左滑的对象
  723. lastObject = undefined;
  724. }
  725. var diffX = e.originalEvent.changedTouches[0].pageX - startPoint.x;
  726. if (diffX < -diffXDistance) {
  727. //左滑←
  728. $(currentObject).addClass('animate-slide');
  729. if (lastObject && lastObject != currentObject) {
  730. //右滑→
  731. $(lastObject).removeClass('animate-slide');
  732. }
  733. //记录上一个左滑的对象
  734. lastObject = currentObject;
  735. } else if (diffX >= diffXDistance) {
  736. if (currentObject == lastObject) {
  737. //右滑→
  738. $(currentObject).removeClass('animate-slide');
  739. //清空上一个左滑的对象
  740. lastObject = undefined;
  741. }
  742. }
  743. });
  744. }
  745. var btnMuted = document.querySelector('#btnMuted');
  746. btnMuted &&
  747. (function () {
  748. var setHistory = function (left, top) {
  749. try {
  750. localStorage.setItem(
  751. 'muted-btn-loc',
  752. JSON.stringify({
  753. left: left,
  754. top: top,
  755. }),
  756. );
  757. } catch (ex) {}
  758. };
  759. var getHistory = function () {
  760. try {
  761. var value = localStorage.getItem('muted-btn-loc');
  762. if (!value) return null;
  763. value = JSON.parse(value);
  764. if (!value) return null;
  765. return value;
  766. } catch (ex) {
  767. return null;
  768. }
  769. };
  770. var fixLoc = function (loc) {
  771. var rect = btnMuted.getBoundingClientRect();
  772. rect = {
  773. top: rect.top,
  774. left: rect.left,
  775. width: rect.width,
  776. height: rect.height,
  777. }; // 部分低版本浏览器,该属性为只读
  778. if (loc) {
  779. rect.left = loc.left;
  780. rect.top = loc.top;
  781. }
  782. var minX = 0;
  783. var minY = 0;
  784. var docRect = document.documentElement.getBoundingClientRect();
  785. var maxY = docRect.height - rect.height;
  786. var maxX = docRect.width - rect.width;
  787. var left = rect.left;
  788. var top = rect.top;
  789. left = Math.min(left, maxX);
  790. left = Math.max(left, minX);
  791. top = Math.min(top, maxY);
  792. top = Math.max(top, minY);
  793. if (loc || top !== rect.top || left !== rect.left) {
  794. btnMuted.style.cssText +=
  795. 'left:' + left + 'px;top:' + top + 'px;';
  796. }
  797. };
  798. window.addEventListener('resize', function () {
  799. fixLoc();
  800. });
  801. var touchPoint = {
  802. pageY: 0,
  803. pageX: 0,
  804. };
  805. var currentLoc = {
  806. top: 0,
  807. left: 0,
  808. curTop: 0,
  809. curLeft: 0,
  810. };
  811. var toMove = false;
  812. var touchmove = function (e) {
  813. e.preventDefault();
  814. var point = e.changedTouches[0];
  815. var top = -touchPoint.pageY + point.pageY;
  816. var left = -touchPoint.pageX + point.pageX;
  817. if (toMove) {
  818. top += currentLoc.top;
  819. left += currentLoc.left;
  820. currentLoc.curLeft = left;
  821. currentLoc.curTop = top;
  822. btnMuted.style.cssText +=
  823. 'left:' + left + 'px;top:' + top + 'px;';
  824. } else {
  825. if (Math.abs(top) >= 5 || Math.abs(left) >= 5) {
  826. toMove = true;
  827. }
  828. }
  829. };
  830. var touchend = function () {
  831. window.removeEventListener('touchmove', touchmove, {
  832. passive: false,
  833. });
  834. window.removeEventListener('touchend', touchend, {
  835. passive: false,
  836. });
  837. if (toMove) {
  838. setHistory(currentLoc.curLeft, currentLoc.curTop);
  839. fixLoc();
  840. } else {
  841. //按点击处理
  842. var set = $('.control-right-img').attr('data-id');
  843. if (set == '1') {
  844. $('.control-right-img').attr({
  845. 'data-id': '2',
  846. });
  847. $('.leftmains').css({
  848. right: '0rem',
  849. });
  850. } else {
  851. $('.control-right-img').attr({
  852. 'data-id': '1',
  853. });
  854. $('.leftmains').css({
  855. right: '-4rem',
  856. });
  857. }
  858. }
  859. };
  860. btnMuted.addEventListener(
  861. 'touchstart',
  862. function (e) {
  863. e.preventDefault();
  864. toMove = false;
  865. var point = e.changedTouches[0];
  866. touchPoint.pageX = point.pageX;
  867. touchPoint.pageY = point.pageY;
  868. var rect = e.target.getBoundingClientRect();
  869. currentLoc.top = rect.top;
  870. currentLoc.left = rect.left;
  871. window.addEventListener('touchmove', touchmove, {
  872. passive: false,
  873. });
  874. window.addEventListener('touchend', touchend, {
  875. passive: false,
  876. });
  877. },
  878. {
  879. passive: false,
  880. },
  881. );
  882. var history = getHistory();
  883. if (history) {
  884. fixLoc(history);
  885. }
  886. btnMuted.classList.remove('hide');
  887. })();
  888. $('#upload').on('click', function () {
  889. decodeWoker.postMessage('close');
  890. decodeWoker.terminate();
  891. quit();
  892. });
  893. function handleClose() {
  894. $('.mask').hide();
  895. }
  896. var decodeCount = 1;
  897. var isFinish = false;
  898. var player = new PCMPlayer({
  899. encoding: '16bitInt',
  900. channels: 2,
  901. sampleRate: 44100,
  902. flushingTime: 22,
  903. debug: false,
  904. });
  905. Module = {};
  906. Module.onRuntimeInitialized = function () {
  907. isFinish = true;
  908. };
  909. function decodeAAC(data) {
  910. var retPtr = Module._malloc(4 * 5 * 1024); //接收的数据
  911. var inputPtr = Module._malloc(4 * data.length); //输入数据
  912. for (var i = 0; i < data.length; i++) {
  913. Module.HEAPU8[inputPtr + i] = data[i]; //转换为堆数据
  914. }
  915. var pcmLen = Module._feedData(retPtr, inputPtr, data.length);
  916. if (pcmLen >= 0) {
  917. var pcmData = new Uint8Array(pcmLen);
  918. for (var i = 0; i < pcmLen; i++) {
  919. pcmData[i] = Module.HEAPU8[retPtr + i];
  920. }
  921. player.feed(pcmData);
  922. }
  923. decodeCount++;
  924. Module._free(inputPtr);
  925. Module._free(retPtr);
  926. }
  927. var decodeWoker = new Worker('decoder.js');
  928. var myVideo = document.getElementById('playCanvas');
  929. var logicWidth = 720;
  930. var logicHeight = 1280;
  931. decodeWoker.onmessage = function (event) {
  932. var objData = event.data;
  933. // console.log("🚀 ~ file: WXtrialInterface.html ~ line 806 ~ objData", objData)
  934. switch (objData.cmd) {
  935. case 0:
  936. break;
  937. case 1:
  938. // console.log(objData);
  939. if (logicWidth != objData.width || logicHeight != objData.height) {
  940. logicWidth = objData.width;
  941. logicHeight = objData.height;
  942. }
  943. // logicWidth = 375
  944. // logicHeight = 812
  945. webglPlayer.renderFrame(
  946. objData.data,
  947. logicWidth,
  948. logicHeight,
  949. logicWidth * logicHeight,
  950. (logicWidth / 2) * (logicHeight / 2),
  951. );
  952. $('.weui-mask_transparent').hide();
  953. $('.weui-toast').hide();
  954. $('.loading').hide();
  955. break;
  956. case 5:
  957. var buffer = RequestIFrame();
  958. webSocketWorker.postMessage(buffer);
  959. }
  960. };
  961. var isFinish = false;
  962. var webglPlayer = new WebGLPlayer(myVideo, {
  963. preserveDrawingBuffer: false,
  964. });
  965. function GetRequest() {
  966. var url = location.search; // 获取url中"?"符后的字串
  967. var obj = new Object();
  968. if (url.indexOf('?') != -1) {
  969. var str = url.substr(1);
  970. strs = str.split('&');
  971. for (var i = 0; i < strs.length; i++) {
  972. obj[strs[i].split('=')[0]] = strs[i].split('=')[1];
  973. }
  974. }
  975. return obj;
  976. }
  977. function doConnectBusiness() {
  978. var webSocketWorker = new Worker(
  979. 'websocket.js?socketURL=' +
  980. encodeURIComponent(socketURL) +
  981. '&cardToken=' +
  982. encodeURIComponent(cardToken),
  983. );
  984. window.webSocketWorker = webSocketWorker;
  985. webSocketWorker.onmessage = function (event) {
  986. var input = event.data;
  987. if (input[0] == 0xff && isAudioPlay) {
  988. decodeAAC(input);
  989. }
  990. if (
  991. input[0] == 0 &&
  992. input[1] == 0 &&
  993. input[2] == 0 &&
  994. input[3] == 1
  995. ) {
  996. var cmd = {
  997. type: 'rawData',
  998. data: event.data,
  999. };
  1000. decodeWoker.postMessage(cmd);
  1001. }
  1002. if (input[0] == 0x68) {
  1003. if (input[23] == 0x5c) {
  1004. if (CheckVerifyCode(input)) {
  1005. webSocketWorker.postMessage(ConfigChannel('RK3923C1201900139'));
  1006. var checkBuffer = GetScreenState();
  1007. webSocketWorker.postMessage(checkBuffer);
  1008. } else {
  1009. connect('update');
  1010. }
  1011. }
  1012. if (input[23] == 0x05) {
  1013. //横竖屏标识
  1014. var state = CheckScreenDirection(input.slice(24, 24 + 8));
  1015. if (state == 1) {
  1016. console.log('安卓卡此时竖屏');
  1017. //竖屏处理
  1018. resolving = 1;
  1019. $('#playCanvas').removeClass('horizontal').addClass('vertical');
  1020. } else {
  1021. console.log('安卓卡此时横屏');
  1022. //横屏处理
  1023. resolving = 0;
  1024. $('#playCanvas').removeClass('vertical').addClass('horizontal');
  1025. }
  1026. }
  1027. if (input[23] == 0x0b) {
  1028. console.log('多端登陆');
  1029. }
  1030. }
  1031. if (event.data === 'close') {
  1032. $.toast('画面异常,请重新进入', 'text');
  1033. setTimeout(() => {
  1034. decodeWoker.postMessage('close');
  1035. decodeWoker.terminate();
  1036. quit();
  1037. }, 3000);
  1038. }
  1039. };
  1040. }
  1041. // 激活码广告相关配置
  1042. function getConfigByPhoneType() {
  1043. return new Promise((resolve, reject) => {
  1044. $.ajax({
  1045. url: baseUrl + '/api/pay/v5/trialCodeConfig/getConfigByPhoneType',
  1046. headers: {
  1047. Authorization: token,
  1048. },
  1049. data: {
  1050. userCardId: userCardId,
  1051. phoneType: mealType,
  1052. },
  1053. type: 'get',
  1054. dataType: 'json',
  1055. success: function (res) {
  1056. console.log(res);
  1057. let obj = res.data;
  1058. if (res.status === 0) {
  1059. resolve(obj);
  1060. } else {
  1061. $.toast(res.msg, 'text');
  1062. }
  1063. },
  1064. });
  1065. });
  1066. }
  1067. //列表
  1068. function getSetmealList() {
  1069. return new Promise((resolve, reject) => {
  1070. $.ajax({
  1071. url: baseUrl + '/api/resources/v4/freetrial/setmeal/list',
  1072. headers: {
  1073. Authorization: token,
  1074. },
  1075. type: 'get',
  1076. dataType: 'json',
  1077. success: function (res) {
  1078. if (res.status === 0) {
  1079. let list = res.data;
  1080. list.map((item) => {
  1081. if (item.phoneType === mealType) {
  1082. resolve(item);
  1083. }
  1084. });
  1085. } else {
  1086. $.toast(res.msg, 'text');
  1087. }
  1088. },
  1089. });
  1090. });
  1091. }
  1092. //广告信息
  1093. var adData = null; // 广告数据
  1094. var adLastTime = 0; // 广告时间
  1095. var intervalTime = 0; // 间隔时间
  1096. // let adType = 0;
  1097. console.log(
  1098. '🚀 ~ file: WXtrialInterface.html ~ line 973 ~ sourceType',
  1099. sourceType,
  1100. );
  1101. // 拉取广告数据
  1102. function getAD() {
  1103. return $.ajax({
  1104. url: baseUrl + '/api/public/v5/advertising/getAdInfoByAdPlace',
  1105. headers: {
  1106. Authorization: token,
  1107. },
  1108. data: JSON.stringify({
  1109. adPlace: adType,
  1110. os: 0,
  1111. }),
  1112. type: 'POST',
  1113. dataType: 'json',
  1114. contentType: 'application/json;charset=UTF-8',
  1115. }).then(function (res) {
  1116. if (res.status === 0) {
  1117. var list = res.data.filter(
  1118. (v) => v.adType === 1 && !!v.adVideoBase.videoUrl,
  1119. );
  1120. adData = list[Math.floor(Math.random() * list.length)];
  1121. console.log(
  1122. '🚀 ~ file: WXtrialInterface.html ~ line 990 ~ getAD ~ adData',
  1123. adData,
  1124. );
  1125. return adData;
  1126. } else {
  1127. return Promise.reject(new Error(res.msg));
  1128. }
  1129. });
  1130. }
  1131. // 播放广告
  1132. function playAD() {
  1133. var nowTime = Date.now();
  1134. if (
  1135. adData &&
  1136. // [1, 2].includes(sourceType) &&
  1137. $('.try-use-wrap').eq(0).is(':hidden') &&
  1138. nowTime > adLastTime + intervalTime
  1139. ) {
  1140. $('#source').attr('src', adData.adVideoBase.videoUrl);
  1141. $('.try-use-wrap').eq(0).show();
  1142. $('#source')[0].play();
  1143. videoTime = adData.forcedTime;
  1144. adData = null;
  1145. adLastTime = nowTime;
  1146. videoTimer = setInterval(() => {
  1147. if (videoTime > 0) {
  1148. videoTime--;
  1149. $('.time-node')
  1150. .eq(0)
  1151. .text(videoTime + 's');
  1152. } else {
  1153. clearInterval(videoTimer);
  1154. $('.time-node').eq(0).text('');
  1155. }
  1156. }, 1000);
  1157. if (intervalTime > 0) {
  1158. // 间隔广告拉取下一次广告数据
  1159. adType = 16;
  1160. getAD();
  1161. }
  1162. if (adType === 16 && sourceType == 1) {
  1163. // 间隔广告和试用才上报
  1164. report(0);
  1165. }
  1166. }
  1167. }
  1168. /**
  1169. * 初始化广告
  1170. * 因移动端video无法自动播放,play()方法不能异步调用。
  1171. * 解决方案,初始化时预先请求广告数据,在用户对云手机touchmove事件中去播放广告并请求下一次广告数据。
  1172. */
  1173. function initAD() {
  1174. console.log(
  1175. '🚀 ~ file: WXtrialInterface.html ~ line 1052 ~ initAD ~ sourceType',
  1176. sourceType,
  1177. );
  1178. (function () {
  1179. switch (sourceType) {
  1180. case 1: {
  1181. return getSetmealList().then(function (res) {
  1182. intervalTime =
  1183. res.intervalSwitch === 1
  1184. ? res.intervalAdvertDuration * 1000 * 60
  1185. : 0;
  1186. if (res.pushFlowAdvert === 1) {
  1187. adType = 15;
  1188. adTime = 0;
  1189. } else if (intervalTime > 0) {
  1190. adType = 16;
  1191. adTime = date.now();
  1192. }
  1193. });
  1194. }
  1195. case 2: {
  1196. return getConfigByPhoneType().then(function (res) {
  1197. if (res.isDisconnectionTime === 1) {
  1198. var time = res.disconnectionTime * 60 * 1000;
  1199. setTimeout(() => {
  1200. disconnectionFlag = true;
  1201. $('.buy-phone-wrap').eq(0).show();
  1202. }, time);
  1203. }
  1204. intervalTime =
  1205. res.isIntervalPlayAd === 1
  1206. ? res.intervalPlayAdTime * 1000 * 60
  1207. : 0;
  1208. if (res.isShowAd === 1) {
  1209. adType = 15;
  1210. adTime = 0;
  1211. } else if (intervalTime > 0) {
  1212. adType = 16;
  1213. adTime = date.now();
  1214. }
  1215. });
  1216. }
  1217. default: {
  1218. return Promise.reject();
  1219. }
  1220. }
  1221. })().then(function () {
  1222. console.log(adType);
  1223. this.$('#playCanvas').on('touchstart', playAD);
  1224. // this.$('#playCanvas').on('touchmove', playAD);
  1225. getAD();
  1226. });
  1227. }
  1228. // 观看广告次数上报1
  1229. function reportFrequency() {
  1230. $.ajax({
  1231. url:
  1232. baseUrl +
  1233. '/api/resoures/v1/trial/reportFrequency/' +
  1234. form.userCardId,
  1235. headers: {
  1236. Authorization: form.token,
  1237. },
  1238. type: 'post',
  1239. contentType: 'application/json',
  1240. dataType: 'json',
  1241. success: function (res) {},
  1242. });
  1243. }
  1244. //间隔广告上报
  1245. function report(type) {
  1246. $.ajax({
  1247. url: baseUrl + '/api/resources/v1/trial/report',
  1248. headers: {
  1249. Authorization: token,
  1250. },
  1251. data: JSON.stringify({
  1252. userCardId: userCardId,
  1253. reportType: type,
  1254. }),
  1255. type: 'POST',
  1256. dataType: 'json',
  1257. contentType: 'application/json;charset=UTF-8',
  1258. success: function (res) {},
  1259. });
  1260. }
  1261. //关闭广告
  1262. $('.time-close-wrap')[0].addEventListener('click', () => {
  1263. if (videoTime == 0) {
  1264. reportFrequency();
  1265. }
  1266. $('.buy-phone-wrap').eq(0).show();
  1267. });
  1268. // 点击取消
  1269. $('.cannel-btn')[0].addEventListener('click', () => {
  1270. $('.buy-phone-wrap').eq(0).hide();
  1271. if (disconnectionFlag || getDate) {
  1272. //设置了断线时间,取消直接退出
  1273. systemBuriedPoint('激活码-断线-取消');
  1274. quit();
  1275. return;
  1276. }
  1277. let pointName = '';
  1278. if (sourceType == 1) {
  1279. pointName =
  1280. videoTime == 0 ? '免费试用-关闭-取消' : '免费试用-强制关闭-取消';
  1281. } else {
  1282. pointName =
  1283. videoTime == 0 ? '激活码-关闭-取消' : '激活码-强制关闭-取消';
  1284. }
  1285. systemBuriedPoint(pointName);
  1286. if (videoTime == 0) {
  1287. if (adType === 16 && sourceType == 1) {
  1288. report(1);
  1289. }
  1290. $('.try-use-wrap').eq(0).hide();
  1291. $('#source')[0].pause();
  1292. return;
  1293. }
  1294. $('.look-wrap').eq(0).show();
  1295. });
  1296. // 点击去购买
  1297. $('.go-bug')[0].addEventListener('click', () => {
  1298. let pointName = '';
  1299. if (disconnectionFlag) {
  1300. pointName = '激活码-断线-去购买';
  1301. } else if (sourceType == 1) {
  1302. pointName =
  1303. videoTime == 0
  1304. ? '免费试用-关闭-去购买'
  1305. : '免费试用-强制关闭-去购买';
  1306. } else {
  1307. pointName =
  1308. videoTime == 0 ? '激活码-关闭-去购买' : '激活码-强制关闭-去购买';
  1309. }
  1310. systemBuriedPoint(pointName);
  1311. if (getDate) {
  1312. if (window.__wxjs_environment === 'miniprogram') {
  1313. wx.miniProgram.navigateTo({
  1314. url: '/packageA/order/buy/index?buyType=试用界面购买',
  1315. });
  1316. } else {
  1317. uni.webView.navigateTo({
  1318. url: '/pages/order/order',
  1319. });
  1320. }
  1321. } else {
  1322. if (window.__wxjs_environment === 'miniprogram') {
  1323. wx.miniProgram.navigateTo({
  1324. url:
  1325. `/packageA/order/renew/index?buyType=${
  1326. sourceType == 1
  1327. ? '试用弹窗购买按钮进入-普通试用'
  1328. : '试用弹窗购买按钮进入-激活码试用'
  1329. }&record=` + userCardId,
  1330. });
  1331. } else {
  1332. uni.webView.navigateTo({
  1333. url: '/pages/order/order',
  1334. });
  1335. }
  1336. }
  1337. });
  1338. window.onbeforeunload = function () {
  1339. wsss.close();
  1340. decodeWoker.postMessage('close');
  1341. decodeWoker.terminate();
  1342. };
  1343. function quit() {
  1344. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  1345. tt.miniProgram.switchTab({
  1346. url: '/pages/home/home',
  1347. });
  1348. } else if (window.__wxjs_environment === 'miniprogram') {
  1349. wx.miniProgram.switchTab({
  1350. url: '/pages/home/home',
  1351. });
  1352. } else {
  1353. uni.webView.navigateBack({
  1354. delta: 1,
  1355. });
  1356. }
  1357. }
  1358. function updatePhoneSizeListHtml() {
  1359. const templatePhoneSizeItem = doT.template(
  1360. $('#template-phone-size-item').html().replace(/&amp;/g, '&'),
  1361. );
  1362. const phoneSizeListItemsHtml = templatePhoneSizeItem({
  1363. list: window.phoneSizeList,
  1364. active: window.activePhoneSize,
  1365. });
  1366. $('#phone-size-list').html(phoneSizeListItemsHtml);
  1367. }
  1368. $('#open-set-phone-size-dialog-btn').on('click', function (e) {
  1369. window.activePhoneSize = window.currentPhoneSize;
  1370. updatePhoneSizeListHtml();
  1371. $('#set-phone-size-dialog').addClass('show');
  1372. });
  1373. // $('#set-phone-size-dialog').addClass('show');
  1374. $('.dialog .dialog-mask')
  1375. .add('.dialog .dialog-btn.cancel')
  1376. .on('click', function (e) {
  1377. $(e.currentTarget).parents('.dialog').removeClass('show');
  1378. });
  1379. // 分辨率列表
  1380. window.phoneSizeList = [];
  1381. // 当前生效的分辨率
  1382. window.currentPhoneSize = {
  1383. // id: 1,
  1384. width: 720,
  1385. height: 1280,
  1386. };
  1387. // 选中的分辨率
  1388. window.activePhoneSize = window.currentPhoneSize;
  1389. function getPhoneSizeList() {
  1390. return $.ajax({
  1391. url:
  1392. baseUrl + '/api/resources/v5/machine/resolution/getResolvingPower',
  1393. headers: {
  1394. Authorization: token,
  1395. },
  1396. type: 'get',
  1397. dataType: 'json',
  1398. data: {
  1399. userCardId,
  1400. },
  1401. }).then(function (response) {
  1402. return response.data.map(function (v) {
  1403. return {
  1404. id: v.id,
  1405. dpi: v.dpi,
  1406. width: v.width || v.abscissa,
  1407. height: v.height || v.ordinate || v.high,
  1408. };
  1409. });
  1410. });
  1411. }
  1412. getPhoneSizeList().then(function (phoneSizeList) {
  1413. window.phoneSizeList = phoneSizeList;
  1414. const currentPhoneSize = window.phoneSizeList.find(function (v) {
  1415. return (
  1416. v.width === window.currentPhoneSize.width &&
  1417. v.height === window.currentPhoneSize.height
  1418. );
  1419. });
  1420. window.currentPhoneSize = currentPhoneSize || window.currentPhoneSize;
  1421. return updatePhoneSizeListHtml();
  1422. });
  1423. // const phoneSizeListSwiper = new Swiper('#phone-size-list-swiper', {
  1424. // direction: 'vertical',
  1425. // slidesPerView: 'auto',
  1426. // loop: false,
  1427. // centeredSlides: true,
  1428. // });
  1429. function setPhoneSize(config) {
  1430. // 修改云机分辨率
  1431. wsss.send(
  1432. JSON.stringify({
  1433. type: 'setPhoneSize',
  1434. data: {
  1435. id: config.id,
  1436. width: config.width,
  1437. height: config.height,
  1438. dpi: config.dpi,
  1439. },
  1440. }),
  1441. );
  1442. // 通知其他在线端
  1443. wsss.send(
  1444. JSON.stringify({
  1445. type: 'forwardMsg',
  1446. data: {
  1447. code: 'phoneSizeChange',
  1448. id: config.id,
  1449. width: config.width,
  1450. height: config.height,
  1451. dpi: config.dpi,
  1452. desc: '分辨率修改', // 可选
  1453. },
  1454. }),
  1455. );
  1456. // 上报分辨率
  1457. $.ajax({
  1458. url:
  1459. baseUrl +
  1460. '/api/resources/v5/machine/resolution/operationResolvingPower',
  1461. headers: {
  1462. Authorization: token,
  1463. },
  1464. type: 'post',
  1465. dataType: 'json',
  1466. contentType: 'application/json; charset=UTF-8',
  1467. data: JSON.stringify({
  1468. userCardId: window.userCardId,
  1469. resolvingPowerId: config.id,
  1470. width: config.width,
  1471. height: config.height,
  1472. dpi: config.dpi,
  1473. }),
  1474. });
  1475. window.currentPhoneSize = config;
  1476. }
  1477. // wsss.addEventListener('message', function (event) {
  1478. // console.log(
  1479. // '🚀 ~ file: WXtrialInterface.html ~ line 1476 ~ event',
  1480. // event,
  1481. // );
  1482. // });
  1483. $('#phone-size-list').on('click', '.phone-size-item', function (e) {
  1484. const data = $(e.currentTarget).data();
  1485. console.log(
  1486. '🚀 ~ file: WXtrialInterface.html ~ line 1494 ~ data',
  1487. data,
  1488. );
  1489. window.activePhoneSize = data;
  1490. updatePhoneSizeListHtml();
  1491. // setPhoneSize(data.width, data.height);
  1492. });
  1493. $('#set-phone-size-dialog .dialog-btn.confirm').on('click', function (e) {
  1494. setPhoneSize(window.activePhoneSize);
  1495. $('#set-phone-size-dialog').removeClass('show');
  1496. });
  1497. </script>
  1498. <script type="text/javascript" src="WXdraw.js"></script>
  1499. <script type="text/javascript" src="aac.js"></script>
  1500. </body>
  1501. </html>