|
@@ -8,6 +8,31 @@ class TrainingScene extends scene {
|
|
this.curImageIndex = 0;
|
|
this.curImageIndex = 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ renderLeftRightBtn() {
|
|
|
|
+ let btnRight = document.getElementById('imgRight');
|
|
|
|
+ let btnLeft = document.getElementById('imgLeft');
|
|
|
|
+ // 如果是最后一张,不显示向右按钮
|
|
|
|
+ if (this.imageList.length - 1 === this.curImageIndex) {
|
|
|
|
+ if (btnRight) {
|
|
|
|
+ btnRight.style.display = 'none';
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if (btnRight) {
|
|
|
|
+ btnRight.style.display = 'block';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 如果是第一张,不显示向左按钮
|
|
|
|
+ if (this.curImageIndex === 0) {
|
|
|
|
+ if (btnLeft) {
|
|
|
|
+ btnLeft.style.display = 'none';
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if (btnLeft) {
|
|
|
|
+ btnLeft.style.display = 'block';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
loadTrainingContent(trainingId, index) {
|
|
loadTrainingContent(trainingId, index) {
|
|
APIClient.getTrainingDetail(trainingId, (isTrue, res) => {
|
|
APIClient.getTrainingDetail(trainingId, (isTrue, res) => {
|
|
if (!isTrue) { return; }
|
|
if (!isTrue) { return; }
|
|
@@ -25,6 +50,7 @@ class TrainingScene extends scene {
|
|
renderImageView() {
|
|
renderImageView() {
|
|
const curImage = this.imageList[this.curImageIndex];
|
|
const curImage = this.imageList[this.curImageIndex];
|
|
document.getElementById('trainingImg').setAttribute('src', Consts.IMG_PATH + '/' + curImage);
|
|
document.getElementById('trainingImg').setAttribute('src', Consts.IMG_PATH + '/' + curImage);
|
|
|
|
+ this.renderLeftRightBtn();
|
|
}
|
|
}
|
|
|
|
|
|
keyRightHandler() {
|
|
keyRightHandler() {
|
|
@@ -74,8 +100,17 @@ class TrainingScene extends scene {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- onOK() {
|
|
|
|
-
|
|
|
|
|
|
+ onOK(e) {
|
|
|
|
+ // 后退
|
|
|
|
+ if (e.target.con.classList.contains('goback')) {
|
|
|
|
+ this.hideScene({});
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (e.target.id === 'imgLeft') {
|
|
|
|
+ this.keyLeftHandler();
|
|
|
|
+ } else if (e.target.id === 'imgRight') {
|
|
|
|
+ this.keyRightHandler();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
onBack() {
|
|
onBack() {
|