WXtrialInterface.html 55 KB

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