Commit da89e336 authored by 李维's avatar 李维

Bug fix

parent 8eb9b89a
......@@ -77,6 +77,13 @@
(imageUploaded)="onImageUploadSuccess($event, 'pic_url', it)"
></app-upload-image-with-preview>
<div>
<span>选项音频</span>
<app-audio-recorder
[audioUrl]="it.audio_url"
(audioUploaded)="onAudioUploadSuccess($event, 'audio_url', it)"
></app-audio-recorder>
</div>
</div>
</div>
</div>
......
......@@ -97,9 +97,12 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
* 储存音频数据
* @param e
*/
onAudioUploadSuccess(e, key) {
this.item[key] = e.url;
onAudioUploadSuccess(e, key, item?) {
if(item) {
item[key] = e.url;
} else {
this.item[key] = e.url;
}
this.save();
}
......
......@@ -399,7 +399,6 @@ export class PlayComponent implements OnInit, OnDestroy {
checkClickTarget(target) {
const rect = target.getBoundingBox();
if (this.checkPointInRect(this.mx, this.my, rect)) {
......@@ -451,7 +450,7 @@ export class PlayComponent implements OnInit, OnDestroy {
audio.volume = vlomue;
audioObj[key] = audio;
if (callback) {
audio.onended = () => {
callback();
......@@ -544,6 +543,13 @@ export class PlayComponent implements OnInit, OnDestroy {
this.addUrlToAudioObj('cuowu', this.rawAudios.get('cuowu'), 1);
this.addUrlToAudioObj('sahua', this.rawAudios.get('sahua'), 1);
this.addUrlToAudioObj('songshu', this.rawAudios.get('songshu'), 1);
this.data.answerArr.forEach(( item ) => {
if(item.audio_url) {
this.addUrlToAudioObj(item.audio_url, this.rawAudios.get(item.audio_url), 1);
}
});
}
......@@ -876,7 +882,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this["bg_3"] = bg_3;
questionBG.addChild(bg_3);
if(this.data.short_audio_url) {
if(this.data.short_audio_url && (this.data.questionType=='text' || this.data.questionType =='pic')) {
const shortAudio = createSprite('btn_laba (1)');
shortAudio.setScaleXY(getMaxScale(shortAudio, 100, 82));
shortAudio.x = 470;
......@@ -928,7 +934,6 @@ export class PlayComponent implements OnInit, OnDestroy {
private initQuestionPic() {
const questionPic = createSprite(this.data.pic_url);
console.log(questionPic)
questionPic.setScaleXY(getMinScale(questionPic, this.questionBG.width * 0.95, this.questionBG.height * 0.95));
this.questionBG.addChild(questionPic);
}
......@@ -942,7 +947,9 @@ export class PlayComponent implements OnInit, OnDestroy {
barBtn: 'bar_btn',
};
this["bg_3"].visible = true;
this.initAudioPlayer(res);
if(this.data.audio_url) {
this.initAudioPlayer(res);
}
}
private initQuestionVideo() {
......@@ -1091,6 +1098,7 @@ export class PlayComponent implements OnInit, OnDestroy {
for (let i = 0; i < this.data.answerArr.length; i++) {
const textAnswer = this.createAnswerText(this.data.answerArr[i], i + 1);
textAnswer["audio_url"] = this.data.answerArr[i].audio_url
this.answerArr.push(textAnswer);
textAnswer.x = baseX + (i % 2) * offX;
textAnswer.y = baseY;
......@@ -1111,6 +1119,7 @@ export class PlayComponent implements OnInit, OnDestroy {
for (let i = 0; i < this.data.answerArr.length; i++) {
const textAnswer = this.createAnswerPicText(this.data.answerArr[i], i + 1);
textAnswer["audio_url"] = this.data.answerArr[i].audio_url
this.answerArr.push(textAnswer);
textAnswer.x = baseX + i * (picW + disW);
textAnswer.y = baseY;
......@@ -1128,6 +1137,7 @@ export class PlayComponent implements OnInit, OnDestroy {
for (let i = 0; i < this.data.answerArr.length; i++) {
const textAnswer = this.createAnswerPic(this.data.answerArr[i], i + 1);
textAnswer["audio_url"] = this.data.answerArr[i].audio_url
this.answerArr.push(textAnswer);
textAnswer.x = baseX + i * (picW + disW);
textAnswer.y = baseY;
......@@ -1218,14 +1228,28 @@ export class PlayComponent implements OnInit, OnDestroy {
tweenChange(answerArrElement['rightIcon'], {alpha: 1}, 0.5, () => {
this.playAudio("songshu")
tweenChange(this["songShu"], {x: targetX, y: targetY}, 1, () => {
tweenChange(this["songShu"], {x: targetX, y: targetY}, 0.5, () => {
setTimeout(() => {
this["songShu"].songShu_1.visible = true;
if(answerArrElement['jianguo']) {
answerArrElement['jianguo'].visible = false
}
answerArrElement.alpha = 0
tweenChange(this["songShu"], {x: targetX, y: -1 * this["songShu"].height}, 1, () => {
tweenChange(this["songShu"], {x: targetX, y: -1 * this["songShu"].height}, 0.5, () => {
this["songShu"].songShu_1.visible = false;
this.canTouch = true;
this.checkGameEnd();
if(answerArrElement.audio_url) {
let audio = this.audioObj[answerArrElement.audio_url]
// audio.pause();
// audio.currentTime = 0;
audio.play();
audio.onended = () =>{
this.canTouch = true;
this.checkGameEnd();
}
} else {
this.canTouch = true;
this.checkGameEnd();
}
});
}, 500);
});
......@@ -1263,20 +1287,10 @@ export class PlayComponent implements OnInit, OnDestroy {
}
private createAnswerPic(data: any, id: number) {
const picBg = createSprite('bg_xuan3pic');
const picBg = createSprite('bg_xuan3');
picBg.setScaleXY(this.mapScale);
this.renderArr.push(picBg);
// const picIcon = createSprite('pic_icon');
// picBg.addChild(picIcon);
// picIcon.x = -picBg.width / 2 + 30;
// picIcon.y = -picBg.height / 2 + 20;
// const textId = createSprite('text_' + id);
// picIcon.addChild(textId);
// textId.x = -picBg.width / 2 + 27;
// textId.y = -12;
const maxW = 245;
const maxH = 160;
const pic = createSprite(data.pic_url);
......@@ -1285,25 +1299,31 @@ export class PlayComponent implements OnInit, OnDestroy {
picBg['answerRight'] = data.answerRight === '1' ? true : false;
const jianguo = createSprite('bg_xuan3pic');
picBg.addChild(jianguo);
if (picBg['answerRight']) {
const rightIcon = createSprite('bg_xuan4');
picBg.addChild(rightIcon, -1);
rightIcon.x = -11;
rightIcon.y = -4.5;
rightIcon.x = -2;
rightIcon.y = 0;
rightIcon.alpha = 0;
picBg['rightIcon'] = rightIcon;
picBg['jianguo'] = jianguo;
}
return picBg;
}
private createAnswerPicText(data: any, id: number) {
const picBg = createSprite('bg_xuan3pic');
const picBg = createSprite('bg_xuan3');
picBg.setScaleXY(this.mapScale);
this.renderArr.push(picBg);
const textBg = createSprite('bg_worddi');
textBg.y = 120;
textBg.x = 10;
picBg.addChild(textBg, -1)
const label = new Label();
......@@ -1318,21 +1338,27 @@ export class PlayComponent implements OnInit, OnDestroy {
label.x = 12;
textBg.addChild(label);
const maxW = 245;
const maxH = 160;
const maxW = 250;
const maxH = 160 * 1.1;
const pic = createSprite(data.pic_url);
pic.x = 10;
pic.y = 2;
pic.setScaleXY(getMinScale(pic, maxW, maxH));
picBg.addChild(pic);
picBg['answerRight'] = data.answerRight === '1' ? true : false;
const jianguo = createSprite('bg_xuan3pic');
picBg.addChild(jianguo);
if (picBg['answerRight']) {
const rightIcon = createSprite('bg_xuan4');
picBg.addChild(rightIcon, -1);
rightIcon.x = -11;
rightIcon.y = -4.5;
rightIcon.x = -2;
rightIcon.y = 0;
rightIcon.alpha = 0;
picBg['rightIcon'] = rightIcon;
picBg['jianguo'] = jianguo;
}
return picBg;
......
......@@ -23,9 +23,13 @@ const res = [
['bg_xuan1', "assets/play/bg_xuan1.png"],
['bg_xuan2', "assets/play/bg_xuan2.png"],
['video_play', "assets/play/video_play.png"],
['video_pause', "assets/play/video_pause.png"],
['bg_songshu1', "assets/play/bg_songshu1.png"],
['bg_songshu2', "assets/play/bg_songshu2.png"],
['bg_xuan3', "assets/play/bg_xuan3.png"],
['bg_xuan3pic', "assets/play/bg_xuan3pic.png"],
['bg_xuan4', "assets/play/bg_xuan4.png"],
['bg_worddi', "assets/play/bg_worddi.png"],
......
src/assets/play/bg_xuan3pic.png

24.5 KB | W: | H:

src/assets/play/bg_xuan3pic.png

13.5 KB | W: | H:

src/assets/play/bg_xuan3pic.png
src/assets/play/bg_xuan3pic.png
src/assets/play/bg_xuan3pic.png
src/assets/play/bg_xuan3pic.png
  • 2-up
  • Swipe
  • Onion skin
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