Sfoglia il codice sorgente

上线前的修改合并

sophieChenyx 6 anni fa
parent
commit
51f693d3d4

+ 2 - 2
src/res/tpl/LoginScene.tpl

@@ -5,7 +5,7 @@
 
 		<div class="form-sid">
 			<div class="form-sid-label">
-				学&nbsp;&nbsp;号
+				学&nbsp;&nbsp;号:
 			</div>
 			<div class="form-sid-input">
 				<input id="sid-input" class="form-item" name="sid" type="text" readonly fe-role="Widget"/>
@@ -14,7 +14,7 @@
 
 		<div class="form-password">
 			<div class="form-password-label">
-				密&nbsp;&nbsp;码
+				密&nbsp;&nbsp;码:
 			</div>
 			<div class="form-password-input">
 				<input id="password-input" class="form-item" name="password" type="text" readonly fe-role="Widget"/>

+ 1 - 1
src/stage/index/index.html

@@ -66,7 +66,7 @@
 		document.head.appendChild(appCss);
 
 		var appScript = document.createElement('script');
-		appScript.src = './index.min.js?t=' + ts;
+		appScript.src = './index.js?t=' + ts;
 		document.body.appendChild(appScript);
 	</script>
 	<script>

+ 6 - 2
src/stage/index/scene/DownloadManagerScene.js

@@ -113,6 +113,10 @@ class DownloadManagerScene extends scene {
             default:
                 downloadDesc = '未下载';
             }
+            // 删除按钮是否可点击
+            let delDisable = downloadStatus === Consts.DOWNLOAD_STATUS_ONGOING ? true : false;
+            let feRole = delDisable ? '' : 'fe-role="Widget"';
+
             if (!rec['lessonName']) {
                 rec['lessonName'] = rec['courseName'];
             }
@@ -127,8 +131,8 @@ class DownloadManagerScene extends scene {
                 <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']}" >
-                  <img src="./assets/img/DownloadScene/download_del_btn.png" class="img-btn"/>
+                <div id="del-btn-lesson-${rec['lessonId']}" class="download-del-btn" ${feRole} data-id="${rec['lessonId']}" >
+                  <img src="./assets/img/DownloadScene/download_del_btn.png" class="${delDisable ? 'img-disable-btn' : 'img-btn'}"/>
                 </div>
               </div>
             </div>

+ 19 - 34
src/stage/index/scene/LessonScene.js

@@ -24,10 +24,11 @@ function checkDownloadStatus(status) {
   }
 }
 
-function getLocalResourceUrl(absoluteUrl) {
-  if (!absoluteUrl) return;
-  const segments = absoluteUrl.split('/') || [];
-  return `${Consts.NODE_SERVER}/lesson/readFile?n=${segments.slice(3).join('*')}`;
+function getLocalResourceUrl(onlineURL) {
+  if (!onlineURL) return;
+  const segments = onlineURL.split('/') || [];
+  const localURL = `${Consts.NODE_SERVER}/lesson/readFile?n=${segments.slice(3).join('*')}`;
+  return localURL;
 }
 
 class LessonScene extends scene {
@@ -155,10 +156,6 @@ class LessonScene extends scene {
     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 = '';
@@ -223,7 +220,7 @@ class LessonScene extends scene {
   	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)}" onerror="this.src='${curImage.url}'" />`
+      imageDom = `<img src="${getLocalResourceUrl(curImage.url)}" />`
     }
   	document.getElementById('view-content').innerHTML = imageDom;
   }
@@ -232,29 +229,16 @@ class LessonScene extends scene {
   * 渲染视频视图
   */
   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', url);
-    }
+    // 初始化视频播放器
+    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()) {
@@ -290,12 +274,9 @@ class LessonScene extends scene {
     content.innerHTML = imgHTML;
     // 2.根据是否有无audioURL来控制面板及audio的展现
     if (type === Consts.TYPE_AUDIOBOOK && audioUrl) {
-      if (this.isDownload) {
-        audioUrl = getLocalResourceUrl(audioUrl)
-      }
       let audioElement = document.createElement('audio');
       audioElement.setAttribute('id', 'courseware-audio');
-      audioElement.setAttribute('src', audioUrl);
+      audioElement.setAttribute('src', this.isDownload ? getLocalResourceUrl(audioUrl) : audioUrl);
       audioElement.setAttribute('autoplay', 'autoplay');
       let controlsElement = document.createElement('div');
       controlsElement.setAttribute('class', 'audio-controls');
@@ -465,8 +446,12 @@ class LessonScene extends scene {
   onOK(e) {
     // 点击后退按钮
     if (e.target.con.classList.contains('goback')) {
-      this.hideScene({id: this.courseId}, 'CourseScene');
-      return;
+			if ( -1 != this.moye.focusList.indexOf('CourseScene')) {
+        this.hideScene({id: this.courseId}, 'CourseScene');
+        return;
+      } else {
+        this.hideScene();
+      }
     }
     // 拦截音频控制相关事件单独处理
   	const leaf = FocusEngine.getFocusedLeaf();

+ 68 - 76
src/stage/index/scene/LoginScene.js

@@ -15,6 +15,9 @@ class LoginScene extends scene {
 	 * @desc 将登录逻辑抽象为此函数,方便多处调用
 	 */
 	loginLogic() {
+		//触发登录逻辑后输入框置灰
+		document.querySelector('.form-sid').style.borderColor = '#d3d3d3';
+		document.querySelector('.form-password').style.borderColor = '#d3d3d3';
 		let stu_no = this.sidInput.value.replace(/\s|\|/g, '');
 		let password = this.passwordInput.value.replace(/\s|\|/g, '');
 		APIClient.userLoginAndBindDevice({
@@ -30,7 +33,7 @@ class LoginScene extends scene {
 				if ( -1 != this.moye.focusList.indexOf('IndexScene')){
 					this.hideScene({success: true}, 'IndexScene');
 				} else {
-      				this.showScene(require('./IndexScene.js'), {});
+      		this.showScene(require('./IndexScene.js'), {});
 				}
 			} else if (Consts.API_CODE_ISBOUND == res.code) {
 				//账号被登陆
@@ -42,10 +45,6 @@ class LoginScene extends scene {
 
 			} else {
 				TVUtil.Toast.show('帐号或密码错误!', 3000);
-				this.sidInput.value = '|';
-				this.passwordInput.value = '';
-				this.moye.root.getWidgetById('sid-input').focus();
-				this.onKeydown();
 			}
 		});
 	}
@@ -57,12 +56,11 @@ class LoginScene extends scene {
 			this.submitInput = document.getElementById('submit-input');
 			this.sidInput.value = '|';
 			this.passwordInput.value = '';
-			this.moye.root.getWidgetById('key-5').focus();
 		});
 		document.querySelector('.form-sid').style.borderColor = '#4682B4';
 	}
 
-	onResume(data) { }
+	onResume() { }
 
 	onPause() { }
 
@@ -76,7 +74,43 @@ class LoginScene extends scene {
 
 	onKeyup(e) { }
 
+	onKeydown(e) { }
+
 	onOK(e) {
+		if (e.target.id !== this.currFocus) {
+			if (this.currFocus === 'sid-input' || this.currFocus === 'password-input') {
+				const currInput = document.getElementById(this.currFocus);
+				currInput.value = currInput.value.replace(/\|/g, '');
+				if (e.target.id !== 'submit-input') {
+					const nextInput = document.getElementById(e.target.id);
+					nextInput.value = nextInput.value + '|';
+				}
+			}
+		}
+		//左侧input控件切换逻辑
+		switch(e.target.id) {
+			case 'sid-input':
+				document.querySelector('.form-sid').style.borderColor = '#4682B4';
+				document.querySelector('.form-password').style.borderColor = '#d3d3d3';
+				this.currFocus = e.target.id;
+				return;
+			case 'password-input':
+				document.querySelector('.form-password').style.borderColor = '#4682B4';
+				document.querySelector('.form-sid').style.borderColor = '#d3d3d3';
+				this.currFocus = e.target.id;
+				return;
+			case 'submit-input':
+				const account = this.sidInput.value.replace(/\s|\|/g, '');
+				const password = this.passwordInput.value.replace(/\s|\|/g, '');
+				if (account && password) {
+					this.loginLogic();
+				}
+				return;
+			default:
+				break;
+		}
+
+		//右侧键盘点击处理逻辑
 		let key = null;
 		switch (e.target.id) {
 			case 'key-1':
@@ -117,80 +151,38 @@ class LoginScene extends scene {
 				break;
 		}
 
-		let currInput = document.getElementById(this.currFocus);
-		if (this.currFocus !== 'submit-input') {
-			if (typeof key === 'number') {
-				if (this.currFocus === 'sid-input') {
-					currInput.value = (currInput.value.replace(/\s|\|/g, '') + key.toString()).replace(/(\d{4})/g, '$1 ').trim() + '|';
-				}
-				if (this.currFocus === 'password-input') {
-					currInput.value = (currInput.value.replace(/\s|\|/g, '') + key.toString()).replace(/(\d{4})/g, '$1 ').trim() + '|';
-				}
-			} else if (key === 'backspace') {
-				currInput.value = currInput.value.indexOf('|') === -1 ? currInput.value.slice(0, -1) : currInput.value.slice(0, -2) + '|';
-			} else if (key === 'enter') {
-				if (this.currFocus === 'password-input') {
-					this.loginLogic();
-				}
-				let focusArr = ['sid-input', 'password-input', 'submit-input', 'submit-input'];
-				let nextInputIndex = focusArr.indexOf(this.currFocus);
-				// console.log(focusArr[nextInputIndex + 1]);
-				let nextInput = this.moye.root.getWidgetById(focusArr[nextInputIndex + 1]);
-				nextInput.focus();
-				this.onKeydown();
+		/* 动态改变input内的值 */
+		const currInput = document.getElementById(this.currFocus);
+		if (typeof key === 'number') {
+			if (this.currFocus === 'sid-input') {
+				currInput.value = (currInput.value.replace(/\s|\|/g, '') + key.toString()).replace(/(\d{4})/g, '$1 ').trim() + '|';
 			}
-		} else {
-			if (key !== null) {
-				this.moye.root.getWidgetById('submit-input').focus();
-			} else {
+			if (this.currFocus === 'password-input') {
+				currInput.value = (currInput.value.replace(/\s|\|/g, '') + key.toString()).replace(/(\d{4})/g, '$1 ').trim() + '|';
+			}
+		} else if (key === 'backspace') {
+			currInput.value = currInput.value.indexOf('|') === -1 ? currInput.value.slice(0, -1) : currInput.value.slice(0, -2) + '|';
+		} else if (key === 'enter') {
+			const account = this.sidInput.value.replace(/\s|\|/g, '');
+			const password = this.passwordInput.value.replace(/\s|\|/g, '');
+			if (this.currFocus === 'sid-input' && account) {
+				document.querySelector('.form-password').style.borderColor = '#4682B4';
+				document.querySelector('.form-sid').style.borderColor = '#d3d3d3';
+				document.querySelector('#submit-input').style.background = '#ccc';
+				this.currFocus = 'password-input';
+			}
+			else if (this.currFocus === 'password-input' && password) {
 				this.loginLogic();
 			}
 		}
-	}
 
-	onKeydown(e) {
-		const leaf = FocusEngine.getFocusedLeaf();
-		switch (leaf.id) {
-			case 'sid-input':
-				document.querySelector('.form-sid').style.borderColor = '#ff5a00';
-				document.querySelector('.form-password').style.borderColor = '#d3d3d3';
-				this.passwordInput.value = this.passwordInput.value.replace(/\|/g, '');
-				this.sidInput.value = this.sidInput.value.indexOf('|') === -1 ? this.sidInput.value + '|' : this.sidInput.value;
-				if (this.currFocus !== 'sid-input') {
-					this.moye.root.getWidgetById('key-5').focus();
-					this.currFocus = 'sid-input';
-					// 焦点离开 - 颜色变为输入状态颜色
-					document.querySelector('.form-sid').style.borderColor = '#4682B4';
-				}
-				break;
-			case 'password-input':
-				document.querySelector('.form-sid').style.borderColor = '#d3d3d3';
-				document.querySelector('.form-password').style.borderColor = '#ff5a00';
-				this.sidInput.value = this.sidInput.value.replace(/\|/g, '');
-				this.passwordInput.value = this.passwordInput.value.indexOf('|') === -1 ? this.passwordInput.value + '|' : this.passwordInput.value;
-				if (this.currFocus !== 'password-input') {
-					this.moye.root.getWidgetById('key-5').focus();
-					this.currFocus = 'password-input';
-					// 焦点离开 - 颜色变为输入状态颜色
-					document.querySelector('.form-password').style.borderColor = '#4682B4';
-				}
-				break;
-			case 'submit-input':
-				document.querySelector('.form-sid').style.borderColor = '#d3d3d3';
-				document.querySelector('.form-password').style.borderColor = '#d3d3d3';
-				this.passwordInput.value = this.passwordInput.value.replace(/\|/g, '');
-				this.sidInput.value = this.sidInput.value.replace(/\|/g, '');
-				this.currFocus = 'submit-input';
-				break;
-			default:
-				if (this.currFocus == 'sid-input') {
-					document.querySelector('.form-sid').style.borderColor = '#4682B4';
-					document.querySelector('.form-password').style.borderColor = '#d3d3d3';
-				} else if (this.currFocus == 'password-input') {
-					document.querySelector('.form-sid').style.borderColor = '#d3d3d3';
-					document.querySelector('.form-password').style.borderColor = '#4682B4';
-				}
-				break;
+		/* 根据sid-input与password-input是否有值动态更换submit-input颜色 */
+		const account = this.sidInput.value.replace(/\s|\|/g, '');
+		const password = this.passwordInput.value.replace(/\s|\|/g, '');
+		if (account && password) {
+			document.querySelector('#submit-input').style.background = '#2973d7';
+		} else {
+			document.querySelector('#submit-input').style.background = '#ccc';
 		}
 	}
 }

+ 10 - 3
src/stage/index/style/DownloadScene.less

@@ -176,13 +176,20 @@
 						height: 100%;
 						width: 100%;
 					}
-					&.fe-focus {
-						//border: .05rem solid #ffe100;
-						//border-radius: .25rem;
+					.img-disable-btn {
+						height: 100%;
+						width: 100%;
+						-webkit-filter: grayscale(100%);
+						-moz-filter: grayscale(100%);
+						-ms-filter: grayscale(100%);
+						-o-filter: grayscale(100%);
+						filter: grayscale(100%);
+						filter: gray;
 					}
 				}
 			}
 			
+			
 		}
 		&.row-header{
 			height: 0.9rem;

+ 1 - 8
src/stage/index/style/LoginScene.less

@@ -112,11 +112,7 @@
 				font-size: 0.45rem;
 				color: #fff;
 				background: #ccc;
-
-				&.fe-focus {
-					background: #2973d7;
-				//	.after-focus(@outLineSize; #ff5a00; 0; #ff5a00);
-				}
+				outline: none;
 			}
 		}
 	}
@@ -190,9 +186,6 @@
 					background-image: url('assets/img/LoginScene/enter.png');
 				}
 			}
-			&.fe-focus .key-icon {
-			//	.after-focus(@outLineSize; #ff5a00; 0; #ff5a00);
-			}
 		}
 	}
 }

+ 1 - 1
src/util/Consts.js

@@ -11,7 +11,7 @@ class Consts {
 }
 
 //node服务接口地址
-Consts.NODE_SERVER = 'http://127.0.0.1:8089';
+Consts.NODE_SERVER = 'http://127.0.0.1:9191';
 
 //图片/视频资源域名
 Consts.IMG_PATH = 'https://efunimgs.ai160.com';

+ 6 - 12
src/util/WinBoxAPI.js

@@ -8,13 +8,13 @@ class WinBoxAPI {
     if (httpRequest.readyState != 4) {
 			return;
 		}
-    if(httpRequest.status !== 200) {
-     callback( httpRequest.status !== 200,{data:''})
-     return;
+    try {
+		  let res = JSON.parse(httpRequest.responseText);
+		  callback(httpRequest.status == 200, res);
+    }
+    catch(err) {
+      callback(false, {});
     }
-    let res = JSON.parse(httpRequest.responseText);
-    callback(httpRequest.status == 200, res);
-    
   }
 
   static baseRequest(method, path, params, callback) {
@@ -64,12 +64,6 @@ class WinBoxAPI {
     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;