Commit afd125a8 by Chao Sun

疾病吸烟居住

parent b43aad5c
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
<ul class="jobContent"> <ul class="jobContent">
<li <li
*ngFor="let options of this.options" *ngFor="let options of this.options"
[ngClass]="{ selected: selectedOptionId == options.optionId }" [ngClass]="{ selected: options['selected'] == true }"
(click)="getAnswer(options)" (click)="checkFun(options)"
> >
{{ options.optionName }} {{ options.optionName }}
</li> </li>
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<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 [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }"
(click)="next()"> 下一步 </div> (click)="next()"> 下一步 </div>
</div> </div>
</div> </div>
</div> </div>
...@@ -14,6 +14,7 @@ export class DiseaseComponent implements OnInit { ...@@ -14,6 +14,7 @@ export class DiseaseComponent implements OnInit {
nextBtn:boolean; nextBtn:boolean;
options:Array<any>; options:Array<any>;
selectedOptionId:any; selectedOptionId:any;
questions:Array<any> = [];
constructor( constructor(
private commonService: CommonService, private commonService: CommonService,
private router: Router, private router: Router,
...@@ -74,9 +75,14 @@ export class DiseaseComponent implements OnInit { ...@@ -74,9 +75,14 @@ export class DiseaseComponent implements OnInit {
}) })
} }
getAnswer(option){ getOneAnswer(option){
// console.log(options) for(let i=0;i<this.options.length;i++){
this.selectedOptionId = option.optionId; if(option['optionId']==this.options[i]['optionId']){
this.options[i]['selected'] = true;
}else{
this.options[i]['selected'] = false;
}
}
this.pageAnswers = { this.pageAnswers = {
pageId : this.curPageData['pageId'], pageId : this.curPageData['pageId'],
questions:[{ questions:[{
...@@ -93,10 +99,54 @@ export class DiseaseComponent implements OnInit { ...@@ -93,10 +99,54 @@ export class DiseaseComponent implements OnInit {
this.nextBtn = false this.nextBtn = false
} }
} }
getManyAnswer(option){
option['selected'] = !option['selected'];
this.questions = [];
for (let i = 0; i < this.curPageData['questions'][0]['options'].length; i++) {
if (option.optionId == 111 && option['selected']) {
this.curPageData['questions'][0]['options'][i]['selected'] = false;
if (this.curPageData['questions'][0]['options'][i]['optionId'] == 111) {
this.curPageData['questions'][0]['options'][i]['selected'] = true;
}
} else {
if (this.curPageData['questions'][0]['options'][i]['optionId'] == 111) {
this.curPageData['questions'][0]['options'][i]['selected'] = false;
}
}
// 拿到所有selected为true的选项
if (this.curPageData['questions'][0]['options'][i]['selected']) {
this.questions.push(this.curPageData['questions'][0]['options'][i]);
}
}
this.pageAnswers = {
pageId: this.curPageData['pageId'],
questions: [{
questionId: this.curPageData['questions']['0']['questionId'],
questionName: this.curPageData['questions']['0']['questionName'],
options: this.questions
}],
};
if(this.pageAnswers['questions'].length>0){
this.nextBtn = true
}else{
this.nextBtn = false
}
console.log(this.pageAnswers)
this.commonService.addAnswer(this.pageAnswers);
}
//根据type区分单选多选
checkFun(option){
if(this.type==1){
this.getOneAnswer(option)
}else{
this.getManyAnswer(option)
}
}
next(){ next(){
if(this.nextBtn == true){ if(this.nextBtn == true){
this.router.navigate(['/smoke'],{queryParams:{type:this.type}}) this.router.navigate(['/smoke'],{queryParams:{type:this.type}})
}else{
return
} }
} }
} }
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
</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 class="toastWrapper toast" *ngIf="isShow" (click)="closeToast();"> <div class="toastWrapper toast" *ngIf="isShow" (click)="closeToast();">
......
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-live', selector: 'app-live',
...@@ -19,12 +20,28 @@ export class LiveComponent implements OnInit { ...@@ -19,12 +20,28 @@ export class LiveComponent implements OnInit {
address: Object address: Object
//页面地址 //页面地址
strAddress: string strAddress: string
pageAnswers: any;
type:any;
nextBtn:boolean;
constructor( constructor(
private commonService: CommonService private commonService: CommonService,
) { } private router: Router,
private route: ActivatedRoute
) {
this.type = this.route.snapshot.queryParams['type'];
this.pageAnswers = {
pageId: '',
questions: [{
questionId: '',
questionName: '',
options: [{optionId: '', optionName: '', optionOrder: '', selected: ''}]
}],
};
}
ngOnInit() { ngOnInit() {
this.surveyInfo() this.surveyInfo()
this.nextBtn = false;
this.showAddress = false; this.showAddress = false;
} }
surveyInfo() { surveyInfo() {
...@@ -50,6 +67,13 @@ export class LiveComponent implements OnInit { ...@@ -50,6 +67,13 @@ export class LiveComponent implements OnInit {
// console.log(this.selectedProvinceObj) // console.log(this.selectedProvinceObj)
this.provinceName = option.provinceName this.provinceName = option.provinceName
this.provinceId = option.provinceId this.provinceId = option.provinceId
for(let i=0;i<this.provinceList.length;i++){
if(option['provinceId']==this.provinceList[i]['provinceId']){
this.provinceList[i]['selected'] = true;
}else{
this.provinceList[i]['selected'] = false;
}
}
this.getCityqry() this.getCityqry()
} }
closeToast() { closeToast() {
...@@ -75,5 +99,28 @@ export class LiveComponent implements OnInit { ...@@ -75,5 +99,28 @@ export class LiveComponent implements OnInit {
this.address = { this.address = {
customerInput: this.provinceName + ',' + e.cityName customerInput: this.provinceName + ',' + e.cityName
} }
this.pageAnswers = {
pageId: this.curPageData['pageId'],
questions: [{
questionId: this.curPageData['questions']['0']['questionId'],
questionName: this.curPageData['questions']['0']['questionName'],
options: [this.address]
}],
};
this.commonService.addAnswer(this.pageAnswers)
if(this.pageAnswers['questions'].length>0){
this.nextBtn = true
}else{
this.nextBtn = false
}
console.log(this.pageAnswers)
}
next(){
if(this.nextBtn == true){
this.router.navigate(['/transit3'])
}else{
return;
}
} }
} }
...@@ -6,8 +6,9 @@ ...@@ -6,8 +6,9 @@
</div> </div>
<ul class="jobContent"> <ul class="jobContent">
<li <li
*ngFor="let options of this.curPageData?.questions[0]['options']" *ngFor="let options of this.options"
[ngClass]="{ selected: options['selected'] == true }" [ngClass]="{ selected: options['selected'] == true }"
(click)="checkFun(options)"
> >
{{ options.optionName }} {{ options.optionName }}
</li> </li>
...@@ -15,7 +16,8 @@ ...@@ -15,7 +16,8 @@
</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-smoking', selector: 'app-smoking',
...@@ -8,20 +9,146 @@ import {CommonService} from '../common.service'; ...@@ -8,20 +9,146 @@ import {CommonService} from '../common.service';
}) })
export class SmokingComponent implements OnInit { export class SmokingComponent implements OnInit {
curPageData:Array<any>; curPageData:Array<any>;
constructor( type:any;
private commonService: CommonService nextBtn:boolean;
pageAnswers:any;
options:Array<any>;
questions:Array<any> = [];
) { } constructor(
private commonService: CommonService,
private router: Router,
private route: ActivatedRoute
) {
this.type = this.route.snapshot.queryParams['type'];
this.pageAnswers = {
pageId: '',
questions: [{
questionId: '',
questionName: '',
options: [{optionId: '', optionName: '', optionOrder: '', selected: ''}]
}],
};
}
ngOnInit() { ngOnInit() {
this.nextBtn = false;
this.surveyInfo() this.surveyInfo()
} }
surveyInfo() { surveyInfo() {
this.commonService.surveyInfo().then(res => { this.commonService.surveyInfo().then(res => {
if (res['success']) { if (res['success']) {
this.curPageData = res['data']['survey'].pages['14'] this.curPageData = res['data']['survey'].pages['14']
console.log(this.curPageData) /**
* 1:单身贵族
* 2:二人世界
* 3:独立带娃
* 4:多口之家
* @type {any}
*/
//过滤选项
if(this.type == 1){
this.options = this.curPageData['questions']['0']['options']
this.options = this.options.filter(option=>{
return option.optionId == 112 || option.optionId == 113
})
}
if(this.type == 2){
this.options = this.curPageData['questions']['0']['options']
this.options = this.options.filter(option=>{
return option.optionId == 114 || option.optionId == 115 || option.optionId == 117
})
}
if(this.type == 3){
this.options = this.curPageData['questions']['0']['options']
this.options = this.options.filter(option=>{
return option.optionId == 114 || option.optionId == 116 || option.optionId == 117
})
}
if(this.type == 4){
this.options = this.curPageData['questions']['0']['options']
this.options = this.options.filter(option=>{
return option.optionId == 114 || option.optionId == 115 || option.optionId == 116 || option.optionId == 117
})
}
} }
}) })
} }
getOneAnswer(option){
for(let i=0;i<this.options.length;i++){
if(option['optionId']==this.options[i]['optionId']){
this.options[i]['selected'] = true;
}else{
this.options[i]['selected'] = false;
}
}
this.pageAnswers = {
pageId : this.curPageData['pageId'],
questions:[{
questionId: this.curPageData['questions']['0']['questionId'],
questionName: this.curPageData['questions']['0']['questionName'],
options:[option]
}]
}
this.commonService.addAnswer(this.pageAnswers)
console.log(this.pageAnswers)
if(this.pageAnswers['questions'].length>0){
this.nextBtn = true
}else{
this.nextBtn = false
}
}
getManyAnswer(option){
option['selected'] = !option['selected'];
this.questions = [];
for (let i = 0; i < this.curPageData['questions'][0]['options'].length; i++) {
if (option.optionId == 117 && option['selected']) {
this.curPageData['questions'][0]['options'][i]['selected'] = false;
if (this.curPageData['questions'][0]['options'][i]['optionId'] == 117) {
this.curPageData['questions'][0]['options'][i]['selected'] = true;
}
} else {
if (this.curPageData['questions'][0]['options'][i]['optionId'] == 117) {
this.curPageData['questions'][0]['options'][i]['selected'] = false;
}
}
// 拿到所有selected为true的选项
if (this.curPageData['questions'][0]['options'][i]['selected']) {
this.questions.push(this.curPageData['questions'][0]['options'][i]);
}
}
this.pageAnswers = {
pageId: this.curPageData['pageId'],
questions: [{
questionId: this.curPageData['questions']['0']['questionId'],
questionName: this.curPageData['questions']['0']['questionName'],
options: this.questions
}],
};
if(this.pageAnswers['questions'].length>0){
this.nextBtn = true
}else{
this.nextBtn = false
}
console.log(this.pageAnswers)
this.commonService.addAnswer(this.pageAnswers);
}
checkFun(option){
if(this.type==1){
this.getOneAnswer(option)
}else{
this.getManyAnswer(option)
}
}
next(){
if(this.nextBtn == true){
this.router.navigate(['/live'],{queryParams:{type:this.type}})
}else{
return;
}
}
} }
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
<img src="assets/images/bg_17.png" /> <img src="assets/images/bg_17.png" />
</div> </div>
<div class="footer" style="margin-top: 10%;" (click)="getHref()"> <div class="footer" style="margin-top: 10%;" (click)="getHref()">
<div>我知道了</div> <div (click)="getHref()">我知道了</div>
</div> </div>
</div> </div>
...@@ -11,5 +11,7 @@ export class Transit3Component implements OnInit { ...@@ -11,5 +11,7 @@ export class Transit3Component implements OnInit {
ngOnInit() { ngOnInit() {
} }
getHref(){
window.location.href = 'https://' + window.location.host+ '/member'
}
} }
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