WXtrialInterface.html 55 KB

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