WXtrialInterface.html 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562
  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="">
  82. <div class="menu-btn" 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. var btnMuted = document.querySelector('#btnMuted');
  747. btnMuted &&
  748. (function () {
  749. var setHistory = function (left, top) {
  750. try {
  751. localStorage.setItem(
  752. 'muted-btn-loc',
  753. JSON.stringify({
  754. left: left,
  755. top: top,
  756. }),
  757. );
  758. } catch (ex) {}
  759. };
  760. var getHistory = function () {
  761. try {
  762. var value = localStorage.getItem('muted-btn-loc');
  763. if (!value) return null;
  764. value = JSON.parse(value);
  765. if (!value) return null;
  766. return value;
  767. } catch (ex) {
  768. return null;
  769. }
  770. };
  771. var fixLoc = function (loc) {
  772. var rect = btnMuted.getBoundingClientRect();
  773. rect = {
  774. top: rect.top,
  775. left: rect.left,
  776. width: rect.width,
  777. height: rect.height,
  778. }; // 部分低版本浏览器,该属性为只读
  779. if (loc) {
  780. rect.left = loc.left;
  781. rect.top = loc.top;
  782. }
  783. var minX = 0;
  784. var minY = 0;
  785. var docRect = document.documentElement.getBoundingClientRect();
  786. var maxY = docRect.height - rect.height;
  787. var maxX = docRect.width - rect.width;
  788. var left = rect.left;
  789. var top = rect.top;
  790. left = Math.min(left, maxX);
  791. left = Math.max(left, minX);
  792. top = Math.min(top, maxY);
  793. top = Math.max(top, minY);
  794. if (loc || top !== rect.top || left !== rect.left) {
  795. btnMuted.style.cssText +=
  796. 'left:' + left + 'px;top:' + top + 'px;';
  797. }
  798. };
  799. window.addEventListener('resize', function () {
  800. fixLoc();
  801. });
  802. var touchPoint = {
  803. pageY: 0,
  804. pageX: 0,
  805. };
  806. var currentLoc = {
  807. top: 0,
  808. left: 0,
  809. curTop: 0,
  810. curLeft: 0,
  811. };
  812. var toMove = false;
  813. var touchmove = function (e) {
  814. e.preventDefault();
  815. var point = e.changedTouches[0];
  816. var top = -touchPoint.pageY + point.pageY;
  817. var left = -touchPoint.pageX + point.pageX;
  818. if (toMove) {
  819. top += currentLoc.top;
  820. left += currentLoc.left;
  821. currentLoc.curLeft = left;
  822. currentLoc.curTop = top;
  823. btnMuted.style.cssText +=
  824. 'left:' + left + 'px;top:' + top + 'px;';
  825. } else {
  826. if (Math.abs(top) >= 5 || Math.abs(left) >= 5) {
  827. toMove = true;
  828. }
  829. }
  830. };
  831. var touchend = function () {
  832. window.removeEventListener('touchmove', touchmove, {
  833. passive: false,
  834. });
  835. window.removeEventListener('touchend', touchend, {
  836. passive: false,
  837. });
  838. if (toMove) {
  839. setHistory(currentLoc.curLeft, currentLoc.curTop);
  840. fixLoc();
  841. } else {
  842. //按点击处理
  843. var set = $('.control-right-img').attr('data-id');
  844. if (set == '1') {
  845. $('.control-right-img').attr({
  846. 'data-id': '2',
  847. });
  848. $('.leftmains').css({
  849. right: '0rem',
  850. });
  851. } else {
  852. $('.control-right-img').attr({
  853. 'data-id': '1',
  854. });
  855. $('.leftmains').css({
  856. right: '-4rem',
  857. });
  858. }
  859. }
  860. };
  861. btnMuted.addEventListener(
  862. 'touchstart',
  863. function (e) {
  864. e.preventDefault();
  865. toMove = false;
  866. var point = e.changedTouches[0];
  867. touchPoint.pageX = point.pageX;
  868. touchPoint.pageY = point.pageY;
  869. var rect = e.target.getBoundingClientRect();
  870. currentLoc.top = rect.top;
  871. currentLoc.left = rect.left;
  872. window.addEventListener('touchmove', touchmove, {
  873. passive: false,
  874. });
  875. window.addEventListener('touchend', touchend, {
  876. passive: false,
  877. });
  878. },
  879. {
  880. passive: false,
  881. },
  882. );
  883. var history = getHistory();
  884. if (history) {
  885. fixLoc(history);
  886. }
  887. btnMuted.classList.remove('hide');
  888. })();
  889. $('#upload').on('click', function () {
  890. decodeWoker.postMessage('close');
  891. decodeWoker.terminate();
  892. quit();
  893. });
  894. function handleClose() {
  895. $('.mask').hide();
  896. }
  897. var decodeCount = 1;
  898. var isFinish = false;
  899. var player = new PCMPlayer({
  900. encoding: '16bitInt',
  901. channels: 2,
  902. sampleRate: 44100,
  903. flushingTime: 22,
  904. debug: false,
  905. });
  906. Module = {};
  907. Module.onRuntimeInitialized = function () {
  908. isFinish = true;
  909. };
  910. function decodeAAC(data) {
  911. var retPtr = Module._malloc(4 * 5 * 1024); //接收的数据
  912. var inputPtr = Module._malloc(4 * data.length); //输入数据
  913. for (var i = 0; i < data.length; i++) {
  914. Module.HEAPU8[inputPtr + i] = data[i]; //转换为堆数据
  915. }
  916. var pcmLen = Module._feedData(retPtr, inputPtr, data.length);
  917. if (pcmLen >= 0) {
  918. var pcmData = new Uint8Array(pcmLen);
  919. for (var i = 0; i < pcmLen; i++) {
  920. pcmData[i] = Module.HEAPU8[retPtr + i];
  921. }
  922. player.feed(pcmData);
  923. }
  924. decodeCount++;
  925. Module._free(inputPtr);
  926. Module._free(retPtr);
  927. }
  928. var decodeWoker = new Worker('decoder.js');
  929. var myVideo = document.getElementById('playCanvas');
  930. var logicWidth = 720;
  931. var logicHeight = 1280;
  932. decodeWoker.onmessage = function (event) {
  933. var objData = event.data;
  934. // console.log("🚀 ~ file: WXtrialInterface.html ~ line 806 ~ objData", objData)
  935. switch (objData.cmd) {
  936. case 0:
  937. break;
  938. case 1:
  939. // console.log(objData);
  940. if (logicWidth != objData.width || logicHeight != objData.height) {
  941. logicWidth = objData.width;
  942. logicHeight = objData.height;
  943. }
  944. // logicWidth = 375
  945. // logicHeight = 812
  946. webglPlayer.renderFrame(
  947. objData.data,
  948. logicWidth,
  949. logicHeight,
  950. logicWidth * logicHeight,
  951. (logicWidth / 2) * (logicHeight / 2),
  952. );
  953. $('.weui-mask_transparent').hide();
  954. $('.weui-toast').hide();
  955. $('.loading').hide();
  956. break;
  957. case 5:
  958. var buffer = RequestIFrame();
  959. webSocketWorker.postMessage(buffer);
  960. }
  961. };
  962. var isFinish = false;
  963. var webglPlayer = new WebGLPlayer(myVideo, {
  964. preserveDrawingBuffer: false,
  965. });
  966. function GetRequest() {
  967. var url = location.search; // 获取url中"?"符后的字串
  968. var obj = new Object();
  969. if (url.indexOf('?') != -1) {
  970. var str = url.substr(1);
  971. strs = str.split('&');
  972. for (var i = 0; i < strs.length; i++) {
  973. obj[strs[i].split('=')[0]] = strs[i].split('=')[1];
  974. }
  975. }
  976. return obj;
  977. }
  978. function doConnectBusiness() {
  979. var webSocketWorker = new Worker(
  980. 'websocket.js?socketURL=' +
  981. encodeURIComponent(socketURL) +
  982. '&cardToken=' +
  983. encodeURIComponent(cardToken),
  984. );
  985. window.webSocketWorker = webSocketWorker;
  986. webSocketWorker.onmessage = function (event) {
  987. var input = event.data;
  988. if (input[0] == 0xff && isAudioPlay) {
  989. decodeAAC(input);
  990. }
  991. if (
  992. input[0] == 0 &&
  993. input[1] == 0 &&
  994. input[2] == 0 &&
  995. input[3] == 1
  996. ) {
  997. var cmd = {
  998. type: 'rawData',
  999. data: event.data,
  1000. };
  1001. decodeWoker.postMessage(cmd);
  1002. }
  1003. if (input[0] == 0x68) {
  1004. if (input[23] == 0x5c) {
  1005. if (CheckVerifyCode(input)) {
  1006. webSocketWorker.postMessage(ConfigChannel('RK3923C1201900139'));
  1007. var checkBuffer = GetScreenState();
  1008. webSocketWorker.postMessage(checkBuffer);
  1009. } else {
  1010. connect('update');
  1011. }
  1012. }
  1013. if (input[23] == 0x05) {
  1014. //横竖屏标识
  1015. var state = CheckScreenDirection(input.slice(24, 24 + 8));
  1016. if (state == 1) {
  1017. console.log('安卓卡此时竖屏');
  1018. //竖屏处理
  1019. resolving = 1;
  1020. // $('#playCanvas').removeClass('horizontal').addClass('vertical');
  1021. } else {
  1022. console.log('安卓卡此时横屏');
  1023. //横屏处理
  1024. resolving = 0;
  1025. // $('#playCanvas').removeClass('vertical').addClass('horizontal');
  1026. }
  1027. }
  1028. if (input[23] == 0x0b) {
  1029. console.log('多端登陆');
  1030. }
  1031. }
  1032. if (event.data === 'close') {
  1033. $.toast('画面异常,请重新进入', 'text');
  1034. setTimeout(() => {
  1035. decodeWoker.postMessage('close');
  1036. decodeWoker.terminate();
  1037. quit();
  1038. }, 3000);
  1039. }
  1040. };
  1041. }
  1042. // 激活码广告相关配置
  1043. function getConfigByPhoneType() {
  1044. return new Promise((resolve, reject) => {
  1045. $.ajax({
  1046. url: baseUrl + '/api/pay/v5/trialCodeConfig/getConfigByPhoneType',
  1047. headers: {
  1048. Authorization: token,
  1049. },
  1050. data: {
  1051. userCardId: userCardId,
  1052. phoneType: mealType,
  1053. },
  1054. type: 'get',
  1055. dataType: 'json',
  1056. success: function (res) {
  1057. console.log(res);
  1058. let obj = res.data;
  1059. if (res.status === 0) {
  1060. resolve(obj);
  1061. } else {
  1062. $.toast(res.msg, 'text');
  1063. }
  1064. },
  1065. });
  1066. });
  1067. }
  1068. //列表
  1069. function getSetmealList() {
  1070. return new Promise((resolve, reject) => {
  1071. $.ajax({
  1072. url: baseUrl + '/api/resources/v4/freetrial/setmeal/list',
  1073. headers: {
  1074. Authorization: token,
  1075. },
  1076. type: 'get',
  1077. dataType: 'json',
  1078. success: function (res) {
  1079. if (res.status === 0) {
  1080. let list = res.data;
  1081. list.map((item) => {
  1082. if (item.phoneType === mealType) {
  1083. resolve(item);
  1084. }
  1085. });
  1086. } else {
  1087. $.toast(res.msg, 'text');
  1088. }
  1089. },
  1090. });
  1091. });
  1092. }
  1093. //广告信息
  1094. var adData = null; // 广告数据
  1095. var adLastTime = 0; // 广告时间
  1096. var intervalTime = 0; // 间隔时间
  1097. // let adType = 0;
  1098. console.log(
  1099. '🚀 ~ file: WXtrialInterface.html ~ line 973 ~ sourceType',
  1100. sourceType,
  1101. );
  1102. // 拉取广告数据
  1103. function getAD() {
  1104. return $.ajax({
  1105. url: baseUrl + '/api/public/v5/advertising/getAdInfoByAdPlace',
  1106. headers: {
  1107. Authorization: token,
  1108. },
  1109. data: JSON.stringify({
  1110. adPlace: adType,
  1111. os: 0,
  1112. }),
  1113. type: 'POST',
  1114. dataType: 'json',
  1115. contentType: 'application/json;charset=UTF-8',
  1116. }).then(function (res) {
  1117. if (res.status === 0) {
  1118. var list = res.data.filter(
  1119. (v) => v.adType === 1 && !!v.adVideoBase.videoUrl,
  1120. );
  1121. adData = list[Math.floor(Math.random() * list.length)];
  1122. console.log(
  1123. '🚀 ~ file: WXtrialInterface.html ~ line 990 ~ getAD ~ adData',
  1124. adData,
  1125. );
  1126. return adData;
  1127. } else {
  1128. return Promise.reject(new Error(res.msg));
  1129. }
  1130. });
  1131. }
  1132. // 播放广告
  1133. function playAD() {
  1134. var nowTime = Date.now();
  1135. if (
  1136. adData &&
  1137. // [1, 2].includes(sourceType) &&
  1138. $('.try-use-wrap').eq(0).is(':hidden') &&
  1139. nowTime > adLastTime + intervalTime
  1140. ) {
  1141. $('#source').attr('src', adData.adVideoBase.videoUrl);
  1142. $('.try-use-wrap').eq(0).show();
  1143. $('#source')[0].play();
  1144. videoTime = adData.forcedTime;
  1145. adData = null;
  1146. adLastTime = nowTime;
  1147. videoTimer = setInterval(() => {
  1148. if (videoTime > 0) {
  1149. videoTime--;
  1150. $('.time-node')
  1151. .eq(0)
  1152. .text(videoTime + 's');
  1153. } else {
  1154. clearInterval(videoTimer);
  1155. $('.time-node').eq(0).text('');
  1156. }
  1157. }, 1000);
  1158. if (intervalTime > 0) {
  1159. // 间隔广告拉取下一次广告数据
  1160. adType = 16;
  1161. getAD();
  1162. }
  1163. if (adType === 16 && sourceType == 1) {
  1164. // 间隔广告和试用才上报
  1165. report(0);
  1166. }
  1167. }
  1168. }
  1169. /**
  1170. * 初始化广告
  1171. * 因移动端video无法自动播放,play()方法不能异步调用。
  1172. * 解决方案,初始化时预先请求广告数据,在用户对云手机touchmove事件中去播放广告并请求下一次广告数据。
  1173. */
  1174. function initAD() {
  1175. console.log(
  1176. '🚀 ~ file: WXtrialInterface.html ~ line 1052 ~ initAD ~ sourceType',
  1177. sourceType,
  1178. );
  1179. (function () {
  1180. switch (sourceType) {
  1181. case 1: {
  1182. return getSetmealList().then(function (res) {
  1183. intervalTime =
  1184. res.intervalSwitch === 1
  1185. ? res.intervalAdvertDuration * 1000 * 60
  1186. : 0;
  1187. if (res.pushFlowAdvert === 1) {
  1188. adType = 15;
  1189. adTime = 0;
  1190. } else if (intervalTime > 0) {
  1191. adType = 16;
  1192. adTime = date.now();
  1193. }
  1194. });
  1195. }
  1196. case 2: {
  1197. return getConfigByPhoneType().then(function (res) {
  1198. if (res.isDisconnectionTime === 1) {
  1199. var time = res.disconnectionTime * 60 * 1000;
  1200. setTimeout(() => {
  1201. disconnectionFlag = true;
  1202. $('.buy-phone-wrap').eq(0).show();
  1203. }, time);
  1204. }
  1205. intervalTime =
  1206. res.isIntervalPlayAd === 1
  1207. ? res.intervalPlayAdTime * 1000 * 60
  1208. : 0;
  1209. if (res.isShowAd === 1) {
  1210. adType = 15;
  1211. adTime = 0;
  1212. } else if (intervalTime > 0) {
  1213. adType = 16;
  1214. adTime = date.now();
  1215. }
  1216. });
  1217. }
  1218. default: {
  1219. return Promise.reject();
  1220. }
  1221. }
  1222. })().then(function () {
  1223. console.log(adType);
  1224. this.$('#playCanvas').on('touchstart', playAD);
  1225. // this.$('#playCanvas').on('touchmove', playAD);
  1226. getAD();
  1227. });
  1228. }
  1229. // 观看广告次数上报1
  1230. function reportFrequency() {
  1231. $.ajax({
  1232. url:
  1233. baseUrl +
  1234. '/api/resoures/v1/trial/reportFrequency/' +
  1235. form.userCardId,
  1236. headers: {
  1237. Authorization: form.token,
  1238. },
  1239. type: 'post',
  1240. contentType: 'application/json',
  1241. dataType: 'json',
  1242. success: function (res) {},
  1243. });
  1244. }
  1245. //间隔广告上报
  1246. function report(type) {
  1247. $.ajax({
  1248. url: baseUrl + '/api/resources/v1/trial/report',
  1249. headers: {
  1250. Authorization: token,
  1251. },
  1252. data: JSON.stringify({
  1253. userCardId: userCardId,
  1254. reportType: type,
  1255. }),
  1256. type: 'POST',
  1257. dataType: 'json',
  1258. contentType: 'application/json;charset=UTF-8',
  1259. success: function (res) {},
  1260. });
  1261. }
  1262. //关闭广告
  1263. $('.time-close-wrap')[0].addEventListener('click', () => {
  1264. if (videoTime == 0) {
  1265. reportFrequency();
  1266. }
  1267. $('.buy-phone-wrap').eq(0).show();
  1268. });
  1269. // 点击取消
  1270. $('.cannel-btn')[0].addEventListener('click', () => {
  1271. $('.buy-phone-wrap').eq(0).hide();
  1272. if (disconnectionFlag || getDate) {
  1273. //设置了断线时间,取消直接退出
  1274. systemBuriedPoint('激活码-断线-取消');
  1275. quit();
  1276. return;
  1277. }
  1278. let pointName = '';
  1279. if (sourceType == 1) {
  1280. pointName =
  1281. videoTime == 0 ? '免费试用-关闭-取消' : '免费试用-强制关闭-取消';
  1282. } else {
  1283. pointName =
  1284. videoTime == 0 ? '激活码-关闭-取消' : '激活码-强制关闭-取消';
  1285. }
  1286. systemBuriedPoint(pointName);
  1287. if (videoTime == 0) {
  1288. if (adType === 16 && sourceType == 1) {
  1289. report(1);
  1290. }
  1291. $('.try-use-wrap').eq(0).hide();
  1292. $('#source')[0].pause();
  1293. return;
  1294. }
  1295. $('.look-wrap').eq(0).show();
  1296. });
  1297. // 点击去购买
  1298. $('.go-bug')[0].addEventListener('click', () => {
  1299. let pointName = '';
  1300. if (disconnectionFlag) {
  1301. pointName = '激活码-断线-去购买';
  1302. } else if (sourceType == 1) {
  1303. pointName =
  1304. videoTime == 0
  1305. ? '免费试用-关闭-去购买'
  1306. : '免费试用-强制关闭-去购买';
  1307. } else {
  1308. pointName =
  1309. videoTime == 0 ? '激活码-关闭-去购买' : '激活码-强制关闭-去购买';
  1310. }
  1311. systemBuriedPoint(pointName);
  1312. if (getDate) {
  1313. if (window.__wxjs_environment === 'miniprogram') {
  1314. wx.miniProgram.navigateTo({
  1315. url: '/packageA/order/buy/index?buyType=试用界面购买',
  1316. });
  1317. } else {
  1318. uni.webView.navigateTo({
  1319. url: '/pages/order/order',
  1320. });
  1321. }
  1322. } else {
  1323. if (window.__wxjs_environment === 'miniprogram') {
  1324. wx.miniProgram.navigateTo({
  1325. url:
  1326. `/packageA/order/renew/index?buyType=${
  1327. sourceType == 1
  1328. ? '试用弹窗购买按钮进入-普通试用'
  1329. : '试用弹窗购买按钮进入-激活码试用'
  1330. }&record=` + userCardId,
  1331. });
  1332. } else {
  1333. uni.webView.navigateTo({
  1334. url: '/pages/order/order',
  1335. });
  1336. }
  1337. }
  1338. });
  1339. window.onbeforeunload = function () {
  1340. wsss.close();
  1341. decodeWoker.postMessage('close');
  1342. decodeWoker.terminate();
  1343. };
  1344. function quit() {
  1345. if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
  1346. tt.miniProgram.switchTab({
  1347. url: '/pages/home/home',
  1348. });
  1349. } else if (window.__wxjs_environment === 'miniprogram') {
  1350. wx.miniProgram.switchTab({
  1351. url: '/pages/home/home',
  1352. });
  1353. } else {
  1354. uni.webView.navigateBack({
  1355. delta: 1,
  1356. });
  1357. }
  1358. }
  1359. function updatePhoneSizeListHtml() {
  1360. const templatePhoneSizeItem = doT.template(
  1361. $('#template-phone-size-item').html().replace(/&amp;/g, '&'),
  1362. );
  1363. const phoneSizeListItemsHtml = templatePhoneSizeItem({
  1364. list: window.phoneSizeList,
  1365. active: window.activePhoneSize,
  1366. });
  1367. $('#phone-size-list').html(phoneSizeListItemsHtml);
  1368. }
  1369. $('#open-set-phone-size-dialog-btn').on('click', function (e) {
  1370. window.activePhoneSize = window.currentPhoneSize;
  1371. updatePhoneSizeListHtml();
  1372. $('#set-phone-size-dialog').addClass('show');
  1373. });
  1374. // $('#set-phone-size-dialog').addClass('show');
  1375. $('.dialog .dialog-mask')
  1376. .add('.dialog .dialog-btn.cancel')
  1377. .on('click', function (e) {
  1378. $(e.currentTarget).parents('.dialog').removeClass('show');
  1379. });
  1380. // 分辨率列表
  1381. window.phoneSizeList = [];
  1382. // 当前生效的分辨率
  1383. window.currentPhoneSize = {
  1384. // id: 1,
  1385. width: 720,
  1386. height: 1280,
  1387. };
  1388. // 选中的分辨率
  1389. window.activePhoneSize = window.currentPhoneSize;
  1390. function getPhoneSizeList() {
  1391. return $.ajax({
  1392. url:
  1393. baseUrl + '/api/resources/v5/machine/resolution/getResolvingPower',
  1394. headers: {
  1395. Authorization: token,
  1396. },
  1397. type: 'get',
  1398. dataType: 'json',
  1399. data: {
  1400. userCardId,
  1401. },
  1402. }).then(function (response) {
  1403. return response.data.map(function (v) {
  1404. return {
  1405. id: v.id,
  1406. dpi: v.dpi,
  1407. width: v.width || v.abscissa,
  1408. height: v.height || v.ordinate || v.high,
  1409. };
  1410. });
  1411. });
  1412. }
  1413. getPhoneSizeList().then(function (phoneSizeList) {
  1414. window.phoneSizeList = phoneSizeList;
  1415. const currentPhoneSize = window.phoneSizeList.find(function (v) {
  1416. return (
  1417. v.width === window.currentPhoneSize.width &&
  1418. v.height === window.currentPhoneSize.height
  1419. );
  1420. });
  1421. window.currentPhoneSize = currentPhoneSize || window.currentPhoneSize;
  1422. return updatePhoneSizeListHtml();
  1423. });
  1424. // const phoneSizeListSwiper = new Swiper('#phone-size-list-swiper', {
  1425. // direction: 'vertical',
  1426. // slidesPerView: 'auto',
  1427. // loop: false,
  1428. // centeredSlides: true,
  1429. // });
  1430. function setPhoneSize(config) {
  1431. // 修改云机分辨率
  1432. wsss.send(
  1433. JSON.stringify({
  1434. type: 'setPhoneSize',
  1435. data: {
  1436. id: config.id,
  1437. width: config.width,
  1438. height: config.height,
  1439. dpi: config.dpi,
  1440. },
  1441. }),
  1442. );
  1443. // 通知其他在线端
  1444. wsss.send(
  1445. JSON.stringify({
  1446. type: 'forwardMsg',
  1447. data: {
  1448. code: 'phoneSizeChange',
  1449. id: config.id,
  1450. width: config.width,
  1451. height: config.height,
  1452. dpi: config.dpi,
  1453. desc: '分辨率修改', // 可选
  1454. },
  1455. }),
  1456. );
  1457. // 上报分辨率
  1458. $.ajax({
  1459. url:
  1460. baseUrl +
  1461. '/api/resources/v5/machine/resolution/operationResolvingPower',
  1462. headers: {
  1463. Authorization: token,
  1464. },
  1465. type: 'post',
  1466. dataType: 'json',
  1467. contentType: 'application/json; charset=UTF-8',
  1468. data: JSON.stringify({
  1469. userCardId: window.userCardId,
  1470. resolvingPowerId: config.id,
  1471. // width: config.width,
  1472. // height: config.height,
  1473. // dpi: config.dpi,
  1474. }),
  1475. });
  1476. window.currentPhoneSize = config;
  1477. }
  1478. // wsss.addEventListener('message', function (event) {
  1479. // console.log(
  1480. // '🚀 ~ file: WXtrialInterface.html ~ line 1476 ~ event',
  1481. // event,
  1482. // );
  1483. // });
  1484. $('#phone-size-list').on('click', '.phone-size-item', function (e) {
  1485. const data = $(e.currentTarget).data();
  1486. console.log(
  1487. '🚀 ~ file: WXtrialInterface.html ~ line 1494 ~ data',
  1488. data,
  1489. );
  1490. window.activePhoneSize = data;
  1491. updatePhoneSizeListHtml();
  1492. // setPhoneSize(data.width, data.height);
  1493. });
  1494. $('#set-phone-size-dialog .dialog-btn.confirm').on('click', function (e) {
  1495. setPhoneSize(window.activePhoneSize);
  1496. $('#set-phone-size-dialog').removeClass('show');
  1497. });
  1498. </script>
  1499. <script type="text/javascript" src="WXdraw.js"></script>
  1500. <script type="text/javascript" src="aac.js"></script>
  1501. </body>
  1502. </html>