Commit 3c675c72 by Chao Sun

citySave

parent 6e850088
...@@ -43,7 +43,37 @@ export class AskComponent implements OnInit { ...@@ -43,7 +43,37 @@ export class AskComponent implements OnInit {
}) })
} }
reducePage() { reducePage() {
console.log('start', this.curPage)
if (this.curPage > 0) { if (this.curPage > 0) {
const page2Answer = this.allAnswers[1]
const optionId = page2Answer.questions[0].options[0].optionId
if (this.curPage == 5 || this.curPage == 6) {
if (optionId == 1 || optionId == 3) {
this.curPage = this.curPage - 2
this.setCurPageData()
return
}
}
if (this.curPage == 13) {
if (optionId == 1) {
this.curPage = this.curPage - 3
this.setCurPageData()
return
}
if (optionId == 2) {
this.curPage = this.curPage - 2
this.setCurPageData()
return
}
}
if (this.curPage == 12) {
if (optionId == 3) {
this.curPage = this.curPage - 2
this.setCurPageData()
return
}
}
this.curPage-- this.curPage--
this.setCurPageData() this.setCurPageData()
} else { } else {
...@@ -51,8 +81,8 @@ export class AskComponent implements OnInit { ...@@ -51,8 +81,8 @@ export class AskComponent implements OnInit {
} }
} }
filterItems() { filterItems() {
return this.allAnswers.filter(item=> { return this.allAnswers.filter(item => {
return item !=null return item != null
}) })
} }
addPage() { addPage() {
...@@ -71,14 +101,14 @@ export class AskComponent implements OnInit { ...@@ -71,14 +101,14 @@ export class AskComponent implements OnInit {
return return
} }
const answerParam = { const answerParam = {
"survey":{ survey: {
"customerId": 20, customerId: 20,
"orderId":9999996, orderId: 9999996,
"pages":this.filterItems() pages: this.filterItems()
} }
} }
console.log(answerParam) console.log(answerParam)
if(this.curPage==16){ if (this.curPage == 16) {
this.commonService.saveCustomerAnwers(answerParam).then(res => { this.commonService.saveCustomerAnwers(answerParam).then(res => {
console.log(res) console.log(res)
}) })
...@@ -124,7 +154,7 @@ export class AskComponent implements OnInit { ...@@ -124,7 +154,7 @@ export class AskComponent implements OnInit {
this.allQues[this.curPage] this.allQues[this.curPage]
) )
} }
if(this.curPage == 14){ if (this.curPage == 14) {
this.filterPage15( this.filterPage15(
page2Answer.questions[0].options[0].optionId, page2Answer.questions[0].options[0].optionId,
this.allQues[this.curPage] this.allQues[this.curPage]
...@@ -212,7 +242,7 @@ export class AskComponent implements OnInit { ...@@ -212,7 +242,7 @@ export class AskComponent implements OnInit {
questions: [ questions: [
{ {
...thePateData.questions[0], ...thePateData.questions[0],
optionType:1, optionType: 1,
options: thePateData.questions[0]['options'].filter(option => { options: thePateData.questions[0]['options'].filter(option => {
return option.optionId == 106 || option.optionId == 107 return option.optionId == 106 || option.optionId == 107
}) })
...@@ -226,7 +256,7 @@ export class AskComponent implements OnInit { ...@@ -226,7 +256,7 @@ export class AskComponent implements OnInit {
questions: [ questions: [
{ {
...thePateData.questions[0], ...thePateData.questions[0],
optionType:2, optionType: 2,
options: thePateData.questions[0]['options'].filter(option => { options: thePateData.questions[0]['options'].filter(option => {
return ( return (
option.optionId == 108 || option.optionId == 108 ||
...@@ -244,7 +274,7 @@ export class AskComponent implements OnInit { ...@@ -244,7 +274,7 @@ export class AskComponent implements OnInit {
questions: [ questions: [
{ {
...thePateData.questions[0], ...thePateData.questions[0],
optionType:2, optionType: 2,
options: thePateData.questions[0]['options'].filter(option => { options: thePateData.questions[0]['options'].filter(option => {
return ( return (
option.optionId == 108 || option.optionId == 108 ||
...@@ -262,7 +292,7 @@ export class AskComponent implements OnInit { ...@@ -262,7 +292,7 @@ export class AskComponent implements OnInit {
questions: [ questions: [
{ {
...thePateData.questions[0], ...thePateData.questions[0],
optionType:2, optionType: 2,
options: thePateData.questions[0]['options'].filter(option => { options: thePateData.questions[0]['options'].filter(option => {
return ( return (
option.optionId == 108 || option.optionId == 108 ||
...@@ -278,8 +308,8 @@ export class AskComponent implements OnInit { ...@@ -278,8 +308,8 @@ export class AskComponent implements OnInit {
} }
//判断是否吸烟option内容 //判断是否吸烟option内容
filterPage15(optionId,thePateData){ filterPage15(optionId, thePateData) {
//如果单身或者单亲选择相中没有配偶选项 //如果单身或者单亲选择相中没有配偶选项
//传一个optionType告诉子页面是单选还是多选1表示单选2表示多选 //传一个optionType告诉子页面是单选还是多选1表示单选2表示多选
if (optionId == 1) { if (optionId == 1) {
this.curPageData = { this.curPageData = {
...@@ -287,7 +317,7 @@ export class AskComponent implements OnInit { ...@@ -287,7 +317,7 @@ export class AskComponent implements OnInit {
questions: [ questions: [
{ {
...thePateData.questions[0], ...thePateData.questions[0],
optionType:1, optionType: 1,
options: thePateData.questions[0]['options'].filter(option => { options: thePateData.questions[0]['options'].filter(option => {
return option.optionId == 112 || option.optionId == 113 return option.optionId == 112 || option.optionId == 113
}) })
...@@ -301,7 +331,7 @@ export class AskComponent implements OnInit { ...@@ -301,7 +331,7 @@ export class AskComponent implements OnInit {
questions: [ questions: [
{ {
...thePateData.questions[0], ...thePateData.questions[0],
optionType:2, optionType: 2,
options: thePateData.questions[0]['options'].filter(option => { options: thePateData.questions[0]['options'].filter(option => {
return ( return (
option.optionId == 114 || option.optionId == 114 ||
...@@ -319,7 +349,7 @@ export class AskComponent implements OnInit { ...@@ -319,7 +349,7 @@ export class AskComponent implements OnInit {
questions: [ questions: [
{ {
...thePateData.questions[0], ...thePateData.questions[0],
optionType:2, optionType: 2,
options: thePateData.questions[0]['options'].filter(option => { options: thePateData.questions[0]['options'].filter(option => {
return ( return (
option.optionId == 114 || option.optionId == 114 ||
...@@ -337,7 +367,7 @@ export class AskComponent implements OnInit { ...@@ -337,7 +367,7 @@ export class AskComponent implements OnInit {
questions: [ questions: [
{ {
...thePateData.questions[0], ...thePateData.questions[0],
optionType:2, optionType: 2,
options: thePateData.questions[0]['options'].filter(option => { options: thePateData.questions[0]['options'].filter(option => {
return ( return (
option.optionId == 114 || option.optionId == 114 ||
...@@ -351,5 +381,4 @@ export class AskComponent implements OnInit { ...@@ -351,5 +381,4 @@ export class AskComponent implements OnInit {
} }
} }
} }
} }
...@@ -8,12 +8,13 @@ ...@@ -8,12 +8,13 @@
<li <li
*ngFor="let provinces of this.provinceList" *ngFor="let provinces of this.provinceList"
[ngClass]="{ selected: provinces['selected'] == true }" [ngClass]="{ selected: provinces['selected'] == true }"
(click)="showToast();selectProvince(provinces)"> (click)="showToast(); selectProvince(provinces)"
>
{{ provinces.provinceAbbr }} {{ provinces.provinceAbbr }}
</li> </li>
</ul> </ul>
<div class="address" *ngIf="this.showAddress"> <div class="address" *ngIf="this.showAddress">
{{this.strAddress}} {{ this.strAddress }}
</div> </div>
</div> </div>
</div> </div>
...@@ -21,14 +22,14 @@ ...@@ -21,14 +22,14 @@
<div class="toastContent city"> <div class="toastContent city">
<div class="live">所在地区</div> <div class="live">所在地区</div>
<div class="province"> <div class="province">
<span>{{this.provinceName}}</span> <span>{{ this.provinceName }}</span>
</div> </div>
<ul class="city"> <ul class="city">
<li <li
*ngFor="let city of this.cityList" *ngFor="let city of this.cityList"
(click)="closeToast();selectCity(city);getAnswer(city)" (click)="closeToast(); selectCity(city); getAnswer(city)"
> >
{{city.cityName}} {{ city.cityName }}
</li> </li>
</ul> </ul>
</div> </div>
......
...@@ -14,34 +14,34 @@ export class Page16Component implements OnInit { ...@@ -14,34 +14,34 @@ export class Page16Component implements OnInit {
isShow: boolean isShow: boolean
cityList: Array<any> cityList: Array<any>
provinceId: number provinceId: number
provinceName:string; provinceName: string
//具体地址显示 //具体地址显示
showAddress:boolean; showAddress: boolean
address:Object; address: Object
selectedProvinceObj:Object; selectedProvinceObj: Object
selectedCityObj:Object; selectedCityObj: Object
strAddress:string; strAddress: string
constructor(private commonService: CommonService) {} constructor(private commonService: CommonService) {}
ngOnInit() { ngOnInit() {
this.selectedProvinceObj = {} this.selectedProvinceObj = {}
this.selectedCityObj = {} this.selectedCityObj = {}
console.log(this.curPageData) console.log(this.curPageData)
this.showAddress = false; this.showAddress = false
this.setOptionSelected() this.setOptionSelected()
} }
showToast() { showToast() {
this.isShow = true this.isShow = true
} }
selectProvince(option){ selectProvince(option) {
if(!this.selectedProvinceObj['selected']){ if (!this.selectedProvinceObj['selected']) {
this.selectedProvinceObj = option this.selectedProvinceObj = option
option['selected'] = true; option['selected'] = true
}else{ } else {
if(this.selectedProvinceObj['provinceId']!=option.provinceId){ if (this.selectedProvinceObj['provinceId'] != option.provinceId) {
this.selectedProvinceObj['selected'] = false; this.selectedProvinceObj['selected'] = false
option['selected'] = true; option['selected'] = true
this.selectedProvinceObj = option this.selectedProvinceObj = option
} }
} }
...@@ -67,22 +67,22 @@ export class Page16Component implements OnInit { ...@@ -67,22 +67,22 @@ export class Page16Component implements OnInit {
}) })
} }
selectCity(e){ selectCity(e) {
this.showAddress = true; this.showAddress = true
this.strAddress = this.provinceName + e.cityName this.strAddress = this.provinceName + e.cityName
this.address = { this.address = {
'customerInput': this.provinceName +',' + e.cityName customerInput: this.provinceName + ',' + e.cityName
} }
} }
getAnswer(option) { getAnswer(option) {
if(!this.selectedCityObj['selected']){ if (!this.selectedCityObj['selected']) {
this.selectedCityObj = option this.selectedCityObj = option
option['selected'] = true; option['selected'] = true
}else{ } else {
if(this.selectedCityObj['optionId']!=option.optionId){ if (this.selectedCityObj['optionId'] != option.optionId) {
this.selectedCityObj['selected'] = false; this.selectedCityObj['selected'] = false
option['selected'] = true; option['selected'] = true
this.selectedCityObj = option this.selectedCityObj = option
} }
} }
...@@ -111,5 +111,4 @@ export class Page16Component implements OnInit { ...@@ -111,5 +111,4 @@ export class Page16Component implements OnInit {
} }
}) })
} }
} }
...@@ -8,7 +8,7 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core' ...@@ -8,7 +8,7 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
export class Page4Component implements OnInit { export class Page4Component implements OnInit {
@Input() curPageData: Array<any> @Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>() @Output() getAllAnswer = new EventEmitter<any>()
selectedObj:Object; selectedObj: Object
constructor() {} constructor() {}
ngOnInit() { ngOnInit() {
...@@ -16,13 +16,13 @@ export class Page4Component implements OnInit { ...@@ -16,13 +16,13 @@ export class Page4Component implements OnInit {
this.setOptionSelected() this.setOptionSelected()
} }
getAnswer(option) { getAnswer(option) {
if(!this.selectedObj['selected']){ if (!this.selectedObj['selected']) {
this.selectedObj = option this.selectedObj = option
option['selected'] = true; option['selected'] = true
}else{ } else {
if(this.selectedObj['optionId']!=option.optionId){ if (this.selectedObj['optionId'] != option.optionId) {
this.selectedObj['selected'] = false; this.selectedObj['selected'] = false
option['selected'] = true; option['selected'] = true
this.selectedObj = option this.selectedObj = option
} }
} }
...@@ -31,7 +31,7 @@ export class Page4Component implements OnInit { ...@@ -31,7 +31,7 @@ export class Page4Component implements OnInit {
questions: [ questions: [
{ {
questionId: this.curPageData['questions'][0].questionId, questionId: this.curPageData['questions'][0].questionId,
option: [option] options: [option]
} }
] ]
} }
......
...@@ -8,7 +8,7 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core' ...@@ -8,7 +8,7 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
export class Page5Component implements OnInit { export class Page5Component implements OnInit {
@Input() curPageData: Array<any> @Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>() @Output() getAllAnswer = new EventEmitter<any>()
selectedObj:Object; selectedObj: Object
constructor() {} constructor() {}
ngOnInit() { ngOnInit() {
...@@ -16,13 +16,13 @@ export class Page5Component implements OnInit { ...@@ -16,13 +16,13 @@ export class Page5Component implements OnInit {
this.setOptionSelected() this.setOptionSelected()
} }
getAnswer(option) { getAnswer(option) {
if(!this.selectedObj['selected']){ if (!this.selectedObj['selected']) {
this.selectedObj = option this.selectedObj = option
option['selected'] = true; option['selected'] = true
}else{ } else {
if(this.selectedObj['optionId']!=option.optionId){ if (this.selectedObj['optionId'] != option.optionId) {
this.selectedObj['selected'] = false; this.selectedObj['selected'] = false
option['selected'] = true; option['selected'] = true
this.selectedObj = option this.selectedObj = option
} }
} }
...@@ -31,7 +31,7 @@ export class Page5Component implements OnInit { ...@@ -31,7 +31,7 @@ export class Page5Component implements OnInit {
questions: [ questions: [
{ {
questionId: this.curPageData['questions'][0].questionId, questionId: this.curPageData['questions'][0].questionId,
option: [option] options: [option]
} }
] ]
} }
......
...@@ -33,7 +33,7 @@ export class Page7Component implements OnInit { ...@@ -33,7 +33,7 @@ export class Page7Component implements OnInit {
} }
this.curAllQues[questionId] = options this.curAllQues[questionId] = options
const questions = Object.keys(this.curAllQues).map(questionId => { const questions = Object.keys(this.curAllQues).map(questionId => {
return { questionId, options: this.curAllQues[questionId] } return { questionId, options: [this.curAllQues[questionId]] }
}) })
const ret = { const ret = {
pageId: 7, pageId: 7,
...@@ -57,5 +57,4 @@ export class Page7Component implements OnInit { ...@@ -57,5 +57,4 @@ export class Page7Component implements OnInit {
}) })
}) })
} }
} }
...@@ -9,8 +9,8 @@ export class Page8Component implements OnInit { ...@@ -9,8 +9,8 @@ export class Page8Component implements OnInit {
@Input() curPageData: Array<any> @Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>() @Output() getAllAnswer = new EventEmitter<any>()
curAllQues: Object curAllQues: Object
selectedNum:number; selectedNum: number
selectedTwo:number; selectedTwo: number
selectedObj: Object selectedObj: Object
constructor() {} constructor() {}
...@@ -34,7 +34,7 @@ export class Page8Component implements OnInit { ...@@ -34,7 +34,7 @@ export class Page8Component implements OnInit {
} }
this.curAllQues[questionId] = options this.curAllQues[questionId] = options
const questions = Object.keys(this.curAllQues).map(questionId => { const questions = Object.keys(this.curAllQues).map(questionId => {
return { questionId, options: this.curAllQues[questionId] } return { questionId, options: [this.curAllQues[questionId]] }
}) })
const ret = { const ret = {
pageId: 8, pageId: 8,
......
...@@ -33,7 +33,7 @@ export class Page9Component implements OnInit { ...@@ -33,7 +33,7 @@ export class Page9Component implements OnInit {
} }
this.curAllQues[questionId] = options this.curAllQues[questionId] = options
const questions = Object.keys(this.curAllQues).map(questionId => { const questions = Object.keys(this.curAllQues).map(questionId => {
return { questionId, options: this.curAllQues[questionId] } return { questionId, options: [this.curAllQues[questionId]] }
}) })
const ret = { const ret = {
pageId: 9, pageId: 9,
......
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