Commit 6097235f authored by Tt's avatar Tt

题目调整完成

parent 761b51d8
import { ApplicationRef, ChangeDetectorRef, ElementRef, ViewChild } from "@angular/core";
export class ComponentBase {
// 储存数据用
saveKey = "";
// 储存对象
item: any = {};
ngOnChanges() { }
ngOnDestroy() { }
constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) { }
ngOnInit() {
// 获取存储的数据
(<any>window).courseware.getData((data) => {
if (data) {
this.item = data;
this.itemStr = JSON.stringify(this.item, null, 4).trim();
}
this.init();
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
}, this.saveKey);
}
@ViewChild("itemTextarea", { static: true }) itemTextarea: ElementRef;
copyData() {
this.itemTextarea.nativeElement.select();
document.execCommand("copy");
}
/**
* 储存图片数据
* @param e
*/
// onAssetUploadSuccess(e: any, ...key: Array<string>) {
// let item = this.item;
// for (let i = 0; i < key.length; i++) {
// if (i + 1 == key.length) {
// if (key[i] == "audio") {
// let sp = e.url.split(".mp3");
// let u = sp[0] + "_l.mp3";
// item[key[i]] = u;
// item["audioName"] = e.name || "";
// } else {
// item[key[i]] = e.url;
// }
// this.save();
// return;
// }
// item = item[key[i]];
// }
// }
/**
* 储存图片数据
* @param e
*/
onImageUploadSuccess(e, key, it = this.item) {
it[key] = e.url;
this.save();
}
/**
* 储存音频数据
* @param e
*/
onAudioUploadSuccess(e, key, it = this.item, audioName) {
let url = e.url;
it[key] = url;
it[audioName] = e.audioName || "";
console.log(JSON.stringify(e));
this.save();
}
save() {
(<any>window).courseware.setData(this.item, null, this.saveKey);
this.itemStr = JSON.stringify(this.item, null, 4).trim();
this.refresh();
console.log('this.item = ' + JSON.stringify(this.item));
}
itemStr = "";
load() {
this.itemStr = this.itemTextarea.nativeElement.value;
if (this.isJSON(this.itemStr)) {
this.item = JSON.parse(this.itemStr);
this.init();
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
}
}
isJSON(str) {
if (typeof str == 'string') {
try {
var obj = JSON.parse(str);
if (typeof obj == 'object' && obj) {
return true;
}
return false;
} catch (e) {
return false;
}
}
return false;
}
/**
* 刷新 渲染页面
*/
refresh() {
setTimeout(() => {
this.appRef.tick();
}, 1);
}
init() { }
}
...@@ -33,3 +33,30 @@ ...@@ -33,3 +33,30 @@
padding: 10px; padding: 10px;
margin: 10px; margin: 10px;
} }
.button-right {
border-style: dotted;
border-color: rgb(42, 142, 72);
width: 100px;
height: 50px;
color: rgb(42, 142, 72);
background-color: white;
}
.button-wrong {
border-style: dotted;
border-color: rgb(180, 0, 0);
width: 100px;
height: 50px;
color: rgb(180, 0, 0);
background-color: white;
}
.button-disable {
border-style: dotted;
border-color: black;
width: 100px;
height: 50px;
color: black;
background-color: white;
}
\ No newline at end of file
<div class="model-content" style="padding: 10px"> <style>
<div style="width: 300px; margin-top: 15px"> .border-solid {
<span>请输入标题: </span> border: 1px solid #333;
<input type="text" nz-input [(ngModel)]="item.title" (blur)="save()" /> border-radius: 10px;
</div> padding: 20px;
}
<div style="margin-top: 15px;display:none">
<span>标题音频: </span> .border-dashed {
<app-audio-recorder border: 1px dashed #333;
[audioUrl]="item.audio_title" border-radius: 10px;
(audioUploaded)="onAudioUploadSuccess($event, 'audio_title')" padding: 20px;
></app-audio-recorder> }
</div>
.option-title {
<div style="margin-top: 25px">选择样式:</div> color: #000;
font-size: 18px;
<nz-radio-group min-width: 70px;
[(ngModel)]="type" /* margin-right: 10px; */
name="radioValue" }
id="radioValue"
(ngModelChange)="onSetType()" .option-content {
style="width: 60%" border: 1px dashed #333;
> border-radius: 1px;
<div *ngFor="let style of styles" style="width: 50%; float: left; text-align: center"> padding: 20px;
<span>{{ style.name }}</span> margin-right: 10px;
<br /> width: 800px;
<br /> }
<img
[alt]="style.name" .option-img {
[src]="style.image" margin-top: 10px;
style="width: 200px; height: auto" }
/>
<br /> .option-audio {
<span>(示例)</span> margin-top: 10px;
<br /> }
<br />
<span>选择 </span><label nz-radio [nzValue]="style.id" (blur)="save()"></label> .option-text {
</div> margin-top: 10px;
</nz-radio-group> }
<div class="border" style="width: 90%; height: 1600px" *ngIf="type == 0"> .option-time {
<div style="width: 100%; text-align: center"> margin-top: 10px;
<h3>样式1</h3> }
</div>
<div style="float: left; width: 30%"> .word-type-title {
<div style="margin-top: 255px"> color: #169BD5;
<strong>左侧字母:</strong> font-size: 18px;
<input }
type="text"
nz-input .word-type-option-title {
[(ngModel)]="dataType.single.words" color: #333;
(blur)="onSaveWord('single')" font-size: 18px;
style="width: 20%" }
maxlength="2"
/> .word-input-title {
color: #333;
<div font-size: 20px;
*ngFor="let word of dataType['single'].wordArr; let j = index" }
>
<div *ngIf="word.type == 'normal'" style="float: left"> .btn-blue {
<a color: #169BD5;
style=" border-color: #169BD5;
float: left; }
font-size: 42px;
font-family: FuturaBT-Bold; .btn-red {
color: #000000; color: #f00;
margin-right: 2px; border-color: #f00;
" }
(click)="onUpWordClicked('single', j)"
>{{ word.word }}</a .input-place-red::-webkit-input-placeholder {
> color: rgba(255, 0, 0, 0.3);
</div> font-size: 12px;
<div *ngIf="word.type != 'normal'" style="float: left"> }
<a </style>
style=" <div class="model-content">
float: left; <div style="padding: 10px;background-color: #fff;">
font-size: 42px; <!-- 标题区 -->
font-family: FuturaBT-Bold; <div class="border-dashed" style="margin: 20px;width: 1000px;display:none">
border-bottom-width: 3px; <!-- <span style="font-size: 20px;">选项分数: </span>
border-bottom-color: #000000; <input type="text" nz-input [(ngModel)]="item.score" (blur)="save()"> -->
border-bottom-style: solid; <span style="font-size: 20px;">标题文字: </span>
color: #c8161e; <input type="text" nz-input [(ngModel)]="item.title" (blur)="save()">
margin-right: 2px; <!-- <span style="font-size: 20px;">标题图片: </span>
" <div style="width:300px">
(click)="onUpWordClicked('single', j)" <app-upload-image-with-preview [picUrl]="item.image"
>{{ word.word }}</a (imageUploaded)="onImageUploadSuccess($event,'image', item.top)"></app-upload-image-with-preview>
> </div> -->
</div> <span style="font-size: 20px;">题目说明: </span>
<input type="text" nz-input [(ngModel)]="item.questionText" (blur)="save()">
<span style="font-size: 20px;">标题音频: </span>
<div style="display:flex ;">
<div>
<app-audio-recorder [audioUrl]="item.questionTextAudio"
(audioUploaded)="onAudioUploadSuccess($event, 'questionTextAudio',item,'audioName')"></app-audio-recorder>
</div>
<div style="margin: 5px">
<span>{{ item.audioName}}</span>
</div> </div>
<br />
<br />
<br />
<br />
<span>(点击字母设置为高亮显示)</span>
<br />
<br />
<span>音频: </span>
<app-audio-recorder
[audioUrl]="dataType.single_audio"
(audioUploaded)="
onAudioUploadSuccessByItem($event, dataType, 'single_audio')
"
></app-audio-recorder>
<br />
<span>默认显示: </span>
<label nz-checkbox [(ngModel)]="dataType.single_show" (ngModelChange)="save()"></label>
</div> </div>
</div> </div>
</div>
<div style="float: right; width: 40%"> <div style="padding: 10px;background-color: #fff;display:none">
<div *ngFor="let index of doubleLetterIndexes" style="margin-top: 30px"> <!-- 标题区 -->
<strong>右侧字母-{{index+1}}:</strong> <div class="border-dashed" style="margin: 20px;width: 1000px;">
<input <div class="word-input-title">
type="text" <div>
nz-input <span>游戏背景音乐: </span>
[(ngModel)]="dataType['character_'+index+index].words" </div>
(blur)="onSaveWord('character_'+index+index)" <div>
style="width: 15%" <span style="color:rgb(201, 200, 200);margin-left:5px;font-size: 10px;"> *可不传,不传既无背景音乐</span>
maxlength="4"
/>
<div
*ngFor="let word of dataType['character_'+index+index].wordArr; let j = index"
>
<div *ngIf="word.type == 'normal'" style="float: left">
<a
style="
float: left;
font-size: 42px;
font-family: FuturaBT-Bold;
color: #000000;
margin-right: 2px;
"
(click)="onUpWordClicked('character_'+index+index, j)"
>{{ word.word }}</a
>
</div>
<div *ngIf="word.type != 'normal'" style="float: left">
<a
style="
float: left;
font-size: 42px;
font-family: FuturaBT-Bold;
border-bottom-width: 3px;
border-bottom-color: #000000;
border-bottom-style: solid;
color: #c8161e;
margin-right: 2px;
"
(click)="onUpWordClicked('character_'+index+index, j)"
>{{ word.word }}</a
>
</div>
</div> </div>
<br />
<br />
<br />
<br />
<span>(点击字母设置为高亮显示)</span>
<br />
<br />
<span>音频: </span>
<app-audio-recorder
[audioUrl]="dataType['character_'+index+index+'_audio']"
(audioUploaded)="
onAudioUploadSuccessByItem($event, dataType, 'character_'+index+index+'_audio')
"
></app-audio-recorder>
<br />
<span>默认显示: </span>
<label nz-checkbox [(ngModel)]="dataType['character_'+index+index+'_show']" (ngModelChange)="save()"></label>
</div> </div>
</div> <div style="display:flex ;margin-top: 10px;">
<div>
<div style="float: right; width: 30%"> <app-audio-recorder [audioUrl]="item.bgAudio"
<div *ngFor="let index of singleLetterIndexes" style="margin-top: 30px"> (audioUploaded)="onAudioUploadSuccess($event, 'bgAudio',item,'audioBgName')">
<strong>中间字母-{{index+1}}:</strong> </app-audio-recorder>
<input </div>
type="text" <div style="margin: 5px">
nz-input <span>{{ item.audioBgName}}</span>
[(ngModel)]="dataType['character_'+index].words" </div>
(blur)="onSaveWord('character_'+index)" <div style="margin: 5px">
style="width: 20%" <span style="color: #169BD5;text-decoration: underline;" type="button" nzDanger
maxlength="2" (click)="deleteBgAudio()">删除背景音</span>
/>
<div
*ngFor="let word of dataType['character_'+index].wordArr; let j = index"
>
<div *ngIf="word.type == 'normal'" style="float: left">
<a
style="
float: left;
font-size: 42px;
font-family: FuturaBT-Bold;
color: #000000;
margin-right: 2px;
"
(click)="onUpWordClicked('character_'+index, j)"
>{{ word.word }}</a
>
</div>
<div *ngIf="word.type != 'normal'" style="float: left">
<a
style="
float: left;
font-size: 42px;
font-family: FuturaBT-Bold;
border-bottom-width: 3px;
border-bottom-color: #000000;
border-bottom-style: solid;
color: #c8161e;
margin-right: 2px;
"
(click)="onUpWordClicked('character_'+index, j)"
>{{ word.word }}</a
>
</div>
</div> </div>
<br />
<br />
<br />
<br />
<span>(点击字母设置为高亮显示)</span>
<br />
<br />
<span>音频: </span>
<app-audio-recorder
[audioUrl]="dataType['character_'+index+'_audio']"
(audioUploaded)="
onAudioUploadSuccessByItem($event, dataType, 'character_'+index+'_audio')
"
></app-audio-recorder>
<br />
<span>默认显示: </span>
<label nz-checkbox [(ngModel)]="dataType['character_'+index+'_show']" (ngModelChange)="save()"></label>
</div> </div>
</div> </div>
</div> </div>
<div class="border" style="width: 90%; height: 1600px" *ngIf="type == 1"> <!-- 题目区 -->
<div style="width: 100%; text-align: center"> <div style=" margin: 20px;width: 1000px;">
<h3>样式2</h3> <div *ngFor="let question of item.questions; let i = index">
</div> <div style="display: flex;margin-top: 20px;">
<div class="border-solid" style="min-width: 1000px;">
<div style="float: right; width: 40%"> <div class="word-type-title">
<div *ngFor="let index of doubleLetterIndexes" style="margin-top: 30px"> 题目{{i+1}}
<strong>右侧字母-{{index+1}}:</strong>
<input
type="text"
nz-input
[(ngModel)]="dataType['character_'+index+index].words"
(blur)="onSaveWord('character_'+index+index)"
style="width: 15%"
maxlength="4"
/>
<div
*ngFor="let word of dataType['character_'+index+index].wordArr; let j = index"
>
<div *ngIf="word.type == 'normal'" style="float: left">
<a
style="
float: left;
font-size: 42px;
font-family: FuturaBT-Bold;
color: #000000;
margin-right: 2px;
"
(click)="onUpWordClicked('character_'+index+index, j)"
>{{ word.word }}</a
>
</div> </div>
<div *ngIf="word.type != 'normal'" style="float: left"> <div>
<a <span style="font-size: 20px;">图片: </span>
style=" <div style="margin-top: 5px;">
float: left; <nz-radio-group [(ngModel)]="question.imgSize" (ngModelChange)="ngChange()">
font-size: 42px; <label nz-radio nzValue="big">
font-family: FuturaBT-Bold; <span [style]="{color:question.imgSize=='big' ? '#169BD5':'#000'}">大图片</span>
border-bottom-width: 3px; </label>
border-bottom-color: #000000; <label nz-radio nzValue="small">
border-bottom-style: solid; <span [style]="{color:question.imgSize=='small' ? '#169BD5':'#000'}">小图片</span>
color: #c8161e; </label>
margin-right: 2px; </nz-radio-group>
" </div>
(click)="onUpWordClicked('character_'+index+index, j)" <div style="width:300px; margin-top: 10px;">
>{{ word.word }}</a <app-upload-image-with-preview [picUrl]="question.image"
> (imageUploaded)="onImageUploadSuccess($event,'image',question)"></app-upload-image-with-preview>
</div>
</div>
<div class="option-audio">
<div class="word-input-title">
音频:
</div>
<div style="display: flex">
<div>
<app-audio-recorder [audioUrl]="question.audio"
(audioUploaded)="onAudioUploadSuccess($event, 'audio',question,'audioName')">
</app-audio-recorder>
</div>
<div style="margin: 5px">
<span>
{{ question.audioName}}
</span>
</div>
</div>
</div> </div>
</div>
<br /> </div>
<br /> <div style="margin:0 20px">
<br /> <button class="btn-red" nz-button nzType="default" nzDanger (click)="removeQuestion(i)">删除题目</button>
<br /> <button class="btn-blue" style="margin-top: 10px;" nz-button nzType="default" nzDanger
<span>(点击字母设置为高亮显示)</span> (click)="copyQuestion(i)">复制题目</button>
<br /> </div>
<br />
<span>音频: </span>
<app-audio-recorder
[audioUrl]="dataType['character_'+index+index+'_audio']"
(audioUploaded)="
onAudioUploadSuccessByItem($event, dataType, 'character_'+index+index+'_audio')
"
></app-audio-recorder>
<br />
<span>默认显示: </span>
<label nz-checkbox [(ngModel)]="dataType['character_'+index+index+'_show']" (ngModelChange)="save()"></label>
</div> </div>
</div> </div>
<div style="float: right; width: 30%"> <div style="margin-top: 20px;">
<div style="margin-top: 255px"> <button class="btn-blue" style="width: 1000px; height: 50px;" nz-button nzType="default" nzDanger
<strong>中间字母:</strong> (click)="addQuestion()">+增加题目</button>
<input
type="text"
nz-input
[(ngModel)]="dataType.single.words"
(blur)="onSaveWord('single')"
style="width: 20%"
maxlength="2"
/>
<div
*ngFor="let word of dataType['single'].wordArr; let j = index"
>
<div *ngIf="word.type == 'normal'" style="float: left">
<a
style="
float: left;
font-size: 42px;
font-family: FuturaBT-Bold;
color: #000000;
margin-right: 2px;
"
(click)="onUpWordClicked('single', j)"
>{{ word.word }}</a
>
</div>
<div *ngIf="word.type != 'normal'" style="float: left">
<a
style="
float: left;
font-size: 42px;
font-family: FuturaBT-Bold;
border-bottom-width: 3px;
border-bottom-color: #000000;
border-bottom-style: solid;
color: #c8161e;
margin-right: 2px;
"
(click)="onUpWordClicked('single', j)"
>{{ word.word }}</a
>
</div>
</div>
<br />
<br />
<br />
<br />
<span>(点击字母设置为高亮显示)</span>
<br />
<br />
<span>音频: </span>
<app-audio-recorder
[audioUrl]="dataType.single_audio"
(audioUploaded)="
onAudioUploadSuccessByItem($event, dataType, 'single_audio')
"
></app-audio-recorder>
<br />
<span>默认显示: </span>
<label nz-checkbox [(ngModel)]="dataType.single_show" (ngModelChange)="save()"></label>
</div>
</div> </div>
</div>
<div style="float: left; width: 30%"> <nz-modal [(nzVisible)]="isVisible" [nzTitle]="null" [nzContent]="modalContent" [nzFooter]="modalFooter"
<div *ngFor="let index of singleLetterIndexes" style="margin-top: 30px"> (nzOnCancel)="handleCancel()">
<strong>左侧字母-{{index+1}}:</strong>
<input
type="text"
nz-input
[(ngModel)]="dataType['character_'+index].words"
(blur)="onSaveWord('character_'+index)"
style="width: 20%"
maxlength="2"
/>
<div <ng-template #modalContent>
*ngFor="let word of dataType['character_'+index].wordArr; let j = index" <p>{{deleteTitle}}</p>
> </ng-template>
<div *ngIf="word.type == 'normal'" style="float: left">
<a
style="
float: left;
font-size: 42px;
font-family: FuturaBT-Bold;
color: #000000;
margin-right: 2px;
"
(click)="onUpWordClicked('character_'+index, j)"
>{{ word.word }}</a
>
</div>
<div *ngIf="word.type != 'normal'" style="float: left">
<a
style="
float: left;
font-size: 42px;
font-family: FuturaBT-Bold;
border-bottom-width: 3px;
border-bottom-color: #000000;
border-bottom-style: solid;
color: #c8161e;
margin-right: 2px;
"
(click)="onUpWordClicked('character_'+index, j)"
>{{ word.word }}</a
>
</div>
</div>
<br /> <ng-template #modalFooter>
<br /> <button nz-button nzType="default" (click)="handleCancel()">取消</button>
<br /> <button nz-button nzType="primary" (click)="handleOk()">确定</button>
<br /> </ng-template>
<span>(点击字母设置为高亮显示)</span> </nz-modal>
<br />
<br />
<span>音频: </span>
<app-audio-recorder
[audioUrl]="dataType['character_'+index+'_audio']"
(audioUploaded)="
onAudioUploadSuccessByItem($event, dataType, 'character_'+index+'_audio')
"
></app-audio-recorder>
<br />
<span>默认显示: </span>
<label nz-checkbox [(ngModel)]="dataType['character_'+index+'_show']" (ngModelChange)="save()"></label>
</div>
</div>
</div>
</div> </div>
import { import { Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef, ChangeDetectorRef } from '@angular/core';
Component, import { JsonPipe } from '@angular/common';
EventEmitter, import { ComponentBase } from './ComponentBase';
Input,
OnDestroy,
OnChanges,
OnInit,
Output,
ApplicationRef,
ChangeDetectorRef,
} from "@angular/core";
import { JsonPipe } from "@angular/common";
import { log } from "ng-zorro-antd";
@Component({ @Component({
selector: "app-form", selector: 'app-form',
templateUrl: "./form.component.html", templateUrl: './form.component.html',
styleUrls: ["./form.component.css"], styleUrls: ['./form.component.css']
}) })
export class FormComponent implements OnInit, OnChanges, OnDestroy { export class FormComponent extends ComponentBase implements OnInit, OnChanges, OnDestroy {
// 储存数据用 // 储存数据用
saveKey = "ssiwb2501"; saveKey = "ssapp2501";
// 储存对象 // 储存对象
item; item: any = {
type = 0; score: 0,
dataType; title: '',
questionText: "",
// 样式选项 questionType: "read",
styles = [ questionTextAudio: "",
{ id: 0, name: '样式1', image: 'http://staging-teach.cdn.ireadabc.com/b41bf63c28c65bc46c3a1ae77e70cb75.png' }, bgAudio: "",
{ id: 1, name: '样式2', image: 'http://staging-teach.cdn.ireadabc.com/49f2cb0d2b76bf866788a2c0244af69e.png' } questions: [],
]; };
// 字母索引数组 // item: any = {
singleLetterIndexes = [0, 1, 2, 3, 4]; // 对应character_0到character_4 // title: '幸运大转盘',
doubleLetterIndexes = [0, 1, 2, 3, 4]; // 对应character_00到character_44 // questionText: "亲爱的小玩家,游戏马上就要开始啦!请动动手指转动转盘,当转盘停止,注意观察指针指向的魔法图片,并大声说出魔法咒语,魔法咒语正确,你就可以获得一张魔法卡牌。 游戏结束后,根据获得的魔法卡牌数量,你将获得相应的能量石奖励!开始挑战吧!",
// questionTextAudio: "http://staging-teach.cdn.ireadabc.com/18ebee93b3eabcd55649a01366431af7.mp3",
constructor( // questions: [],
private appRef: ApplicationRef, // };
private changeDetectorRef: ChangeDetectorRef
) {} isVisible = false;
deleteTitle = "是否删除题目";
createShell() { deleteCallback = function () { };
this.item.wordList.push({ openDelete(title, callback) {
word: "", this.deleteCallback = callback;
audio: "", this.deleteTitle = title;
backWord: "", this.isVisible = true;
backWordAudio: "",
});
this.save();
}
removeShell(idx) {
this.item.wordList.splice(idx, 1);
this.save();
}
ngOnInit() {
this.item = { title: "", audio_title: "" };
this.dataType = {
single: { words: "", wordArr: [] },
single_audio: "",
single_show: true,
character_00: { words: "", wordArr: [] },
character_11: { words: "", wordArr: [] },
character_22: { words: "", wordArr: [] },
character_33: { words: "", wordArr: [] },
character_44: { words: "", wordArr: [] },
character_0: { words: "", wordArr: [] },
character_1: { words: "", wordArr: [] },
character_2: { words: "", wordArr: [] },
character_3: { words: "", wordArr: [] },
character_4: { words: "", wordArr: [] },
character_0_show: true,
character_1_show: true,
character_2_show: true,
character_3_show: true,
character_4_show: true,
character_00_show: true,
character_11_show: true,
character_22_show: true,
character_33_show: true,
character_44_show: true,
};
this.type = 0;
// 获取存储的数据
(<any>window).courseware.getData((data) => {
if (data) {
this.item = data;
}
this.init();
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
}, this.saveKey);
}
ngOnChanges() {}
ngOnDestroy() {}
init() {
if (this.item.type) {
this.type = this.item.type;
}
// 加载数据
if (this.item.dataType) {
this.dataType = this.item.dataType;
}
}
/**
* 储存图片数据
* @param e
*/
onImageUploadSuccess(e, key) {
this.item[key] = e.url;
this.save();
} }
handleCancel() {
/** this.isVisible = false;
* 储存音频数据
* @param e
*/
onAudioUploadSuccess(e, key) {
this.item[key] = e.url;
this.save();
} }
handleOk() {
onAudioUploadSuccessByItem(e, it, key) { this.deleteCallback && this.deleteCallback();
it[key] = e.url; this.handleCancel();
this.save();
} }
onWordAudioUploadSuccess(e, idx) { addQuestion() {
this.item.wordList[idx].audio = e.url; this.item.questions.push({
type: 'img',
imgSize: 'big', // 默认大图片
audio: '',
image: '',
time: null,
// word: '',
audioName: "",
});
this.save(); this.save();
} }
onBackWordAudioUploadSuccess(e, idx) { removeQuestion(idx) {
this.item.wordList[idx].backWordAudio = e.url; this.openDelete("确定删除题目?", () => {
this.save(); this.item.questions.splice(idx, 1);
this.save();
})
} }
copyQuestion(idx) {
onUpWordClicked(key, index) { let data = this.item.questions[idx]
if (this.dataType[key].wordArr[index].type == "normal") { this.item.questions.push(JSON.parse(JSON.stringify(data)));
this.dataType[key].wordArr[index].type = "red";
} else {
this.dataType[key].wordArr[index].type = "normal";
}
this.save(); this.save();
} }
deleteBgAudio() {
onSaveWord(key) { this.item.bgAudio = "";
// console.log(this.dataType); this.item.audioBgName = "";
let res = [];
let words = this.dataType[key].words.split("");
for (let w of words) {
res.push({ word: w, type: "normal" });
}
this.dataType[key].wordArr = res;
this.save(); this.save();
} }
// addOption(idx) {
/** // if (this.item.questions[idx].options.length == 4) return;
* 储存数据 // this.item.questions[idx].options.push({
*/ // text: '',
save() { // audio: '',
this.item.type = this.type; // image: '',
this.item.dataType = this.dataType; // word: '',
// });
(<any>window).courseware.setData(this.item, null, this.saveKey); // this.save();
// }
this.refresh();
console.log("this.item = " + JSON.stringify(this.item)); // removeOption(idx, n) {
} // this.openDelete("确定删除选项?", () => {
// this.item.questions[idx].options.splice(n, 1);
/** // this.save();
* 刷新 渲染页面 // })
*/ // }
refresh() { ngChange() {
setTimeout(() => {
this.appRef.tick();
}, 1);
}
onSetType() {
this.save(); this.save();
} }
} }
...@@ -342,8 +342,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -342,8 +342,8 @@ export class PlayComponent implements OnInit, OnDestroy {
initBackground() { initBackground() {
// 创建背景元素 // 创建背景元素
var element = this.g_cartoon.createCartoonElement(`background`, "MySprite") var element = this.g_cartoon.createCartoonElement(`background`, "MySprite")
// 初始化背景图像,使用resources.js中的bg资源 // 初始化背景图像,使用resources.js中的bei_jing资源
element.ref.init(this.g_cartoon.images.get("bg")); element.ref.init(this.g_cartoon.images.get("bei_jing"));
// 计算背景缩放比例,确保背景能够覆盖整个画布 // 计算背景缩放比例,确保背景能够覆盖整个画布
// 使用g_mapScale作为基础缩放比例,确保与其他元素保持一致的缩放 // 使用g_mapScale作为基础缩放比例,确保与其他元素保持一致的缩放
......
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