WXtrialInterface.html 60 KB

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