沈明 1 year ago
parent
commit
8008b88ab8
  1. 10
      src/api/votingElection.ts
  2. 25
      src/pages/myElection/index.vue
  3. 44
      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">

44
src/pages/votingElection/index.vue

@ -3,16 +3,18 @@ import { getVoteprogress, voteMember } from '../../api/votingElection'
import useUserStore from '@/store/user'
const userStore = useUserStore()
const xjList = ref({})
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
}
})
})
}
@ -98,7 +100,7 @@ const submit = () => {
}
}
onShow(() => {
if (userStore.mobile) {
if (!userStore.mobile) {
uni.navigateTo({
url: '/pages/login/login'
})
@ -108,7 +110,7 @@ onShow(() => {
<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,6 +147,12 @@ 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">
@ -383,4 +387,12 @@ onShow(() => {
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