Forráskód Böngészése

支持本地下载及播放功能

zhanghe 6 éve
szülő
commit
d0557a4631

+ 0 - 0
src/stage/index/scene/CourseList.js


+ 25 - 60
src/stage/index/scene/CourseScene.js

@@ -5,6 +5,7 @@ import efMarquee from '../../../component/EFMarquee';
 import ShopCartState from '../../../util/ShopCartState';
 import NotificationCenter from '../../../util/NotificationCenter';
 import {CommandBus, CMD_TYPE} from '../../../util/CommandBus';
+import WinBoxAPI from '../../../util/WinBoxAPI';
 import Consts from '../../../util/Consts';
 
 class CourseScene extends scene {
@@ -19,9 +20,9 @@ class CourseScene extends scene {
 		this.id = 1;
 		this.isFirst = true;
 		this.marquee = null;
-	    //course name
-	    this.title = '';
-	    this.isBought = false;
+    //course name
+    this.title = '';
+    this.isBought = false;
 	}
 
 	generateCourseDetailTitle(itemTitle, secondTitle){
@@ -243,31 +244,20 @@ class CourseScene extends scene {
 	/**
 	 * 添加课程下载任务
 	 */
-	addLessonDownloadTask({resData, courseID, courseName, lessonID, lessonName}){
-		let { images, videos } = this.getDownloadTargetFromLessonData(resData);
-		let lessonDownloadData = {
-			courseID,
-			courseName,
-			lessonID,
-			lessonName,
-			images,
-			videos,
-		}
-		console.log('下载数据...', lessonDownloadData);
-	    //send to download
-	    let {status} = CommandBus.execute({type:CMD_TYPE.DOWNLOAD_LESSON_POST, payload:lessonDownloadData});
-	    //统计下载行为
-	    CommandBus.execute({type:CMD_TYPE.APP_BHV_POST, payload:{
-			eventName: "downloadLesson",
-			eventPage: "courseScene",
-			eventAttr: {
-				courseId:courseID,
-				courseName:courseName,
-				lessonId:lessonID,
-				lessonName:lessonName
+	addLessonDownloadTask({lessonID, courseID, event}){
+		WinBoxAPI.postDownloadRequest(lessonID, courseID, (isTrue, res) => {
+			if (!isTrue) {
+				TVUtil.Toast.show('本地服务请求失败...', 3000);
+				return;
 			}
-		}});
-		return true;
+			if (event.target.con.classList.contains('download-btn-lesson-list-ready')) {
+  			event.target.con.classList.add('download-btn-lesson-list-ongoing');
+  			event.target.con.classList.remove('download-btn-lesson-list-ready');
+			} else {
+  			event.target.con.classList.add('download-btn-lesson-icon-ongoing');
+  			event.target.con.classList.remove('download-btn-lesson-icon-ready');
+			}
+		});
 	}
 
 	onCreate(data) {
@@ -278,11 +268,6 @@ class CourseScene extends scene {
 			// check course is blank
 			this.renderCourse(this.id);
 		});
-	    CommandBus.execute({type:CMD_TYPE.APP_BHV_POST, payload:{
-			eventName: "enter_courseScene",
-			eventPage: "courseScene",
-			eventAttr: { courseID: data.id },
-	    }});
 	}
 
 	onResume(data) {
@@ -351,7 +336,7 @@ class CourseScene extends scene {
             this.hideScene({});
             return;
         }
-		
+
 		// 点击某一课
 		if (e.target.con.classList.contains('img-wrapper') || e.target.con.classList.contains('text-wrapper')) {
 			// 课件模版 COURSE_WARE_VIDEO(课视频模版)  COURSE_WARE_LIST(课列表)
@@ -366,7 +351,8 @@ class CourseScene extends scene {
 				return;
 			}
 			let title = e.target.con.dataset.name;
-			this.showScene(require('./LessonScene.js'), { id, title, courseId: this.id });
+			let downloadStatus = parseInt(e.target.con.dataset.dload);
+			this.showScene(require('./LessonScene.js'), { id, title, downloadStatus, courseId: this.id });
 			return;
 		}
 
@@ -420,43 +406,22 @@ class CourseScene extends scene {
 			let lessonID = e.target.con.dataset.id;
 			let lessonName = e.target.con.dataset.name;
 
+			/*调试不启用
 			let lessonSeq = parseInt(e.target.con.dataset.seq);
 			if (!this.isAuthorized(lessonSeq)) {
 				TVUtil.Toast.show('购买后方可下载!', 3000);
 				return;
-			}
+			}*/
 
+			/* windows不提供此方法
 			if (this.getAvailableBlocks() < 200*1024){
 				//剩余空间小于200M
 				TVUtil.Toast.show('存储空间不足! 请到下载管理界面删除不需要的课以释放存储空间!', 3000);
 				return;
 			}
+			*/
 
-			//get courseware via Lesson
-			console.error('DEBUG, download cmd begin');
-			APIClient.getWareList(lessonID, courseID, (isTrue, res) => {
-				if (!isTrue) { return; }
-				if (!res.success) {
-					TVUtil.Toast.show('获取课件列表失败!', 1500);
-					return;
-				}
-				let resData = res.data.list;
-				if (!resData){
-					console.log('Cannot Get coursewares, lessonID=%s', lessonID);
-					return;
-				}
-
-	      if (this.addLessonDownloadTask({resData, courseID, courseName, lessonID, lessonName})){
-					//set download-btn to ongoing
-					if (e.target.con.classList.contains('download-btn-lesson-list-ready')) {
-	    			e.target.con.classList.add('download-btn-lesson-list-ongoing')
-	    			e.target.con.classList.remove('download-btn-lesson-list-ready')
-					} else {
-	    			e.target.con.classList.add('download-btn-lesson-icon-ongoing')
-	    			e.target.con.classList.remove('download-btn-lesson-icon-ready')
-					}
-	      }
-			});//APIClient Over
+			this.addLessonDownloadTask({ lessonID, courseID, event: e });
 		}
 	}
 

+ 1 - 1
src/stage/index/scene/DelConfirmScene.js

@@ -27,7 +27,7 @@ class DelConfirmScene extends scene {
 			this.moye.root.getWidgetById('cancle-btn').focus();
 			// 记录下课id
 			this.store = {
-				lessonID: data.lessonID,
+				lessonId: data.lessonId,
 				parentScene: data.parentScene,
 			};
 		});

+ 82 - 70
src/stage/index/scene/DownloadManagerScene.js

@@ -1,6 +1,7 @@
 import Consts from '../../../util/Consts';
+import APIClient from '../../../util/API/APIClient';
+import WinBoxAPI from '../../../util/WinBoxAPI';
 import Utils from '../../../util/Utils';
-import {CommandBus, CMD_TYPE} from '../../../util/CommandBus';
 
 class DownloadManagerScene extends scene {
     constructor(scope) {
@@ -9,6 +10,65 @@ class DownloadManagerScene extends scene {
         this.lessonItems = {};
     }
 
+    fetchDownloadList() {
+      APIClient.getUserDownloadList((isTrue, res) => {
+        // 判断响应内容
+        if (!isTrue || !res || !res.success) {
+          TVUtil.Toast.show('获取下载内容失败', 2000);
+          return;
+        };
+        // 遍历下载列表数据
+        const downloadedList = res.data || [];
+        let recs = [];
+        for (let i in downloadedList) {
+          recs.push(downloadedList[i]);
+          let item = downloadedList[i];
+          // 记录lessonId
+          this.lessonIds = [];
+          this.lessonIds.push(item['lessonId']);
+          // make a map of lessonId to courseId
+          this.lessonItems[item['lessonId']] = {
+              'lessonName':item['lessonName'],
+              'courseId':item['courseId'],
+              'downloadStatus':item['downloadStatus'],
+          }
+        }
+        let downloadStatusTableHtml = this.generateDownloadStatusTable({recs});
+        let downloadStatusTableWrapper = document.getElementById('download-status-table-wrapper');
+        downloadStatusTableWrapper.innerHTML = downloadStatusTableHtml;
+        this.moye.root.reRender();
+      })
+    }
+
+    deleteDownloadFile(lessonId, courseId) {
+      WinBoxAPI.deleteDownloadFile(lessonId, courseId, (isTrue, res) => {
+        if (!isTrue || !res || !res.success) {
+          TVUtil.Toast.show('本地文件删除失败', 2000);
+          return;
+        }
+        //删除dom节点
+        let curNode = document.getElementById('lesson-download-record-'+lessonId);
+        curNode.parentNode.removeChild(curNode);
+        this.moye.root.reRender();
+        //找兄弟结点
+        let findIdx = this.lessonIds.indexOf(lessonId);
+        if(-1 == findIdx){
+            return;
+        }
+        this.lessonIds.splice(findIdx, 1);
+        if(findIdx >= this.lessonIds.length){
+            findIdx = this.lessonIds.length - 1;
+        }
+        let nextFocusLessonId = null;
+        if(findIdx >= 0){
+            nextFocusLessonId = this.lessonIds[findIdx];
+        }
+        if(nextFocusLessonId){
+          this.moye.root.getWidgetById('del-btn-lesson-'+nextFocusLessonId).focus();
+        }
+      });
+    }
+
     generateDownloadStatusTable({recs}) {
         let trAcc = '';
         let count = 0;
@@ -19,13 +79,12 @@ class DownloadManagerScene extends scene {
                 feCfg = "default_focus:yes";
             }
             count += 1;
-            //for tmp
 
             //downloadDate
             let downloadDateStr = '2017-09-10';
-            if (rec.createTime) {
+            if (rec.gmtCreated) {
                 let createDate = new Date();
-                createDate.setTime(rec.createTime);
+                createDate.setTime(rec.gmtCreated);
                 downloadDateStr = Utils.dateFormat(createDate, 'yyyy-MM-dd');
             }
             let downloadStatus = rec['downloadStatus'];
@@ -33,8 +92,8 @@ class DownloadManagerScene extends scene {
 
             //storageUsage
             let storageUsageStr = '';
-            if (rec.storageUsage){
-                storageUsageStr = '' + parseInt(rec.storageUsage/1000) + 'M';
+            if (rec.storageUsage || 0){
+                storageUsageStr = '' + parseInt((rec.storageUsage || 0)/1000) + 'M';
             }
 
             //downloadStatus
@@ -43,7 +102,6 @@ class DownloadManagerScene extends scene {
                 downloadDesc = '未下载';
                 break;
             case Consts.DOWNLOAD_STATUS_ONGOING:
-                //downloadDesc = '已下载'+rec['progress']*100 + '%';
                 downloadDesc = '正在下载';
                 break;
             case Consts.DOWNLOAD_STATUS_SUCCESS:
@@ -59,7 +117,7 @@ class DownloadManagerScene extends scene {
                 rec['lessonName'] = rec['courseName'];
             }
 
-            trAcc += `<div id='lesson-download-record-${rec['lessonID']}' class="row" lesson_id="${rec['lessonID']}">
+            trAcc += `<div id='lesson-download-record-${rec['lessonId']}' class="row" lesson_id="${rec['lessonId']}">
             <div class="one">${downloadDateStr}</div>
             <div class="two">${rec['courseName']}</div>
             <div class="three">${rec['lessonName']}</div>
@@ -67,17 +125,15 @@ class DownloadManagerScene extends scene {
             <div class="five">${downloadDesc}</div>
             <div class="six" >
               <div id="download-btn-wrapper" fe-fole="Switch">
-                <div id="enter-btn-lesson-${rec['lessonID']}" class="download-enter-btn" fe-role="Widget" data-id="${rec['lessonID']}">
+                <div id="enter-btn-lesson-${rec['lessonId']}" class="download-enter-btn" fe-role="Widget" data-id="${rec['lessonId']}">
                   <img src="./assets/img/DownloadScene/download_enter_btn.png" class="img-btn"/>
                 </div>
-                <div id="del-btn-lesson-${rec['lessonID']}" class="download-del-btn" fe-role="Widget" data-id="${rec['lessonID']}" >
+                <div id="del-btn-lesson-${rec['lessonId']}" class="download-del-btn" fe-role="Widget" data-id="${rec['lessonId']}" >
                   <img src="./assets/img/DownloadScene/download_del_btn.png" class="img-btn"/>
                 </div>
               </div>
             </div>
             </div>`
-            //<div class="delete-btn"  fe-role="Widget" fe-cfg="${feCfg}"/>
-            //<img src="./assets/img/download_del_btn.png" />
         }
         let header = `<div class="row header">
           <div class="one">下载日期</div>
@@ -97,71 +153,26 @@ class DownloadManagerScene extends scene {
             recs.push({
               'date':'2017-09-01',
               'courseName':'同步辅导语文一年级上'+i,
-              'courseID':'course-'+i,
+              'courseId':'course-'+i,
               'lessonName':'悯农',
-              'lessonID':'lesson-'+i,
+              'lessonId':'lesson-'+i,
               'downloadStatus':'下载完成',
               'createTime':1505187194,
               'storageUsage':150211,
             });
           }
           */
-        let {status, data, error} = CommandBus.execute({type:CMD_TYPE.DOWNLOAD_ALL_LESSON_STATUS_GET, payload:{}});
-        let recs = [];
-        if (!status && data && data.recs){
-            recs = data.recs;
-        }
-
-        this.lessonIds = [];
-        for(let idx in recs){
-            let item = recs[idx];
-            this.lessonIds.push(item['lessonID']);
-
-            // make a map of lessonID to courseID
-            this.lessonItems[item['lessonID']] = {
-                'lessonName':item['lessonName'],
-                'courseID':item['courseID'],
-            }
-        }
-
-        //TVUtil.Toast.show(JSON.stringify({status,data, error, recs}), 5000);
         this.setContentView(require('../../../res/tpl/DownloadScene.tpl'), {}, 'DownloadManagerScene', {}, () => {
-            let downloadStatusTableHtml = this.generateDownloadStatusTable({recs});
-            let downloadStatusTableWrapper = document.getElementById('download-status-table-wrapper');
-            downloadStatusTableWrapper.innerHTML = downloadStatusTableHtml;
-            this.moye.root.reRender();
+          this.fetchDownloadList();
         });
     }
 
     onResume(retData) {
       if (!retData) return;
       //send delete cmd
-      let lessonID = retData.lessonID;
-      let {status, data} = CommandBus.execute({type:CMD_TYPE.DOWNLOAD_LESSON_DELETE, payload:{lessonID}});
-      //delete dom node
-
-      //if(0 == status){
-      let curNode = document.getElementById('lesson-download-record-'+lessonID);
-      curNode.parentNode.removeChild(curNode);
-      //}
-
-      this.moye.root.reRender();
-      //找兄弟结点
-      let findIdx = this.lessonIds.indexOf(lessonID);
-      if(-1 == findIdx){
-          return;
-      }
-      this.lessonIds.splice(findIdx, 1);
-      if(findIdx >= this.lessonIds.length){
-          findIdx = this.lessonIds.length - 1;
-      }
-      let nextFocusLessonId = null;
-      if(findIdx >= 0){
-          nextFocusLessonId = this.lessonIds[findIdx];
-      }
-      if(nextFocusLessonId){
-        this.moye.root.getWidgetById('del-btn-lesson-'+nextFocusLessonId).focus();
-      }
+      let lessonId = retData.lessonId;
+      let courseId = this.lessonItems[lessonId]['courseId']
+      this.deleteDownloadFile(lessonId, courseId)
     }
 
     onPause() {
@@ -187,16 +198,17 @@ class DownloadManagerScene extends scene {
             return;
         }
         if(e.target.con.classList.contains('download-del-btn')){
-            let lessonID = e.target.con.dataset.id;
-            let title = this.lessonItems[lessonID].lessonName;
+            let lessonId = e.target.con.dataset.id;
+            let title = this.lessonItems[lessonId].lessonName;
             let parentScene = 'DownloadManagerScene';
-            this.showScene(require('./DelConfirmScene.js'), { parentScene, lessonID, title });
+            this.showScene(require('./DelConfirmScene.js'), { parentScene, lessonId, title });
         } else if (e.target.con.classList.contains('download-enter-btn')) {
-            let lessonID = e.target.con.dataset.id;
-            let courseID = this.lessonItems[lessonID].courseID;
-            let lessonName = this.lessonItems[lessonID].lessonName;
+            let lessonId = e.target.con.dataset.id;
+            let courseId = this.lessonItems[lessonId].courseId;
+            let lessonName = this.lessonItems[lessonId].lessonName;
+            let downloadStatus = this.lessonItems[lessonId].downloadStatus;
             // enter relative lesson scene
-            this.showScene(require('./LessonScene.js'), {id:lessonID, courseId:courseID, title:lessonName});
+            this.showScene(require('./LessonScene.js'), {courseId, downloadStatus, id:lessonId, title:lessonName});
         }
     }
 

+ 13 - 1
src/stage/index/scene/ImageWareFullScreenScene.js

@@ -1,8 +1,15 @@
 import Consts from '../../../util/Consts';
 
+function getLocalResourceUrl(absoluteUrl) {
+  if (!absoluteUrl) return;
+  const segments = absoluteUrl.split('/') || [];
+  return `${Consts.NODE_SERVER}/lesson/readFile?n=${segments.slice(3).join('*')}`;
+}
+
 class ImageWareFullScreenScene extends scene {
 	constructor(scope) {
 		super(scope);
+		this.isDownload = false;
 		this.wareList = [];
 		this.curWareIndex = 0;
 		this.curWareType = null;
@@ -12,7 +19,11 @@ class ImageWareFullScreenScene extends scene {
 
 	renderImageView() {
 		const curImage = this.curImageList[this.curImageIndex];
-		document.getElementById('wareImg').setAttribute('src', curImage.url);
+		if (this.isDownload) {
+			document.getElementById('wareImg').setAttribute('src', getLocalResourceUrl(curImage.url));
+		} else {
+			document.getElementById('wareImg').setAttribute('src', curImage.url);
+		}
 	}
 
 	dynamicChangeWare(wareIndex, type) {
@@ -94,6 +105,7 @@ class ImageWareFullScreenScene extends scene {
 	}
 
 	onCreate(data) {
+		this.isDownload = data.isDownload;
     this.wareList = data.wareList;
     this.curWareIndex = data.curWareIndex;
     if (data.curImageList) {

+ 371 - 367
src/stage/index/scene/LessonScene.js

@@ -1,8 +1,8 @@
 import APIClient from '../../../util/API/APIClient';
+import WinBoxAPI from '../../../util/WinBoxAPI';
 import Consts from '../../../util/Consts';
 import Utils from '../../../util/Utils';
 import EfunVideoPlayer from '../../../util/EfunVideoPlayer';
-import {CommandBus, CMD_TYPE} from '../../../util/CommandBus';
 
 function matchWare(wareList, wareId) {
     const matchedWareList = wareList.filter((ware) => {
@@ -16,12 +16,27 @@ function matchWare(wareList, wareId) {
     return false;
 }
 
+function checkDownloadStatus(status) {
+  if (status === Consts.DOWNLOAD_STATUS_SUCCESS) {
+    return true;
+  } else {
+    return false;
+  }
+}
+
+function getLocalResourceUrl(absoluteUrl) {
+  if (!absoluteUrl) return;
+  const segments = absoluteUrl.split('/') || [];
+  return `${Consts.NODE_SERVER}/lesson/readFile?n=${segments.slice(3).join('*')}`;
+}
+
 class LessonScene extends scene {
-    constructor(scope) {
+  constructor(scope) {
     super(scope);
     this.timer = null;        //记录定时器
     this.isBack = false;      //是否返回上个场景
     this.videoPlayer = null;  //视频播放器
+    this.isDownload = false;  //是否已下载
     this.courseId = null;     //记录课程ID
     this.lessonId = null;     //记录课ID
     this.wareList = null;     //记录课件列表
@@ -36,404 +51,393 @@ class LessonScene extends scene {
     	width: 1072,
     	height: 603,
     };
-    }
+  }
 
-    /**
-    * 根据课程id及课id请求课件列表
-    */
-    loadWareList() {
-        APIClient.getWareList(this.lessonId, this.courseId, (isTrue, response) => {
-        	if (!isTrue) { return; }
-        	if (!response.success) {
-        		TVUtil.Toast.show('获取课件列表失败!', 1500);
-                return;
-        	}
-        	if (response.data && response.data.list && response.data.list.length > 0) {
-        		this.renderWareList(response.data.list);
-        		this.wareList = response.data.list;
-        	} else {
-        		this.hideScene();
-        		this.showScene(require('./DataBuildingScene'), {});
-        	}
-        });
-    }
+  /**
+  * 根据课程id及课id请求课件列表
+  */
+  loadWareList() {
+    APIClient.getWareList(this.lessonId, this.courseId, (isTrue, response) => {
+    	if (!isTrue) { return; }
+    	if (!response.success) {
+    		TVUtil.Toast.show('获取课件列表失败!', 1500);
+            return;
+    	}
+    	if (response.data && response.data.list && response.data.list.length > 0) {
+    		this.renderWareList(response.data.list);
+    		this.wareList = response.data.list;
+    	} else {
+    		this.hideScene();
+    		this.showScene(require('./DataBuildingScene'), {});
+    	}
+    });
+  }
 
-    /**
-    * 把课件列表进行渲染
-    */
-    renderWareList(dataset) {
-    	let listDom = document.getElementById('list-content');
-    	dataset.forEach(function(item, index) {
-    		const { id, type } = item;
+  /**
+  * 把课件列表进行渲染
+  */
+  renderWareList(dataset) {
+  	let listDom = document.getElementById('list-content');
+  	dataset.forEach(function(item, index) {
+  		const { id, type } = item;
 
-    		let itemDom = document.createElement('div');
-    		itemDom.setAttribute('id', `item-${type}-${id}-${index}`);
-    		itemDom.setAttribute('class', 'ware-item');
-    		itemDom.setAttribute('fe-role', 'Widget');
-    		itemDom.innerHTML = this.createHTMLString(item);
-    		listDom.appendChild(itemDom);
-    		if (index === 0) {
-    			this.curWareType = parseInt(type);
-    			this.curWareId = id;
-    			this.createRightView(item);
-    		}
-    	}.bind(this));
+  		let itemDom = document.createElement('div');
+  		itemDom.setAttribute('id', `item-${type}-${id}-${index}`);
+  		itemDom.setAttribute('class', 'ware-item');
+  		itemDom.setAttribute('fe-role', 'Widget');
+  		itemDom.innerHTML = this.createHTMLString(item);
+  		listDom.appendChild(itemDom);
+  		if (index === 0) {
+  			this.curWareType = parseInt(type);
+  			this.curWareId = id;
+  			this.createRightView(item);
+  		}
+  	}.bind(this));
 
-    	let listScroll = this.moye.root.getWidgetById('list');
-    	listScroll.on('focus', e => {
-    		if (this.curWareId === e.target.id.split('-')[2]) {
-    			return;
-    		}
-    		this.curWareId = e.target.id.split('-')[2]
-    		this.curWareType = parseInt(e.target.id.split('-')[1]);
-    		this.curWareIndex = parseInt(e.target.id.split('-')[3]);
-            let curWare = matchWare(this.wareList, this.curWareId);
-            if (curWare) {
-                this.createRightView(curWare);
-            }
-    	});
-    	this.moye.root.reRender();
-    }
+  	let listScroll = this.moye.root.getWidgetById('list');
+  	listScroll.on('focus', e => {
+  		if (this.curWareId === e.target.id.split('-')[2]) {
+  			return;
+  		}
+  		this.curWareId = e.target.id.split('-')[2]
+  		this.curWareType = parseInt(e.target.id.split('-')[1]);
+  		this.curWareIndex = parseInt(e.target.id.split('-')[3]);
+      let curWare = matchWare(this.wareList, this.curWareId);
+      if (curWare) {
+          this.createRightView(curWare);
+      }
+  	});
+  	this.moye.root.reRender();
+  }
 
-    /**
-    * 创建左侧列表项内容
-    */
-    createHTMLString(data) {
-    	let item = {
-    		text: data.category || '',
-    		icon: '',
-    	}
-    	switch (data.type) {
-    		case Consts.TYPE_IMAGE:
-    			item.icon = 'assets/img/LessonScene/img.png';
-    			break;
-    		case Consts.TYPE_VIDEO:
-    			item.icon = 'assets/img/LessonScene/video.png';
-    			break;
-    	}
-    	return `<div class="ware-item-frame">
-              <div class="ware-type">${item.text}</div>
-              <div class="ware-desc">
-                <div class="ware-names">${data.title}</div>
-                <div class="ware-icon">
-                	<img class="ware-icon-content" src="${item.icon}">
-                </div>
-              </div>
-            </div>
-          `;
-    }
+  /**
+  * 创建左侧列表项内容
+  */
+  createHTMLString(data) {
+  	let item = {
+  		text: data.category || '',
+  		icon: '',
+  	}
+  	switch (data.type) {
+  		case Consts.TYPE_IMAGE:
+  			item.icon = 'assets/img/LessonScene/img.png';
+  			break;
+  		case Consts.TYPE_VIDEO:
+  			item.icon = 'assets/img/LessonScene/video.png';
+  			break;
+  	}
+  	return `
+      <div class="ware-item-frame">
+        <div class="ware-type">${item.text}</div>
+        <div class="ware-desc">
+          <div class="ware-names">${data.title}</div>
+          <div class="ware-icon">
+          	<img class="ware-icon-content" src="${item.icon}">
+          </div>
+        </div>
+      </div>
+    `;
+  }
 
-    /**
-    * 创建右侧视窗
-    */
-    createRightView(item) {
-        // 清一下定时器
-        window.clearInterval(this.timer);
-        this.timer = null;
+  /**
+  * 创建右侧视窗
+  */
+  createRightView(item) {
+    // 清一下定时器
+    window.clearInterval(this.timer);
+    this.timer = null;
 
-        const { title, type, list } = item;
-        //设定视窗的标题
-        document.getElementById('view-top').innerHTML = title;
-        //关闭安卓播放器
-    	if (window.efunbox) {
-    		window.efunbox.closePlayer();
-    	}
-    	switch (type) {
-    		case Consts.TYPE_VIDEO:
-    			let playUrl = '';
-    			if (list && list.length >= 1) {
-    				playUrl = Utils.videoUrlFormat(list[0].url);
-    			}
-          /*
-    			let videoViewDom =
-            `
-              <div id="view-full-screen" fe-role="Widget" class="view-full-screen-video">
-              </div>
-              <div id="view-video-start" fe-role="Widget">
-                <div class="transparent-btn">播放</div>
-              </div>
-            `;
-          */
-          let videoViewDom = '';
-    			document.getElementById('view-bottom').innerHTML = videoViewDom;
-    			this.moye.root.reRender();
-    			this.renderVideoView(title, playUrl, type);
-    			break;
-    		case Consts.TYPE_IMAGE:
-    			let imageViewDom =
-    			`
-    				<div id="view-full-screen" fe-role="Widget" class="view-full-screen-img"></div>
-    				<div id="view-previous" fe-role="Widget">
-              <div class="transparent-btn">上一页</div>
+    const { title, type, list } = item;
+    //设定视窗的标题
+    document.getElementById('view-top').innerHTML = title;
+    //关闭安卓播放器
+  	if (window.efunbox) {
+  		window.efunbox.closePlayer();
+  	}
+  	switch (type) {
+  		case Consts.TYPE_VIDEO:
+  			let playUrl = '';
+  			if (list && list.length >= 1) {
+  				playUrl = Utils.videoUrlFormat(list[0].url);
+  			}
+        /*
+  			let videoViewDom =
+          `
+            <div id="view-full-screen" fe-role="Widget" class="view-full-screen-video">
             </div>
-    				<div id="view-page">1/1</div>
-              <div id="view-next" fe-role="Widget">
-              <div class="transparent-btn">下一页</div>
+            <div id="view-video-start" fe-role="Widget">
+              <div class="transparent-btn">播放</div>
             </div>
-    			`;
-    			document.getElementById('view-bottom').innerHTML = imageViewDom;
-    			this.moye.root.reRender();
-    			this.curImageList = list;
-    			if (this.curImageList.length > 0) {
-    				this.curImageIndex = 0;
-    				this.renderImageView();
-    			}
-    			break;
-            default:
-                break;
-    	}
+          `;
+        */
+        let videoViewDom = '';
+  			document.getElementById('view-bottom').innerHTML = videoViewDom;
+  			this.moye.root.reRender();
+  			this.renderVideoView(title, playUrl, type);
+  			break;
+  		case Consts.TYPE_IMAGE:
+  			let imageViewDom =
+  			`
+  				<div id="view-full-screen" fe-role="Widget" class="view-full-screen-img"></div>
+  				<div id="view-previous" fe-role="Widget">
+            <div class="transparent-btn">上一页</div>
+          </div>
+  				<div id="view-page">1/1</div>
+            <div id="view-next" fe-role="Widget">
+            <div class="transparent-btn">下一页</div>
+          </div>
+  			`;
+  			document.getElementById('view-bottom').innerHTML = imageViewDom;
+  			this.moye.root.reRender();
+  			this.curImageList = list;
+  			if (this.curImageList.length > 0) {
+  				this.curImageIndex = 0;
+  				this.renderImageView();
+  			}
+  			break;
+          default:
+              break;
+  	}
+  }
+
+  /**
+  * 渲染图片视图
+  */
+  renderImageView() {
+  	const curImage = this.curImageList[this.curImageIndex];
+  	document.getElementById('view-page').innerHTML = (this.curImageIndex + 1) + '/' + this.curImageList.length;
+    let imageDom = `<img src=${curImage.url} />`
+    if (this.isDownload) {
+      imageDom = `<img src=${getLocalResourceUrl(curImage.url)} />`
     }
+  	document.getElementById('view-content').innerHTML = imageDom;
+  }
 
-    /**
-    * 渲染图片视图
-    */
-    renderImageView() {
-    	const curImage = this.curImageList[this.curImageIndex];
-    	document.getElementById('view-page').innerHTML = (this.curImageIndex + 1) + '/' + this.curImageList.length; const imageDom = `<img src=${curImage.url} />`
-    	document.getElementById('view-content').innerHTML = imageDom;
+  /**
+  * 渲染视频视图
+  */
+  renderVideoView(name, url, type) {
+    let localUrl = url;
+    if (this.isDownload) {
+      localUrl = getLocalResourceUrl(url)
+    }
+    if (window.efunbox) {
+        window.efunbox.initAndroidPlayer(
+        	name,
+        	localUrl,
+        	1, //与android里的音视频类型定义有关,这里写死为type=1
+        	this.videoPosition.top,
+        	this.videoPosition.left,
+        	this.videoPosition.width,
+        	this.videoPosition.height,
+        	false
+        );
+        window.efunbox.start();
+        this.videoPlayer = window.efunbox;
+    } else {
+        const videoDom = `<div id="hls-video"></div>`;
+        document.getElementById('view-content').innerHTML = videoDom;
+        this.videoPlayer = new EfunVideoPlayer();
+        this.videoPlayer.initPlayer(localUrl, 'hls-video');
     }
+  	// 监控到初始化视频成功后暂停画面
+  	this.timer = window.setInterval(() => {
+  		if (this.videoPlayer.playStatus()) {
+  			if(this.videoPlayer.getCurtime() > 1000){
+  				this.videoPlayer.pause();
+  				document.getElementById('view-video-start').innerHTML = '播放';
+  				window.clearInterval(this.timer);
+  				this.timer = null;
+  			}
+  		}
+  	}, 500);
+  }
 
-    /**
-    * 渲染视频视图
-    */
-    renderVideoView(name, url, type) {
-      if (window.efunbox) {
-          window.efunbox.initAndroidPlayer(
-          	name,
-          	url,
-          	1, //与android里的音视频类型定义有关,这里写死为type=1
-          	this.videoPosition.top,
-          	this.videoPosition.left,
-          	this.videoPosition.width,
-          	this.videoPosition.height,
-          	false
-          );
-          window.efunbox.start();
-          this.videoPlayer = window.efunbox;
-      } else {
+  updateRightView(item) {
+  	const { title, type, list } = item;
+  	document.getElementById('view-top').innerHTML = title;
+  	switch (type) {
+  		case Consts.TYPE_VIDEO:
+  			let playUrl = '';
+  			if (list && list.length >= 1) {
+  				playUrl = Utils.videoUrlFormat(list[0].url);
+  			}
+        /*
+        let playText = '播放';
+        if (this.videoPlayer && this.videoPlayer.playStatus()) {
+            playText = '暂停';
+        }
+  			let videoViewDom =
+          `
+            <div id="view-full-screen" fe-role="Widget" class="view-full-screen-video">
+            </div>
+            <div id="view-video-start" fe-role="Widget">
+              <div class="transparent-btn">${playText}</div>
+            </div>
+          `;
+        */
+  			document.getElementById('view-bottom').innerHTML = '';
+  			this.moye.root.reRender();
+        //如果是H5播放器,则重新创建video标签
+        if (window.efunbox) {
+            window.efunbox.customScreen(270, 790, 1072, 603);
+        } else {
           const videoDom = `<div id="hls-video"></div>`;
           document.getElementById('view-content').innerHTML = videoDom;
           this.videoPlayer = new EfunVideoPlayer();
-          this.videoPlayer.initPlayer(url, 'hls-video');
-      }
-    	// 监控到初始化视频成功后暂停画面
-    	this.timer = window.setInterval(() => {
-    		if (this.videoPlayer.playStatus()) {
-    			if(this.videoPlayer.getCurtime() > 1000){
-    				this.videoPlayer.pause();
-    				document.getElementById('view-video-start').innerHTML = '播放';
-    				window.clearInterval(this.timer);
-    				this.timer = null;
-    			}
-    		}
-    	}, 500);
-    }
+          this.videoPlayer.initPlayer(playUrl, 'hls-video');
+        }
+  			break;
+  		case Consts.TYPE_IMAGE:
+  			let imageViewDom =
+  			`
+  				<div id="view-full-screen" fe-role="Widget" class="view-full-screen-img"></div>
+  				<div id="view-previous" fe-role="Widget">
+                      <div class="transparent-btn">上一页</div>
+                  </div>
+  				<div id="view-page">1/1</div>
+  				<div id="view-next" fe-role="Widget">
+                      <div class="transparent-btn">下一页</div>
+                  </div>
+  			`;
+  			document.getElementById('view-bottom').innerHTML = imageViewDom;
+  			this.moye.root.reRender();
+  			this.renderImageView();
+  			break;
+      default:
+        break;
+  	}
+  }
 
-    updateRightView(item) {
-    	const { title, type, list } = item;
-    	document.getElementById('view-top').innerHTML = title;
-    	switch (type) {
-    		case Consts.TYPE_VIDEO:
-    			let playUrl = '';
-    			if (list && list.length >= 1) {
-    				playUrl = Utils.videoUrlFormat(list[0].url);
-    			}
-          /*
-          let playText = '播放';
-          if (this.videoPlayer && this.videoPlayer.playStatus()) {
-              playText = '暂停';
-          }
-    			let videoViewDom =
-            `
-              <div id="view-full-screen" fe-role="Widget" class="view-full-screen-video">
-              </div>
-              <div id="view-video-start" fe-role="Widget">
-                <div class="transparent-btn">${playText}</div>
-              </div>
-            `;
-          */
-    			document.getElementById('view-bottom').innerHTML = '';
-    			this.moye.root.reRender();
-          //如果是H5播放器,则重新创建video标签
-          if (window.efunbox) {
-              window.efunbox.customScreen(270, 790, 1072, 603);
-          } else {
-            const videoDom = `<div id="hls-video"></div>`;
-            document.getElementById('view-content').innerHTML = videoDom;
-            this.videoPlayer = new EfunVideoPlayer();
-            this.videoPlayer.initPlayer(playUrl, 'hls-video');
-          }
-    			break;
-    		case Consts.TYPE_IMAGE:
-    			let imageViewDom =
-    			`
-    				<div id="view-full-screen" fe-role="Widget" class="view-full-screen-img"></div>
-    				<div id="view-previous" fe-role="Widget">
-                        <div class="transparent-btn">上一页</div>
-                    </div>
-    				<div id="view-page">1/1</div>
-    				<div id="view-next" fe-role="Widget">
-                        <div class="transparent-btn">下一页</div>
-                    </div>
-    			`;
-    			document.getElementById('view-bottom').innerHTML = imageViewDom;
-    			this.moye.root.reRender();
-    			this.renderImageView();
-    			break;
-        default:
-          break;
-    	}
-    }
+  /**
+  * 记录播放行为事件
+  */
+  postPlayRecord(lessonId, courseId, playStopTime=1){
+  	APIClient.putUserAction(
+  		Consts.USER_ACTION_WATCH,
+  		Consts.USER_ACTION_WATCH_NAME,
+  		`${courseId}_${lessonId}`,
+  		playStopTime,
+  		(isTrue, res) => {},
+  	);
+  }
 
-    /**
-    * 记录播放行为事件
-    */
-    postPlayRecord(lessonId, courseId, playStopTime=1){
-    	APIClient.putUserAction(
-    		Consts.USER_ACTION_WATCH,
-    		Consts.USER_ACTION_WATCH_NAME,
-    		`${courseId}_${lessonId}`,
-    		playStopTime,
-    		(isTrue, res) => {},
-    	);
-    }
+  onCreate(data) {
+    //是否已下载
+    this.isDownload = checkDownloadStatus(data.downloadStatus);
+    this.lessonId = data.id;
+    this.courseId = data.courseId;
+    this.setContentView(require('../../../res/tpl/LessonScene.tpl'), {}, 'LessonScene', {}, () => {
+      document.getElementById('title').appendChild(document.createTextNode(data.title));
+      this.loadWareList();
+    });
+  }
 
-    onCreate(data) {
-        this.lessonId = data.id;
-        this.courseId = data.courseId;
-        this.setContentView(require('../../../res/tpl/LessonScene.tpl'), {}, 'LessonScene', {}, () => {
-            document.getElementById('title').appendChild(document.createTextNode(data.title));
-            this.loadWareList();
-    		CommandBus.execute({
-    			type: CMD_TYPE.APP_BHV_POST,
-    			payload: {
-    				eventName: "enter_wareScene",
-    				eventPage: "wareScene",
-    				eventAttr: {
-    					courseId: data.courseId,
-    					lessonId: data.id,
-    				}
-                },
-    		});
-          }
-        );
+  onResume(data) {
+    if (!data) { return; }
+    //更新下当前的课件信息
+    const { curWareIndex, curImageList, curImageIndex } = data;
+    this.curWareIndex = curWareIndex;
+    this.curWareId = this.wareList[curWareIndex].id;
+    this.curWareType = this.wareList[curWareIndex].type;
+    if (curImageList) {
+        this.curImageList = curImageList;
     }
-
-    onResume(data) {
-        if (!data) { return; }
-        //更新下当前的课件信息
-        const { curWareIndex, curImageList, curImageIndex } = data;
-        this.curWareIndex = curWareIndex;
-        this.curWareId = this.wareList[curWareIndex].id;
-        this.curWareType = this.wareList[curWareIndex].type;
-        if (curImageList) {
-            this.curImageList = curImageList;
-        }
-        if (curImageIndex) {
-            this.curImageIndex = curImageIndex;
-        }
-        //更新左侧焦点位置
-        this.moye.root.getWidgetById(`item-${this.curWareType}-${this.curWareId}-${this.curWareIndex}`).focus();
-        //更新右侧视图
-        this.updateRightView(this.wareList[curWareIndex]);
-        this.isBack = true;
+    if (curImageIndex) {
+        this.curImageIndex = curImageIndex;
     }
+    //更新左侧焦点位置
+    this.moye.root.getWidgetById(`item-${this.curWareType}-${this.curWareId}-${this.curWareIndex}`).focus();
+    //更新右侧视图
+    this.updateRightView(this.wareList[curWareIndex]);
+    this.isBack = true;
+  }
 
-    onOK(e) {
-        // 后退
-        if (e.target.con.classList.contains('goback')) {
-            this.hideScene({id: this.courseId}, 'CourseScene');
-            return;
-        }
-    	const leaf = FocusEngine.getFocusedLeaf();
-    	switch (leaf.id) {
-    		case 'view-video-start':
-    			if (this.curWareType == Consts.TYPE_VIDEO) {
-    				if (this.videoPlayer.playStatus()) {
-    					this.videoPlayer.pause();
-    					document.getElementById('view-video-start').innerHTML = '播放';
-    				} else {
-    					this.videoPlayer.start();
-    					document.getElementById('view-video-start').innerHTML = '暂停';
-    				}
-    			}
-    			//添加播放记录
-    			this.postPlayRecord(this.curWareId, this.courseId);
-    			break;
-    		case 'view-full-screen':
-                if (this.curWareType === Consts.TYPE_IMAGE) {
-            		this.showScene(require('./ImageWareFullScreenScene.js'), {
-            			wareList: this.wareList,
-            			curWareIndex: this.curWareIndex,
-            			curImageList: this.curImageList,
-            			curImageIndex: this.curImageIndex,
-            		});
-                } else if (this.curWareType === Consts.TYPE_VIDEO) {
-                    let video = document.getElementById('hls-video');
-                    if (video) {
-                        video.webkitEnterFullScreen();
-                        // document.getElementById('view-content').removeChild(video);
-                    }
-                    // this.showScene(require('./VideoWareFullScreenScene.js'), {
-                    //     isFull: true,
-                    //     wareList: this.wareList,
-                    //     curWareIndex: this.curWareIndex,
-                    // });
-                }
-    			this.postPlayRecord(this.cur_item_id, this.courseId);
-    			break;
-    		case 'view-previous':
-    			if (this.curWareType === Consts.TYPE_IMAGE && this.curImageIndex - 1 >= 0) {
-    				this.curImageIndex -= 1;
-    				this.renderImageView();
-    			}
-    			this.postPlayRecord(this.curWareId, this.courseId);
-    			break;
-    		case 'view-next':
-    			if (this.curWareType === Consts.TYPE_IMAGE && this.curImageIndex + 1 < this.curImageList.length) {
-    				this.curImageIndex += 1;
-    				this.renderImageView();
-    			}
-    			this.postPlayRecord(this.curWareId, this.courseId);
-    			break;
-            default:
-                break;
-    	}
+  onOK(e) {
+    // 后退
+    if (e.target.con.classList.contains('goback')) {
+      this.hideScene({id: this.courseId}, 'CourseScene');
+      return;
     }
+  	const leaf = FocusEngine.getFocusedLeaf();
+  	switch (leaf.id) {
+  		case 'view-video-start':
+  			if (this.curWareType == Consts.TYPE_VIDEO) {
+  				if (this.videoPlayer.playStatus()) {
+  					this.videoPlayer.pause();
+  					document.getElementById('view-video-start').innerHTML = '播放';
+  				} else {
+  					this.videoPlayer.start();
+  					document.getElementById('view-video-start').innerHTML = '暂停';
+  				}
+  			}
+  			//添加播放记录
+  			this.postPlayRecord(this.curWareId, this.courseId);
+  			break;
+  		case 'view-full-screen':
+        if (this.curWareType === Consts.TYPE_IMAGE) {
+      		this.showScene(require('./ImageWareFullScreenScene.js'), {
+      			wareList: this.wareList,
+      			curWareIndex: this.curWareIndex,
+      			curImageList: this.curImageList,
+      			curImageIndex: this.curImageIndex,
+            isDownload: this.isDownload,
+      		});
+        }
+  			this.postPlayRecord(this.cur_item_id, this.courseId);
+  			break;
+  		case 'view-previous':
+  			if (this.curWareType === Consts.TYPE_IMAGE && this.curImageIndex - 1 >= 0) {
+  				this.curImageIndex -= 1;
+  				this.renderImageView();
+  			}
+  			this.postPlayRecord(this.curWareId, this.courseId);
+  			break;
+  		case 'view-next':
+  			if (this.curWareType === Consts.TYPE_IMAGE && this.curImageIndex + 1 < this.curImageList.length) {
+  				this.curImageIndex += 1;
+  				this.renderImageView();
+  			}
+  			this.postPlayRecord(this.curWareId, this.courseId);
+  		  break;
+      default:
+        break;
+  	}
+  }
 
-    onPause() {
+  onPause() {
 
-    }
+  }
 
-    onDestroy() {
+  onDestroy() {
 
-    }
+  }
 
-    onActive() {
+  onActive() {
 
-    }
+  }
 
-    onInactive() {
+  onInactive() {
 
-    }
+  }
 
-    onBack() {
-    	if (this.isBack) {
-    		return true;
-    	} else if (window.efunbox) {
-    		window.efunbox.closePlayer();
-    	}
-    }
+  onBack() {
+  	if (this.isBack) {
+  		return true;
+  	} else if (window.efunbox) {
+  		window.efunbox.closePlayer();
+  	}
+  }
 
-    onKeydown(e) {
-    	switch (e.keyCode) {
-    		case Consts.KEYCODE_EXIT:
-    			this.isBack = false;
-    			break;
-            default:
-                break;
-    	}
-    }
+  onKeydown(e) {
+  	switch (e.keyCode) {
+  		case Consts.KEYCODE_EXIT:
+  			this.isBack = false;
+  			break;
+      default:
+        break;
+  	}
+  }
 }
 
 module.exports = LessonScene;

+ 5 - 0
src/util/API/APIClient.js

@@ -166,6 +166,11 @@ class APIClient {
 	  let params = { eventType, tarName, tarId, value };
 	  AJAXHelper.post('/callback/event', params, callback);
 	}
+
+	// 获取用户的下载记录
+	static getUserDownloadList(callback) {
+		AJAXHelper.get('/callback/download/list', {}, callback);
+	}
 }
 
 module.exports = APIClient;

+ 5 - 2
src/util/Consts.js

@@ -10,6 +10,9 @@ class Consts {
     }
 }
 
+//node服务接口地址
+Consts.NODE_SERVER = 'http://127.0.0.1:8089';
+
 //图片/视频资源域名
 Consts.IMG_PATH = 'https://efunimgs.ai160.com';
 Consts.VIDEO_PATH = 'https://efunvideo.ai160.com';
@@ -40,8 +43,8 @@ Consts.DOM_ID_LOCAL_DOWNLOAD_BUTTON = 'local-download-btn'
 Consts.EVENT_TYPE_OK = 'ok';
 
 Consts.DOWNLOAD_STATUS_UNDOWNLOAD = 0;
-Consts.DOWNLOAD_STATUS_ONGOING = 1;
-Consts.DOWNLOAD_STATUS_SUCCESS = 2;
+Consts.DOWNLOAD_STATUS_SUCCESS = 1;
+Consts.DOWNLOAD_STATUS_ONGOING = 2;
 Consts.DOWNLOAD_STATUS_FAILED = 3;
 
 Consts.ANDROID_FORCE_VERSION = '2.2.2';

+ 64 - 0
src/util/WinBoxAPI.js

@@ -0,0 +1,64 @@
+import userDataStorage from './userDataStorage';
+import Consts from './Consts';
+
+class WinBoxAPI {
+  constructor() {}
+
+  static whenAjaxResponse(httpRequest, callback) {
+		if (httpRequest.readyState != 4) {
+			return;
+		}
+		let res = JSON.parse(httpRequest.responseText);
+		callback(httpRequest.status == 200, res);
+  }
+
+  static baseRequest(method, path, params, callback) {
+		let xmlHttpReq = new XMLHttpRequest();
+
+		let sendBody = null;
+    let url = `${Consts.NODE_SERVER}${path}?`;
+    if (method === 'GET') {
+      for (let key in params) {
+        url += `${key}=${params[key]}&`;
+      }
+    }
+		if (params && (method == 'POST' || method == 'PUT')) {
+			sendBody = JSON.stringify({...params});
+		}
+		xmlHttpReq.open(method, url, true);
+		xmlHttpReq.onreadystatechange = function () {
+			WinBoxAPI.whenAjaxResponse(xmlHttpReq, callback);
+		};
+		xmlHttpReq.send(sendBody);
+  }
+
+  static get(path, params, callback) {
+    WinBoxAPI.baseRequest('GET', path, params, callback);
+  }
+
+  static post(path, params) {
+    WinBoxAPI.baseRequest('POST', path, params, callback);
+  }
+
+  static postDownloadRequest(lessonId, courseId, callback) {
+		const { token = '', uid = '', eid = '' } = userDataStorage.getData() || {};
+    let path = '/lesson/downloadFile';
+    let params = { lessonId, courseId, uid, eid, token };
+    WinBoxAPI.get(path, params, callback);
+  }
+
+  static deleteDownloadFile(lessonId, courseId, callback) {
+		const { token = '', uid = '', eid = '' } = userDataStorage.getData() || {};
+    let path = '/lesson/delFile';
+    let params = { lessonId, courseId, uid, eid, token };
+    WinBoxAPI.get(path, params, callback);
+  }
+
+  static readDownloadedFile(lessonId, courseId, callback) {
+		const { token = '', uid = '', eid = '' } = userDataStorage.getData() || {};
+    let path = '/lesson/readFile';
+    let params = { lessonId, courseId, uid, eid, token };
+  }
+}
+
+module.exports = WinBoxAPI;

+ 8 - 60
src/util/course.js

@@ -16,70 +16,23 @@ class Course {
 			recs.push(item.id);
 		}
 
-    	let cmdResult = CommandBus.execute({type:CMD_TYPE.DOWNLOAD_LESSON_STATUS_GET, payload:{recs}});
-		let lessonDownloadStatus = {};
-		if (!cmdResult.status){
-			for(let idx in cmdResult.data.recs){
-        		let rec = cmdResult.data.recs[idx];
-				lessonDownloadStatus[rec.lessonID.toString()] = parseInt(rec.downloadStatus);
-			}
-		}
-
 		// 现在只按文字模板进行渲染
-		main.innerHTML = this.textList(data, lessonDownloadStatus, auth);
+		main.innerHTML = this.textList(data, auth);
 	}
 
-	//废弃
-	static imgList(data, lessonDownloadStatus) {
+	static textList(data, auth) {
 		let content = '';
-		function listItem(data, seq, downloadStatus) {
-
-      	//根据不同的下载状态,设置不同的Button状态
-		let btnClass = 'download-btn-lesson-icon-ready';
-		if (downloadStatus == Consts.DOWNLOAD_STATUS_ONGOING){
-			btnClass = 'download-btn-lesson-icon-ongoing';
-		}
-		else if (downloadStatus == Consts.DOWNLOAD_STATUS_SUCCESS) {
-			btnClass = 'download-btn-lesson-icon-success';
-		}
-
-		let url = data.picUrl ? `${Consts.IMG_PATH}/${data.picUrl}` : `http://via.placeholder.com/350x150?text=NO PIC ${data.id}`
-		return `<div data-seq="${seq}" class="lesson-icon-wrapper">
-		        <div id="lesson-btn-${seq}" data-id="${data.id}" data-template="${data.templateCode}" data-name="${data.itemTitle}" fe-role="Widget" class="img-wrapper" data-seq="${seq}">
-		  				<img src="${url}" alt="${data.itemTitle}">
-		  			</div>
-		        <div id="download-btn-${data.id}" fe-role="Widget" class="${btnClass}" data-id="${data.id}" data-name="${data.itemTitle}" data-seq="${seq}" ></div>
-			</div>`;
-		}
-
-		for (let i in data) {
-			let downloadStatus = Consts.DOWNLOAD_STATUS_UNDOWNLOAD;
-			let lessonId = data[i].id.toString();
-			if (lessonDownloadStatus[lessonId]){
-				downloadStatus = lessonDownloadStatus[lessonId];
-			}
-
-			content += listItem(data[i], i, downloadStatus);
-		}
-
-		return `<div class="list-pic-container" fe-role="Scroll" fe-cfg="scroll_dir:v,scroll_center:con,scroll_duration:0.2,scroll_easing:linear">
-		<div class="scroll-list clearfix" id="course-main-list">${content}</div>
-		</div>`;
-	}
-
-	static textList(data, lessonDownloadStatus, auth) {
-		let content = '';
-		function listItem(data, seq, downloadStatus, isFree) {
+		function listItem(data, seq, isFree) {
 			let btnClass = 'download-btn-lesson-list-ready';
-			if (downloadStatus == Consts.DOWNLOAD_STATUS_ONGOING){
+			if (data.downloadStatus == Consts.DOWNLOAD_STATUS_ONGOING){
 				btnClass = 'download-btn-lesson-list-ongoing';
 			}
-			else if (downloadStatus == Consts.DOWNLOAD_STATUS_SUCCESS) {
+			else if (data.downloadStatus == Consts.DOWNLOAD_STATUS_SUCCESS) {
 				btnClass = 'download-btn-lesson-list-success';
 			}
 			return `
 				<div data-seq="${seq}">
-		        	<div id="lesson-btn-${seq}" data-id="${data.id}" data-name="${data.title}" data-seq="${seq}" fe-role="Widget" class="text-wrapper">
+		        	<div id="lesson-btn-${seq}" data-id="${data.id}" data-name="${data.title}" data-dload="${data.downloadStatus}" data-seq="${seq}" fe-role="Widget" class="text-wrapper">
 						${Utils.fixOverflowStr(data.title, 32, '...')}
 						<div class="free-flag" style="display: ${isFree ? "block" : "none"}"></div>
 					</div>
@@ -89,16 +42,11 @@ class Course {
 			`;
 		}
 		for (let i in data) {
-			let downloadStatus = Consts.DOWNLOAD_STATUS_UNDOWNLOAD;
-			let lessonId = data[i].id.toString();
-			if (lessonDownloadStatus[lessonId]){
-				downloadStatus = lessonDownloadStatus[lessonId];
-			}
 			// 课程未购买的第一课加入free标记
 			if (i == 0 && !auth) {
-				content += listItem(data[i], i, downloadStatus, true);
+				content += listItem(data[i], i, true);
 			} else {
-				content += listItem(data[i], i, downloadStatus, false);
+				content += listItem(data[i], i, false);
 			}
 		}
 		return `<div id="list-text-container" class="list-text-container" fe-role="Scroll" fe-cfg="scroll_dir:v,scroll_center:con,scroll_duration:0.2,scroll_easing:linear"><div class="scroll-list clearfix" id="course-main-list">${content}</div></div> `;