Commit afd125a8 by Chao Sun

疾病吸烟居住

parent b43aad5c
......@@ -7,8 +7,8 @@
<ul class="jobContent">
<li
*ngFor="let options of this.options"
[ngClass]="{ selected: selectedOptionId == options.optionId }"
(click)="getAnswer(options)"
[ngClass]="{ selected: options['selected'] == true }"
(click)="checkFun(options)"
>
{{ options.optionName }}
</li>
......
......@@ -14,6 +14,7 @@ export class DiseaseComponent implements OnInit {
nextBtn:boolean;
options:Array<any>;
selectedOptionId:any;
questions:Array<any> = [];
constructor(
private commonService: CommonService,
private router: Router,
......@@ -74,9 +75,14 @@ export class DiseaseComponent implements OnInit {
})
}
getAnswer(option){
// console.log(options)
this.selectedOptionId = option.optionId;
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:[{
......@@ -93,10 +99,54 @@ export class DiseaseComponent implements OnInit {
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(){
if(this.nextBtn == true){
this.router.navigate(['/smoke'],{queryParams:{type:this.type}})
}else{
return
}
}
}
......@@ -19,7 +19,8 @@
</div>
<div class="content_footer">
<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 class="toastWrapper toast" *ngIf="isShow" (click)="closeToast();">
......
import { Component, OnInit } from '@angular/core';
import { CommonService } from '../common.service'
import {ActivatedRoute, Router} from "@angular/router";
@Component({
selector: 'app-live',
......@@ -19,12 +20,28 @@ export class LiveComponent implements OnInit {
address: Object
//页面地址
strAddress: string
pageAnswers: any;
type:any;
nextBtn:boolean;
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() {
this.surveyInfo()
this.nextBtn = false;
this.showAddress = false;
}
surveyInfo() {
......@@ -50,6 +67,13 @@ export class LiveComponent implements OnInit {
// console.log(this.selectedProvinceObj)
this.provinceName = option.provinceName
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()
}
closeToast() {
......@@ -75,5 +99,28 @@ export class LiveComponent implements OnInit {
this.address = {
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 @@
</div>
<ul class="jobContent">
<li
*ngFor="let options of this.curPageData?.questions[0]['options']"
*ngFor="let options of this.options"
[ngClass]="{ selected: options['selected'] == true }"
(click)="checkFun(options)"
>
{{ options.optionName }}
</li>
......@@ -15,7 +16,8 @@
</div>
<div class="content_footer">
<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>
import { Component, OnInit } from '@angular/core';
import {CommonService} from '../common.service';
import {ActivatedRoute, Router} from "@angular/router";
@Component({
selector: 'app-smoking',
......@@ -8,20 +9,146 @@ import {CommonService} from '../common.service';
})
export class SmokingComponent implements OnInit {
curPageData:Array<any>;
constructor(
private commonService: CommonService
type:any;
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() {
this.nextBtn = false;
this.surveyInfo()
}
surveyInfo() {
this.commonService.surveyInfo().then(res => {
if (res['success']) {
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 @@
<img src="assets/images/bg_17.png" />
</div>
<div class="footer" style="margin-top: 10%;" (click)="getHref()">
<div>我知道了</div>
<div (click)="getHref()">我知道了</div>
</div>
</div>
......@@ -11,5 +11,7 @@ export class Transit3Component implements OnInit {
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