Browse Source

对接接口

dev
岳鹏龙 1 year ago
parent
commit
63d248f227
  1. 10
      src/api/votingElection.ts
  2. 14
      src/pages/myElection/index.vue
  3. 42
      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' 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
}) })
} }

14
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,11 +108,19 @@ const getList = async () => {
try { try {
loading.value = true loading.value = true
let param = {
openid: userStore.openId,
page: page.value,
limit: pageSize.value
}
console.log(param,5555555555);
// //
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]
// //
noMoreData.value = mockData.length < pageSize.value noMoreData.value = mockData.length < pageSize.value

42
src/pages/votingElection/index.vue

@ -3,16 +3,18 @@ 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) => { const doSearch = (_formData : { page : number; limit : number }, onSuccess : Function) => {
getVoteprogress().then((res) => { getVoteprogress().then((res) => {
xjList.value = res.data const { data } = res as { data : { candidate : any[] } }
res.data.data = res.data.candidate xjList.value = data || {}
// 2. onSuccess({
delete res.data.candidate data: {
res.data.total = res.data.candidate?.length data: data.candidate || [],
const { data } = res as { data: { data: any; total: number } } total: (data.candidate || []).length
onSuccess({ data }) }
})
}) })
} }
@ -108,7 +110,7 @@ onShow(() => {
<template> <template>
<!-- 你的页面内容 --> <!-- 你的页面内容 -->
<view class="box"> <view class="box" v-if="xjList.length != 0">
<view class="headpart"> <view class="headpart">
<view class="title">{{ xjList.title }}</view> <view class="title">{{ xjList.title }}</view>
<view class="time">投票开始时间{{ xjList.start_time }}</view> <view class="time">投票开始时间{{ xjList.start_time }}</view>
@ -130,13 +132,9 @@ onShow(() => {
</view> </view>
</view> </view>
<view class="bottomp"> <view class="bottomp">
<view <view class="minbut" v-for="(item, ele) in buttlist" :key="ele"
class="minbut"
v-for="(item, ele) in buttlist"
: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 }} {{ item.butname }}
</view> </view>
</view> </view>
@ -149,6 +147,12 @@ onShow(() => {
<view class="tjtp" @click="submit">提交投票</view> <view class="tjtp" @click="submit">提交投票</view>
</view> </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> </template>
<style scoped lang="scss"> <style scoped lang="scss">
@ -383,4 +387,12 @@ onShow(() => {
border-top: 2rpx solid #ebebec; 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> </style>

BIN
src/static/img/Group.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Loading…
Cancel
Save