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 { ...@@ -14,7 +14,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
// 储存对象 // 储存对象
item; 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 { ...@@ -34,17 +34,20 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
console.log('item:', this.item); console.log('item:', this.item);
// 获取存储的数据 // 获取存储的数据
(<any> window).courseware.getData((data) => { (<any>window).courseware.getData((data) => {
if (data) { if (data) {
this.item = 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 = {}; this.item.skinB = {};
} }
if(!this.item.skinA){ if (!this.item.skinA) {
this.item.skinA = {}; this.item.skinA = {};
} }
...@@ -67,20 +70,20 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -67,20 +70,20 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
init() { init() {
if(!this.item.title){ if (!this.item.title) {
this.item.title = this.getDefaultTile(); this.item.title = this.getDefaultTile();
} }
//设置默认皮肤 //设置默认皮肤
if(!this.item.skin){ if (!this.item.skin) {
this.item.skin = "A"; 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 = []; this.item.exercisesArr = [];
for(let i = 0; i < 6; ++ i){ for (let i = 0; i < 6; ++i) {
let exercises = this.getDefaultExercisesItem(); let exercises = this.getDefaultExercisesItem();
...@@ -117,7 +120,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -117,7 +120,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
* 储存数据 * 储存数据
*/ */
save() { save() {
(<any> window).courseware.setData(this.item, null, this.saveKey); (<any>window).courseware.setData(this.item, null, this.saveKey);
this.changeDetectorRef.detectChanges(); this.changeDetectorRef.detectChanges();
this.refresh(); this.refresh();
} }
...@@ -135,22 +138,22 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -135,22 +138,22 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
/** /**
* 获取缺省的练习题内容 * 获取缺省的练习题内容
*/ */
getDefaultExercisesItem(){ getDefaultExercisesItem() {
const exercises = { const exercises = {
text:'', text: '',
pic_url:'', pic_url: '',
audio_url:'', audio_url: '',
letters:[] letters: []
}; };
return exercises; return exercises;
} }
getDefaultTile(){ getDefaultTile() {
const title = { const title = {
part1:'', part1: '',
part2:'', part2: '',
audio_url:'' audio_url: ''
}; };
return title; return title;
...@@ -159,10 +162,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -159,10 +162,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
/** /**
* 获取默认的字母 * 获取默认的字母
*/ */
getDefaultLetter(){ getDefaultLetter() {
let letter = { let letter = {
val:'', val: '',
isColor:'0' isColor: '0'
}; };
return letter; return letter;
...@@ -185,11 +188,11 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -185,11 +188,11 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
} }
} }
clearBg(){ clearBg() {
if(this.item.skin ==='A'){ if (this.item.skin === 'A') {
this.item.skinA = {}; this.item.skinA = {};
} }
else{ else {
this.item.skinB = {}; 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