沈明 1 year ago
parent
commit
8008b88ab8
  1. 12
      src/api/votingElection.ts
  2. 31
      src/pages/myElection/index.vue
  3. 784
      src/pages/votingElection/index.vue
  4. BIN
      src/static/img/Group.png

12
src/api/votingElection.ts

@ -1,10 +1,12 @@
import { request } from '@/utils/http' import { request } from '@/utils/http'
// 获取投票选举(正在进行) // 获取投票选举(正在进行)
export function getVoteprogress() { export function getVoteprogress() {
return request.http({ return request.http({
url: '/api/vote_progress', url: '/api/vote_progress',
method: 'GET' method: "GET"
}) })
} }
@ -17,9 +19,11 @@ export function voteMember(data: any) {
} }
// 获取我的选举 // 获取我的选举
export function getMyvote() { export function getMyvote(data:any) {
return request.http({ return request.http({
url: '/api/my_vote', url: '/api/my_vote',
method: 'GET' method: "GET",
data
}) })
} }

31
src/pages/myElection/index.vue

@ -55,6 +55,8 @@
<script setup> <script setup>
import { ref, watch } from 'vue' import { ref, watch } from 'vue'
import { getMyvote } from '../../api/votingElection' import { getMyvote } from '../../api/votingElection'
import useUserStore from '@/store/user'
const userStore = useUserStore()
const electionList = ref([]) const electionList = ref([])
const page = ref(1) const page = ref(1)
@ -106,14 +108,22 @@ const getList = async () => {
try { try {
loading.value = true loading.value = true
let param = {
openid: userStore.openId,
page: page.value,
limit: pageSize.value
}
// //
const mockData = await getMyvote() const mockData = await getMyvote(param).then((res)=> {
console.log(res,66666666666);
// })
dataList.value = [...dataList.value, ...mockData]
//
// electionList.value = [...electionList.value, ...mockData]
electionList.value.push(mockData)
// //
noMoreData.value = mockData.length < pageSize.value // noMoreData.value = mockData.length < pageSize.value
} finally { } finally {
loading.value = false loading.value = false
} }
@ -126,17 +136,10 @@ const loadMore = () => {
getList() getList()
} }
onMounted(() => { onShow(() => {
getList() getList()
}) })
onShow(() => {
if (userStore.mobile) {
uni.navigateTo({
url: '/pages/login/login'
})
}
})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

784
src/pages/votingElection/index.vue

@ -1,386 +1,398 @@
<script setup lang="ts"> <script setup lang="ts">
import { getVoteprogress, voteMember } from '../../api/votingElection' import { getVoteprogress, voteMember } from '../../api/votingElection'
import useUserStore from '@/store/user' import useUserStore from '@/store/user'
const userStore = useUserStore() const userStore = useUserStore()
const xjList = ref({}) const xjList = ref<any>({})
const doSearch = (_formData: { page: number; limit: number }, onSuccess: Function) => {
getVoteprogress().then((res) => { const doSearch = (_formData : { page : number; limit : number }, onSuccess : Function) => {
xjList.value = res.data getVoteprogress().then((res) => {
res.data.data = res.data.candidate const { data } = res as { data : { candidate : any[] } }
// 2. xjList.value = data || {}
delete res.data.candidate onSuccess({
res.data.total = res.data.candidate?.length data: {
const { data } = res as { data: { data: any; total: number } } data: data.candidate || [],
onSuccess({ data }) total: (data.candidate || []).length
}) }
} })
})
const buttlist = ref([ }
{
type: '1', const buttlist = ref([
butname: '同意' {
}, type: '1',
{ butname: '同意'
type: '2', },
butname: '反对' {
}, type: '2',
{ butname: '反对'
type: '3', },
butname: '弃权' {
} type: '3',
]) butname: '弃权'
}
const params = ref([]) ])
const selectBut = (data: any, cardid: any, type: string, butname: string) => {
if (cardid) { const params = ref([])
const target = data.find((card: { id: any }) => card.id === cardid) const selectBut = (data : any, cardid : any, type : string, butname : string) => {
uni.showModal({ if (cardid) {
title: '您本轮选举投' + butname + '票', const target = data.find((card : { id : any }) => card.id === cardid)
content: '确定吗?', uni.showModal({
success: function (res) { title: '您本轮选举投' + butname + '票',
if (res.confirm) { content: '确定吗?',
if (target) { success: function (res) {
target.vote_result = type if (res.confirm) {
} if (target) {
} else if (res.cancel) { target.vote_result = type
console.log('用户点击取消') }
} } else if (res.cancel) {
} console.log('用户点击取消')
}) }
params.value.push(target) }
} else { })
data.forEach((ele: { vote_result: number; id: any }) => { params.value.push(target)
ele.vote_result = 1 } else {
}) data.forEach((ele : { vote_result : number; id : any }) => {
} ele.vote_result = 1
} })
const allChange = () => { }
uni.showModal({ }
title: '您本轮选举全投同意票', const allChange = () => {
content: '确定吗?', uni.showModal({
success: function (res) { title: '您本轮选举全投同意票',
if (res.confirm) { content: '确定吗?',
xjList.value.data?.forEach((ele: { vote_result: number }) => { success: function (res) {
ele.vote_result = 1 if (res.confirm) {
}) xjList.value.data?.forEach((ele : { vote_result : number }) => {
params.value = xjList.value.data ele.vote_result = 1
submit() })
} else if (res.cancel) { params.value = xjList.value.data
console.log('用户点击取消') submit()
} } else if (res.cancel) {
} console.log('用户点击取消')
}) }
} }
})
function extractTwoProps(arr: any, key1: string, key2: string) { }
return arr.map(({ [key1]: prop1, [key2]: prop2 }) => ({
[key1]: prop1, function extractTwoProps(arr : any, key1 : string, key2 : string) {
[key2]: prop2 return arr.map(({ [key1]: prop1, [key2]: prop2 }) => ({
})) [key1]: prop1,
} [key2]: prop2
const submit = () => { }))
let param = { }
openid: userStore.openId, const submit = () => {
id: xjList.value.id, let param = {
candidate: JSON.stringify(extractTwoProps(params.value, 'id', 'vote_result')) openid: userStore.openId,
} id: xjList.value.id,
if (param.candidate === '[]') { candidate: JSON.stringify(extractTwoProps(params.value, 'id', 'vote_result'))
uni.showToast({ }
title: '未选举', if (param.candidate === '[]') {
icon: 'none', // 'success', 'loading', 'none' uni.showToast({
duration: 1500 // ms title: '未选举',
}) icon: 'none', // 'success', 'loading', 'none'
} else { duration: 1500 // ms
voteMember(param).then((res) => { })
console.log(res, 555555555555555) } else {
}) voteMember(param).then((res) => {
} console.log(res, 555555555555555)
} })
onShow(() => { }
if (userStore.mobile) { }
uni.navigateTo({ onShow(() => {
url: '/pages/login/login' if (!userStore.mobile) {
}) uni.navigateTo({
} url: '/pages/login/login'
}) })
</script> }
})
<template> </script>
<!-- 你的页面内容 -->
<view class="box"> <template>
<view class="headpart"> <!-- 你的页面内容 -->
<view class="title">{{ xjList.title }}</view> <view class="box" v-if="xjList.length != 0">
<view class="time">投票开始时间{{ xjList.start_time }}</view> <view class="headpart">
<view class="time">投票截止时间{{ xjList.end_time }}</view> <view class="title">{{ xjList.title }}</view>
</view> <view class="time">投票开始时间{{ xjList.start_time }}</view>
<ex-list ref="reListRef" custom-list-type="custom" :on-form-search="doSearch"> <view class="time">投票截止时间{{ xjList.end_time }}</view>
<template v-slot="{ data }"> </view>
<view class="tppart"> <ex-list ref="reListRef" custom-list-type="custom" :on-form-search="doSearch">
<view class="tpone" v-for="(row, index) of data" :key="'tpone' + index"> <template v-slot="{ data }">
<view class="topp"> <view class="tppart">
<img style="width: 96rpx; height: 96rpx; border-radius: 50%" :src="row.photo" alt="" /> <view class="tpone" v-for="(row, index) of data" :key="'tpone' + index">
<view class="rightpart"> <view class="topp">
<view class="name"> <img style="width: 96rpx; height: 96rpx; border-radius: 50%" :src="row.photo" alt="" />
{{ row.name }} <view class="rightpart">
</view> <view class="name">
<view class="class"> {{ row.name }}
{{ row.position }} </view>
</view> <view class="class">
</view> {{ row.position }}
</view> </view>
<view class="bottomp"> </view>
<view </view>
class="minbut" <view class="bottomp">
v-for="(item, ele) in buttlist" <view class="minbut" v-for="(item, ele) in buttlist" :key="ele"
:key="ele" @click="selectBut(data, row.id, item.type, item.butname)"
@click="selectBut(data, row.id, item.type, item.butname)" :class="{ active: row.vote_result === item.type }">
:class="{ active: row.vote_result === item.type }" {{ item.butname }}
> </view>
{{ item.butname }} </view>
</view> </view>
</view> </view>
</view> </template>
</view> </ex-list>
</template> <view class="bottbutton">
</ex-list> <view class="qbty" @click="allChange">全部同意</view>
<view class="bottbutton"> <view class="tjtp" @click="submit">提交投票</view>
<view class="qbty" @click="allChange">全部同意</view> </view>
<view class="tjtp" @click="submit">提交投票</view> </view>
</view> <view style="display: grid;align-items: center;justify-content: center;width: 100%;height: 100vh;align-content: center;" v-else>
</view> <img style="width: 188px;height: 140px;" src="@/static/img/Group.png" alt="" />
</template> <text class="nodata">
暂时没有选举 请刷新重试
<style scoped lang="scss"> </text>
.box { </view>
width: 100%; </template>
background-color: #f9fafb;
<style scoped lang="scss">
.headpart { .box {
width: 92%; width: 100%;
height: 194rpx; background-color: #f9fafb;
border-radius: 24rpx;
background-color: #eff6ff; .headpart {
margin: 32rpx auto; width: 92%;
padding: 20rpx 3%; height: 194rpx;
border-radius: 24rpx;
.title { background-color: #eff6ff;
color: #2563eb; margin: 32rpx auto;
font-size: 28rpx; padding: 20rpx 3%;
margin-top: 16rpx;
} .title {
color: #2563eb;
.time { font-size: 28rpx;
margin-top: 16rpx; margin-top: 16rpx;
color: #4b5563; }
font-size: 28rpx;
} .time {
} margin-top: 16rpx;
color: #4b5563;
.tppart { font-size: 28rpx;
width: 100%; }
max-height: 69vh; }
overflow-y: auto;
display: grid; .tppart {
justify-items: center; width: 100%;
max-height: 69vh;
.tpone { overflow-y: auto;
width: 91%; display: grid;
height: 264rpx; justify-items: center;
padding: 20rpx 4%;
box-sizing: border-box; .tpone {
border-radius: 24rpx; width: 91%;
background: linear-gradient(0deg, rgba(0, 0, 0, 0.001), rgba(0, 0, 0, 0.001)), #ffffff; height: 264rpx;
box-sizing: border-box; padding: 20rpx 4%;
border: 2rpx solid #f3f4f6; box-sizing: border-box;
box-shadow: border-radius: 24rpx;
0rpx 2rpx 4rpx -2rpx rgba(0, 0, 0, 0.1), background: linear-gradient(0deg, rgba(0, 0, 0, 0.001), rgba(0, 0, 0, 0.001)), #ffffff;
0rpx 2rpx 6rpx 0rpx rgba(0, 0, 0, 0.1); box-sizing: border-box;
margin-top: 32rpx; border: 2rpx solid #f3f4f6;
display: grid; box-shadow:
0rpx 2rpx 4rpx -2rpx rgba(0, 0, 0, 0.1),
.topp { 0rpx 2rpx 6rpx 0rpx rgba(0, 0, 0, 0.1);
display: flex; margin-top: 32rpx;
display: grid;
.rightpart {
margin-left: 32rpx; .topp {
display: grid; display: flex;
justify-items: left;
align-content: baseline; .rightpart {
margin-left: 32rpx;
.name { display: grid;
font-family: Roboto; justify-items: left;
font-size: 28rpx; align-content: baseline;
font-weight: 500;
line-height: 42rpx; .name {
letter-spacing: normal; font-family: Roboto;
color: #000000; font-size: 28rpx;
margin-top: 7rpx; font-weight: 500;
} line-height: 42rpx;
letter-spacing: normal;
.class { color: #000000;
font-family: Roboto; margin-top: 7rpx;
font-size: 28rpx; }
font-weight: normal;
line-height: 40rpx; .class {
letter-spacing: normal; font-family: Roboto;
color: #6b7280; font-size: 28rpx;
margin-top: 7rpx; font-weight: normal;
} line-height: 40rpx;
} letter-spacing: normal;
} color: #6b7280;
margin-top: 7rpx;
.bottomp { }
display: flex; }
justify-content: space-between; }
gap: 0rpx 20rpx;
.bottomp {
.minbut { display: flex;
flex: 1; justify-content: space-between;
width: 190rpx; gap: 0rpx 20rpx;
height: 76rpx;
/* 自动布局 */ .minbut {
display: flex; flex: 1;
justify-content: center; width: 190rpx;
padding: 16rpx 32rpx; height: 76rpx;
flex-wrap: wrap; /* 自动布局 */
align-content: flex-start; display: flex;
border-radius: 8rpx; justify-content: center;
background: #ffffff; padding: 16rpx 32rpx;
box-sizing: border-box; flex-wrap: wrap;
border: 2rpx solid #d1d5db; align-content: flex-start;
font-family: Roboto; border-radius: 8rpx;
font-size: 28rpx; background: #ffffff;
font-weight: normal; box-sizing: border-box;
line-height: 40rpx; border: 2rpx solid #d1d5db;
text-align: center; font-family: Roboto;
letter-spacing: normal; font-size: 28rpx;
color: #4b5563; font-weight: normal;
} line-height: 40rpx;
text-align: center;
.minbut.active { letter-spacing: normal;
border: 2rpx solid #2563eb; color: #4b5563;
color: #2563eb; }
}
} .minbut.active {
} border: 2rpx solid #2563eb;
color: #2563eb;
.tpone:first-child { }
margin-top: 0; }
} }
}
.tpone:first-child {
.bottbutton { margin-top: 0;
width: 100%; }
height: 10vh; }
display: flex;
padding: 24rpx 32rpx; .bottbutton {
gap: 0rpx 24rpx; width: 100%;
flex-wrap: wrap; height: 10vh;
align-content: flex-start; display: flex;
background: #ffffff; padding: 24rpx 32rpx;
box-sizing: border-box; gap: 0rpx 24rpx;
border-width: 2rpx 0rpx 0rpx 0rpx; flex-wrap: wrap;
border-style: solid; align-content: flex-start;
border-color: #f3f4f6; background: #ffffff;
position: fixed; box-sizing: border-box;
bottom: 0; border-width: 2rpx 0rpx 0rpx 0rpx;
border-style: solid;
.qbty { border-color: #f3f4f6;
width: 331rpx; position: fixed;
height: 90rpx; bottom: 0;
/* 自动布局 */
display: flex; .qbty {
box-sizing: border-box; width: 331rpx;
justify-content: center; height: 90rpx;
padding: 24rpx 0rpx; /* 自动布局 */
gap: 0rpx 20rpx; display: flex;
flex-wrap: wrap; box-sizing: border-box;
border-radius: 8rpx; justify-content: center;
background: #eff6ff; padding: 24rpx 0rpx;
font-family: Roboto; gap: 0rpx 20rpx;
font-size: 28rpx; flex-wrap: wrap;
font-weight: 500; border-radius: 8rpx;
line-height: 42rpx; background: #eff6ff;
text-align: center; font-family: Roboto;
letter-spacing: normal; font-size: 28rpx;
color: #2563eb; font-weight: 500;
} line-height: 42rpx;
text-align: center;
.tjtp { letter-spacing: normal;
width: 331rpx; color: #2563eb;
height: 90rpx; }
/* 自动布局 */
display: flex; .tjtp {
box-sizing: border-box; width: 331rpx;
justify-content: center; height: 90rpx;
padding: 24rpx 0rpx; /* 自动布局 */
gap: 0rpx 20rpx; display: flex;
flex-wrap: wrap; box-sizing: border-box;
border-radius: 8rpx; justify-content: center;
background: #2563eb; padding: 24rpx 0rpx;
font-family: Roboto; gap: 0rpx 20rpx;
font-size: 28rpx; flex-wrap: wrap;
font-weight: 500; border-radius: 8rpx;
line-height: 42rpx; background: #2563eb;
text-align: center; font-family: Roboto;
letter-spacing: normal; font-size: 28rpx;
color: #ffffff; font-weight: 500;
} line-height: 42rpx;
} text-align: center;
letter-spacing: normal;
.address-items { color: #ffffff;
padding: 20rpx 15rpx 32rpx 28rpx; }
background-color: #fff; }
border-bottom: 2rpx solid #f5f5f5;
.address-items {
.left { padding: 20rpx 15rpx 32rpx 28rpx;
flex: 1; background-color: #fff;
overflow: hidden; border-bottom: 2rpx solid #f5f5f5;
.name { .left {
font-size: 28rpx; flex: 1;
font-weight: 700; overflow: hidden;
color: #101010;
line-height: 40rpx; .name {
margin-right: 16rpx; font-size: 28rpx;
} font-weight: 700;
color: #101010;
.isdefault { line-height: 40rpx;
font-size: 20rpx; margin-right: 16rpx;
font-weight: 400; }
color: #fff;
padding: 4rpx 12rpx; .isdefault {
border-radius: 8rpx; font-size: 20rpx;
background: linear-gradient(90deg, #4778ff 0%, #4778ffb8 100%); font-weight: 400;
} color: #fff;
padding: 4rpx 12rpx;
.info { border-radius: 8rpx;
width: 100%; background: linear-gradient(90deg, #4778ff 0%, #4778ffb8 100%);
color: #666; }
font-size: 24rpx;
font-weight: 400; .info {
margin-top: 12rpx; width: 100%;
} color: #666;
} font-size: 24rpx;
font-weight: 400;
.right { margin-top: 12rpx;
width: 140rpx; }
padding-left: 32rpx; }
font-size: 24rpx;
font-weight: 400; .right {
color: #4979ff; width: 140rpx;
text-align: right; padding-left: 32rpx;
} font-size: 24rpx;
} font-weight: 400;
color: #4979ff;
.buts { text-align: right;
width: 100%; }
height: 10vh; }
background-color: F3F4F6;
position: fixed; .buts {
bottom: 0; width: 100%;
border-top: 2rpx solid #ebebec; height: 10vh;
} background-color: F3F4F6;
} position: fixed;
</style> bottom: 0;
border-top: 2rpx solid #ebebec;
}
}
.nodata {
margin-top: 43px;
font-family: Source Han Sans;
font-size: 18px;
font-weight: 500;
letter-spacing: normal;
color: #34343F;
}
</style>

BIN
src/static/img/Group.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Loading…
Cancel
Save