|
@@ -52,7 +52,7 @@
|
|
|
})
|
|
|
let title = decodeURIComponent(GetRequest().plateName);
|
|
|
let timer,flag = true;
|
|
|
- let labelId = '', pageNum = 1, pageSize = 10, index = 0, recordFlag = true, total = 0, nowlength = 0, isLoading = false;
|
|
|
+ let labelId = '', pageNum = 1, pageSize = 10, index = 0, recordFlag = true, total = 0, nowlength = 0, isLoading = false, appList= [], downloadObj = {};
|
|
|
$('.title').eq(0).text(title);
|
|
|
(function(){
|
|
|
init();
|
|
@@ -67,6 +67,7 @@
|
|
|
success: function (res) {
|
|
|
isLoading = false;
|
|
|
let node = '';
|
|
|
+ $('.tag-wrap').eq(0).text('');
|
|
|
let list = res.data;
|
|
|
if(list.length === 0) {
|
|
|
node = `<div class="none-wrap">
|
|
@@ -128,35 +129,36 @@
|
|
|
cache: false,
|
|
|
success: function (res) {
|
|
|
if(res.status === 0){
|
|
|
- let list = res.data.records;
|
|
|
- nowlength += list.length;
|
|
|
+ appList = res.data.records;
|
|
|
+ nowlength += appList.length;
|
|
|
total = res.data.total;
|
|
|
recordFlag = true;
|
|
|
let node = '';
|
|
|
if(type != 'down'){
|
|
|
$('.download-content').eq(0).text('');
|
|
|
}
|
|
|
- for(let i=0; i < list.length; i++){
|
|
|
+
|
|
|
+ for(let i=0; i < appList.length; i++){
|
|
|
node += `<div class="download-item">
|
|
|
<div class="main-wrap">
|
|
|
- <img class="app-icon" src=${fileCenterApi}/document/newFile/download/0/3dn9b4585511476691c6?fileKey=${list[i].iconKey} />
|
|
|
+ <img class="app-icon" src=${fileCenterApi}/document/newFile/download/0/3dn9b4585511476691c6?fileKey=${appList[i].iconKey} />
|
|
|
<div class="app-wrap">
|
|
|
- <div class="app-title">${list[i].appName}</div>
|
|
|
- <div class="app-description">${list[i].introduction}</div>
|
|
|
+ <div class="app-title">${appList[i].appName}</div>
|
|
|
+ <div class="app-description">${appList[i].introduction}</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="btn-wrap" data-key="${list[i].fileKey}" data-id="${list[i].id}" data-index="${i}" data-md5="${list[i].md5}">
|
|
|
- <div class="progress" data-key="${list[i].fileKey}" data-id="${list[i].id}" data-index="${i}" data-md5="${list[i].md5}"></div>
|
|
|
- <text class="text" data-key="${list[i].fileKey}" data-id="${list[i].id}" data-index="${i}" data-md5="${list[i].md5}">下载</text>
|
|
|
+ <div class="btn-wrap" data-key="${appList[i].fileKey}" data-id="${appList[i].id}" data-index="${i}" data-md5="${appList[i].md5}">
|
|
|
+ <div class="progress" data-key="${appList[i].fileKey}" data-id="${appList[i].id}" data-index="${i}" data-md5="${appList[i].md5}"></div>
|
|
|
+ <text class="text" data-key="${appList[i].fileKey}" data-id="${appList[i].id}" data-index="${i}" data-md5="${appList[i].md5}">下载</text>
|
|
|
</div>
|
|
|
</div>`
|
|
|
}
|
|
|
- if(nowlength < total && list.length !== 0){
|
|
|
+ if(nowlength < total && appList.length !== 0){
|
|
|
$('.loading').eq(0).text('正在努力加载中...');
|
|
|
} else if(nowlength != 0) {
|
|
|
$('.loading').eq(0).text('已加载全部内容');
|
|
|
}
|
|
|
- if(list.length === 0){
|
|
|
+ if(appList.length === 0){
|
|
|
node = `<div class="none-wrap">
|
|
|
<img class="none-img" src="../static/img/browser/none.png" />
|
|
|
<div class="none-text">没有更多内容哦~</div>
|
|
@@ -219,6 +221,7 @@
|
|
|
if(className === 'btn-wrap btn-active' || e.target.innerText !== '下载'){
|
|
|
return
|
|
|
}
|
|
|
+ let appName = $('.app-title').eq(index).text();
|
|
|
if(['btn-wrap','progress', 'text'].includes(className)){
|
|
|
$.ajax({
|
|
|
url: `${baseUrl}/api/public/v1/ranking/getstatus/${id}`,
|
|
@@ -228,7 +231,6 @@
|
|
|
cache: false,
|
|
|
success: function (res) {
|
|
|
if(res.status === 0){
|
|
|
- $('.btn-wrap')[index].className = 'btn-wrap btn-active';
|
|
|
const downloadUrl = `${fileCenterApi}/document/newFile/breakpointDownloadFile/3dn9b4585511476691c6?fileKey=${key}`;
|
|
|
window.location.href = downloadUrl;
|
|
|
let xhr = new XMLHttpRequest();
|
|
@@ -237,12 +239,11 @@
|
|
|
// 响应头要有Content-Length
|
|
|
if (event.lengthComputable) {
|
|
|
let percentComplete = event.loaded / event.total;
|
|
|
- // 进度条的位置也是translate,一开始是用translateX(-100%)挪到外面去
|
|
|
- $('.progress')[index].style.transform = `translateX(${percentComplete * 100}%)`;
|
|
|
- $('.text').eq(index).text(`${(percentComplete * 100).toFixed(1)}%`);
|
|
|
- if((percentComplete * 100).toFixed(1) == 100){
|
|
|
- $('.text').eq(index).text('下载完成');
|
|
|
- }
|
|
|
+ downloadObj[appName] = {
|
|
|
+ index: index,
|
|
|
+ name: appName,
|
|
|
+ percentComplete: percentComplete
|
|
|
+ };
|
|
|
}
|
|
|
}, false);
|
|
|
xhr.send();
|
|
@@ -255,6 +256,32 @@
|
|
|
})
|
|
|
}
|
|
|
},false);
|
|
|
+ setInterval(() => {
|
|
|
+ newData();
|
|
|
+ },2000);
|
|
|
+ //更新百分数
|
|
|
+ function newData() {
|
|
|
+ if(JSON.stringify(downloadObj) == "{}"){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ appList.map((item, index) => {
|
|
|
+ Object.keys(downloadObj).map((key) => {
|
|
|
+ if(item.appName === downloadObj[key].name){
|
|
|
+ // 进度条的位置也是translate,一开始是用translateX(-100%)挪到外面去
|
|
|
+ $('.btn-wrap')[index].className = 'btn-wrap btn-active';
|
|
|
+ $('.progress')[index].style.transform = `translateX(${downloadObj[key].percentComplete * 100}%)`;
|
|
|
+ $('.text').eq(index).text(`${(downloadObj[key].percentComplete * 100).toFixed(1)}%`);
|
|
|
+ if((downloadObj[key].percentComplete * 100).toFixed(1) == 100){
|
|
|
+ delete downloadObj[key]
|
|
|
+ console.log(downloadObj)
|
|
|
+ $('.text').eq(index).text('下载完成');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
//点击返回按钮
|
|
|
$('.left-arrow')[0].addEventListener('click',()=>{
|
|
|
location.href = './browser.html'
|