Commit dbc4c314 authored by Chen Jiping's avatar Chen Jiping

完成

parent 7b9a904b
...@@ -128,5 +128,8 @@ ...@@ -128,5 +128,8 @@
} }
} }
}, },
"defaultProject": "ng-template-generator" "defaultProject": "ng-template-generator",
"cli": {
"analytics": "d4049f16-cc8a-4a40-a984-afeed976b129"
}
} }
\ No newline at end of file
<div class="model-content"> <div class="model-content">
<div nz-row>
<div nz-col nzOffset='4'><h1 nz-title>课程内容编辑</h1></div>
</div>
<div nz-form>
<nz-form-item>
<nz-form-control [nzSpan]="15" nzOffset="3">
<div *ngFor="let it of item.exercises; let i = index" class="card-item" style="padding: 0.5vw;">
<nz-form-item>
<nz-form-label [nzSpan]="6" nzFor="{{i}}.contents">内容</nz-form-label>
<nz-form-control [nzSpan]="6">
<button nz-button nzType="dashed" [disabled]="it.contents.length == 5 ? true : false" class="add-btn" id="add-btn"
(click)="addContentItem(it.contents)">
<i nz-icon nzType="plus-circle" nzTheme="outline"></i>添加
</button>
</nz-form-control>
</nz-form-item>
<div >
<div style="position: absolute; left: 200px; top: 100px; width: 800px;">
<input type="text" nz-input [(ngModel)]="item.text" (blur)="save()">
<div *ngFor="let data of it.contents;let j = index" class="card-item" style="padding: 0.5vw;">
<div class="border">
<nz-divider nzText="内容-{{j+1}}" nzOrientation="left"></nz-divider>
<nz-form-item>
<nz-form-label [nzSpan]="6" >内容形式</nz-form-label>
<nz-form-control [nzSpan]="6">
<nz-radio-group [(ngModel)]="data.contentType" (ngModelChange)="setContentType($event, data)">
<label nz-radio nzValue="T">文字</label>
<label nz-radio nzValue="P">图片</label>
</nz-radio-group>
</nz-form-control>
</nz-form-item>
<div *ngIf="data.contentType == 'T'">
<nz-form-item>
<nz-form-label [nzSpan]="6" nzFor="{{j}}.val">文本</nz-form-label>
<nz-form-control [nzSpan]="6">
<input nz-input type="text" id="{{j}}.val" placeholder="请录入内容" [(ngModel)]="data.val" (blur)="save()">
</nz-form-control>
</nz-form-item>
</div>
<div *ngIf="data.contentType == 'P'">
<nz-form-item>
<nz-form-label [nzSpan]="6" nzFor="{{j}}.pic_url">图片</nz-form-label>
<nz-form-control [nzSpan]="6">
<app-upload-image-with-preview <app-upload-image-with-preview
[picUrl]="item.pic_url" style="width: 100%"
(imageUploaded)="onImageUploadSuccess($event, 'pic_url')" [picUrl]="data.pic_url"
(imageUploaded)="onImageUploadSuccess($event, data, 'pic_url')"
></app-upload-image-with-preview> ></app-upload-image-with-preview>
</nz-form-control>
<app-audio-recorder </nz-form-item>
[audioUrl]="item.audio_url" </div>
(audioUploaded)="onAudioUploadSuccess($event, 'audio_url')" <nz-form-item>
></app-audio-recorder> <nz-form-label [nzSpan]="6" nzFor="{{j}}.pic_url">音频</nz-form-label>
<app-custom-hot-zone></app-custom-hot-zone> <nz-form-control [nzSpan]="6">
<app-upload-video></app-upload-video> <app-audio-recorder id="{{j}}.audio_url"
<app-lesson-title-config></app-lesson-title-config> [audioUrl]="data.audio_url"
(audioUploaded)="onAudioUploadSuccess($event, data, 'audio_url')">
</app-audio-recorder>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<button style="margin: 10px;" nz-button nzType="danger" (click)="delContentItem(it.contents, j)">
<span>删除</span>
</button>
</nz-form-item>
</div> </div>
</div>
</div>
</div>
</nz-form-control>
</nz-form-item>
</div>
</div> </div>
\ No newline at end of file
\ No newline at end of file
...@@ -10,7 +10,7 @@ import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, Ap ...@@ -10,7 +10,7 @@ import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, Ap
export class FormComponent implements OnInit, OnChanges, OnDestroy { export class FormComponent implements OnInit, OnChanges, OnDestroy {
// 储存数据用 // 储存数据用
saveKey = "test_0011"; saveKey = "DF_L223";
// 储存对象 // 储存对象
item; item;
...@@ -31,6 +31,14 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -31,6 +31,14 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.item = data; this.item = data;
} }
if(!this.item.exercises){
this.item.exercises = [];
this.addExercisesItem();
this.item.exercises[0].contents.push(this.getDefaultContentItem());
}
this.init(); this.init();
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges(); this.changeDetectorRef.detectChanges();
...@@ -58,9 +66,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -58,9 +66,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
* 储存图片数据 * 储存图片数据
* @param e * @param e
*/ */
onImageUploadSuccess(e, key) { onImageUploadSuccess(e, item, key) {
this.item[key] = e.url; item[key] = e.url;
this.save(); this.save();
} }
...@@ -68,9 +76,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -68,9 +76,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
* 储存音频数据 * 储存音频数据
* @param e * @param e
*/ */
onAudioUploadSuccess(e, key) { onAudioUploadSuccess(e, item, key) {
this.item[key] = e.url; item[key] = e.url;
this.save(); this.save();
} }
...@@ -93,5 +101,87 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -93,5 +101,87 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}, 1); }, 1);
} }
/**
* 添加练习
*/
addExercisesItem(){
let exercises = this.getDefaultExercisesItem();
this.item.exercises.push(exercises);
this.save();
}
delExercisesItem(index){
if (index !== -1) {
this.item.exercises.splice(index, 1);
this.save();
}
}
/**
* 获取缺省的练习题内容
*/
getDefaultExercisesItem(){
let exercises = {
contents:[]
}
return exercises;
}
/**
* 添加练习题内容
*/
addContentItem(contents){
let content = this.getDefaultContentItem();
contents.push(content);
this.save();
}
/**
* 删除练习题内容
* @param contents
* @param index
*/
delContentItem(contents, index){
if (index !== -1) {
contents.splice(index, 1);
this.save();
}
}
/**
* 获取缺省的练习题内容
*/
getDefaultContentItem(){
let content = {
contentType:"T",
val:"",
pic_url:"",
audio_url:""
}
return content;
}
setContentType(e, item){
item['contentType'] = e;
if("T" == e){
item['pic_url'] = "";
}
else if("P" == e){
item['val'] = "";
}
this.save();
}
} }
import {
Label,
MySprite
} from './Unit';
/**
* 根据父级组件大小设置字体大小
* @param parWidth
* @param label
*/
export function setFontSize(parWidth : number, label: Label){
if(!label){
return;
}
let w = label.width;
let h = label.height;
let r = Math.sqrt( w * w + h * h)/2;
//如果宽度超过,则缩小字体
if(r > parWidth/2){
shrinkFont(parWidth, label);
}
else{
magnifyingFontSize(parWidth, label);
}
}
export function shrinkFont(parWidth : number, label: Label){
if(!label){
return;
}
let w = label.width;
let h = label.height;
let r = Math.sqrt( w * w + h * h)/2;
//如果宽度超过,则缩小字体
if(r > parWidth/2){
let fontSize = label.fontSize;
fontSize = fontSize - 2;
label.fontSize = fontSize;
label.refreshSize();
shrinkFont(parWidth, label);
}
}
export function magnifyingFontSize(parWidth : number, label: Label){
if(!label){
return;
}
let w = label.width;
let h = label.height;
let r = Math.sqrt( w * w + h * h)/2;
//如果宽度超过,则缩小字体
if(r < parWidth/2){
let fontSize = label.fontSize;
fontSize = fontSize + 2;
label.fontSize = fontSize;
label.refreshSize();
magnifyingFontSize(parWidth, label);
}
}
/**
* 获取按钮图片
* @param text 文本内容
* @param font 字体
* @param fontColor
*/
export function getBtnPic(text, font, fontColor){
const btn = new MySprite();
btn.init(this.images.get('btn'));
btn.setScaleXY(this.mapScale);
let btnText = new Label();
btnText.text = text;
btnText.textAlign='middle';
btnText.fontSize = 50;
btnText.fontName = font;
btnText.fontColor = fontColor;
btnText.refreshSize();
btnText.x = -btnText.width/2;
btnText.y = 0;
btn.addChild(btnText);
btn.childDepandAlpha = true;
return btn;
}
export function getRandomItemFromArr(arr){
if(!arr){
return;
}
let length = arr.length;
let index = Math.ceil(Math.random()*100000000)%length;
return arr[index];
}
\ No newline at end of file
This diff is collapsed.
const res = [ const res = [
// ['bg', "assets/play/bg.jpg"], ['bg', "assets/play/bg.png"],
['btn_left', "assets/play/btn_left.png"], ['start', "assets/play/start.png"],
['btn_right', "assets/play/btn_right.png"], ['restart', "assets/play/restart.png"],
// ['text_bg', "assets/play/text_bg.png"], ['l_wave', "assets/play/l_wave.png"],
['r_wave', "assets/play/r_wave.png"],
['b_leaf_wave', "assets/play/b_leaf_wave.png"],
['b_lotus_leaf', "assets/play/b_lotus_leaf.png"],
['b_shadow', "assets/play/b_shadow.png"],
['s_wave', "assets/play/s_wave.png"],
['s_lotus_leaf', "assets/play/s_lotus_leaf.png"],
['s_shadow', "assets/play/s_shadow.png"],
['s_lotus_leaf_light', "assets/play/s_lotus_leaf_light.png"],
['jumped_up', "assets/play/jumped_up.png"],
['droplet', "assets/play/droplet.png"],
['star', "assets/play/star.png"],
['standby-01', "assets/play/frog_standby/standby-01.png"],
['standby-02', "assets/play/frog_standby/standby-02.png"],
['standby-03', "assets/play/frog_standby/standby-03.png"],
['standby-04', "assets/play/frog_standby/standby-04.png"],
['standby-05', "assets/play/frog_standby/standby-05.png"],
['standby-06', "assets/play/frog_standby/standby-06.png"],
['standby-07', "assets/play/frog_standby/standby-07.png"],
['standby-08', "assets/play/frog_standby/standby-08.png"],
['standby-09', "assets/play/frog_standby/standby-09.png"],
['standby-10', "assets/play/frog_standby/standby-10.png"],
['standby-11', "assets/play/frog_standby/standby-11.png"],
['standby-12', "assets/play/frog_standby/standby-12.png"],
['standby-13', "assets/play/frog_standby/standby-13.png"],
['standby-14', "assets/play/frog_standby/standby-14.png"],
['standby-15', "assets/play/frog_standby/standby-15.png"],
['standby-16', "assets/play/frog_standby/standby-16.png"],
['standby-17', "assets/play/frog_standby/standby-17.png"],
['standby-18', "assets/play/frog_standby/standby-18.png"],
['standby-19', "assets/play/frog_standby/standby-19.png"],
['standby-20', "assets/play/frog_standby/standby-20.png"],
['standby-21', "assets/play/frog_standby/standby-21.png"],
['standby-22', "assets/play/frog_standby/standby-22.png"],
['standby-23', "assets/play/frog_standby/standby-23.png"],
['standby-24', "assets/play/frog_standby/standby-24.png"],
['standby-25', "assets/play/frog_standby/standby-25.png"],
['standby-26', "assets/play/frog_standby/standby-26.png"],
['standby-27', "assets/play/frog_standby/standby-27.png"],
['standby-28', "assets/play/frog_standby/standby-28.png"],
['petal_1', "assets/play/petal_1.png"],
['petal_2', "assets/play/petal_2.png"],
['petal_3', "assets/play/petal_3.png"],
['petal_4', "assets/play/petal_4.png"],
['petal_5', "assets/play/petal_5.png"],
['petal_6', "assets/play/petal_6.png"],
['petal_7', "assets/play/petal_7.png"],
['petal_8', "assets/play/petal_8.png"],
['petal_9', "assets/play/petal_9.png"]
]; ];
...@@ -12,7 +62,10 @@ const res = [ ...@@ -12,7 +62,10 @@ const res = [
const resAudio = [ const resAudio = [
['click', "assets/play/music/click.mp3"], ['click', "assets/play/music/click.mp3"],
['croak', "assets/play/music/croak.mp3"],
['handclap', "assets/play/music/handclap.mp3"],
['jump', "assets/play/music/jump.mp3"],
['showContent', "assets/play/music/showContent.mp3"]
]; ];
export {res, resAudio}; export {res, resAudio};
This diff is collapsed.
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