浏览代码

我的家园

wulanhaote
yujk 3 年前
父节点
当前提交
8f15cb2afc
共有 5 个文件被更改,包括 330 次插入70 次删除
  1. +33
    -0
      src/api/onlineHome/poll.js
  2. +9
    -0
      src/router/index.js
  3. +68
    -70
      src/views/onlineHome/homePoll.vue
  4. +220
    -0
      src/views/onlineHome/homePollDetail.vue
  5. 二进制
      static/images/onlineHome/voteMenu.png

+ 33
- 0
src/api/onlineHome/poll.js 查看文件

@@ -0,0 +1,33 @@
import request from '@/utils/request'

// 查询投票主题列表
export function listPoll(query) {
return request({
url: '/poll/poll/list',
method: 'get',
params: query
})
}
// 查询投票主题详细
export function getPoll(id) {
return request({
url: '/poll/poll/get/' + id,
method: 'get'
})
}
// 新增投票主题
export function votePoll(id,list) {
return request({
url: '/poll/poll/votePoll/'+ id +'/'+ list,
method: 'get'
})
}

// 查询投票详情列表
export function listPollVote(query) {
return request({
url: '/poll/pollVote/list',
method: 'get',
params: query
})
}

+ 9
- 0
src/router/index.js 查看文件

@@ -645,6 +645,15 @@ export const constantRoutes = [
}, },
component: (resolve) => require(['@/views/onlineHome/zdjs'], resolve) component: (resolve) => require(['@/views/onlineHome/zdjs'], resolve)
}, },
{
path: '/onlineHome/homePollDetail',
name: 'homePollDetail',
meta: {
title: '投票详情',
hidden: true,
},
component: (resolve) => require(['@/views/onlineHome/homePollDetail'], resolve)
},
{ {
path: '/flowChart', path: '/flowChart',
name: 'flowChart', name: 'flowChart',


+ 68
- 70
src/views/onlineHome/homePoll.vue 查看文件

@@ -6,83 +6,54 @@
@click-left="$router.back(-1)" @click-left="$router.back(-1)"
> >
<template #right> <template #right>
<van-image src=""></van-image>
<van-image
width="18"
height="18"
src="../../../static/images/onlineHome/voteMenu.png"/>
</template> </template>
</van-nav-bar> </van-nav-bar>
<van-row style="margin-top: 20px">
<van-col span="20" offset="2">
<H3 style="line-height: 20px;">活动主题活动主题活动主题活动主题</H3>
</van-col>
</van-row>
<van-row style="margin-top: 10px">
<van-col span="20" offset="2">
<h4 style="color: #878787;line-height: 20px;">活动描述活动描述活动描述</h4>
</van-col>
</van-row>
<van-list>
<van-row v-for="(item,index) in list" :key="index" style="background:#fff;width: 96%;margin:2%;border-radius: 6px;overflow: hidden;padding-top: 10px;padding-bottom: 10px;box-shadow: 0px 3px 6px 0px rgba(0,0,0,0.16);">
<van-col span="3" style="text-align: center;">
<van-image
width="18"
height="18"
style="display: inline-block;margin-top: 16px"
src="../../../static/images/onlineHome/home3.png"
/>
</van-col>
<van-col span="17">
<van-row>
<h3 style="line-height: 26px">{{item.subjectName}}</h3>
</van-row>
<van-row>
<p v-if="new Date(item.startTime) > new Date()" style="line-height: 26px">
开始时间:{{item.startTime}}
</p>
<p v-if="new Date(item.startTime) <= new Date() && new Date(item.endTime) >= new Date()" style="line-height: 26px">
截止时间:{{item.endTime}}
</p>
<p v-if="new Date(item.endTime) < new Date()" style="line-height: 26px">
发起人:{{item.promoters}}
</p>
</van-row>
</van-col>
<van-col span="4">
<h3 v-if="new Date(item.startTime) > new Date()" style="line-height: 50px;color: #1D6FE9" >未开始</h3>
<h3 v-if="new Date(item.endTime) < new Date()" style="line-height: 50px;color: #1D6FE9" @click="go(item.id)">查看</h3>
<h3 v-if="new Date(item.startTime) <= new Date() && new Date(item.endTime) >= new Date()" style="line-height: 50px;color: #1D6FE9" @click="go(item.id)">投票</h3>
</van-col>
</van-row>
</van-list>


<van-row style="margin-top: 10px">
<van-col span="9" offset="2">
<van-image
width="12"
height="12"
style="display: inline-block;"
src="../../../static/images/onlineHome/vote1.png"
/>
<p style="display: inline-block;color:#1D6FE9 ">实名</p>
<van-image
width="12"
height="12"
style="display: inline-block;"
src="../../../static/images/onlineHome/vote1.png"
/>
<p style="display: inline-block;color:#1D6FE9 ">单选</p>
<van-image
width="12"
height="12"
style="display: inline-block;"
src="../../../static/images/onlineHome/vote1.png"
/>
<p style="display: inline-block;color:#1D6FE9 ">多选</p>
</van-col>
<van-col span="8" offset="5">
<van-image
width="12"
height="12"
style="display: inline-block;"
src="../../../static/images/onlineHome/vote.png"
/>
<p style="display: inline-block">3人已参与</p>
</van-col>
</van-row>
<van-checkbox-group v-model="result" style="margin-top: 20px">
<van-cell-group style="width: 96%;margin:2%;border-radius: 6px;overflow: hidden;padding-top: 10px;padding-bottom: 10px;box-shadow: 0px 3px 6px 0px rgba(0,0,0,0.16);">
<van-cell title="选项1">
<template #icon>
<van-image
fit="contain"
height="18"
style="margin-right: 10px"
src="../../../static/images/onlineHome/home3.png"
/>
</template>
<van-checkbox name="a" style="float: right"/>
</van-cell>
<van-row>
<van-col span="15" :offset="2" style=" margin-top: 7px;">
<van-progress :percentage="87" :show-pivot="false"/>
</van-col>
<van-col span="5" :offset="2">
57票 87%
</van-col>
</van-row>
</van-cell-group>
</van-checkbox-group>
<onlineHomeIndex></onlineHomeIndex> <onlineHomeIndex></onlineHomeIndex>
</div> </div>
</template> </template>


<script> <script>
import onlineHomeIndex from "../onlineHomeIndex"; import onlineHomeIndex from "../onlineHomeIndex";
import {getFinancialInAndOut} from "../../api/onlineHome/finacial";
import {listPoll} from "../../api/onlineHome/poll";


export default { export default {
components: { components: {
@@ -92,17 +63,44 @@
data() { data() {
return { return {
activeName: 'a', activeName: 'a',
list: [],
list: [{},{}],
loading: false, loading: false,
finished: false, finished: false,
result:[], result:[],
// 查询参数
queryParams: {
// 分页
pageNum: 1,
pageSize: 10,
// 查询排序
//orderByColumn: "id",
//isAsc: "desc",
subjectName: null,
status: 3
},
}; };
}, },
created() {
this.getList();
},
methods: {
go(val){
this.$router.push({path:'/onlineHome/homePollDetail',query:{id:val}});
},
getList(){
this.loading = true;
listPoll(this.queryParams).then(response => {
this.list = response.rows;
this.total = response.total;
this.loading = false;
});
},
},
} }
</script> </script>


<style scoped> <style scoped>
>>>.van-cell::after {
>>>.van-col::after {
border-bottom: none; border-bottom: none;
} }
</style> </style>

+ 220
- 0
src/views/onlineHome/homePollDetail.vue 查看文件

@@ -0,0 +1,220 @@
<template>
<div class="app-container">
<van-nav-bar
title="投票"
left-arrow
@click-left="$router.back(-1)"
>
<template #right>
<van-image src=""></van-image>
</template>
</van-nav-bar>
<van-row style="margin-top: 20px">
<van-col span="20" offset="2">
<H3 style="line-height: 20px;">{{form.subjectName}}</H3>
</van-col>
</van-row>
<van-row style="margin-top: 10px">
<van-col span="20" offset="2">
<h4 style="color: #878787;line-height: 20px;">{{form.description}}</h4>
</van-col>
</van-row>

<van-row style="margin-top: 10px">
<van-col span="9" offset="2">
<van-image
v-if="form.anonymous==1"
width="12"
height="12"
style="display: inline-block;"
src="../../../static/images/onlineHome/vote1.png"
/>
<p style="display: inline-block;color:#1D6FE9 ">实名</p>
<van-image
v-if="form.type==1"
width="12"
height="12"
style="display: inline-block;"
src="../../../static/images/onlineHome/vote1.png"
/>
<p v-if="form.type==1" style="display: inline-block;color:#1D6FE9 ">单选</p>
<van-image
v-if="form.type==2"
width="12"
height="12"
style="display: inline-block;"
src="../../../static/images/onlineHome/vote1.png"
/>
<p v-if="form.type==2" style="display: inline-block;color:#1D6FE9 ">多选</p>
</van-col>
<van-col span="8" offset="5">
<van-image
width="12"
height="12"
style="display: inline-block;"
src="../../../static/images/onlineHome/vote.png"
/>
<p style="display: inline-block">{{this.form.nums}}人已参与</p>
</van-col>
</van-row>
<van-checkbox-group v-if="form.type==2" v-model="result" style="margin-top: 20px">
<van-cell-group v-for="(item,index) in pollOptions" :key="index" style="width: 96%;margin:2%;border-radius: 6px;overflow: hidden;padding-top: 10px;padding-bottom: 10px;box-shadow: 0px 3px 6px 0px rgba(0,0,0,0.16);">
<van-cell :title="item.name">
<template #icon>
<van-image
fit="contain"
height="18"
style="margin-right: 10px"
src="../../../static/images/onlineHome/home3.png"
/>
</template>
<van-checkbox :name="item.id" style="float: right"/>
</van-cell>
<van-row>
<van-col span="15" :offset="2" style="margin-top: 7px;">
<van-progress v-if="result.indexOf(item.id)==-1" :percentage="voteNum>0?((item.num/voteNum)*100).toFixed(2):0" :show-pivot="false"/>
<van-progress v-if="result.indexOf(item.id)!=-1" :percentage="(voteNum+result.length)>0?(((item.num+1)/(voteNum+result.length))*100).toFixed(2):0" :show-pivot="false"/>
</van-col>
<van-col span="5" :offset="2" v-if="result.indexOf(item.id)==-1">
{{item.num}}票 {{voteNum>0?((item.num/voteNum)*100).toFixed(2):0}}%
</van-col>
<van-col span="5" :offset="2" v-if="result.indexOf(item.id)!=-1">
{{item.num+1}}票 {{(voteNum+result.length)>0?(((item.num+1)/(voteNum+result.length))*100).toFixed(2):0}}%
</van-col>
</van-row>
</van-cell-group>
</van-checkbox-group>
<van-radio-group v-if="form.type==1" v-model="result1" style="margin-top: 20px">
<van-cell-group v-for="(item,index) in pollOptions" :key="index" style="width: 96%;margin:2%;border-radius: 6px;overflow: hidden;padding-top: 10px;padding-bottom: 10px;box-shadow: 0px 3px 6px 0px rgba(0,0,0,0.16);">
<van-cell :title="item.name">
<template #icon>
<van-image
fit="contain"
height="18"
style="margin-right: 10px"
src="../../../static/images/onlineHome/home3.png"
/>
</template>
<van-radio :name="item.id" style="float: right" />
</van-cell>
<van-row>
<van-col span="15" :offset="2" style="margin-top: 7px;">
<van-progress v-if="result1!=item" :percentage="voteNum>0?((item.num/voteNum)*100).toFixed(2):0" :show-pivot="false"/>
<van-progress v-if="result1==item" :percentage="voteNum>0?(((item.num+1)/(voteNum+1))*100).toFixed(2):0" :show-pivot="false"/>
</van-col>
<van-col span="5" :offset="2" v-if="result1!=item.id">
{{item.num}}票 {{voteNum>0?((item.num/voteNum)*100).toFixed(2):0}}%
</van-col>
<van-col span="5" :offset="2" v-if="result1==item.id">
{{item.num+1}}票 {{voteNum>0?(((item.num+1)/(voteNum+1))*100).toFixed(2):0}}%
</van-col>
</van-row>
</van-cell-group>
</van-radio-group>
<van-row style="text-align: center;margin-top: 40px" v-if="isPoll">
<van-button color="#1D6FE9" style="border-radius: 6px;width: 90%;margin: 0 auto" @click="submit">提交</van-button>
</van-row>
<onlineHomeIndex></onlineHomeIndex>
</div>
</template>

<script>
import onlineHomeIndex from "../onlineHomeIndex";
import {getPoll, listPollVote, votePoll} from "../../api/onlineHome/poll";

export default {
components: {
onlineHomeIndex
},
name: "homePollDetail",
data() {
return {
loading: false,
form:{},
pollOptions:[],
id:this.$route.query.id,
voteNum:0,
result:[],
result1:"",
isPoll:true,
};
},
created() {
this.getInfo(this.id);
listPollVote().then(res => {
if(res.rows.length>0){
res.rows.map(r => {
if(r.pollId==this.id){
this.isPoll=false
}
})
}
})
},
methods:{
reset(){
this.pollOptions = []
},
getInfo(val){
this.reset();
this.loading = true
getPoll(val).then(response => {
response.data.options.map(res => {
this.voteNum += res.num
this.pollOptions.push(res)
})
this.form = response.data;
this.loading = true
});
},
submit(){
let list = []
let _this = this
if (this.form.type == 1) {
if (this.result1 != "") {
list.push(this.pollRadioValue)
} else {
this.$toast({
icon: 'error', // 找到自己需要的图标
message: '请选择一个选项',
duration:"1000",
onClose:function(){
return false;
}
})

}
} else {
if (this.result.length > 0) {
list = this.result
} else {
this.$toast({
icon: 'error', // 找到自己需要的图标
message: '请至少选择一个选项',
duration:"1000",
onClose:function(){
return false;
}
})
}
}
votePoll(this.id,list).then(response => {
this.$toast({
icon: 'success', // 找到自己需要的图标
message: '保存成功',
duration:"1000",
onClose:function(){
_this.getInfo(this.id);
}
})
});
},
},
}
</script>

<style scoped>
>>>.van-cell::after {
border-bottom: none;
}
</style>

二进制
static/images/onlineHome/voteMenu.png 查看文件

之前 之后
宽度: 40  |  高度: 36  |  大小: 800 B

正在加载...
取消
保存