WXtrialInterface.html 53 KB

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