Browse Source

选举结果

dev
沈明 1 year ago
parent
commit
d9c6f0ea11
  1. 8
      src/api/common.ts
  2. 2
      src/pages.json
  3. 41
      src/pages/electionResults/index.vue
  4. 14
      src/pages/myElection/index.vue
  5. 65
      src/pages/votingElection/index.vue

8
src/api/common.ts

@ -15,3 +15,11 @@ export function getVoteDetail(data: { id: number }) {
data
})
}
export function getVoteResult(data: pageType) {
return request.http({
url: '/api/vote_result',
method: 'GET',
data
})
}

2
src/pages.json

@ -33,7 +33,7 @@
"style": {
"navigationBarTitleText": "选举结果",
"navigationBarTextStyle": "white",
"enablePullDownRefresh": false
"enablePullDownRefresh": true
}
},
{

41
src/pages/electionResults/index.vue

@ -1,11 +1,10 @@
<script setup lang="ts">
import { getVoteResult } from '@/api/common'
const navto = (url: string, params = {}) => uni.$util.goToPage({ url, params })
const doSearch = (_formData: { page: number; limit: number }, onSuccess: Function) => {
onSuccess({
data: {
data: [{ name: '测试一' }, { name: '测试二' }],
total: 4
}
const doSearch = (formData: { page: number; limit: number }, onSuccess: Function) => {
getVoteResult(formData).then((res) => {
const { data } = res as { data: { data: any; total: number } }
onSuccess({ data })
})
}
</script>
@ -18,36 +17,38 @@ const doSearch = (_formData: { page: number; limit: number }, onSuccess: Functio
<view class="flex">
<view class="flex1">
<view class="flex-center-start">
<text class="text-ellipsis title">{{ '2024年度学生会主席选举' }}</text>
<!-- <text class="status b">进行中</text> -->
<!-- <text class="status f">未开始</text> -->
<text class="status e">已结束</text>
<text class="text-ellipsis title">{{ row.title }}</text>
<text class="status b" v-if="row.status === 2">进行中</text>
<text class="status f" v-else-if="row.status === 1">未开始</text>
<text class="status e" v-else>已结束</text>
</view>
<view class="time">{{ '投票时间:2024-03-01 至 2024-03-07' }}</view>
<view class="time">{{ `投票时间:${row.start_time}${row.end_time}` }}</view>
</view>
<view :class="{ arrow: true, active: row.showInfo }" @click="row.showInfo = !row.showInfo">
<u-icon name="arrow-down" color="#9CA3AF" />
</view>
</view>
<view class="info" v-if="row.showInfo">
<view class="flex info-items" v-for="(v, k) of 2" :key="k">
<view class="head"></view>
<view class="flex info-items" v-for="(v, k) of row.candidate" :key="k">
<view class="head">
<image :src="v.photo" mode="aspectFill" />
</view>
<view class="content flex1">
<view class="name flex-center-start">
<text>陈佳怡</text>
<!-- <text class="status">当选</text> -->
<text class="status un">未当选</text>
<text>{{ v.name }}</text>
<text class="status" v-if="v.vote_result == 1">当选</text>
<text class="status un" v-else>未当选</text>
</view>
<view class="votes">得票数286</view>
<view class="votes">得票数{{ v.agree_num }}</view>
</view>
<view class="progress">
<u-line-progress :percentage="60" height="8rpx" active-color="#2563EB" :show-text="false" />
<view class="progress-text">60%</view>
<u-line-progress :percentage="v.ageree_percent" height="8rpx" active-color="#2563EB" :show-text="false" />
<view class="progress-text">{{ v.ageree_percent }}%</view>
</view>
</view>
<view class="info-bts" @click.stop="navto('pages/electionList/info')">查看投票详情</view>
<view class="info-bts" @click.stop="navto('pages/electionList/info', { id: row.id })">查看投票详情</view>
</view>
</view>
</template>

14
src/pages/myElection/index.vue

@ -101,23 +101,13 @@ const choiceText = (choice) => {
)
}
const choiceText = (choice) => {
return ({
1: '同意',
0: '反对',
2: '弃权'
} [choice] || '')
}
//
const getList = async () => {
try {
loading.value = true
//
const mockData = await getMyvote().then((res)=> {
})
const mockData = await getMyvote()
//
dataList.value = [...dataList.value, ...mockData]
@ -144,7 +134,7 @@ const choiceText = (choice) => {
if (userStore.mobile) {
uni.navigateTo({
url: '/pages/login/login'
});
})
}
})
</script>

65
src/pages/votingElection/index.vue

@ -30,6 +30,7 @@ const buttlist = ref([
butname: '弃权'
}
])
const params = ref([])
const selectBut = (data: any, cardid: any, type: string, butname: string) => {
if (cardid) {
@ -72,69 +73,11 @@ const allChange = () => {
})
}
const buttlist = ref([
{
type: '1',
butname: '同意'
},
{
type: '2',
butname: '反对'
},
{
type: '3',
butname: '弃权'
}
])
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)
uni.showModal({
title: '您本轮选举投' + butname + '票',
content: '确定吗?',
success: function (res) {
if (res.confirm) {
if (target) {
target.vote_result = type
}
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
params.value.push(target)
} else {
data.forEach((ele : {
vote_result : number; id : any;
}) => {
ele.vote_result = 1
})
}
}
const allChange = () => {
uni.showModal({
title: '您本轮选举全投同意票',
content: '确定吗?',
success: function (res) {
if (res.confirm) {
xjList.value.data?.forEach((ele : { vote_result : number; }) => {
ele.vote_result = 1
})
params.value = xjList.value.data
submit()
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
}
function extractTwoProps(arr: any, key1: string, key2: string) {
return arr.map(({ [key1]: prop1, [key2]: prop2 }) => ({
[key1]: prop1,
[key2]: prop2
}));
}))
}
const submit = () => {
let param = {
@ -147,7 +90,7 @@ const allChange = () => {
title: '未选举',
icon: 'none', // 'success', 'loading', 'none'
duration: 1500 // ms
});
})
} else {
voteMember(param).then((res) => {
console.log(res, 555555555555555)
@ -158,7 +101,7 @@ const allChange = () => {
if (userStore.mobile) {
uni.navigateTo({
url: '/pages/login/login'
});
})
}
})
</script>

Loading…
Cancel
Save