WXtrialInterface.html 54 KB

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