Commit a53903df by Chao Sun

收入页下一步

parent 6a8794fa
...@@ -42,6 +42,7 @@ export class FamilyComponent implements OnInit { ...@@ -42,6 +42,7 @@ export class FamilyComponent implements OnInit {
}], }],
}; };
this.commonService.addAnswer(this.pageAnswers); this.commonService.addAnswer(this.pageAnswers);
console.log(this.pageAnswers)
} }
// 下一步 // 下一步
......
...@@ -7,9 +7,10 @@ ...@@ -7,9 +7,10 @@
</div> </div>
<ul class="income"> <ul class="income">
<li <li
[ngClass]="{ selected: options['selected'] == true }" [ngClass]="{ selected: selectedOptionId == options.optionId }"
*ngFor="let options of this.curPageData?.questions[0].options" *ngFor="let options of this.curPageData?.questions[0].options"
> (click)="selectedIncome(this.curPageData?.questions[0],options)"
>
{{ options.optionName }} {{ options.optionName }}
</li> </li>
</ul> </ul>
...@@ -18,8 +19,9 @@ ...@@ -18,8 +19,9 @@
</div> </div>
<ul class="income" *ngIf="hasMate"> <ul class="income" *ngIf="hasMate">
<li <li
[ngClass]="{ selected: options['selected'] == true }" [ngClass]="{ selected: selectedOptionId == options.optionId}"
*ngFor="let options of this.curPageData?.questions[1]['options']" *ngFor="let options of this.curPageData?.questions[1]['options']"
(click)="selectedIncome(this.curPageData?.questions[1],options)"
> >
{{ options.optionName }} {{ options.optionName }}
</li> </li>
...@@ -28,7 +30,7 @@ ...@@ -28,7 +30,7 @@
</div> </div>
<div class="content_footer"> <div class="content_footer">
<div style="color: #8a8a8a;">&lt;</div> <div style="color: #8a8a8a;">&lt;</div>
<div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }"> 下一步 </div> <div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }" (click)="next()"> 下一步 </div>
</div> </div>
</div> </div>
</div> </div>
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import {CommonService} from '../common.service'; import {CommonService} from '../common.service';
import {ActivatedRoute, Router} from "@angular/router";
@Component({ @Component({
selector: 'app-income', selector: 'app-income',
...@@ -9,19 +10,70 @@ import {CommonService} from '../common.service'; ...@@ -9,19 +10,70 @@ import {CommonService} from '../common.service';
export class IncomeComponent implements OnInit { export class IncomeComponent implements OnInit {
hasMate:boolean; hasMate:boolean;
curPageData:Array<any>; curPageData:Array<any>;
constructor(private commonService: CommonService) { } pageAnswers: any;
// 家庭结构
type: any;
selectedOptionId: any;
constructor(
private commonService: CommonService,
private router: Router,
private route: ActivatedRoute
) {
/**
* 1:单身贵族
* 2:二人世界
* 3:独立带娃
* 4:多口之家
* @type {any}
*/
this.type = this.route.snapshot.queryParams['type'];
this.pageAnswers = {
pageId: '',
questions: [],
};
}
ngOnInit() { ngOnInit() {
this.surveyInfo() this.surveyInfo()
this.hasMate = true; this.hasMate = true;
//判断家庭决定是否显示配偶
if(this.type==2 || this.type == 4){
}else{
}
} }
surveyInfo() { surveyInfo() {
this.commonService.surveyInfo().then(res => { this.commonService.surveyInfo().then(res => {
if (res['success']) { if (res['success']) {
this.curPageData = res['data']['survey'].pages['6'] this.curPageData = res['data']['survey'].pages['6']
console.log(this.curPageData) console.log(this.curPageData)
this.pageAnswers.pageId = this.curPageData['pageId'];
} }
}) })
} }
selectedIncome(question,option){
this.selectedOptionId = option.optionId;
option.selected = true;
const questions = {
questionId: question.questionId,
questionName: question.questionName,
options: [option]
};
for (let i = 0; i < this.pageAnswers.questions.length; i++) {
if (this.pageAnswers.questions[i].questionId == question.questionId) {
const index = this.pageAnswers.questions.indexOf(this.pageAnswers.questions[i]);
this.pageAnswers.questions.splice(index, 1);
}
}
this.pageAnswers.questions.push(questions);
this.commonService.addAnswer(this.pageAnswers);
console.log(question)
console.log(option)
console.log(this.pageAnswers)
}
} }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<div class="questionTitle">{{ this.curPageData?.pageName }}</div> <div class="questionTitle">{{ this.curPageData?.pageName }}</div>
<ul class="jobContent"> <ul class="jobContent">
<li <li
[ngClass]="{ selected: options['selected'] == true }" [ngClass]="{ selected: selectedOptionId == options.optionId }"
*ngFor="let options of this.curPageData?.questions[0].options" *ngFor="let options of this.curPageData?.questions[0].options"
(click)="selectedJob(options)" (click)="selectedJob(options)"
> >
......
...@@ -4,6 +4,6 @@ ...@@ -4,6 +4,6 @@
</div> </div>
<div class="content_footer"> <div class="content_footer">
<div style="color: #8a8a8a;">&lt;</div> <div style="color: #8a8a8a;">&lt;</div>
<div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }"> 下一步 </div> <div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }" (click)="next()"> 下一步 </div>
</div> </div>
</div> </div>
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import {Router,ActivatedRoute} from '@angular/router';
@Component({ @Component({
selector: 'app-transit1', selector: 'app-transit1',
templateUrl: './transit1.component.html', templateUrl: './transit1.component.html',
styleUrls: ['./transit1.component.css'] styleUrls: ['./transit1.component.css']
}) })
export class Transit1Component implements OnInit { export class Transit1Component implements OnInit {
type:any;
constructor() { } constructor(
private router: Router,
private route: ActivatedRoute) {
/**
* 1:单身贵族
* 2:二人世界
* 3:独立带娃
* 4:多口之家
* @type {any}
*/
this.type = this.route.snapshot.queryParams['type'];
}
ngOnInit() { ngOnInit() {
} }
next(){
this.router.navigate(['/income'],{queryParams:{type:this.type}})
}
} }
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