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