Commit 3c9bbfda authored by 范雪寒's avatar 范雪寒

fix: bugs

parent ebc5514e
This diff is collapsed.
import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef, ChangeDetectorRef} from '@angular/core';
import { Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef, ChangeDetectorRef } from '@angular/core';
......@@ -14,7 +14,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
// 储存对象
item;
constructor(private appRef: ApplicationRef,private changeDetectorRef: ChangeDetectorRef) {
constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) {
}
......@@ -34,17 +34,20 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
console.log('item:', this.item);
// 获取存储的数据
(<any> window).courseware.getData((data) => {
(<any>window).courseware.getData((data) => {
if (data) {
this.item = data;
if (data.contentObj && data.contentObj.data) {
this.item = data.contentObj.data;
}
}
if(!this.item.skinB){
if (!this.item.skinB) {
this.item.skinB = {};
}
if(!this.item.skinA){
if (!this.item.skinA) {
this.item.skinA = {};
}
......@@ -67,20 +70,20 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
init() {
if(!this.item.title){
if (!this.item.title) {
this.item.title = this.getDefaultTile();
}
//设置默认皮肤
if(!this.item.skin){
if (!this.item.skin) {
this.item.skin = "A";
}
if(!this.item.exercisesArr || this.item.exercisesArr.length == 0){
if (!this.item.exercisesArr || this.item.exercisesArr.length == 0) {
this.item.exercisesArr = [];
for(let i = 0; i < 6; ++ i){
for (let i = 0; i < 6; ++i) {
let exercises = this.getDefaultExercisesItem();
......@@ -117,7 +120,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
* 储存数据
*/
save() {
(<any> window).courseware.setData(this.item, null, this.saveKey);
(<any>window).courseware.setData(this.item, null, this.saveKey);
this.changeDetectorRef.detectChanges();
this.refresh();
}
......@@ -135,22 +138,22 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
/**
* 获取缺省的练习题内容
*/
getDefaultExercisesItem(){
getDefaultExercisesItem() {
const exercises = {
text:'',
pic_url:'',
audio_url:'',
letters:[]
text: '',
pic_url: '',
audio_url: '',
letters: []
};
return exercises;
}
getDefaultTile(){
getDefaultTile() {
const title = {
part1:'',
part2:'',
audio_url:''
part1: '',
part2: '',
audio_url: ''
};
return title;
......@@ -159,10 +162,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
/**
* 获取默认的字母
*/
getDefaultLetter(){
getDefaultLetter() {
let letter = {
val:'',
isColor:'0'
val: '',
isColor: '0'
};
return letter;
......@@ -185,11 +188,11 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}
}
clearBg(){
if(this.item.skin ==='A'){
clearBg() {
if (this.item.skin === 'A') {
this.item.skinA = {};
}
else{
else {
this.item.skinB = {};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment