browserDetail.html 8.5 KB

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