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