Commit 5ea1c6ca authored by yu's avatar yu

表单

parent 40c3401d
......@@ -37,8 +37,8 @@ export default class Game {
this.score = data.score;
this.aniEnter = data.aniEnter;
let id = 0;
for (let i = 0; i < this.data.item.length; i++) {
let data = this.data.item[i];
for (let i = 0; i < this.data.questions.length; i++) {
let data = this.data.questions[i];
data.page = id++;
this.lists.push(data);
}
......
......@@ -9833,7 +9833,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 267,
"width": 344,
"height": 97
},
"_anchorPoint": {
......@@ -9981,7 +9981,7 @@
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "f4df267f-8ffc-495c-96ae-95cd01b59f92"
"__uuid__": "256aa9a1-430c-4c92-96b6-a3ce7b98034e"
},
"_type": 0,
"_sizeMode": 2,
......@@ -10026,7 +10026,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 267,
"width": 344,
"height": 97
},
"_anchorPoint": {
......@@ -10174,7 +10174,7 @@
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "fb5a080b-5e50-4a37-a2d0-a040d0870e7d"
"__uuid__": "69bd08e4-d059-4529-a0ce-ad07823abb15"
},
"_type": 0,
"_sizeMode": 1,
......
......@@ -111,7 +111,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}, 1800);
}
private showGame() {
if (this.roundIdx >= this.data.item.length) {
if (this.roundIdx >= this.data.questions.length) {
this.gameOver();
return;
}
......@@ -122,11 +122,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.showLayout();
}
private showQuestion() {
let quest = this.data.item[this.roundIdx];
let quest = this.data.questions[this.roundIdx];
let desc = cc.find("top/topTitle/title", this.node);
desc.active = true;
desc.getComponent(cc.Label).string = quest.title;
if (quest.audio_title) {
desc.getComponent(cc.Label).string = quest.text;
if (quest.questionAudio) {
this.playTopLaba()
}
}
......@@ -151,16 +151,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}, 150)
let quest = this.data.item[this.roundIdx];
quest.audio_title && pg.audio.playAudioByUrl(quest.audio_title).then(() => { stop = true; })
let quest = this.data.questions[this.roundIdx];
quest.questionAudio && pg.audio.playAudioByUrl(quest.questionAudio).then(() => { stop = true; })
}
private randomData() {
this.upArr = [];
this.downArr = [];
let dt = this.data.item[this.roundIdx];
let dt = this.data.questions[this.roundIdx];
if (!dt) return;
let data = dt.group;
let data = dt.options;
data.forEach((dt, idx) => {
if (dt.up) {
dt.up.id = idx;
......@@ -181,7 +181,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
private getItemLeftNode(type) {
let item;
// let isText = this.upArr[0].type == 1;
let isText = type == 1;
let isText = type == "txt";
if (this.upArr.length == 5) {
item = isText ? cc.instantiate(this.item5_left) : cc.instantiate(this.item5_pic);
}
......@@ -198,7 +198,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
private getItemRightNode(type) {
let item;
let isText = type == 1;
let isText = type == "txt";
// let isText = this.downArr[0].type == 1;
if (this.upArr.length == 5) {
item = isText ? cc.instantiate(this.item5_right) : cc.instantiate(this.item5_pic);
......@@ -222,7 +222,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
private showLayout() {
let data = this.data.item.group;
let data = this.data.questions.options;
this.layout_left.removeAllChildren();
this.layout_right.removeAllChildren();
let spacing = this.getlayoutSpacing();
......@@ -232,24 +232,24 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.layout_left.getComponent(cc.Layout).paddingTop = spacing.top;
this.upArr.forEach((item) => {
if (item.type == 1) {
let textItem = this.getItemLeftNode(1);
if (item.type == "txt") {
let textItem = this.getItemLeftNode("txt");
this.initTextItem(textItem, item);
textItem.parent = this.layout_left;
} else if (item.type == 0) {
let textItem = this.getItemLeftNode(0);
} else if (item.type == "img") {
let textItem = this.getItemLeftNode("img");
let size = this.getHeadSize(1);
this.initPicItem(textItem, item, size);
textItem.parent = this.layout_left;
}
});
this.downArr.forEach((item) => {
if (item.type == 1) {
let textItem = this.getItemRightNode(1);
if (item.type == "txt") {
let textItem = this.getItemRightNode("txt");
this.initTextItem(textItem, item);
textItem.parent = this.layout_right;
} else if (item.type == 0) {
let textItem = this.getItemRightNode(0);
} else if (item.type == "img") {
let textItem = this.getItemRightNode("img");
let size = this.getHeadSize(2);
this.initPicItem(textItem, item, size);
textItem.parent = this.layout_right;
......@@ -487,11 +487,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.resetLayout();
}, 0.15);
this._drawIndex++;
if (this._drawIndex >= this.data.item[this.roundIdx].group.length) {
if (this._drawIndex >= this.data.questions[this.roundIdx].options.length) {
this.scheduleOnce(() => {
this._drawIndex = 0;
this.roundIdx++;
if (this.roundIdx < this.data.item.length) graphics.clear();
if (this.roundIdx < this.data.questions.length) graphics.clear();
this.showGame();
// this.updateRound();
// pg.event.emit("mouse_add");
......
This diff is collapsed.
......@@ -80,11 +80,11 @@
<input type="text" nz-input [(ngModel)]="item.score" (blur)="save()">
<span style="font-size: 20px;">标题文字: </span>
<input type="text" nz-input [(ngModel)]="item.top.text" (blur)="save()">
<span style="font-size: 20px;">标题图片: </span>
<!-- <span style="font-size: 20px;">标题图片: </span>
<div style="width:300px">
<app-upload-image-with-preview [picUrl]="item.top.image"
(imageUploaded)="onImageUploadSuccess($event,'image', item.top)"></app-upload-image-with-preview>
</div>
</div> -->
<span style="font-size: 20px;">标题音频: </span>
<div style="display:flex ;">
<div>
......@@ -132,7 +132,7 @@
</div>
</div>
<div class="option-img">
<!-- <div class="option-img">
<div class="word-input-title">
默认线图:
</div>
......@@ -140,13 +140,13 @@
<app-upload-image-with-preview [picUrl]="question.image"
(imageUploaded)="onImageUploadSuccess($event,'image', question)"></app-upload-image-with-preview>
</div>
</div>
</div> -->
<div *ngFor="let option of question.options; let m = index">
<div *ngFor="let option of question.options; let j = index">
<div style="display: flex;margin-top: 20px;">
<div class="border-dashed" style="min-width: 700px;">
<div class="option-title">
<span>连线组-{{ i + 1 }} </span>
<span>连线组-{{ j + 1 }} </span>
</div>
<div>
......@@ -155,25 +155,88 @@
选项类型:
</div>
<div style="margin-top: 5px;">
<nz-radio-group [(ngModel)]="option.type" (ngModelChange)="ngChange(i,j)">
<nz-radio-group [(ngModel)]="option.up.type" (ngModelChange)="ngChange(i,j)">
<label nz-radio nzValue="img">
<span [style]="{color:option.up.type=='img' ? '#169BD5':'#000'}">图片</span>
</label>
<label nz-radio nzValue="txt">
<span [style]="{color:option.up.type=='txt' ? '#169BD5':'#000'}">文字</span>
</label>
</nz-radio-group>
</div>
</div>
<div style="margin-top: 15px;">
<div class="option-img">
<div *ngIf="option.up.type=='img'">
<div class="word-input-title">
图片:
</div>
<div style="width: 300px;">
<app-upload-image-with-preview [picUrl]="option.up.pic_url"
(imageUploaded)="onImageUploadSuccess($event, 'pic_url', option.up)">
</app-upload-image-with-preview>
</div>
</div>
</div>
<div class="option-audio">
<div class="word-input-title">
音频:
</div>
<div style="display: flex">
<div>
<app-audio-recorder [audioUrl]="option.up.audio_url"
(audioUploaded)="onAudioUploadSuccess($event, 'audio_url', option.up)">
</app-audio-recorder>
</div>
<div style="margin: 5px">
<span>
{{ option.up.audioName}}
</span>
</div>
</div>
</div>
<div class="option-text" *ngIf="option.up.type=='txt'">
<div class="word-input-title">
<!-- <span style="color:red;margin-left:-15px">* </span> -->
<span>文本: </span>
</div>
<input class="input-place-red" type="text" nz-input [(ngModel)]="option.up.text"
(blur)="save()">
</div>
</div>
<div style="margin-top: 20px;">
<div class="word-type-option-title">
选项类型:
</div>
<div style="margin-top: 5px;">
<nz-radio-group [(ngModel)]="option.down.type" (ngModelChange)="ngChange(i,j)">
<label nz-radio nzValue="img">
<span [style]="{color:option.type=='img' ? '#169BD5':'#000'}">图片</span>
<span [style]="{color:option.down.type=='img' ? '#169BD5':'#000'}">图片</span>
</label>
<label nz-radio nzValue="txt">
<span [style]="{color:option.type=='txt' ? '#169BD5':'#000'}">文字</span>
<span [style]="{color:option.down.type=='txt' ? '#169BD5':'#000'}">文字</span>
</label>
</nz-radio-group>
</div>
</div>
<div style="margin-top: 15px;">
<div class="option-img">
<div *ngIf="option.type=='img'">
<div *ngIf="option.down.type=='img'">
<div class="word-input-title">
图片:
</div>
<div style="width: 300px;">
<app-upload-image-with-preview [picUrl]="option.image"
(imageUploaded)="onImageUploadSuccess($event, 'image', option)">
<app-upload-image-with-preview [picUrl]="option.down.pic_url"
(imageUploaded)="onImageUploadSuccess($event, 'pic_url', option.down)">
</app-upload-image-with-preview>
</div>
</div>
......@@ -185,35 +248,38 @@
<div style="display: flex">
<div>
<app-audio-recorder [audioUrl]="option.audio"
(audioUploaded)="onAudioUploadSuccess($event, 'audio', option)">
<app-audio-recorder [audioUrl]="option.down.audio_url"
(audioUploaded)="onAudioUploadSuccess($event, 'audio_url', option.down)">
</app-audio-recorder>
</div>
<div style="margin: 5px">
<span>
{{ option.audioName}}
{{ option.down.audioName}}
</span>
</div>
</div>
</div>
<div class="option-text" *ngIf="option.type=='txt'">
<div class="option-text" *ngIf="option.down.type=='txt'">
<div class="word-input-title">
<!-- <span style="color:red;margin-left:-15px">* </span> -->
<span>文本: </span>
</div>
<input class="input-place-red" type="text" nz-input [(ngModel)]="option.text" (blur)="save()">
<input class="input-place-red" type="text" nz-input [(ngModel)]="option.down.text"
(blur)="save()">
</div>
</div>
</div>
</div>
<div style="margin-left: 10px;">
<button class="btn-red" nz-button nzType="default" nzDanger (click)="removeOption(i,m)">删除选项</button>
<button class="btn-red" nz-button nzType="default" nzDanger (click)="removeOption(i,j)">删除选项</button>
</div>
</div>
</div>
<button *ngIf="item.questions.length < 6" class="btn-blue" style="margin-top: 10px;" nz-button
<button *ngIf="question.options.length < 5" class="btn-blue" style="margin-top: 10px;" nz-button
nzType="default" nzDanger (click)="addOption(i)">增加选项</button>
</div>
<div style="margin:0 20px">
......@@ -225,8 +291,8 @@
</div>
<div style="margin-top: 20px;">
<button *ngIf="item.questions.length < 6" class="btn-blue" style="width: 1000px; height: 50px;" nz-button
nzType="default" nzDanger (click)="addQuestion()">+增加题目</button>
<button class="btn-blue" style="width: 1000px; height: 50px;" nz-button nzType="default" nzDanger
(click)="addQuestion()">+增加题目</button>
</div>
</div>
</div>
......
......@@ -11,13 +11,13 @@ import { ComponentBase } from './ComponentBase';
export class FormComponent extends ComponentBase implements OnInit, OnChanges, OnDestroy {
// 储存数据用
saveKey = "card_machine";
saveKey = "boy04";
// 储存对象
item: any = {
score: 0,
top: {
image: "",
text: "",
text: "1",
audio: "",
},
//1 ~ 6 个
......@@ -88,16 +88,27 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
}
addOption(idx) {
if (this.item.questions[idx].options.length == 6) return;
// if (this.item.questions[idx].options.length == 6) return;
this.item.questions[idx].options.push({
right: false,
colorImgWait: '',
colorImgSelected: '',
image: '',
up: {
type: 'txt',
pic_url: '',
text: '',
audio_url: ''
},
down: {
type: 'txt',
pic_url: '',
text: '',
audio_url: ''
},
});
this.save();
}
ngChange(i, j) {
this.save();
}
removeOption(idx, n) {
this.openDelete("确定删除选项?", () => {
this.item.questions[idx].options.splice(n, 1);
......
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