소스 검색

下载中添加提示框

sophieChenyx 6 년 전
부모
커밋
dbf8251c8d

+ 1 - 1
src/res/tpl/DownloadScene.tpl

@@ -12,7 +12,7 @@
 					<div class="one right-border">下载日期</div>
 					<div class="two right-border">课程名称</div>
 					<div class="three right-border">课名称</div>
-					<div class="four right-border">容量</div>
+					<div class="four right-border">进度</div>
 					<div class="five right-border">下载状态</div>
 					<div class="six">操作</div>
 	    		</div>

+ 2 - 1
src/res/tpl/DownloadTipScene.tpl

@@ -1,7 +1,8 @@
 <div id="DownloadTipScene" class="course-download-wrapper" fe-role="Switch">
     <div class="toast">
         <img src="./../../stage/index/assets/img/CourseScene/download_btn_list_undownload.png" alt="">
-        <p>当前正在下载中,请等待下载结束</p>
+        <p>已下载<span id="downloadProcess"></span></p>
+        <p>正在下载中...请等待下载结束</p>
         <div class="ok-btn" fe-role="Widget" id="ok-btn">确认</div>
     </div>
 </div>

+ 15 - 3
src/stage/index/scene/CourseScene.js

@@ -343,25 +343,37 @@ class CourseScene extends scene {
 
 		// 点击正在下载的某一课
 		if (e.target.con.classList.contains('download-btn-lesson-list-ongoing') || e.target.con.classList.contains('download-btn-lesson-icon-ready')) {
+      console.log('e.target', e.target);
+      let id = (e.target.id).split("download-btn-")[1];
+
+      APIClient.getDownloadProcess( id, ( isTrue, res)=> {
+        let storageUsageStr = res.data.resSize + '/' + res.data.resTotal;
+        let downloadProcess = document.getElementById('downloadProcess');
+        downloadProcess.innerText = storageUsageStr;
+      } )
       this.showScene(require('./DownloadTipScene.js'), {});
       return;
 		}
 
 		if (e.target.con.classList.contains('img-wrapper') || e.target.con.classList.contains('text-wrapper')) {
 			// 课件模版 COURSE_WARE_VIDEO(课视频模版)  COURSE_WARE_LIST(课列表)
-
       var targetSeq =(e.target.id).split("lesson-btn-")[1];
+      let id = e.target.con.dataset.id;
+
       let downloadElements = document.getElementsByClassName('download-btn-lesson-list-ongoing');
 			for ( let i = 0;i< downloadElements.length;i++) {
         let goingAeq =  downloadElements[i].getAttribute("data-seq");
         if( targetSeq == goingAeq ) {
+          APIClient.getDownloadProcess( id, ( isTrue, res)=> {
+            let storageUsageStr = res.data.resSize + '/' + res.data.resTotal;
+            let downloadProcess = document.getElementById('downloadProcess');
+            downloadProcess.innerText = storageUsageStr;
+          } )
           this.showScene(require('./DownloadTipScene.js'), {});
           return;
         }
       }
 
-
-			let id = e.target.con.dataset.id;
       //检查课的权限
 			//首先获取课的序号
 			let lessonSeq = parseInt(e.target.con.dataset.seq);

+ 5 - 5
src/stage/index/scene/DownloadManagerScene.js

@@ -91,10 +91,10 @@ class DownloadManagerScene extends scene {
             let downloadDesc = '';
 
             //storageUsage
-            let storageUsageStr = '';
-            if (rec.storageUsage || 0){
-                storageUsageStr = '' + parseInt((rec.storageUsage || 0)/1000) + 'M';
-            }
+            let storageUsageStr =  rec['resSize'] + '/' + rec['resTotal'];
+            // if (rec.storageUsage || 0){
+            //     storageUsageStr = '' + parseInt((rec.storageUsage || 0)/1000) + 'M';
+            // }
 
             //downloadStatus
             switch (downloadStatus) {
@@ -139,7 +139,7 @@ class DownloadManagerScene extends scene {
           <div class="one">下载日期</div>
           <div class="two">课程名称</div>
           <div class="three">课名称</div>
-          <div class="four">容量</div>
+          <div class="four">进度</div>
           <div class="five">下载状态</div>
           <div class="six">操作</div>
           </div>`

+ 7 - 1
src/util/API/APIClient.js

@@ -100,7 +100,6 @@ class APIClient {
     APIClient.getUserMacUrl( ( mac ) => {
       let params = APIClient.addCacheParam({});
       params.mac = mac;
-      console.log('params',params)
       AJAXHelper.get(`/course/${courseId}/lessons`, params , callback);
     });
     // let params = APIClient.addCacheParam({});
@@ -120,6 +119,13 @@ class APIClient {
 		params = APIClient.addCacheParam(params);
 		AJAXHelper.get(`/lesson/${lessonId}`, params, callback);
 	}
+  //在课件里面获取 具体课的下载进度
+  static getDownloadProcess( lessonId, callback) {
+    APIClient.getUserMacUrl( ( mac ) => {
+      let params = { lessonId, mac }
+      AJAXHelper.get(`/callback/download/find`, params, callback);
+    });
+  }
 
 	// 获取该课程相关配套列表
 	static getCourseAboutSupport(courseId, callback) {