WXtrialInterface.html 54 KB

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