Commit fb3f4c19 by Chao Sun

修复多选问题

parent f93ab19e
...@@ -39,7 +39,7 @@ export class AskComponent implements OnInit { ...@@ -39,7 +39,7 @@ export class AskComponent implements OnInit {
this.curPageData = this.allQues[this.curPage] this.curPageData = this.allQues[this.curPage]
} }
}) })
this.commonService.provinceqry({ insurerId: 11 }).subscribe(res => { this.commonService.provinceqry({ insurerId: 11 }).then(res => {
if (res['success']) { if (res['success']) {
this.provinceList = res['data'].provinceList this.provinceList = res['data'].provinceList
} }
...@@ -92,7 +92,6 @@ export class AskComponent implements OnInit { ...@@ -92,7 +92,6 @@ export class AskComponent implements OnInit {
if(this.nextBtn===false){ if(this.nextBtn===false){
return; return;
} }
console.log(this.questionInfo)
this.allAnswers[this.curPage] = this.questionInfo; this.allAnswers[this.curPage] = this.questionInfo;
if (this.curPage < 16) { if (this.curPage < 16) {
//判断当前页是否有答案 //判断当前页是否有答案
...@@ -124,35 +123,21 @@ export class AskComponent implements OnInit { ...@@ -124,35 +123,21 @@ export class AskComponent implements OnInit {
} }
} }
getAllAnswer(e) { getAllAnswer(e) {
let result=false;
this.questionInfo = e; this.questionInfo = e;
console.log(e) if(this.curPage == 6 || this.curPage == 8){
const questions = e.questions; const page2Answer = this.allAnswers[1]
if(questions.length>0){ const optionId = page2Answer.questions[0].options[0].optionId
for(let i=0;i<questions.length;i++){ if(optionId==1 || optionId==3){
let options = questions[i].options; if(e['questions'].length>0){
if(options.length>0){ this.nextBtn = true
result = true; }
}
} }
} }
if (this.curPage < 16) { if(this.curPageData['questions'].length == e['questions'].length){
//判断当前页是否有答案 this.nextBtn = true
if (
this.curPage == 0 ||
result ||
this.curPage == 5 ||
this.curPage == 9
) {
this.nextBtn = true;
}else{
this.nextBtn = false;
}
} }
} }
setCurPageData() { setCurPageData() {
// console.log(this.allAnswers)
const thePateData = this.allQues[this.curPage] const thePateData = this.allQues[this.curPage]
this.curPageData = thePateData this.curPageData = thePateData
......
...@@ -40,12 +40,6 @@ export class CommonService { ...@@ -40,12 +40,6 @@ export class CommonService {
return response; return response;
}); });
} }
// async getAllInfo(){
// const res = await this.surveyInfo()
// if(res['success']){
// this.questionList = res['data']['survey'].pages
// }
// }
/** /**
* 获取TOKEN * 获取TOKEN
...@@ -62,7 +56,7 @@ export class CommonService { ...@@ -62,7 +56,7 @@ export class CommonService {
const url = this.USER_API_URL + '/partner/provinceqry'; const url = this.USER_API_URL + '/partner/provinceqry';
const res = await this.obtainToken(); const res = await this.obtainToken();
this.httpOptions.headers = this.httpOptions.headers.set('X-Authorization', res['data']['token']); this.httpOptions.headers = this.httpOptions.headers.set('X-Authorization', res['data']['token']);
return this.http.post(url,JSON.stringify(objParam),this.httpOptions).pipe(res => { return this.http.post(url,JSON.stringify(objParam),this.httpOptions).toPromise().then(res => {
return res; return res;
}) })
} }
...@@ -73,7 +67,7 @@ export class CommonService { ...@@ -73,7 +67,7 @@ export class CommonService {
this.httpOptions.headers = this.httpOptions.headers.set('X-Authorization', res['data']['token']); this.httpOptions.headers = this.httpOptions.headers.set('X-Authorization', res['data']['token']);
return this.http return this.http
.post(url,JSON.stringify(objParam),this.httpOptions) .post(url,JSON.stringify(objParam),this.httpOptions)
.pipe(res => { .toPromise().then(res => {
return res; return res;
}) })
} }
......
...@@ -10,6 +10,5 @@ export class Page10Component implements OnInit { ...@@ -10,6 +10,5 @@ export class Page10Component implements OnInit {
constructor() {} constructor() {}
ngOnInit() { ngOnInit() {
console.log(this.curPageData)
} }
} }
...@@ -19,7 +19,6 @@ export class Page11Component implements OnInit { ...@@ -19,7 +19,6 @@ export class Page11Component implements OnInit {
this.getAlloptions() this.getAlloptions()
} }
getAnswer(options) { getAnswer(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
...@@ -47,39 +46,6 @@ export class Page11Component implements OnInit { ...@@ -47,39 +46,6 @@ export class Page11Component implements OnInit {
} }
} }
} }
// console.log(this.allOptions)
// 删掉未选中的疾病
// for (let i = 0; i < this.allOptions.length; i++){
// if (!this.allOptions[i]['selected']) {
// let index = this.allOptions.indexOf(this.allOptions[i])
// if (index > -1) {
// this.allOptions.splice(index, 1)
// }
// }
// }
// if (!this.allOption[options['optionId']]) {
// this.allOption[options['optionId']] = {}
// }
// console.log(this.allOption)
// this.allOption[options['optionId']] = {
// selected: !this.allOption[options['optionId']]['selected'],
// options
// }
// const options_ret = Object.keys(this.allOption)
// .filter(item => {
// return this.allOption[item]['selected']
// })
// .map(questionId => {
// return {
// options: this.allOption[questionId]
// }
// })
// const result = this.allOptions.filter(item=>{
// item.selected==true
// })
// console.log(result)
const ret = { const ret = {
// ...this.curPageData, // ...this.curPageData,
pageId: this.curPageData['pageId'], pageId: this.curPageData['pageId'],
...@@ -101,18 +67,14 @@ export class Page11Component implements OnInit { ...@@ -101,18 +67,14 @@ export class Page11Component implements OnInit {
} }
getAlloptions(){ getAlloptions(){
// const questions = this.curPageData['questions'] const questions = this.curPageData['questions']
// if(!questions){ if(!questions){
// return return
// } }
// questions[0]['options'].forEach(option => { questions[0]['options'].forEach(option => {
// if(option['selected']){ if(option['selected']){
// console.log(questions) this.allOptions.push(option)
// this.allOptions = questions[0]['options'] }
});
// // console.log(questions[0]['options'])
// // console.log(this.allOptions[question])
// }
// });
} }
} }
...@@ -13,6 +13,7 @@ export class Page12Component implements OnInit { ...@@ -13,6 +13,7 @@ export class Page12Component implements OnInit {
ngOnInit() { ngOnInit() {
this.allOptions = [] this.allOptions = []
this.getAlloptions()
} }
getAnswer(options) { getAnswer(options) {
options['selected'] = !options['selected'] options['selected'] = !options['selected']
...@@ -61,4 +62,16 @@ export class Page12Component implements OnInit { ...@@ -61,4 +62,16 @@ export class Page12Component implements OnInit {
return item['selected']==true; return item['selected']==true;
}) })
} }
getAlloptions(){
const questions = this.curPageData['questions']
if(!questions){
return
}
questions[0]['options'].forEach(option => {
if(option['selected']){
this.allOptions.push(option)
}
});
}
} }
...@@ -12,6 +12,7 @@ export class Page13Component implements OnInit { ...@@ -12,6 +12,7 @@ export class Page13Component implements OnInit {
ngOnInit() { ngOnInit() {
this.allOptions = [] this.allOptions = []
this.getAlloptions()
} }
getAnswer(options) { getAnswer(options) {
options['selected'] = !options['selected'] options['selected'] = !options['selected']
...@@ -59,4 +60,15 @@ export class Page13Component implements OnInit { ...@@ -59,4 +60,15 @@ export class Page13Component implements OnInit {
return item['selected']==true; return item['selected']==true;
}) })
} }
getAlloptions(){
const questions = this.curPageData['questions']
if(!questions){
return
}
questions[0]['options'].forEach(option => {
if(option['selected']){
this.allOptions.push(option)
}
});
}
} }
...@@ -24,6 +24,7 @@ export class Page14Component implements OnInit { ...@@ -24,6 +24,7 @@ export class Page14Component implements OnInit {
} }
if(this.optionType==2){ if(this.optionType==2){
this.allOptions = [] this.allOptions = []
this.getAlloptions()
} }
} }
...@@ -121,5 +122,15 @@ export class Page14Component implements OnInit { ...@@ -121,5 +122,15 @@ export class Page14Component implements OnInit {
this.getManyAnswer(options) this.getManyAnswer(options)
} }
} }
getAlloptions(){
const questions = this.curPageData['questions']
if(!questions){
return
}
questions[0]['options'].forEach(option => {
if(option['selected']){
this.allOptions.push(option)
}
});
}
} }
...@@ -26,6 +26,7 @@ export class Page15Component implements OnInit { ...@@ -26,6 +26,7 @@ export class Page15Component implements OnInit {
} }
if(this.optionType==2){ if(this.optionType==2){
this.allOptions = [] this.allOptions = []
this.getAlloptions()
} }
} }
...@@ -124,5 +125,17 @@ export class Page15Component implements OnInit { ...@@ -124,5 +125,17 @@ export class Page15Component implements OnInit {
this.getManyAnswer(options) this.getManyAnswer(options)
} }
} }
getAlloptions(){
const questions = this.curPageData['questions']
if(!questions){
return
}
questions[0]['options'].forEach(option => {
if(option['selected']){
this.allOptions.push(option)
}
});
}
} }
...@@ -59,7 +59,7 @@ export class Page16Component implements OnInit { ...@@ -59,7 +59,7 @@ export class Page16Component implements OnInit {
insurerId: 11, insurerId: 11,
provinceId: this.provinceId provinceId: this.provinceId
} }
this.commonService.getCityqry(param).subscribe(res => { this.commonService.getCityqry(param).then(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)
......
...@@ -12,26 +12,26 @@ ...@@ -12,26 +12,26 @@
</li> </li>
</ul> </ul>
</div> </div>
<div class="addChild" *ngIf="isShowChildAgeBtn" (click)="addChild()"> <!-- <div class="addChild" *ngIf="isShowChildAgeBtn" (click)="addChild()">
<div class="icon">+</div> <div class="icon">+</div>
<div data-toggle="modal">增加孩子年龄</div> <div data-toggle="modal">增加孩子年龄</div>
</div> -->
<div class="toastWrapper toast" *ngIf="isShow" (click)="closeToast()">
</div> </div>
<div>{{result}}</div> </div>
<div class="toastWrapper toast" *ngIf="isShow"> <div class="toastContent" *ngIf="isShow">
<div class="toastContent"> <ul>
<ul> <li
<li [ngClass]="{ selected: this.curQuestionSelecte === options.optionName}"
[ngClass]="{ selected: this.selectedNum === options.optionId }" *ngFor="let options of curQues.options"
*ngFor="let options of curQues.options" (click)="
(click)=" closeToast();
closeToast(); getAnswer(options);
getAnswer(options); changeStyle(options, options.optionId)
changeStyle(options, options.optionId) "
" >
> {{ options.optionName }}
{{ options.optionName }} </li>
</li> </ul>
</ul>
</div>
</div>
</div> </div>
...@@ -20,6 +20,7 @@ export class Page3Component implements OnInit { ...@@ -20,6 +20,7 @@ export class Page3Component implements OnInit {
curQuesLen: number curQuesLen: number
//增加孩子点击次数 //增加孩子点击次数
addChildCount: number addChildCount: number
curQuestionSelecte:string;
constructor() {} constructor() {}
ngOnInit() { ngOnInit() {
...@@ -33,6 +34,8 @@ export class Page3Component implements OnInit { ...@@ -33,6 +34,8 @@ export class Page3Component implements OnInit {
this.isShow = true this.isShow = true
this.curQues = question this.curQues = question
this.curQuesIndex = idx this.curQuesIndex = idx
// console.log(question)
this.curQuestionSelecte = question.name
} }
closeToast() { closeToast() {
this.isShow = false this.isShow = false
...@@ -55,23 +58,6 @@ export class Page3Component implements OnInit { ...@@ -55,23 +58,6 @@ export class Page3Component implements OnInit {
this.curPageData['questions'][this.curQuesIndex]['name'] = this.curPageData['questions'][this.curQuesIndex]['name'] =
options.optionName options.optionName
this.selectedNum = optionId this.selectedNum = optionId
// for (let i = 0; i < this.curQuesLen; i++) {
// for (
// let j = 0;
// j < this.curPageData['questions'][i]['options'].length;
// j++
// ) {
// if (
// options.optionId ==
// this.curPageData['questions'][i].options[j].optionId
// ) {
// this.curPageData['questions'][i]['name'] = this.curPageData[
// 'questions'
// ][i].options[j].optionName
// }
// }
// }
} }
addChild() { addChild() {
......
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