Commit d73963a7 authored by 李维's avatar 李维

dev commit

parent 0b6b99d2
<div class="model-content">
<div class="card-config">
<div *ngFor="let item of contentObj.dataArray; let i = index" class="card-item" style="padding: 0.5vw;" >
<div *ngFor="let item of contentObj.dataArray; let i = index" class="card-item" style="padding: 0.5vw; min-width: 900px;" >
<div class="card-item-content border">
<div class="card-item-content">
<div class="title" >
......@@ -74,9 +74,15 @@
<div class="section" >
<div class="section-title" >
错误选项
<div *ngIf="item.options.length<4" style="text-align: center; float: right;">
<button nz-button nzType="primary" (click)="addChoice(i)" >
<i nz-icon nzType="plus-circle" nzTheme="outline"></i>
添加
</button>
</div>
</div>
<div class="section-content" >
<div *ngFor="let choiceItem of item.options; let choiceIndex = index" [ngClass]="{'hidden': choiceItem.isCorrect}" style="flex:1;border:1px solid #CCC; padding:5px; border-radius: 5px; margin: 0 10px;">
<div *ngFor="let choiceItem of item.options; let choiceIndex = index" [ngClass]="{'hidden': choiceItem.isCorrect}" style="float: left;border:1px solid #CCC; padding:5px; border-radius: 5px; margin: 0 10px; width: 300px;">
<div *ngIf="!choiceItem.isCorrect">
<div style="display: flex; margin-bottom: 10px;">
<div style="flex:1">
......@@ -86,18 +92,16 @@
<input type="text" nz-input placeholder="" [(ngModel)]="choiceItem.text" (blur)="saveItem()" />
</div>
</div>
<div style="display: flex; margin-bottom: 10px;">
<div style="flex:1">
图片
</div>
<div style="flex:5">
<div style="width: 400px;">
<div style="width: 200px;">
<app-upload-image-with-preview style="width: 100%;" [picUrl]="choiceItem.image_url" (imageUploaded)="onImageUploadSuccessByItem($event, choiceItem)"></app-upload-image-with-preview>
</div>
</div>
</div>
<div style="display: flex; ">
<div style="flex:2">
显示选项
......@@ -109,11 +113,17 @@
</nz-radio-group>
</div>
</div>
<div *ngIf="choiceIndex>1" style="text-align: center;">
<button style="margin-top: 10px;" nz-button nzType="danger" (click)="deleteChoice(i, choiceIndex)" >
<span>删除此选项</span>
</button>
</div>
</div>
</div>
</div>
</div>
<div class="section" >
<div style="float:right; text-align: left; padding-left: 20px;">
<button style="flex:1;" nz-button nzType="default" (click)="handleMoveItemUp(i)" [disabled]="i==0">
......
......@@ -87,7 +87,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}
cardChoiceData(){
return { isText: true, text: "", image_url: "" }
return {type:"Text", image_url:"", text:"", audio_url:"", isCorrect:false}
}
getDefaultPicArr() {
......@@ -123,9 +123,16 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.save()
}
addChoice(questionIndex) {
// let item = this.cardChoiceData();
// this.dataArray[questionIndex].choice.incorrect.push(item);
// this.saveItem();
let item = this.cardChoiceData();
this.item.contentObj.dataArray[questionIndex].options.push(item)
this.saveItem();
}
deleteChoice(questionIndex, choiceIndex){
if (questionIndex !== -1 && choiceIndex !== -1) {
this.item.contentObj.dataArray[questionIndex].options.splice(choiceIndex, 1);
}
this.save();
}
onImageUploadSuccessByItem(e, item) {
......
......@@ -150,6 +150,27 @@ export class PlayComponent implements OnInit, OnDestroy {
]
m_currentQuestion = 0;
m_bgMusic = null
m_questionCardPosObj = {
"2": [
{x: -300},
{x: 300},
{x: 2000},
{x: 2000}
],
"3": [
{x: -300},
{x: 0},
{x: 300},
{x: 2000}
],
"4": [
{x: -450},
{x: -150},
{x: 150},
{x: 450}
]
}
// ------------------------------------
......@@ -424,9 +445,8 @@ export class PlayComponent implements OnInit, OnDestroy {
}
initHotZooArrow(){
let element = null
for(let index=0; index<4; index++){
element = this.g_cartoon.createCartoonElementImageFunc(`hot-zoo-arrow-${index}`, "arrow", (w,h)=>{
let element = this.g_cartoon.createCartoonElementImageFunc(`hot-zoo-arrow-${index}`, "arrow", (w,h)=>{
return{
sx: 116*this.g_mapScale / w,
sy: 261*this.g_mapScale / h
......@@ -443,6 +463,17 @@ export class PlayComponent implements OnInit, OnDestroy {
y: this.getBaseLine().y+20*this.g_mapScale
}
})
element.enable = true;
element.disable = (status:boolean)=>{
element.enable = !status
if(status){
element.ref.x = 20000
}else{
element.ref.x = element.initX
}
}
element.ref.visible = false
this.render(element.ref,799)
}
......@@ -639,6 +670,10 @@ export class PlayComponent implements OnInit, OnDestroy {
element.textContent = this.g_cartoon.createLabel("DEMO", "BerlinSansFBDemi-Bold", null, 50)
element.down = (callback?)=>{
if(!element.enable){
callback && callback()
return
}
element.bg.ref.visible = false;
element.animationCard = this.g_cartoon.createAnimation("card-frame", 29, 50)
element.animationCard.setScaleXY(0.3)
......@@ -653,6 +688,10 @@ export class PlayComponent implements OnInit, OnDestroy {
}
element.shake = (callback?)=>{
if(!element.enable){
callback && callback()
return
}
tweenChange(element.ref, {rotation:3}, 0.1, ()=>{
tweenChange(element.ref, {rotation:-3}, 0.1, ()=>{
tweenChange(element.ref, {rotation:3}, 0.1, ()=>{
......@@ -667,6 +706,9 @@ export class PlayComponent implements OnInit, OnDestroy {
}
element.setContent = (data)=>{
if(!element.enable){
return
}
if(data.type == "Image"){
if(element.imageContent){
removeItemFromArr(element.ref.children, element.imageContent)
......@@ -736,14 +778,24 @@ export class PlayComponent implements OnInit, OnDestroy {
}
element.out = ()=>{
if(!element.enable){
return
}
tweenChange(element.ref, {y: -500*this.g_mapScale}, 0.2)
}
element.ready = ()=>{
if(!element.enable){
return
}
element.ref.y = -500*this.g_mapScale
}
element.adjustInitY = element.initY
element.in = ()=>{
if(!element.enable){
return
}
element.ref.visible = true;
element.bg.ref.visible = true;
removeItemFromArr(element.ref.children, element.animationSnow)
......@@ -755,6 +807,9 @@ export class PlayComponent implements OnInit, OnDestroy {
}
element.snowBoom = ()=>{
if(!element.enable){
return
}
element.animationSnow = this.g_cartoon.createAnimation("snow", 5, 50)
element.animationSnow.x = -7
element.animationSnow.y = 170
......@@ -764,6 +819,17 @@ export class PlayComponent implements OnInit, OnDestroy {
element.animationSnow.play()
}
element.enable = true;
element.disable = (status:boolean)=>{
element.ref.visible = !status
element.enable = !status
if(status){
element.ref.x = 20000
}else{
element.ref.x = element.initX
}
}
element.ref.addChild(element.imageContent)
element.ref.addChild(element.textContent)
......@@ -774,6 +840,8 @@ export class PlayComponent implements OnInit, OnDestroy {
loadQuestion(callback?){
let dataRandom = this.g_formData.dataArray[this.m_currentQuestion].options
let optionsNumber = this.g_formData.dataArray[this.m_currentQuestion].options.length
this.controlCardAndHotZoo(optionsNumber)
dataRandom = this.randomArray_shuffle(dataRandom)
for(let index=0; index<4; index++){
let element = this.g_cartoon.getCartoonElement(`question-card-${index}`)
......@@ -888,7 +956,8 @@ export class PlayComponent implements OnInit, OnDestroy {
element.go =(runWayindex, callback?)=>{
this.g_cartoon.stopAudio(this.g_formData.dataArray[this.m_currentQuestion].audio_url)
tweenChange(element.ref, {x: element.initX+this.m_questionCardPos[runWayindex].x*this.g_mapScale, y: this.getBaseLine().y - 100*this.g_mapScale, scaleX: element.initScaleX*0.8, scaleY: element.initScaleY*0.8}, 0.5, ()=>{
let targetX = this.g_cartoon.getCartoonElement(`question-card-${runWayindex}`).ref.x
tweenChange(element.ref, {x: targetX, y: this.getBaseLine().y - 100*this.g_mapScale, scaleX: element.initScaleX*0.8, scaleY: element.initScaleY*0.8}, 0.5, ()=>{
this.g_enableMapDown = false
callback && callback()
})
......@@ -1028,7 +1097,26 @@ export class PlayComponent implements OnInit, OnDestroy {
}, 1000))
}
controlCardAndHotZoo(num){
console.log(num)
let allQuestionCards = []
let hotZooArrows = []
for(let index=0; index<4; index++){
allQuestionCards.push(this.g_cartoon.getCartoonElement(`question-card-${index}`))
hotZooArrows.push(this.g_cartoon.getCartoonElement(`hot-zoo-arrow-${index}`))
}
for(let index=0; index<4; index++){
if(index<num){
allQuestionCards[index].disable(false)
hotZooArrows[index].disable(false)
allQuestionCards[index].ref.x = this.g_canvasWidth/2 + this.m_questionCardPosObj[num][index].x*this.g_mapScale
hotZooArrows[index].ref.x = this.g_canvasWidth/2 + this.m_questionCardPosObj[num][index].x*this.g_mapScale
}else{
allQuestionCards[index].disable(true)
hotZooArrows[index].disable(true)
}
}
}
......
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