Commit 6231e9ec authored by 李维's avatar 李维

dev commit

parent fd8e983a
......@@ -186,7 +186,6 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
return true;
}
beforeUpload = (file: File) => {
this.audioUrl = null;
if (!this.checkSelectFile(file)) {
return false;
......@@ -197,7 +196,11 @@ export class AudioRecorderComponent implements OnInit, OnChanges, OnDestroy {
uploadSuccess = (url) => {
this.nzMessageService.info('Upload Success');
this.isUploading = false;
this.audioUrl = url;
if(typeof url == "string"){
this.audioUrl = url
}else{
this.audioUrl = url.url
}
}
uploadFailure = (err, file) => {
this.isUploading = false;
......
......@@ -498,17 +498,17 @@ export class HotZoneImageItem extends MySprite {
arrow: MySprite;
label: Label;
image: MySprite;
imageSrc: String;
image_url: String;
labelBox: MySprite;
audio_url: String;
scale
text;
arrowTop;
arrowRight;
init(imageSrc = null, initWidth, initHeight, callback?){
this.showImage(imageSrc, initWidth, initHeight, (img)=>{
init(image_url = null, initWidth, initHeight, callback?){
this.showImage(image_url, initWidth, initHeight, (img)=>{
callback && callback(img.width, img.height)
this.setSize(img.width*this.image.scaleX, img.height*this.image.scaleY)
this.lineDashFlag = true;
......@@ -553,8 +553,8 @@ export class HotZoneImageItem extends MySprite {
this.label.visible = false;
}
showImage(imageSrc = null, initWidth, initHeight, callback) {
this.loadImage(imageSrc).then((img)=>{
showImage(image_url = null, initWidth, initHeight, callback) {
this.loadImage(image_url).then((img)=>{
if(this.image){
this.removeChild(this.image)
}
......@@ -563,18 +563,18 @@ export class HotZoneImageItem extends MySprite {
this.image.x = this.image.width/2
this.image.y = this.image.height/2
this.image.alpha = 0.7;
this.imageSrc = imageSrc;
this.image_url = image_url;
this.addChild(this.image,-1);
callback && callback(this.image)
})
}
loadImage(imageSrc = null){
loadImage(image_url = null){
return new Promise((resolve, reject) => {
const img = new Image();
img.onload = () => resolve(img);
img.onerror = reject;
img.src = imageSrc;
img.src = image_url;
})
}
......
......@@ -39,15 +39,15 @@
<div class="img-box-upload">
<app-upload-image-with-preview
[picUrl]="it.imageSrc"
(imageUploaded)="onImgUploadSuccessByImg($event, it, i)">
[picUrl]="it.image_url"
(imageUploaded)="onImgUploadSuccessByImg($event, it)">
</app-upload-image-with-preview>
</div>
<app-audio-recorder>
<!-- [audioUrl]="it.audio_url ? it.audio_url : null "
(audioUploaded)="onAudioUploadSuccessByImg($event, it)" -->
<app-audio-recorder
[audioUrl]="it.audio_url? it.audio_url : null "
(audioUploaded)="onAudioUploadSuccess($event, it)">
</app-audio-recorder>
......
......@@ -150,11 +150,15 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
console.log('hotZoneArr:', this.hotZoneArr);
}
onImgUploadSuccessByImg(e, img, index) {
console.log(img)
img.init(e.url)
img.pic_url = e.url;
this.refreshImage (img);
onImgUploadSuccessByImg(e, item) {
item.init(e.url)
item.pic_url = e.url;
this.refreshImage (item);
}
onAudioUploadSuccess(e, item) {
console.log(e)
item.audio_url = e.url;
}
refreshImage(img) {
......@@ -188,19 +192,21 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
const itemH = 200;
const item = new HotZoneImageItem(this.ctx);
if(saveData){
item.init(saveData.rect.src, saveData.rect.width , saveData.rect.height, (w, h)=>{
item.init(saveData.media.image_url, saveData.rect.width , saveData.rect.height, (w, h)=>{
const saveRect = saveData.rect;
item.scaleX = saveData.rect.width / w;
item.scaleY = saveData.rect.height / h;
item.x = saveRect.x // + saveRect.width / 2 ;
item.y = saveRect.y // + saveRect.height / 2;
if(saveData.rect.src.indexOf("bg_200_200") == -1){
item.imageSrc = saveData.rect.src
if(saveData.media.image_url.indexOf("bg_200_200") == -1){
item.image_url = saveData.media.image_url
}
});
item.audio_url = saveData.media.audio_url
console.log(item)
}else{
item.init("assets/default/bg_200_200.png" , 200 , 200, ()=>{
item.imageSrc = "assets/default/bg_200_200.png"
item.image_url = "assets/default/bg_200_200.png"
});
}
item.anchorX = 0.5;
......@@ -660,11 +666,13 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
index: hotZoneArr[i].index,
};
hotZoneItem['rect'] = hotZoneArr[i].getBoundingBox();
hotZoneItem['media'] = {}
hotZoneItem['rect'].x = Math.round( (hotZoneItem['rect'].x - bgItem['rect'].x) * 100) / 100;
hotZoneItem['rect'].y = Math.round( (hotZoneItem['rect'].y - bgItem['rect'].y) * 100) / 100;
hotZoneItem['rect'].width = Math.round( (hotZoneItem['rect'].width) * 100) / 100;
hotZoneItem['rect'].height = Math.round( (hotZoneItem['rect'].height) * 100) / 100;
hotZoneItem['rect'].src = hotZoneArr[i].imageSrc
hotZoneItem['media'].image_url = hotZoneArr[i].image_url
hotZoneItem['media'].audio_url = hotZoneArr[i].audio_url?hotZoneArr[i].audio_url:""
hotZoneItemArr.push(hotZoneItem);
}
this.save.emit({bgItem, hotZoneItemArr});
......
......@@ -110,9 +110,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
addChoice(questionIndex) {
let item = this.cardChoiceData();
this.dataArray[questionIndex].choice.incorrect.push(item);
this.saveItem();
// let item = this.cardChoiceData();
// this.dataArray[questionIndex].choice.incorrect.push(item);
// this.saveItem();
}
onImageUploadSuccessByItem(e, item) {
......
......@@ -13,6 +13,7 @@ import {
} from "./Unit";
import { CartoonAnimation } from './CartoonAnimation'
import { ConsoleReporter } from 'jasmine';
export class Cartoon {
......
This diff is collapsed.
......@@ -5,7 +5,8 @@ const localImages = {
'bg_500_600': "assets/play/bg_500_600.png",
'bg_1280_222': "assets/play/bg_1280_222.png",
'answer-sheet': "assets/play/AnswerSheet.png"
'answer-sheet': "assets/play/AnswerSheet.png",
'baiquan': "assets/play/baiquan.png"
};
......
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