diff --git a/api/question/questionApi.js b/api/question/questionApi.js index 8add50f..f5cbfe7 100644 --- a/api/question/questionApi.js +++ b/api/question/questionApi.js @@ -61,4 +61,31 @@ export function queryQuestionAnswerTitle(_data) { }) } +/** + * add by wuxw + * @param {Object} _data 保存 用户地址 + */ +export function saveUserQuestionAnswerValue(_data){ + + return new Promise((resolve, reject) => { + let moreRooms = []; + request({ + url: url.saveUserQuestionAnswerValue, + method: "POST", + data: _data, //动态数据 + success: function(res) { + let _data = res.data; + if (_data.code == 0) { + resolve(_data); + return ; + } + reject(_data.msg); + }, + fail: function(e) { + reject(e); + } + }); + }) +} + diff --git a/constant/url.js b/constant/url.js index b848b96..74058fc 100644 --- a/constant/url.js +++ b/constant/url.js @@ -116,6 +116,7 @@ export default { queryContract:baseUrl + "app/contract/queryContract", queryQuestionAnswer:baseUrl + "app/questionAnswer/queryQuestionAnswer", queryQuestionAnswerTitle:baseUrl + "app/questionAnswer/queryQuestionAnswerTitle", + saveUserQuestionAnswerValue:baseUrl + "app/userQuestionAnswer/saveUserQuestionAnswerValue", NEED_NOT_LOGIN_PAGE: [ '/pages/login/login', diff --git a/pages/questionAnswer/questionAnswer.vue b/pages/questionAnswer/questionAnswer.vue index db50ab3..ef86de9 100644 --- a/pages/questionAnswer/questionAnswer.vue +++ b/pages/questionAnswer/questionAnswer.vue @@ -12,6 +12,7 @@ 结束时间: {{question.endTime}} 已结束 + 已投票 @@ -41,13 +42,15 @@ communityId: "", questions: [], currPageIndex: 0, - pageSize: 10 + pageSize: 10, + userId:'' }; }, onLoad: function(options) { let that = this; context.onLoad(options); that.communityId = context.getUserInfo().communityId; + that.userId = context.getUserInfo().userId; queryQuestionAnswer({ page:1, @@ -62,7 +65,10 @@ if(_endTime.getTime() > new Date().getTime()){ item.state = '1'; }else{ - item.state = '0' + item.state = '0'; + } + if(item.userId == that.userId){ + item.state = '2'; } item.startTime = item.startTime.replace(/:\d{1,2}$/, ' '); item.endTime = item.endTime.replace(/:\d{1,2}$/, ' '); @@ -82,6 +88,13 @@ }) return ; } + if(_question.state == '2'){ + uni.showToast({ + icon:'none', + title:'此投票问卷已投票' + }) + return ; + } let that = this; this.vc.navigateTo({ url: "/pages/questionAnswerDetail/questionAnswerDetail?qaId=" + _question.qaId+"&objType="+_question.objType diff --git a/pages/questionAnswerDetail/questionAnswerDetail.vue b/pages/questionAnswerDetail/questionAnswerDetail.vue index e0d3ba1..9ee1a7b 100644 --- a/pages/questionAnswerDetail/questionAnswerDetail.vue +++ b/pages/questionAnswerDetail/questionAnswerDetail.vue @@ -36,7 +36,7 @@ const factory = context.factory; import { - queryQuestionAnswerTitle + queryQuestionAnswerTitle,saveUserQuestionAnswerValue } from '../../api/question/questionApi.js' export default { @@ -108,22 +108,53 @@ submitQuestionAnswer: function(e) { console.log(this.titles); + + let _questionAnswerTitles = []; + let _titles = this.titles; + let _valueId = ''; + _titles.forEach(item => { + + if (item.titleType == '2002') { + item.radio.forEach(_radio=>{ + _questionAnswerTitles.push({ + valueContent:_radio.valueId, + titleId:item.titleId, + titleType:item.titleType + }) + }) + } else { + _valueId = item.radio; + _questionAnswerTitles.push({ + valueContent:_valueId, + titleId:item.titleId, + titleType:item.titleType + }) + } + }) + let obj = { - "repairName": this.bindRepairName, - "repairType": this.repairType, - "appointmentTime": this.bindDate + " " + this.bindTime + ":00", - "tel": this.bindTel, - "roomId": this.roomId, - "photos": [], - "context": this.context, - "userId": this.userId, - "userName": this.userName, - "communityId": this.communityId, - "bindDate": this.bindDate, - "bindTime": this.bindTime, - "repairObjType": this.repairObjType, - "repairChannel": 'Z' + "qaId": this.qaId, + "objType": this.objType, + "objId": context.getUserInfo().communityId, + "answerType": '1002', + questionAnswerTitles:_questionAnswerTitles } + + saveUserQuestionAnswerValue(obj) + .then(_data=>{ + uni.showToast({ + icon:'none', + title:'投票成功' + }); + uni.navigateBack({ + delta:1 + }) + },err=>{ + uni.showToast({ + icon:'none', + title:err + }) + })