WXtrialInterface.html 50 KB

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