Commit 410914b8 authored by yu's avatar yu

bug调整

parent 95406706
...@@ -34,23 +34,45 @@ export class ComponentBase { ...@@ -34,23 +34,45 @@ export class ComponentBase {
* 储存图片数据 * 储存图片数据
* @param e * @param e
*/ */
onAssetUploadSuccess(e: any, ...key: Array<string>) { // onAssetUploadSuccess(e: any, ...key: Array<string>) {
let item = this.item; // let item = this.item;
for (let i = 0; i < key.length; i++) { // for (let i = 0; i < key.length; i++) {
if (i + 1 == key.length) { // if (i + 1 == key.length) {
if (key[i] == "audio") { // if (key[i] == "audio") {
let sp = e.url.split(".mp3"); // let sp = e.url.split(".mp3");
let u = sp[0] + "_l.mp3"; // let u = sp[0] + "_l.mp3";
item[key[i]] = u; // item[key[i]] = u;
item["audioName"] = e.name || ""; // item["audioName"] = e.name || "";
} else { // } else {
item[key[i]] = e.url; // 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(); this.save();
return;
}
item = item[key[i]];
} }
/**
* 储存音频数据
* @param e
*/
onAudioUploadSuccess(e, key, it = this.item) {
let url = e.url;
let sp = url.split(".mp3");
let u = sp[0] + "_l.mp3";
it[key] = u;
it["audioName"] = e.name || "";
this.save();
} }
save() { save() {
......
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
<div style="display:flex ;"> <div style="display:flex ;">
<div> <div>
<app-audio-recorder [audioUrl]="item.questionTextAudio" <app-audio-recorder [audioUrl]="item.questionTextAudio"
(audioUploaded)="onAssetUploadSuccess($event, 'questionTextAudio')"></app-audio-recorder> (audioUploaded)="onAudioUploadSuccess($event, 'questionTextAudio')"></app-audio-recorder>
</div> </div>
<div style="margin: 5px"> <div style="margin: 5px">
<span>{{ item.audioName}}</span> <span>{{ item.audioName}}</span>
...@@ -131,7 +131,7 @@ ...@@ -131,7 +131,7 @@
</div> </div>
<div style="width: 300px;"> <div style="width: 300px;">
<app-upload-image-with-preview [picUrl]="option.image" <app-upload-image-with-preview [picUrl]="option.image"
(imageUploaded)="onAssetUploadSuccess($event, 'questions', i, 'options', j, 'image')"> (imageUploaded)="onImageUploadSuccess($event, 'image', option)">
</app-upload-image-with-preview> </app-upload-image-with-preview>
</div> </div>
</div> </div>
...@@ -144,7 +144,7 @@ ...@@ -144,7 +144,7 @@
<div style="display: flex"> <div style="display: flex">
<div> <div>
<app-audio-recorder [audioUrl]="option.audio" <app-audio-recorder [audioUrl]="option.audio"
(audioUploaded)="onAssetUploadSuccess($event, 'questions', i, 'options', j, 'audio')"> (audioUploaded)="onAudioUploadSuccess($event, 'audio', option)">
</app-audio-recorder> </app-audio-recorder>
</div> </div>
<div style="margin: 5px"> <div style="margin: 5px">
......
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