|
@@ -15,6 +15,9 @@ class LoginScene extends scene {
|
|
* @desc 将登录逻辑抽象为此函数,方便多处调用
|
|
* @desc 将登录逻辑抽象为此函数,方便多处调用
|
|
*/
|
|
*/
|
|
loginLogic() {
|
|
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 stu_no = this.sidInput.value.replace(/\s|\|/g, '');
|
|
let password = this.passwordInput.value.replace(/\s|\|/g, '');
|
|
let password = this.passwordInput.value.replace(/\s|\|/g, '');
|
|
APIClient.userLoginAndBindDevice({
|
|
APIClient.userLoginAndBindDevice({
|
|
@@ -30,7 +33,7 @@ class LoginScene extends scene {
|
|
if ( -1 != this.moye.focusList.indexOf('IndexScene')){
|
|
if ( -1 != this.moye.focusList.indexOf('IndexScene')){
|
|
this.hideScene({success: true}, 'IndexScene');
|
|
this.hideScene({success: true}, 'IndexScene');
|
|
} else {
|
|
} else {
|
|
- this.showScene(require('./IndexScene.js'), {});
|
|
|
|
|
|
+ this.showScene(require('./IndexScene.js'), {});
|
|
}
|
|
}
|
|
} else if (Consts.API_CODE_ISBOUND == res.code) {
|
|
} else if (Consts.API_CODE_ISBOUND == res.code) {
|
|
//账号被登陆
|
|
//账号被登陆
|
|
@@ -42,10 +45,6 @@ class LoginScene extends scene {
|
|
|
|
|
|
} else {
|
|
} else {
|
|
TVUtil.Toast.show('帐号或密码错误!', 3000);
|
|
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.submitInput = document.getElementById('submit-input');
|
|
this.sidInput.value = '|';
|
|
this.sidInput.value = '|';
|
|
this.passwordInput.value = '';
|
|
this.passwordInput.value = '';
|
|
- this.moye.root.getWidgetById('key-5').focus();
|
|
|
|
});
|
|
});
|
|
document.querySelector('.form-sid').style.borderColor = '#4682B4';
|
|
document.querySelector('.form-sid').style.borderColor = '#4682B4';
|
|
}
|
|
}
|
|
|
|
|
|
- onResume(data) { }
|
|
|
|
|
|
+ onResume() { }
|
|
|
|
|
|
onPause() { }
|
|
onPause() { }
|
|
|
|
|
|
@@ -76,7 +74,43 @@ class LoginScene extends scene {
|
|
|
|
|
|
onKeyup(e) { }
|
|
onKeyup(e) { }
|
|
|
|
|
|
|
|
+ onKeydown(e) { }
|
|
|
|
+
|
|
onOK(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;
|
|
let key = null;
|
|
switch (e.target.id) {
|
|
switch (e.target.id) {
|
|
case 'key-1':
|
|
case 'key-1':
|
|
@@ -117,80 +151,38 @@ class LoginScene extends scene {
|
|
break;
|
|
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();
|
|
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';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|