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

10
src/api/votingElection.ts

@ -1,10 +1,12 @@
import { request } from '@/utils/http'
// 获取投票选举(正在进行)
export function getVoteprogress() {
return request.http({
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({
url: '/api/my_vote',
method: 'GET'
method: "GET",
data
})
}

25
src/pages/myElection/index.vue

@ -55,6 +55,8 @@
<script setup>
import { ref, watch } from 'vue'
import { getMyvote } from '../../api/votingElection'
import useUserStore from '@/store/user'
const userStore = useUserStore()
const electionList = ref([])
const page = ref(1)
@ -106,14 +108,22 @@ const getList = async () => {
try {
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 {
loading.value = false
}
@ -126,17 +136,10 @@ const loadMore = () => {
getList()
}
onMounted(() => {
onShow(() => {
getList()
})
onShow(() => {
if (userStore.mobile) {
uni.navigateTo({
url: '/pages/login/login'
})
}
})
</script>
<style scoped lang="scss">

90
src/pages/votingElection/index.vue

@ -1,22 +1,24 @@
<script setup lang="ts">
import { getVoteprogress, voteMember } from '../../api/votingElection'
import useUserStore from '@/store/user'
const userStore = useUserStore()
import { getVoteprogress, voteMember } from '../../api/votingElection'
import useUserStore from '@/store/user'
const userStore = useUserStore()
const xjList = ref({})
const doSearch = (_formData: { page: number; limit: number }, onSuccess: Function) => {
const xjList = ref<any>({})
const doSearch = (_formData : { page : number; limit : number }, onSuccess : Function) => {
getVoteprogress().then((res) => {
xjList.value = res.data
res.data.data = res.data.candidate
// 2.
delete res.data.candidate
res.data.total = res.data.candidate?.length
const { data } = res as { data: { data: any; total: number } }
onSuccess({ data })
const { data } = res as { data : { candidate : any[] } }
xjList.value = data || {}
onSuccess({
data: {
data: data.candidate || [],
total: (data.candidate || []).length
}
})
}
})
}
const buttlist = ref([
const buttlist = ref([
{
type: '1',
butname: '同意'
@ -29,12 +31,12 @@ const buttlist = ref([
type: '3',
butname: '弃权'
}
])
])
const params = ref([])
const selectBut = (data: any, cardid: any, type: string, butname: string) => {
const params = ref([])
const selectBut = (data : any, cardid : any, type : string, butname : string) => {
if (cardid) {
const target = data.find((card: { id: any }) => card.id === cardid)
const target = data.find((card : { id : any }) => card.id === cardid)
uni.showModal({
title: '您本轮选举投' + butname + '票',
content: '确定吗?',
@ -50,18 +52,18 @@ const selectBut = (data: any, cardid: any, type: string, butname: string) => {
})
params.value.push(target)
} else {
data.forEach((ele: { vote_result: number; id: any }) => {
data.forEach((ele : { vote_result : number; id : any }) => {
ele.vote_result = 1
})
}
}
const allChange = () => {
}
const allChange = () => {
uni.showModal({
title: '您本轮选举全投同意票',
content: '确定吗?',
success: function (res) {
if (res.confirm) {
xjList.value.data?.forEach((ele: { vote_result: number }) => {
xjList.value.data?.forEach((ele : { vote_result : number }) => {
ele.vote_result = 1
})
params.value = xjList.value.data
@ -71,15 +73,15 @@ const allChange = () => {
}
}
})
}
}
function extractTwoProps(arr: any, key1: string, key2: string) {
function extractTwoProps(arr : any, key1 : string, key2 : string) {
return arr.map(({ [key1]: prop1, [key2]: prop2 }) => ({
[key1]: prop1,
[key2]: prop2
}))
}
const submit = () => {
}
const submit = () => {
let param = {
openid: userStore.openId,
id: xjList.value.id,
@ -96,19 +98,19 @@ const submit = () => {
console.log(res, 555555555555555)
})
}
}
onShow(() => {
if (userStore.mobile) {
}
onShow(() => {
if (!userStore.mobile) {
uni.navigateTo({
url: '/pages/login/login'
})
}
})
})
</script>
<template>
<!-- 你的页面内容 -->
<view class="box">
<view class="box" v-if="xjList.length != 0">
<view class="headpart">
<view class="title">{{ xjList.title }}</view>
<view class="time">投票开始时间{{ xjList.start_time }}</view>
@ -130,13 +132,9 @@ onShow(() => {
</view>
</view>
<view class="bottomp">
<view
class="minbut"
v-for="(item, ele) in buttlist"
:key="ele"
<view class="minbut" v-for="(item, ele) in buttlist" :key="ele"
@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>
</view>
@ -149,10 +147,16 @@ onShow(() => {
<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>
<img style="width: 188px;height: 140px;" src="@/static/img/Group.png" alt="" />
<text class="nodata">
暂时没有选举 请刷新重试
</text>
</view>
</template>
<style scoped lang="scss">
.box {
.box {
width: 100%;
background-color: #f9fafb;
@ -382,5 +386,13 @@ onShow(() => {
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