WXtrialInterface.html 53 KB

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