Commit 87ade0fe authored by 范雪寒's avatar 范雪寒

fix: play页面的bug

parent 3c9bbfda
...@@ -88,7 +88,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -88,7 +88,7 @@ export class PlayComponent implements OnInit, OnDestroy {
curAudio; curAudio;
mask : ShapeRect; mask: ShapeRect;
@HostListener('window:resize', ['$event']) @HostListener('window:resize', ['$event'])
onResize(event) { onResize(event) {
...@@ -106,6 +106,9 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -106,6 +106,9 @@ export class PlayComponent implements OnInit, OnDestroy {
if (data && typeof data == 'object') { if (data && typeof data == 'object') {
this.data = data; this.data = data;
if (data.contentObj && data.contentObj.data) {
this.data = data.contentObj.data;
}
} }
console.log('data:', data); console.log('data:', data);
...@@ -457,8 +460,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -457,8 +460,8 @@ export class PlayComponent implements OnInit, OnDestroy {
this.rawImages.set(url, url); this.rawImages.set(url, url);
} }
addUrlToImage(url, key){ addUrlToImage(url, key) {
if(!key){ if (!key) {
key = url; key = url;
} }
...@@ -522,45 +525,45 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -522,45 +525,45 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
const loadBg = (skin, skinType) =>{ const loadBg = (skin, skinType) => {
if (skin.lt_pic_url) { if (skin.lt_pic_url) {
this.addUrlToImage(skin.lt_pic_url, skinType + "_" + skin.lt_pic_url); this.addUrlToImage(skin.lt_pic_url, skinType + "_" + skin.lt_pic_url);
} }
if (skin.lm_pic_url) { if (skin.lm_pic_url) {
this.addUrlToImage(skin.lm_pic_url, skinType + "_" + skin.lm_pic_url); this.addUrlToImage(skin.lm_pic_url, skinType + "_" + skin.lm_pic_url);
} }
if (skin.lb_pic_url) { if (skin.lb_pic_url) {
this.addUrlToImage(skin.lb_pic_url, skinType + "_" + skin.lb_pic_url); this.addUrlToImage(skin.lb_pic_url, skinType + "_" + skin.lb_pic_url);
} }
if (skin.mt_pic_url) { if (skin.mt_pic_url) {
this.addUrlToImage(skin.mt_pic_url, skinType + "_" + skin.mt_pic_url); this.addUrlToImage(skin.mt_pic_url, skinType + "_" + skin.mt_pic_url);
} }
if (skin.mb_pic_url) { if (skin.mb_pic_url) {
this.addUrlToImage(skin.mb_pic_url, skinType + "_" + skin.mb_pic_url); this.addUrlToImage(skin.mb_pic_url, skinType + "_" + skin.mb_pic_url);
} }
if (skin.rt_pic_url) { if (skin.rt_pic_url) {
this.addUrlToImage(skin.rt_pic_url, skinType + "_" + skin.rt_pic_url); this.addUrlToImage(skin.rt_pic_url, skinType + "_" + skin.rt_pic_url);
} }
if (skin.rm_pic_url) { if (skin.rm_pic_url) {
this.addUrlToImage(skin.rm_pic_url, skinType + "_" + skin.rm_pic_url); this.addUrlToImage(skin.rm_pic_url, skinType + "_" + skin.rm_pic_url);
} }
if (skin.rb_pic_url) { if (skin.rb_pic_url) {
this.addUrlToImage(skin.rb_pic_url, skinType + "_" + skin.rb_pic_url); this.addUrlToImage(skin.rb_pic_url, skinType + "_" + skin.rb_pic_url);
} }
} }
if(this.data.skinA){ if (this.data.skinA) {
loadBg(this.data.skinA, 'A'); loadBg(this.data.skinA, 'A');
} }
if(this.data.skinB){ if (this.data.skinB) {
loadBg(this.data.skinB, 'B'); loadBg(this.data.skinB, 'B');
} }
} }
...@@ -644,7 +647,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -644,7 +647,7 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
initBg() { initBg() {
const getPic = (key, anchorX: number = 0.5, anchorY: number = 0.5) => { const getPic = (key, anchorX: number = 0.5, anchorY: number = 0.5) => {
const pic = new MySprite(); const pic = new MySprite();
pic.init(this.images.get(key), anchorX, anchorY); pic.init(this.images.get(key), anchorX, anchorY);
...@@ -654,7 +657,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -654,7 +657,7 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
const initBg = (skin, skinType) => { const initBg = (skin, skinType) => {
//左上 //左上
if (skin.lt_pic_url) { if (skin.lt_pic_url) {
const pic = getPic(skinType + '_' + skin.lt_pic_url, 0, 0); const pic = getPic(skinType + '_' + skin.lt_pic_url, 0, 0);
...@@ -713,13 +716,13 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -713,13 +716,13 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
} }
if(this.data.skin === 'A'){ if (this.data.skin === 'A') {
if(this.data.skinA){ if (this.data.skinA) {
initBg(this.data.skinA, 'A'); initBg(this.data.skinA, 'A');
} }
} }
else{ else {
if(this.data.skinB){ if (this.data.skinB) {
initBg(this.data.skinB, 'B'); initBg(this.data.skinB, 'B');
} }
} }
...@@ -755,7 +758,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -755,7 +758,7 @@ export class PlayComponent implements OnInit, OnDestroy {
let startX = 81 * this.mapScaleX; let startX = 81 * this.mapScaleX;
let startY = 157 * this.mapScaleY; let startY = 157 * this.mapScaleY;
let lBgArr = []; let lBgArr = [];
...@@ -764,7 +767,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -764,7 +767,7 @@ export class PlayComponent implements OnInit, OnDestroy {
startX = (this.canvasWidth - 1100 * this.mapScale) / 2; startX = (this.canvasWidth - 1100 * this.mapScale) / 2;
let height = 3 * 80 * this.mapScale + (3-1) * 61 * this.mapScale; let height = 3 * 80 * this.mapScale + (3 - 1) * 61 * this.mapScale;
startY = (this.canvasHeight - height) / 2; startY = (this.canvasHeight - height) / 2;
...@@ -776,14 +779,14 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -776,14 +779,14 @@ export class PlayComponent implements OnInit, OnDestroy {
this.skinRenderArr.push(lBg); this.skinRenderArr.push(lBg);
lBgArr.push(lBg); lBgArr.push(lBg);
} }
} }
else{ else {
let width = 2 * 560 * this.mapScale + 25 * this.mapScaleX; let width = 2 * 560 * this.mapScale + 25 * this.mapScaleX;
startX = (this.canvasWidth - width) / 2; startX = (this.canvasWidth - width) / 2;
let height = 3 * 96 * this.mapScale + (3-1) * 78 * this.mapScale; let height = 3 * 96 * this.mapScale + (3 - 1) * 78 * this.mapScale;
startY = (this.canvasHeight - height) / 2; startY = (this.canvasHeight - height) / 2;
} }
...@@ -828,7 +831,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -828,7 +831,7 @@ export class PlayComponent implements OnInit, OnDestroy {
//到下一行增加高度 //到下一行增加高度
startY = tempStartY; startY = tempStartY;
} }
else { else {
if (this.data.skin === 'A') { if (this.data.skin === 'A') {
...@@ -846,9 +849,9 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -846,9 +849,9 @@ export class PlayComponent implements OnInit, OnDestroy {
this.bigCardRenderArr.push(exercises.cardBg); this.bigCardRenderArr.push(exercises.cardBg);
} }
for(let i = 0; i < lBgArr.length; ++ i){ for (let i = 0; i < lBgArr.length; ++i) {
lBgArr[i].y = startYArr[i]; lBgArr[i].y = startYArr[i];
lBgArr[i].height = hight ; lBgArr[i].height = hight;
} }
let minFontSize = 100; let minFontSize = 100;
...@@ -892,7 +895,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -892,7 +895,7 @@ export class PlayComponent implements OnInit, OnDestroy {
if (this.checkClickTarget(this.listening.bg)) { if (this.checkClickTarget(this.listening.bg)) {
this.curAudio = this.listening.play(()=>{ this.curAudio = this.listening.play(() => {
this.listening.reset(); this.listening.reset();
}); });
......
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