browserDetail.html 8.9 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. isGetStatus(labelId)
  179. }
  180. },false);
  181. // 验证是否下架
  182. function isGetStatus(id) {
  183. $.ajax({
  184. url: `${baseUrl}/api/public/v1/browserLabel/getStatus/${id}`,
  185. type: 'get',
  186. contentType:"application/json",
  187. dataType: 'json',
  188. cache: false,
  189. success: function (res) {
  190. if(res.status === 0){
  191. pageNum = 1;
  192. nowlength = 0;
  193. total = 0;
  194. $('.loading').eq(0).text('');
  195. $('.tag-item')[index].className = 'tag-item';
  196. index = e.target.dataset.index;
  197. $('.tag-item')[index].className = 'tag-item active';
  198. rankingGet();
  199. } else {
  200. stopManyClick(() => {
  201. toastr.error(res.msg);
  202. })
  203. }
  204. }
  205. })
  206. }
  207. // 点击下载按钮
  208. $('.download-wrap')[0].addEventListener('click',(e)=>{
  209. let key = e.target.dataset.key;
  210. let md5 = e.target.dataset.md5;
  211. let index = e.target.dataset.index;
  212. let id = e.target.dataset.id;
  213. let className = e.target.className;
  214. if(className === 'btn-wrap btn-active' || e.target.innerText !== '下载'){
  215. return
  216. }
  217. if(['btn-wrap','progress', 'text'].includes(className)){
  218. $.ajax({
  219. url: `${baseUrl}/api/public/v1/ranking/getstatus/${id}`,
  220. type: 'get',
  221. contentType:"application/json",
  222. dataType: 'json',
  223. cache: false,
  224. success: function (res) {
  225. if(res.status === 0){
  226. $('.btn-wrap')[index].className = 'btn-wrap btn-active';
  227. const downloadUrl = `${fileCenterApi}/document/newFile/breakpointDownloadFile/3dn9b4585511476691c6?fileKey=${key}`;
  228. window.location.href = downloadUrl;
  229. let xhr = new XMLHttpRequest();
  230. xhr.open('GET', downloadUrl, true);
  231. xhr.addEventListener('progress', function (event) {
  232. // 响应头要有Content-Length
  233. if (event.lengthComputable) {
  234. let percentComplete = event.loaded / event.total;
  235. // 进度条的位置也是translate,一开始是用translateX(-100%)挪到外面去
  236. $('.progress')[index].style.transform = `translateX(${percentComplete * 100}%)`;
  237. $('.text').eq(index).text(`${(percentComplete * 100).toFixed(1)}%`);
  238. }
  239. }, false);
  240. xhr.send();
  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>