WXtrialInterface.html 53 KB

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