browserDetail.html 9.0 KB

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