browserDetail.html 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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. resolve('SVIP');
  93. // $.ajax({
  94. // url: `http://localhost:9888/getType`,
  95. // type: 'get',
  96. // contentType:"application/json",
  97. // dataType: 'json',
  98. // cache: false,
  99. // success: function (res) {
  100. // if(res.code === 200){
  101. // let cardType = res.data.devType;
  102. // let phoneObj = {
  103. // 'VIRTUAL_RK3399': 'VIP',
  104. // 'RK_3399': 'SVIP',
  105. // 'MTK_G90': 'STAR',
  106. // 'QUALCOMM': 'STARPRO'
  107. // }
  108. // phoneType = phoneObj[cardType];
  109. // resolve(phoneType);
  110. // }
  111. // }
  112. // })
  113. })
  114. }
  115. function rankingGet(type){
  116. getType().then((phoneType) => {
  117. $.ajax({
  118. url: `${baseUrl}/api/public/v1/ranking/client/get`,
  119. type: 'post',
  120. data: JSON.stringify({
  121. labelId: +labelId,
  122. phoneType: phoneType,
  123. pageNum: pageNum,
  124. pageSize: pageSize
  125. }),
  126. contentType:"application/json",
  127. dataType: 'json',
  128. cache: false,
  129. success: function (res) {
  130. if(res.status === 0){
  131. let list = res.data.records;
  132. nowlength += list.length;
  133. total = res.data.total;
  134. recordFlag = true;
  135. let node = '';
  136. if(type != 'down'){
  137. $('.download-content').eq(0).text('');
  138. }
  139. for(let i=0; i < list.length; i++){
  140. node += `<div class="download-item">
  141. <div class="main-wrap">
  142. <img class="app-icon" src=${fileCenterApi}/document/newFile/download/0/3dn9b4585511476691c6?fileKey=${list[i].iconKey} />
  143. <div class="app-wrap">
  144. <div class="app-title">${list[i].appName}</div>
  145. <div class="app-description">${list[i].introduction}</div>
  146. </div>
  147. </div>
  148. <div class="btn-wrap" data-key="${list[i].fileKey}" data-id="${list[i].id}" data-index="${i}" data-md5="${list[i].md5}">
  149. <div class="progress" data-key="${list[i].fileKey}" data-id="${list[i].id}" data-index="${i}" data-md5="${list[i].md5}"></div>
  150. <text class="text" data-key="${list[i].fileKey}" data-id="${list[i].id}" data-index="${i}" data-md5="${list[i].md5}">下载</text>
  151. </div>
  152. </div>`
  153. }
  154. if(nowlength < total && list.length !== 0){
  155. $('.loading').eq(0).text('正在努力加载中...');
  156. } else if(nowlength != 0) {
  157. $('.loading').eq(0).text('已加载全部内容');
  158. }
  159. if(list.length === 0){
  160. node = `<div class="none-wrap">
  161. <img class="none-img" src="../static/img/browser/none.png" />
  162. <div class="none-text">没有更多内容哦~</div>
  163. </div>`
  164. }
  165. $('.download-content').eq(0).append(node);
  166. }else{
  167. stopManyClick(() => {
  168. toastr.error(res.msg);
  169. })
  170. }
  171. }
  172. })
  173. })
  174. };
  175. //点击切换
  176. $('.tag-wrap')[0].addEventListener('click',(e)=>{
  177. if(index === e.target.dataset.index) {
  178. return
  179. }
  180. labelId = e.target.dataset.id;
  181. let className = e.target.className;
  182. if(className.includes('tag-item')){
  183. pageNum = 1;
  184. nowlength = 0;
  185. total = 0;
  186. $('.loading').eq(0).text('');
  187. $('.tag-item')[index].className = 'tag-item';
  188. index = e.target.dataset.index;
  189. $('.tag-item')[index].className = 'tag-item active';
  190. rankingGet();
  191. }
  192. },false);
  193. // // 验证是否下架
  194. // function isGetStatus(id) {
  195. // $.ajax({
  196. // url: `${baseUrl}/api/public/v1/browserLabel/getStatus/${id}`,
  197. // type: 'get',
  198. // contentType:"application/json",
  199. // dataType: 'json',
  200. // cache: false,
  201. // success: function (res) {
  202. // if(res.status === 0){
  203. // } else {
  204. // stopManyClick(() => {
  205. // toastr.error(res.msg);
  206. // })
  207. // }
  208. // }
  209. // })
  210. // }
  211. // 点击下载按钮
  212. $('.download-wrap')[0].addEventListener('click',(e)=>{
  213. let key = e.target.dataset.key;
  214. let md5 = e.target.dataset.md5;
  215. let index = e.target.dataset.index;
  216. let id = e.target.dataset.id;
  217. let className = e.target.className;
  218. if(className === 'btn-wrap btn-active' || e.target.innerText !== '下载'){
  219. return
  220. }
  221. if(['btn-wrap','progress', 'text'].includes(className)){
  222. $.ajax({
  223. url: `${baseUrl}/api/public/v1/ranking/getstatus/${id}`,
  224. type: 'get',
  225. contentType:"application/json",
  226. dataType: 'json',
  227. cache: false,
  228. success: function (res) {
  229. if(res.status === 0){
  230. $('.btn-wrap')[index].className = 'btn-wrap btn-active';
  231. const downloadUrl = `${fileCenterApi}/document/newFile/breakpointDownloadFile/3dn9b4585511476691c6?fileKey=${key}`;
  232. window.location.href = downloadUrl;
  233. let xhr = new XMLHttpRequest();
  234. xhr.open('GET', downloadUrl, true);
  235. xhr.addEventListener('progress', function (event) {
  236. // 响应头要有Content-Length
  237. if (event.lengthComputable) {
  238. let percentComplete = event.loaded / event.total;
  239. // 进度条的位置也是translate,一开始是用translateX(-100%)挪到外面去
  240. $('.progress')[index].style.transform = `translateX(${percentComplete * 100}%)`;
  241. $('.text').eq(index).text(`${(percentComplete * 100).toFixed(1)}%`);
  242. if((percentComplete * 100).toFixed(1) == 100){
  243. $('.text').eq(index).text('下载完成');
  244. }
  245. }
  246. }, false);
  247. xhr.send();
  248. } else {
  249. stopManyClick(() => {
  250. toastr.error(res.msg);
  251. })
  252. }
  253. }
  254. })
  255. }
  256. },false);
  257. //点击返回按钮
  258. $('.left-arrow')[0].addEventListener('click',()=>{
  259. location.href = './browser.html'
  260. },false);
  261. //数据下拉加载
  262. $('.download-wrap')[0].addEventListener('scroll',function () {
  263. let scrollTop = $('.download-wrap')[0].scrollTop;
  264. let clientHeight = $('.download-wrap')[0].clientHeight;
  265. let scrollHeight = $('.download-wrap')[0].scrollHeight;
  266. if(scrollTop + clientHeight + 10 > scrollHeight){
  267. if(recordFlag && nowlength < total && total > 0){
  268. recordFlag = false;
  269. pageNum++;
  270. rankingGet('down');
  271. }
  272. }
  273. });
  274. //防止提示一秒内重复显示
  275. function stopManyClick(fn) {
  276. if (flag) {
  277. fn();
  278. }
  279. flag = false;
  280. if(timer){clearTimeout(timer);}
  281. timer = setTimeout(() => {flag = true}, 1500);
  282. }
  283. //点击按钮搜索
  284. // const searchDom = document.getElementById("search-wrap");
  285. // searchDom.addEventListener('click',()=>{
  286. // var wd = "https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&rsv_idx=1&tn=baidu";
  287. // window.open(wd);
  288. // },false);
  289. </script>
  290. </body>
  291. </html>