browserDetail.html 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <link rel="icon" href="../static/img/favicon2.ico" type="img/x-ico">
  7. <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
  8. <title></title>
  9. <link rel="stylesheet" href="https://cdn.bootcss.com/weui/1.1.3/style/weui.min.css">
  10. <script src="../static/js/vender/vue/axios.min.js"></script>
  11. <script src="../static/js/vender/vue/vue.min.js"></script>
  12. <link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.1/css/jquery-weui.min.css">
  13. <link rel="stylesheet" href="../static/css/browserDetail.css">
  14. <script src="../static/js/vender/jquery-3.4.1.min.js"></script>
  15. <script src="../static/js/vender/config.js"></script>
  16. <script src="../static/js/vender/toastr/toastr.min.js"></script>
  17. <script src="../static/js/vender/vue/config.js"></script>
  18. <script type="text/javascript">
  19. var deviveWidth = document.documentElement.clientWidth;
  20. document.documentElement.style.fontSize = deviveWidth / 7.5 + 'px';
  21. </script>
  22. <script>
  23. toastr.options.positionClass = 'toast-center-center';
  24. // toastr.options.timeOut = '1500';
  25. </script>
  26. </head>
  27. <body>
  28. <div class="container">
  29. <div class="header-wrap">
  30. <!-- <div class="search-wrap" id="search-wrap">
  31. <img class="search-icon" src="../static/img/browser/search-icon2.png" />
  32. <div class="ipt" id="ipt">双子星浏览器</div>
  33. </div> -->
  34. <div class="title-wrap">
  35. <img class="left-arrow" src="../static/img/browser/left-arrow.png" />
  36. <div class="title"></div>
  37. </div>
  38. <div class="tag-wrap"></div>
  39. </div>
  40. <div class="download-wrap">
  41. <div class="download-content"></div>
  42. <div class="loading"></div>
  43. </div>
  44. </div>
  45. <script type="text/javascript">
  46. document.addEventListener("visibilitychange",()=>{
  47. if(document.hidden){
  48. init('visibilitychange');
  49. }else{
  50. init('visibilitychange');
  51. }
  52. })
  53. let title = decodeURIComponent(GetRequest().plateName);
  54. let timer,flag = true;
  55. let labelId = '', pageNum = 1, pageSize = 10, index = 0, recordFlag = true, total = 0, nowlength = 0, isLoading = false;
  56. $('.title').eq(0).text(title);
  57. (function(){
  58. init();
  59. })();
  60. function init(type){
  61. $.ajax({
  62. url: `${baseUrl}/api/public/v1/browserLabel/client/query/${GetRequest().plateId}`,
  63. type: 'get',
  64. contentType:"application/json",
  65. dataType: 'json',
  66. cache: false,
  67. success: function (res) {
  68. isLoading = false;
  69. let node = '';
  70. let list = res.data;
  71. if(list.length === 0) {
  72. node = `<div class="none-wrap">
  73. <img class="none-img" src="../static/img/browser/none.png" />
  74. <div class="none-text">没有更多内容哦~</div>
  75. </div>`
  76. $('.download-content').eq(0).append(node);
  77. return
  78. }
  79. labelId = list[0].id;
  80. if(type != 'visibilitychange'){
  81. rankingGet();
  82. }
  83. for(let i=0; i < list.length; i++){
  84. node += `<div class="tag-item ${i === index ? 'active' : ''}" data-id="${list[i].id}" data-index="${i}">${list[i].labelName}</div>`
  85. }
  86. $('.tag-wrap').eq(0).append(node);
  87. }
  88. })
  89. };
  90. function getType() {
  91. return new Promise((resolve, reject) => {
  92. $.ajax({
  93. url: `http://localhost:9888/getType`,
  94. type: 'get',
  95. contentType:"application/json",
  96. dataType: 'json',
  97. cache: false,
  98. success: function (res) {
  99. if(res.code === 200){
  100. let cardType = res.data.devType;
  101. let phoneObj = {
  102. 'VIRTUAL_RK3399': 'VIP',
  103. 'RK_3399': 'SVIP',
  104. 'MTK_G90': 'STAR',
  105. 'QUALCOMM': 'STARPRO'
  106. }
  107. phoneType = phoneObj[cardType];
  108. resolve(phoneType);
  109. }
  110. }
  111. })
  112. })
  113. }
  114. function rankingGet(){
  115. getType().then((phoneType) => {
  116. $.ajax({
  117. url: `${baseUrl}/api/public/v1/ranking/client/get`,
  118. type: 'post',
  119. data: JSON.stringify({
  120. labelId: +labelId,
  121. phoneType: phoneType,
  122. pageNum: pageNum,
  123. pageSize: pageSize
  124. }),
  125. contentType:"application/json",
  126. dataType: 'json',
  127. cache: false,
  128. success: function (res) {
  129. if(res.status === 0){
  130. let list = res.data.records;
  131. nowlength += list.length;
  132. total = res.data.total;
  133. recordFlag = true;
  134. let node = '';
  135. $('.download-content').eq(0).text('');
  136. for(let i=0; i < list.length; i++){
  137. node += `<div class="download-item">
  138. <div class="main-wrap">
  139. <img class="app-icon" src=${fileCenterApi}/document/newFile/download/0/3dn9b4585511476691c6?fileKey=${list[i].iconKey} />
  140. <div class="app-wrap">
  141. <div class="app-title">${list[i].appName}</div>
  142. <div class="app-description">${list[i].introduction}</div>
  143. </div>
  144. </div>
  145. <div class="btn-wrap" data-key="${list[i].fileKey}" data-id="${list[i].id}" data-index="${i}" data-md5="${list[i].md5}">
  146. <div class="progress" data-key="${list[i].fileKey}" data-id="${list[i].id}" data-index="${i}" data-md5="${list[i].md5}"></div>
  147. <text class="text" data-key="${list[i].fileKey}" data-id="${list[i].id}" data-index="${i}" data-md5="${list[i].md5}">下载</text>
  148. </div>
  149. </div>`
  150. }
  151. if(nowlength < total && list.length !== 0){
  152. $('.loading').eq(0).text('正在努力加载中...');
  153. } else if(nowlength != 0) {
  154. $('.loading').eq(0).text('已加载全部内容');
  155. }
  156. if(list.length === 0){
  157. node = `<div class="none-wrap">
  158. <img class="none-img" src="../static/img/browser/none.png" />
  159. <div class="none-text">没有更多内容哦~</div>
  160. </div>`
  161. }
  162. $('.download-content').eq(0).append(node);
  163. }else{
  164. stopManyClick(() => {
  165. toastr.error(res.msg);
  166. })
  167. }
  168. }
  169. })
  170. })
  171. };
  172. //点击切换
  173. $('.tag-wrap')[0].addEventListener('click',(e)=>{
  174. if(index === e.target.dataset.index) {
  175. return
  176. }
  177. labelId = e.target.dataset.id;
  178. let className = e.target.className;
  179. if(className.includes('tag-item')){
  180. pageNum = 1;
  181. nowlength = 0;
  182. total = 0;
  183. $('.loading').eq(0).text('');
  184. $('.tag-item')[index].className = 'tag-item';
  185. index = e.target.dataset.index;
  186. $('.tag-item')[index].className = 'tag-item active';
  187. rankingGet();
  188. }
  189. },false);
  190. // // 验证是否下架
  191. // function isGetStatus(id) {
  192. // $.ajax({
  193. // url: `${baseUrl}/api/public/v1/browserLabel/getStatus/${id}`,
  194. // type: 'get',
  195. // contentType:"application/json",
  196. // dataType: 'json',
  197. // cache: false,
  198. // success: function (res) {
  199. // if(res.status === 0){
  200. // } else {
  201. // stopManyClick(() => {
  202. // toastr.error(res.msg);
  203. // })
  204. // }
  205. // }
  206. // })
  207. // }
  208. // 点击下载按钮
  209. $('.download-wrap')[0].addEventListener('click',(e)=>{
  210. let key = e.target.dataset.key;
  211. let md5 = e.target.dataset.md5;
  212. let index = e.target.dataset.index;
  213. let id = e.target.dataset.id;
  214. let className = e.target.className;
  215. if(className === 'btn-wrap btn-active' || e.target.innerText !== '下载'){
  216. return
  217. }
  218. if(['btn-wrap','progress', 'text'].includes(className)){
  219. $.ajax({
  220. url: `${baseUrl}/api/public/v1/ranking/getstatus/${id}`,
  221. type: 'get',
  222. contentType:"application/json",
  223. dataType: 'json',
  224. cache: false,
  225. success: function (res) {
  226. if(res.status === 0){
  227. $('.btn-wrap')[index].className = 'btn-wrap btn-active';
  228. const downloadUrl = `${fileCenterApi}/document/newFile/breakpointDownloadFile/3dn9b4585511476691c6?fileKey=${key}`;
  229. window.location.href = downloadUrl;
  230. let xhr = new XMLHttpRequest();
  231. xhr.open('GET', downloadUrl, true);
  232. xhr.addEventListener('progress', function (event) {
  233. // 响应头要有Content-Length
  234. if (event.lengthComputable) {
  235. let percentComplete = event.loaded / event.total;
  236. // 进度条的位置也是translate,一开始是用translateX(-100%)挪到外面去
  237. $('.progress')[index].style.transform = `translateX(${percentComplete * 100}%)`;
  238. $('.text').eq(index).text(`${(percentComplete * 100).toFixed(1)}%`);
  239. if((percentComplete * 100).toFixed(1) == 100){
  240. $('.text').eq(index).text('下载完成');
  241. }
  242. }
  243. }, false);
  244. xhr.send();
  245. } else {
  246. stopManyClick(() => {
  247. toastr.error(res.msg);
  248. })
  249. }
  250. }
  251. })
  252. }
  253. },false);
  254. //点击返回按钮
  255. $('.left-arrow')[0].addEventListener('click',()=>{
  256. location.href = './browser.html'
  257. },false);
  258. //数据下拉加载
  259. $('.download-wrap')[0].addEventListener('scroll',function () {
  260. let scrollTop = $('.download-wrap')[0].scrollTop;
  261. let clientHeight = $('.download-wrap')[0].clientHeight;
  262. let scrollHeight = $('.download-wrap')[0].scrollHeight;
  263. if(scrollTop + clientHeight + 10 > scrollHeight){
  264. if(recordFlag && nowlength < total && total > 0){
  265. recordFlag = false;
  266. pageNum++;
  267. rankingGet();
  268. }
  269. }
  270. });
  271. //防止提示一秒内重复显示
  272. function stopManyClick(fn) {
  273. if (flag) {
  274. fn();
  275. }
  276. flag = false;
  277. if(timer){clearTimeout(timer);}
  278. timer = setTimeout(() => {flag = true}, 1500);
  279. }
  280. //点击按钮搜索
  281. // const searchDom = document.getElementById("search-wrap");
  282. // searchDom.addEventListener('click',()=>{
  283. // var wd = "https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&rsv_idx=1&tn=baidu";
  284. // window.open(wd);
  285. // },false);
  286. </script>
  287. </body>
  288. </html>