Commit 44e6aacc by Chao Sun

下一步置灰

parent 3c675c72
...@@ -78,9 +78,12 @@ ...@@ -78,9 +78,12 @@
<div class="footer" *ngIf="curPage == 0" (click)="addPage()"> <div class="footer" *ngIf="curPage == 0" (click)="addPage()">
<div>获取家庭分析报告</div> <div>获取家庭分析报告</div>
</div> </div>
<div class="content_footer" *ngIf="curPage != 0"> <div class="content_footer" *ngIf="curPage != 0 && curPage!=16">
<div (click)="reducePage()">&lt;</div> <div (click)="reducePage()">&lt;</div>
<div (click)="addPage()" class="next">下一步</div> <div
(click)="addPage()"
[ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }"
>下一步</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -17,6 +17,7 @@ export class AskComponent implements OnInit { ...@@ -17,6 +17,7 @@ export class AskComponent implements OnInit {
hasMate: boolean hasMate: boolean
//获取省份 //获取省份
provinceList: Array<any> provinceList: Array<any>
nextBtn:boolean;
constructor(private commonService: CommonService) {} constructor(private commonService: CommonService) {}
ngOnInit() { ngOnInit() {
...@@ -43,7 +44,7 @@ export class AskComponent implements OnInit { ...@@ -43,7 +44,7 @@ export class AskComponent implements OnInit {
}) })
} }
reducePage() { reducePage() {
console.log('start', this.curPage) // console.log('start', this.curPage)
if (this.curPage > 0) { if (this.curPage > 0) {
const page2Answer = this.allAnswers[1] const page2Answer = this.allAnswers[1]
const optionId = page2Answer.questions[0].options[0].optionId const optionId = page2Answer.questions[0].options[0].optionId
...@@ -74,7 +75,7 @@ export class AskComponent implements OnInit { ...@@ -74,7 +75,7 @@ export class AskComponent implements OnInit {
return return
} }
} }
this.curPage-- this.curPage--;
this.setCurPageData() this.setCurPageData()
} else { } else {
return return
...@@ -86,7 +87,11 @@ export class AskComponent implements OnInit { ...@@ -86,7 +87,11 @@ export class AskComponent implements OnInit {
}) })
} }
addPage() { addPage() {
if(this.nextBtn===false){
return;
}
if (this.curPage < 16) { if (this.curPage < 16) {
//判断当前页是否有答案
if ( if (
this.curPage == 0 || this.curPage == 0 ||
this.allAnswers[this.curPage] || this.allAnswers[this.curPage] ||
...@@ -102,26 +107,52 @@ export class AskComponent implements OnInit { ...@@ -102,26 +107,52 @@ export class AskComponent implements OnInit {
} }
const answerParam = { const answerParam = {
survey: { survey: {
customerId: 20, customerId: this.commonService.getQueryString('customerId'),
orderId: 9999996, orderId: this.commonService.getQueryString('orderId'),
pages: this.filterItems() pages: this.filterItems()
} }
} }
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)
}) })
} }
console.log(this.curPage) // console.log(this.nextBtn)
} }
getAllAnswer(e) { getAllAnswer(e) {
this.allAnswers[this.curPage] = e this.allAnswers[this.curPage] = e
console.log(this.allAnswers) // console.log(this.allAnswers);
if (this.curPage < 16) {
//判断当前页是否有答案
if (
this.curPage == 0 ||
this.allAnswers[this.curPage] ||
this.curPage == 5 ||
this.curPage == 9
) {
this.nextBtn = true;
}else{
this.nextBtn = false;
}
}
} }
setCurPageData() { setCurPageData() {
// console.log(this.allAnswers)
if (this.curPage < 16) {
//判断当前页是否有答案
if (
this.curPage == 0 ||
this.allAnswers[this.curPage] ||
this.curPage == 5 ||
this.curPage == 9
) {
this.nextBtn = true;
}else{
this.nextBtn = false;
}
}
const thePateData = this.allQues[this.curPage] const thePateData = this.allQues[this.curPage]
console.log('thePateData------', this.curPage, thePateData) // console.log('thePateData------', this.curPage, thePateData)
this.curPageData = thePateData this.curPageData = thePateData
const page2Answer = this.allAnswers[1] const page2Answer = this.allAnswers[1]
if (this.curPage == 2) { if (this.curPage == 2) {
...@@ -211,7 +242,7 @@ export class AskComponent implements OnInit { ...@@ -211,7 +242,7 @@ export class AskComponent implements OnInit {
//1单身 3单亲 //1单身 3单亲
if (optionId == 1 || optionId == 3) { if (optionId == 1 || optionId == 3) {
this.curPage++ this.curPage++
console.log('page5', this.curPage, this.curPageData) // console.log('page5', this.curPage, this.curPageData)
this.curPageData = this.allQues[this.curPage] this.curPageData = this.allQues[this.curPage]
} }
} }
......
...@@ -73,4 +73,14 @@ export class CommonService { ...@@ -73,4 +73,14 @@ export class CommonService {
return res; return res;
}) })
} }
getQueryString(name) {
const gitUrlParam = window.location.search;
const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
const r = decodeURIComponent(gitUrlParam).substr(1).match(reg);
if (r != null) {
return r[2];
}
return null;
}
} }
...@@ -15,7 +15,7 @@ export class Page11Component implements OnInit { ...@@ -15,7 +15,7 @@ export class Page11Component implements OnInit {
ngOnInit() { ngOnInit() {
// this.allOption = {} // this.allOption = {}
this.allOptions = [] this.allOptions = []
console.log(this.curPageData) // console.log(this.curPageData)
} }
getAnswer(options) { getAnswer(options) {
options['selected'] = !options['selected'] options['selected'] = !options['selected']
...@@ -46,7 +46,7 @@ export class Page11Component implements OnInit { ...@@ -46,7 +46,7 @@ export class Page11Component implements OnInit {
} }
} }
console.log(this.allOptions) // console.log(this.allOptions)
// 删掉未选中的疾病 // 删掉未选中的疾病
// for (let i = 0; i < this.allOptions.length; i++){ // for (let i = 0; i < this.allOptions.length; i++){
// if (!this.allOptions[i]['selected']) { // if (!this.allOptions[i]['selected']) {
......
...@@ -14,10 +14,10 @@ export class Page14Component implements OnInit { ...@@ -14,10 +14,10 @@ export class Page14Component implements OnInit {
constructor() { } constructor() { }
ngOnInit() { ngOnInit() {
console.log(this.curPageData) // console.log(this.curPageData)
//拿到数据中是多选还是单选2表示多选1表示单选 //拿到数据中是多选还是单选2表示多选1表示单选
this.optionType = this.curPageData['questions'][0].optionType this.optionType = this.curPageData['questions'][0].optionType
console.log(this.optionType) // console.log(this.optionType)
if(this.optionType==1){ if(this.optionType==1){
this.selectedObj = {} this.selectedObj = {}
this.setOptionSelected() this.setOptionSelected()
......
...@@ -16,10 +16,10 @@ export class Page15Component implements OnInit { ...@@ -16,10 +16,10 @@ export class Page15Component implements OnInit {
constructor() { } constructor() { }
ngOnInit() { ngOnInit() {
console.log(this.curPageData) // console.log(this.curPageData)
//拿到数据中是多选还是单选2表示多选1表示单选 //拿到数据中是多选还是单选2表示多选1表示单选
this.optionType = this.curPageData['questions'][0].optionType this.optionType = this.curPageData['questions'][0].optionType
console.log(this.optionType) // console.log(this.optionType)
if(this.optionType==1){ if(this.optionType==1){
this.selectedObj = {} this.selectedObj = {}
this.setOptionSelected() this.setOptionSelected()
...@@ -30,7 +30,7 @@ export class Page15Component implements OnInit { ...@@ -30,7 +30,7 @@ export class Page15Component implements OnInit {
} }
getManyAnswer(options) { getManyAnswer(options) {
console.log(options) // console.log(options)
options['selected'] = !options['selected'] options['selected'] = !options['selected']
for (let i = 0; i < this.allOptions.length; i++) { for (let i = 0; i < this.allOptions.length; i++) {
// 更改问题状态,防止重复往数组push // 更改问题状态,防止重复往数组push
...@@ -104,7 +104,7 @@ export class Page15Component implements OnInit { ...@@ -104,7 +104,7 @@ export class Page15Component implements OnInit {
setOptionSelected() { setOptionSelected() {
const options = this.curPageData['questions'][0].options const options = this.curPageData['questions'][0].options
console.log(this.curPageData['questions'][0]) // console.log(this.curPageData['questions'][0])
if (!options) { if (!options) {
return return
} }
......
...@@ -26,7 +26,7 @@ export class Page16Component implements OnInit { ...@@ -26,7 +26,7 @@ export class Page16Component implements OnInit {
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()
} }
...@@ -45,7 +45,7 @@ export class Page16Component implements OnInit { ...@@ -45,7 +45,7 @@ export class Page16Component implements OnInit {
this.selectedProvinceObj = option this.selectedProvinceObj = option
} }
} }
console.log(this.selectedProvinceObj) // console.log(this.selectedProvinceObj)
this.provinceName = option.provinceName this.provinceName = option.provinceName
this.provinceId = option.provinceId this.provinceId = option.provinceId
this.getCityqry() this.getCityqry()
...@@ -62,7 +62,7 @@ export class Page16Component implements OnInit { ...@@ -62,7 +62,7 @@ export class Page16Component implements OnInit {
this.commonService.getCityqry(param).subscribe(res => { this.commonService.getCityqry(param).subscribe(res => {
if (res['success']) { if (res['success']) {
this.cityList = res['data'].cityList this.cityList = res['data'].cityList
console.log(this.cityList) // console.log(this.cityList)
} }
}) })
} }
...@@ -101,7 +101,7 @@ export class Page16Component implements OnInit { ...@@ -101,7 +101,7 @@ export class Page16Component implements OnInit {
setOptionSelected() { setOptionSelected() {
const options = this.provinceList const options = this.provinceList
console.log(options) // console.log(options)
if (!options) { if (!options) {
return return
} }
......
...@@ -10,6 +10,6 @@ export class Page17Component implements OnInit { ...@@ -10,6 +10,6 @@ export class Page17Component implements OnInit {
constructor() {} constructor() {}
ngOnInit() { ngOnInit() {
console.log(this.curPageData) // console.log(this.curPageData)
} }
} }
...@@ -8,6 +8,7 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core' ...@@ -8,6 +8,7 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
export class Page2Component implements OnInit { export class Page2Component implements OnInit {
@Input() curPageData: Array<any> @Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>() @Output() getAllAnswer = new EventEmitter<any>()
@Output() controlNext = new EventEmitter<any>()
selectedObj:Object; selectedObj:Object;
constructor() {} constructor() {}
...@@ -35,7 +36,11 @@ export class Page2Component implements OnInit { ...@@ -35,7 +36,11 @@ export class Page2Component implements OnInit {
} }
] ]
} }
this.getAllAnswer.emit(ret) // console.log(this.curPageData['questions']);
// console.log(ret.questions)
this.getAllAnswer.emit(ret);
this.controlNext.emit();
// console.log(ret)
} }
setOptionSelected() { setOptionSelected() {
......
...@@ -42,7 +42,7 @@ export class Page3Component implements OnInit { ...@@ -42,7 +42,7 @@ export class Page3Component implements OnInit {
const questionId = this.curQues['questionId'] const questionId = this.curQues['questionId']
this.curAllQues[questionId] = option this.curAllQues[questionId] = option
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: 3, pageId: 3,
...@@ -135,6 +135,6 @@ export class Page3Component implements OnInit { ...@@ -135,6 +135,6 @@ export class Page3Component implements OnInit {
] ]
} }
} }
console.log(this.curPageData['questions']) // console.log(this.curPageData['questions'])
} }
} }
...@@ -10,6 +10,6 @@ export class Page6Component implements OnInit { ...@@ -10,6 +10,6 @@ export class Page6Component implements OnInit {
constructor() {} constructor() {}
ngOnInit() { ngOnInit() {
console.log(this.curPageData) // console.log(this.curPageData)
} }
} }
...@@ -44,14 +44,14 @@ export class Page7Component implements OnInit { ...@@ -44,14 +44,14 @@ export class Page7Component implements OnInit {
setOptionSelected() { setOptionSelected() {
const questions = this.curPageData['questions'] const questions = this.curPageData['questions']
console.log(questions) // console.log(questions)
if (!questions) { if (!questions) {
return return
} }
questions.map(question => { questions.map(question => {
question['options'].forEach(option => { question['options'].forEach(option => {
if (option['selected']) { if (option['selected']) {
console.log(this.selectedObj) // console.log(this.selectedObj)
this.selectedObj[question['questionId']] = option this.selectedObj[question['questionId']] = option
} }
}) })
......
...@@ -18,7 +18,7 @@ export class Page8Component implements OnInit { ...@@ -18,7 +18,7 @@ export class Page8Component implements OnInit {
this.curAllQues = {} this.curAllQues = {}
this.selectedObj = {} this.selectedObj = {}
this.setOptionSelected() this.setOptionSelected()
console.log(this.curPageData) // console.log(this.curPageData)
} }
getAnswer(question, options) { getAnswer(question, options) {
const questionId = question['questionId'] const questionId = question['questionId']
...@@ -40,6 +40,8 @@ export class Page8Component implements OnInit { ...@@ -40,6 +40,8 @@ export class Page8Component implements OnInit {
pageId: 8, pageId: 8,
questions questions
} }
// console.log(this.curPageData['questions']);
// console.log(ret.questions)
this.getAllAnswer.emit(ret) this.getAllAnswer.emit(ret)
} }
setOptionSelected() { setOptionSelected() {
......
...@@ -20,7 +20,7 @@ export class Page9Component implements OnInit { ...@@ -20,7 +20,7 @@ export class Page9Component implements OnInit {
} }
getAnswer(question, options) { getAnswer(question, options) {
const questionId = question['questionId'] const questionId = question['questionId']
console.log('select', this.selectedObj, options) // console.log('select', this.selectedObj, options)
if (!this.selectedObj[questionId]) { if (!this.selectedObj[questionId]) {
this.selectedObj[questionId] = options this.selectedObj[questionId] = options
options['selected'] = true options['selected'] = true
......
...@@ -97,6 +97,9 @@ ul li,ol li{ ...@@ -97,6 +97,9 @@ ul li,ol li{
line-height: 60px; line-height: 60px;
font-weight: bold; font-weight: bold;
} }
.content_footer div.next{
color: #8a8a8a;
}
.content_footer div:nth-child(1){ .content_footer div:nth-child(1){
flex: 0 0 15%; flex: 0 0 15%;
font-size: 30px; font-size: 30px;
......
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