WXtrialInterface.html 54 KB

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