Commit 3c675c72 by Chao Sun

citySave

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