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

dev commit

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