Commit fa4d8075 by Chao Sun

合并

parents d2f1cc40 02d06881
...@@ -41,6 +41,7 @@ export class AgeComponent implements OnInit { ...@@ -41,6 +41,7 @@ export class AgeComponent implements OnInit {
} }
ngOnInit() { ngOnInit() {
console.log(this.commonService.todosCopy)
this.commonService.surveyInfo().then(res => { this.commonService.surveyInfo().then(res => {
this.curPageData = res['data']['survey']['pages'].filter(item => item.pageId === 3).pop(); this.curPageData = res['data']['survey']['pages'].filter(item => item.pageId === 3).pop();
this.pageAnswers.pageId = this.curPageData['pageId']; this.pageAnswers.pageId = this.curPageData['pageId'];
...@@ -161,9 +162,10 @@ export class AgeComponent implements OnInit { ...@@ -161,9 +162,10 @@ export class AgeComponent implements OnInit {
} else { } else {
return; return;
} }
} }
before(){
history.go(-1); // 上一步
before() {
this.commonService.before();
} }
} }
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
</ul> </ul>
</div> </div>
<div class="content_footer"> <div class="content_footer">
<div style="color: #8a8a8a;">&lt;</div> <div style="color: #8a8a8a;" (click)="before()">&lt;</div>
<div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }" (click)="next()"> 下一步 </div> <div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }" (click)="next()"> 下一步 </div>
</div> </div>
</div> </div>
......
...@@ -75,12 +75,8 @@ export class ChildrenHealthComponent implements OnInit { ...@@ -75,12 +75,8 @@ export class ChildrenHealthComponent implements OnInit {
}; };
// console.log(this.pageAnswers); // console.log(this.pageAnswers);
// console.log(this.curPageData) // console.log(this.curPageData)
if (this.curPageData['questions'].length == this.pageAnswers.questions.length) { if (this.pageAnswers.questions.every(item => item.options.length > 0)) {
if (this.pageAnswers.questions.every(item => item.options.length > 0)) { this.nextBtn = true;
this.nextBtn = true;
} else {
this.nextBtn = false;
}
} else { } else {
this.nextBtn = false; this.nextBtn = false;
} }
...@@ -129,6 +125,7 @@ export class ChildrenHealthComponent implements OnInit { ...@@ -129,6 +125,7 @@ export class ChildrenHealthComponent implements OnInit {
type: this.type type: this.type
} }
}); });
this.nextBtn = false;
this.surveyInfo(); this.surveyInfo();
} else { } else {
this.router.navigate(['/disease'], {queryParams: {type: this.type}}); this.router.navigate(['/disease'], {queryParams: {type: this.type}});
...@@ -138,4 +135,9 @@ export class ChildrenHealthComponent implements OnInit { ...@@ -138,4 +135,9 @@ export class ChildrenHealthComponent implements OnInit {
} }
} }
// 上一步
before() {
this.commonService.before();
}
} }
...@@ -132,6 +132,24 @@ export class CommonService { ...@@ -132,6 +132,24 @@ export class CommonService {
return this; return this;
} }
/**
* 删除所有答案
* @returns {Array<any>}
*/
remove() {
this.todos = [];
sessionStorage.removeItem('todos');
this.todosSource.next(this.todos);
}
/**
* 返回上一页
* @returns {Array<any>}
*/
before() {
history.go(-1);
}
get todosCopy() { get todosCopy() {
return this.todos; return this.todos;
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
</ul> </ul>
</div> </div>
<div class="content_footer"> <div class="content_footer">
<div style="color: #8a8a8a;">&lt;</div> <div style="color: #8a8a8a;" (click)="before()">&lt;</div>
<div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }" <div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }"
(click)="next()"> 下一步 </div> (click)="next()"> 下一步 </div>
</div> </div>
......
...@@ -159,4 +159,9 @@ export class DiseaseComponent implements OnInit { ...@@ -159,4 +159,9 @@ export class DiseaseComponent implements OnInit {
return return
} }
} }
// 上一步
before() {
this.commonService.before();
}
} }
...@@ -14,6 +14,6 @@ ...@@ -14,6 +14,6 @@
</div> </div>
</div> </div>
<div class="content_footer"> <div class="content_footer">
<div style="color: #8a8a8a;">&lt;</div> <div style="color: #8a8a8a;" (click)="before()">&lt;</div>
<div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }" (click)="next()"> 下一步</div> <div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }" (click)="next()"> 下一步</div>
</div> </div>
...@@ -12,9 +12,11 @@ export class FamilyComponent implements OnInit { ...@@ -12,9 +12,11 @@ export class FamilyComponent implements OnInit {
selectedOptionId: any; selectedOptionId: any;
// 上一次的答案 // 上一次的答案
lastQuestions: Array<any>; lastQuestions: Array<any>;
// 上一次选择的optionId
lastSelectedOptionId: any;
nextBtn: boolean = false; nextBtn: boolean = false;
Obj:Object = {} targetObj: any = {};
targetObj:Object = {}
constructor(private commonService: CommonService, private router: Router) { constructor(private commonService: CommonService, private router: Router) {
this.pageAnswers = { this.pageAnswers = {
...@@ -31,48 +33,33 @@ export class FamilyComponent implements OnInit { ...@@ -31,48 +33,33 @@ export class FamilyComponent implements OnInit {
this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 2).pop(); this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 2).pop();
this.commonService.surveyInfo().then(res => { this.commonService.surveyInfo().then(res => {
this.curPageData = res['data']['survey']['pages'].filter(item => item.pageId === 2).pop(); this.curPageData = res['data']['survey']['pages'].filter(item => item.pageId === 2).pop();
console.log(this.lastQuestions) if (this.lastQuestions) {
console.log(this.curPageData) this.lastSelectedOptionId = this.lastQuestions['questions']['0']['options']['0'].optionId;
for (let i = 0; i < this.lastQuestions['questions'].length; i++) { for (let i = 0; i < this.lastQuestions['questions'].length; i++) {
for (let j = 0; j < this.curPageData['questions'].length; j++) { for (let j = 0; j < this.curPageData['questions'].length; j++) {
if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) { if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) {
this.lastQuestions['questions'][i]['options'].forEach(option => { this.lastQuestions['questions'][i]['options'].forEach(option => {
if(Object.keys(option).indexOf('optionId')>-1){ if (Object.keys(option).indexOf('optionId') > -1) {
this.targetObj = option this.targetObj = option;
} }
// this.curPageData['questions'][j]['options'].forEach(option=>{ console.log(this.targetObj)
// if(Object.keys(option).indexOf('optionId')>-1){ this.selectedFamily(this.targetObj);
// this.Obj = option });
// } }
// })
// this.Obj['optionId'] = this.targetObj['optionId']
console.log(this.targetObj)
this.selectedFamily(this.targetObj);
});
} }
} }
} }
// for (let i = 0; i < this.lastQuestions['questions'].length; i++) {
// for (let j = 0; j < this.curPageData['questions'].length; j++) {
// if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) {
// for (let m = 0; m < this.lastQuestions['questions'][i].options.length; m++) {
// for (let n = 0; n < this.curPageData['questions'][i].options.length; n++) {
// if (this.lastQuestions['questions'][i].options[m].optionId == this.curPageData['questions'][i].options[n].optionId) {
// this.selectedFamily(this.curPageData['questions'][i].options[n]);
// }
// }
// }
// }
// }
// }
// console.log(this.curPageData)
}); });
} }
// 选择家庭结构 // 选择家庭结构
selectedFamily(option) { selectedFamily(option) {
this.selectedOptionId = option.optionId; this.selectedOptionId = option.optionId;
// 如果选择的跟上一次的家庭结构不一样,那么将以前的答案清空
if (this.lastSelectedOptionId != this.selectedOptionId) {
this.commonService.remove();
}
const options = this.curPageData['questions'][0]['options']; const options = this.curPageData['questions'][0]['options'];
for (let i = 0; i < options.length; i++) { for (let i = 0; i < options.length; i++) {
if (option['optionId'] == options[i]['optionId']) { if (option['optionId'] == options[i]['optionId']) {
...@@ -91,9 +78,7 @@ export class FamilyComponent implements OnInit { ...@@ -91,9 +78,7 @@ export class FamilyComponent implements OnInit {
}; };
this.commonService.addAnswer(this.pageAnswers); this.commonService.addAnswer(this.pageAnswers);
// console.log(this.pageAnswers); // console.log(this.pageAnswers);
if (this.pageAnswers.questions[0].options.every((item) => { if (this.curPageData['questions'].length == this.pageAnswers.questions.length) {
return item.selected;
})) {
this.nextBtn = true; this.nextBtn = true;
} else { } else {
this.nextBtn = false; this.nextBtn = false;
...@@ -107,6 +92,10 @@ export class FamilyComponent implements OnInit { ...@@ -107,6 +92,10 @@ export class FamilyComponent implements OnInit {
} else { } else {
return; return;
} }
}
// 上一步
before() {
this.commonService.before();
} }
} }
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
</ul> </ul>
</div> </div>
<div class="content_footer"> <div class="content_footer">
<div style="color: #8a8a8a;">&lt;</div> <div style="color: #8a8a8a;" (click)="before()">&lt;</div>
<div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }" (click)="next()"> 下一步</div> <div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }" (click)="next()"> 下一步</div>
</div> </div>
</div> </div>
......
...@@ -168,4 +168,9 @@ export class HealthComponent implements OnInit { ...@@ -168,4 +168,9 @@ export class HealthComponent implements OnInit {
} }
} }
// 上一步
before() {
this.commonService.before();
}
} }
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
</div> </div>
</div> </div>
<div class="content_footer"> <div class="content_footer">
<div style="color: #8a8a8a;">&lt;</div> <div style="color: #8a8a8a;" (click)="before()">&lt;</div>
<div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }" (click)="next()"> 下一步 </div> <div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }" (click)="next()"> 下一步 </div>
</div> </div>
</div> </div>
......
...@@ -101,4 +101,9 @@ export class IncomeComponent implements OnInit { ...@@ -101,4 +101,9 @@ export class IncomeComponent implements OnInit {
return; return;
} }
} }
// 上一步
before() {
this.commonService.before();
}
} }
...@@ -15,6 +15,6 @@ ...@@ -15,6 +15,6 @@
</div> </div>
</div> </div>
<div class="content_footer"> <div class="content_footer">
<div style="color: #8a8a8a;">&lt;</div> <div style="color: #8a8a8a;" (click)="before()">&lt;</div>
<div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }" (click)="next()"> 下一步 </div> <div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }" (click)="next()"> 下一步 </div>
</div> </div>
...@@ -102,7 +102,9 @@ export class JobComponent implements OnInit { ...@@ -102,7 +102,9 @@ export class JobComponent implements OnInit {
} else { } else {
return; return;
} }
}
// 上一步
before() {
this.commonService.before();
} }
} }
...@@ -18,13 +18,13 @@ ...@@ -18,13 +18,13 @@
</div> </div>
</div> </div>
<div class="content_footer"> <div class="content_footer">
<div style="color: #8a8a8a;">&lt;</div> <div style="color: #8a8a8a;" (click)="before()">&lt;</div>
<div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }" <div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }"
(click)="next()"> 下一步 </div> (click)="next()"> 下一步 </div>
</div> </div>
</div> </div>
<div class="toastWrapper toast" *ngIf="isShow" (click)="closeToast();"> <div class="toastWrapper toast" *ngIf="isShow" (click)="closeToast();">
</div> </div>
<div class="toastContent city" *ngIf="isShow"> <div class="toastContent city" *ngIf="isShow">
<div class="live">所在地区</div> <div class="live">所在地区</div>
......
...@@ -126,4 +126,9 @@ export class LiveComponent implements OnInit { ...@@ -126,4 +126,9 @@ export class LiveComponent implements OnInit {
return; return;
} }
} }
// 上一步
before() {
this.commonService.before();
}
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
</div> </div>
<ul class="income"> <ul class="income">
<li <li
[ngClass]="{ selected: options['selected'] == true }" [ngClass]="{ selected: options['selected'] == true }"
*ngFor="let options of this.curPageData?.questions[0]['options']" *ngFor="let options of this.curPageData?.questions[0]['options']"
(click)="selectedLoan(this.curPageData?.questions[0],options)" (click)="selectedLoan(this.curPageData?.questions[0],options)"
> >
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
</div> </div>
<ul class="income"> <ul class="income">
<li <li
[ngClass]="{ selected: options['selected'] == true }" [ngClass]="{ selected: options['selected'] == true }"
*ngFor="let options of this.curPageData?.questions[1]['options']" *ngFor="let options of this.curPageData?.questions[1]['options']"
(click)="selectedLoan(this.curPageData?.questions[1],options)" (click)="selectedLoan(this.curPageData?.questions[1],options)"
> >
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
</ul> </ul>
</div> </div>
<div class="content_footer"> <div class="content_footer">
<div style="color: #8a8a8a;">&lt;</div> <div style="color: #8a8a8a;" (click)="before()">&lt;</div>
<div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }" <div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }"
(click)="next()" (click)="next()"
> 下一步 </div> > 下一步 </div>
......
...@@ -105,4 +105,9 @@ export class LoanComponent implements OnInit { ...@@ -105,4 +105,9 @@ export class LoanComponent implements OnInit {
return; return;
} }
} }
// 上一步
before() {
this.commonService.before();
}
} }
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
</ul> </ul>
</div> </div>
<div class="content_footer"> <div class="content_footer">
<div style="color: #8a8a8a;">&lt;</div> <div style="color: #8a8a8a;" (click)="before()">&lt;</div>
<div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }" <div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }"
(click)="next()"> 下一步 </div> (click)="next()"> 下一步 </div>
</div> </div>
......
...@@ -158,4 +158,9 @@ export class SmokingComponent implements OnInit { ...@@ -158,4 +158,9 @@ export class SmokingComponent implements OnInit {
return; return;
} }
} }
// 上一步
before() {
this.commonService.before();
}
} }
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
</ul> </ul>
</div> </div>
<div class="content_footer"> <div class="content_footer">
<div style="color: #8a8a8a;">&lt;</div> <div style="color: #8a8a8a;" (click)="before()">&lt;</div>
<div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }" <div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }"
(click)="next()" (click)="next()"
> 下一步 </div> > 下一步 </div>
......
...@@ -105,4 +105,9 @@ export class SocialSecurityComponent implements OnInit { ...@@ -105,4 +105,9 @@ export class SocialSecurityComponent implements OnInit {
return; return;
} }
} }
// 上一步
before() {
this.commonService.before();
}
} }
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<img src="assets/images/bg_6.png" /> <img src="assets/images/bg_6.png" />
</div> </div>
<div class="content_footer"> <div class="content_footer">
<div style="color: #8a8a8a;">&lt;</div> <div style="color: #8a8a8a;" (click)="before()">&lt;</div>
<div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }" (click)="next()"> 下一步 </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'; import {Router, ActivatedRoute} from '@angular/router';
import {CommonService} from "../common.service";
@Component({ @Component({
selector: 'app-transit1', selector: 'app-transit1',
templateUrl: './transit1.component.html', templateUrl: './transit1.component.html',
...@@ -9,6 +10,7 @@ export class Transit1Component implements OnInit { ...@@ -9,6 +10,7 @@ export class Transit1Component implements OnInit {
type: any; type: any;
constructor(private router: Router, constructor(private router: Router,
private commonService: CommonService,
private route: ActivatedRoute) { private route: ActivatedRoute) {
/** /**
* 1:单身贵族 * 1:单身贵族
...@@ -26,4 +28,9 @@ export class Transit1Component implements OnInit { ...@@ -26,4 +28,9 @@ export class Transit1Component implements OnInit {
next() { next() {
this.router.navigate(['/income'], {queryParams: {type: this.type}}) this.router.navigate(['/income'], {queryParams: {type: this.type}})
} }
// 上一步
before() {
this.commonService.before();
}
} }
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<img src="assets/images/bg_10.png" /> <img src="assets/images/bg_10.png" />
</div> </div>
<div class="content_footer"> <div class="content_footer">
<div style="color: #8a8a8a;">&lt;</div> <div style="color: #8a8a8a;" (click)="before()">&lt;</div>
<div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }" <div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }"
(click)="next()" (click)="next()"
> 下一步 </div> > 下一步 </div>
......
import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {CommonService} from "../common.service";
@Component({ @Component({
selector: 'app-transit2', selector: 'app-transit2',
...@@ -11,6 +12,7 @@ export class Transit2Component implements OnInit { ...@@ -11,6 +12,7 @@ export class Transit2Component implements OnInit {
type: any; type: any;
constructor(private router: Router, constructor(private router: Router,
private commonService: CommonService,
private route: ActivatedRoute) { private route: ActivatedRoute) {
this.type = this.route.snapshot.queryParams['type']; this.type = this.route.snapshot.queryParams['type'];
} }
...@@ -21,4 +23,9 @@ export class Transit2Component implements OnInit { ...@@ -21,4 +23,9 @@ export class Transit2Component implements OnInit {
next() { next() {
this.router.navigate(['/health'], {queryParams: {type: this.type}}); this.router.navigate(['/health'], {queryParams: {type: this.type}});
} }
// 上一步
before() {
this.commonService.before();
}
} }
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