Commit de91749f authored by huoshizhe's avatar huoshizhe

2020-3-26 09:31:13

parent 4b326c83
This diff is collapsed.
This diff is collapsed.
@import '../style/common_mixin';
.model-content {
width: 100%;
height: 100%;
.item-box{
//margin: auto;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
padding: 10px;
padding-bottom: 2vw;
padding-top: 3vw;
}
.pic-sound-box {
width: 50%;
display: flex;
//align-items: center;
flex-direction: column
}
.add-btn-box {
display: flex;
align-items: center;
justify-content: center;
//width: 180px;
height: 20vw;
//background: #FFDC00;
padding: 10px;
padding-top: 5vw;
}
}
.border {
border-radius: 20px;
border-style: dashed;
//border-radius: 20px;
//border-width: 2px;
//border-color: #000000;
}
import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef} from '@angular/core';
import {
Component,
EventEmitter,
Input,
OnDestroy,
OnChanges,
OnInit,
Output,
ApplicationRef,
ChangeDetectorRef
} from '@angular/core';
@Component({
selector: 'app-form',
templateUrl: './form.component.html',
styleUrls: ['./form.component.css']
styleUrls: ['./form.component.scss']
})
export class FormComponent implements OnInit, OnChanges, OnDestroy {
// 储存数据用
saveKey = "test_0011";
// 储存对象
item;
picArr = [];
_item: any;
constructor(private appRef: ApplicationRef) {
KEY = 'hw_004';
answerType = 'A';
showGuideAudio;
// @Input()
set item(item) {
this._item = item;
// this.init();
}
get item() {
return this._item;
}
@Output()
update = new EventEmitter();
constructor(private appRef: ApplicationRef,
public changeDetectorRef: ChangeDetectorRef) {
}
......@@ -23,73 +56,219 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
ngOnInit() {
this.item = {};
this.item.contentObj = {};
// 获取存储的数据
(<any> window).courseware.getData((data) => {
const getData = (<any> window).courseware.getData;
getData((data) => {
if (data) {
this.item = data;
} else {
this.item = {};
}
if ( !this.item.contentObj ) {
this.item.contentObj = {};
}
console.log('~data:', data);
this.init();
this.refresh();
}, this.saveKey);
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
}
this.refresh();
}, this.KEY);
// this.initData();
}
ngOnChanges() {
}
ngOnDestroy() {
}
init() {
}
if (this.item.contentObj.picArr) {
this.picArr = this.item.contentObj.picArr;
} else {
this.picArr = this.getDefaultPicArr();
this.item.contentObj.picArr = this.picArr;
}
let tmpFlag = false;
for (let i = 0; i < this.picArr.length; i++) {
const data = this.picArr[i];
if (!data.optionTypeA || !data.optionTypeB) {
tmpFlag = true;
}
if (!data.optionTypeA) {
if (data.a_pic_url) {
data.optionTypeA = 'B';
} else {
data.optionTypeA = 'A';
}
}
/**
* 储存图片数据
* @param e
*/
onImageUploadSuccess(e, key) {
if (!data.optionTypeB) {
if (data.b_pic_url) {
data.optionTypeB = 'B';
} else {
data.optionTypeB = 'A';
}
}
}
this.item[key] = e.url;
if (tmpFlag) {
this.save();
}
console.log('item:' , this.item);
// this.picArr = this.getDefaultPicArr();
// this.item.contentObj.picArr = this.picArr;
// console.log('this.item:;', this.picArr);
}
getDefaultPicArr() {
const arr = [];
// for (let i = 0; i < 4; i ++) {
// const data = {};
// data['pic_url'] = '';
//
// const soundArr = [];
// for (let i = 0; i < 3; i++) {
// const tmpData = {};
// tmpData['answer'] = false;
// tmpData['audio_url'] = '';
// soundArr.push(tmpData);
// }
// data['soundArr'] = soundArr;
//
// arr.push(data);
// }
return arr;
}
initData() {
}
/**
* 储存音频数据
* @param e
*/
onAudioUploadSuccess(e, key) {
this.item[key] = e.url;
deleteItem(data) {
const index = this.picArr.indexOf(data);
if (index !== -1) {
this.picArr.splice(index, 1);
}
// this.update.emit(this.item);
this.save();
}
/**
* 储存数据
*/
onImageUploadSuccessByItem(e, item, id = null) {
if (id != null) {
item[id + '_pic_url'] = e.url;
} else {
item.pic_url = e.url;
}
this.save();
// this.update.emit(this.item);
// console.log('this.item: ', this.item);
}
onAudioUploadSuccessByItem(e, item, id = null) {
if (id != null) {
item[id + '_audio_url'] = e.url;
} else {
item.audio_url = e.url;
}
// this.update.emit(this.item);
this.save();
}
addPic() {
const data = {
a_text: '',
b_text: '',
a_pic_url: '',
b_pic_url: '',
a_audio_url: '',
b_audio_url: '',
optionTypeA: 'A',
optionTypeB: 'A',
// text: '',
// radioValue: 'A'
};
this.picArr.push(data);
this.saveItem();
}
radioClick(it, radioValue) {
it.radioValue = radioValue;
this.saveItem();
}
clickCheckBox() {
console.log(' in clickCheckBox');
this.saveItem();
}
saveItem() {
console.log(' in saveItem');
// this.update.emit(this.item);
this.save();
}
save() {
(<any> window).courseware.setData(this.item, null, this.saveKey);
(<any> window).courseware.setData(this.item, null, this.KEY);
this.refresh();
}
/**
* 刷新 渲染页面
*/
refresh() {
setTimeout(() => {
this.appRef.tick();
}, 1);
}
guideBtnClick(value) {
this.showGuideAudio = value;
}
}
This diff is collapsed.
.game-container {
width: 100%;
height: 100%;
//background-image: url("/assets/listen-read-circle/bg.jpg");
background: #ffffff;
background-repeat: no-repeat;
background-size: cover;
}
#canvas {
}
@font-face
{
font-family: 'BRLNSDB';
src: url("../../assets/font/BRLNSDB.TTF") ;
}
//
//
//@font-face
//{
// font-family: 'RoundedBold';
// src: url("../../assets/font/ArialRoundedBold.otf") ;
//}
This diff is collapsed.
const res = [
// ['bg', "assets/play/bg.jpg"],
['btn_left', "assets/play/btn_left.png"],
['btn_right', "assets/play/btn_right.png"],
// ['text_bg', "assets/play/text_bg.png"],
['bg', "assets/play/bg.png"],
['dot', "assets/play/dot.png"],
['title', "assets/play/title.png"],
['star', "assets/play/star.png"],
['item_bg', "assets/play/item_bg.png"],
['line_0', "assets/play/line/0.png"],
['line_1', "assets/play/line/1.png"],
['line_2', "assets/play/line/2.png"],
['line_3', "assets/play/line/3.png"],
['line_4', "assets/play/line/4.png"],
['line_5', "assets/play/line/5.png"],
['line_6', "assets/play/line/6.png"],
['line_7', "assets/play/line/7.png"],
['line_8', "assets/play/line/8.png"],
['line_9', "assets/play/line/9.png"],
['petal_1', "assets/play/petal_1.png"],
['petal_2', "assets/play/petal_2.png"],
['petal_3', "assets/play/petal_3.png"],
];
......@@ -11,7 +29,13 @@ const res = [
const resAudio = [
['click', "assets/play/music/click.mp3"],
['line', "assets/play/music/line.mp3"],
['star', "assets/play/music/star.mp3"],
['wrong', "assets/play/music/wrong.mp3"],
['finish', "assets/play/music/finish.mp3"],
];
......
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