加入投票功能

This commit is contained in:
java110 2021-05-24 06:35:50 +08:00
parent 12a11c7ea2
commit 75362a6342
4 changed files with 89 additions and 17 deletions

View File

@ -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);
}
});
})
}

View File

@ -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',

View File

@ -12,6 +12,7 @@
<text class="margin-right-xs">结束时间</text> {{question.endTime}}</view>
</view>
<view class="action" v-if="question.state == '0'">已结束</view>
<view class="action" v-else-if="question.state == '2'">已投票</view>
</view>
</view>
<view class="cu-list menu" v-if="questions.length === 0">
@ -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

View File

@ -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
})
})