WXtrialInterface.html 50 KB

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