Commit 02d06881 by Sweet Zhang

增加前一步

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