Browse Source

选举列表

dev
沈明 1 year ago
parent
commit
d31107f36b
  1. 18
      src/api/votingElection.ts
  2. 165
      src/manifest.json
  3. 211
      src/pages/myElection/index.vue
  4. 147
      src/pages/votingElection/index.vue

18
src/api/votingElection.ts

@ -1,15 +1,25 @@
import { request } from '@/utils/http' import { request } from '@/utils/http'
// 获取投票选举(正在进行) // 获取投票选举(正在进行)
export function getCategoryData() { export function getVoteprogress() {
return request.http({ return request.http({
url: '/api/vote_progress' url: '/api/vote_progress',
method: 'GET'
}) })
} }
export function feedback(data: any) { //用户投票
export function voteMember(data: any) {
return request.http({ return request.http({
url: '/api/t.feedback/add', url: '/api/vote_member',
data data
}) })
} }
// 获取我的选举
export function getMyvote() {
return request.http({
url: '/api/my_vote',
method: 'GET'
})
}

165
src/manifest.json

@ -1,38 +1,38 @@
{ {
"name": "问卷系统", "name" : "问卷系统",
"appid": "__UNI__1AE1F37", "appid" : "__UNI__4CC99EE",
"description": "v3+ts+uniapp模版", "description" : "v3+ts+uniapp模版",
"versionName": "1.0.68", "versionName" : "1.0.68",
"versionCode": 168, "versionCode" : 168,
"transformPx": false, "transformPx" : false,
/* 5+App */ /* 5+App */
"app-plus": { "app-plus" : {
"usingComponents": true, "usingComponents" : true,
"nvueStyleCompiler": "uni-app", "nvueStyleCompiler" : "uni-app",
"compilerVersion": 3, "compilerVersion" : 3,
"splashscreen": { "splashscreen" : {
"alwaysShowBeforeRender": true, "alwaysShowBeforeRender" : true,
"waiting": true, "waiting" : true,
"autoclose": true, "autoclose" : true,
"delay": 0 "delay" : 0
}, },
"compatible": { "compatible" : {
"ignoreVersion": true "ignoreVersion" : true
}, },
/* */ /* */
"modules": { "modules" : {
"Barcode": {}, "Barcode" : {},
"Camera": {}, "Camera" : {},
"VideoPlayer": {}, "VideoPlayer" : {},
"Share": {}, "Share" : {},
"Geolocation": {}, "Geolocation" : {},
"Maps": {} "Maps" : {}
}, },
/* */ /* */
"distribute": { "distribute" : {
/* android */ /* android */
"android": { "android" : {
"permissions": [ "permissions" : [
"<uses-feature android:name=\"android.hardware.camera\"/>", "<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>", "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>", "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
@ -49,86 +49,83 @@
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>", "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>" "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
], ],
"minSdkVersion": 21 "minSdkVersion" : 21
}, },
/* ios */ /* ios */
"ios": { "ios" : {
"dSYMs": false "dSYMs" : false
}, },
/* SDK */ /* SDK */
"sdkConfigs": { "sdkConfigs" : {
"ad": {}, "ad" : {},
"share": { "share" : {
"weixin": { "weixin" : {
"appid": "wxd448c878a54da98d", "appid" : "wx5d1a07b75bd48225",
"UniversalLinks": "" "UniversalLinks" : ""
} }
}, },
"geolocation": { "geolocation" : {
"amap": { "amap" : {
"name": "amap_18648278829CcsBXVUm1", "name" : "amap_18648278829CcsBXVUm1",
"__platform__": [ "__platform__" : [ "ios", "android" ],
"ios", "appkey_ios" : "37180416cb95db05dc9639e616655a7a",
"android" "appkey_android" : "37180416cb95db05dc9639e616655a7a"
],
"appkey_ios": "435934cdfcc901e4872a70391d92cccd",
"appkey_android": "435934cdfcc901e4872a70391d92cccd"
} }
}, },
"maps": { "maps" : {
"amap": { "amap" : {
"name": "amap_18648278829CcsBXVUm1", "name" : "amap_18648278829CcsBXVUm1",
"appkey_ios": "435934cdfcc901e4872a70391d92cccd", "appkey_ios" : "37180416cb95db05dc9639e616655a7a",
"appkey_android": "435934cdfcc901e4872a70391d92cccd" "appkey_android" : "37180416cb95db05dc9639e616655a7a"
} }
} }
}, },
"icons": { "icons" : {
"android": { "android" : {
"hdpi": "src/static/logo.png", "hdpi" : "src/static/logo.png",
"xhdpi": "src/static/logo.png", "xhdpi" : "src/static/logo.png",
"xxhdpi": "src/static/logo.png", "xxhdpi" : "src/static/logo.png",
"xxxhdpi": "src/static/logo.png" "xxxhdpi" : "src/static/logo.png"
} }
}, },
"splashscreen": { "splashscreen" : {
"iosStyle": "common", "iosStyle" : "common",
"androidStyle": "default", "androidStyle" : "default",
"android": { "android" : {
"hdpi": "", "hdpi" : "",
"xhdpi": "", "xhdpi" : "",
"xxhdpi": "" "xxhdpi" : ""
}, },
"ios": { "ios" : {
"storyboard": "C:/Users/Lenovo/Desktop/CustomStoryboard.zip" "storyboard" : "C:/Users/Lenovo/Desktop/CustomStoryboard.zip"
} }
} }
} }
}, },
/* */ /* */
"quickapp": {}, "quickapp" : {},
/* */ /* */
"mp-weixin": { "mp-weixin" : {
"appid": "wx5d1a07b75bd48225", "appid" : "wx5d1a07b75bd48225",
"setting": { "setting" : {
"urlCheck": false, "urlCheck" : false,
"es6": true, "es6" : true,
"postcss": false, "postcss" : false,
"minified": true "minified" : true
}, },
"usingComponents": true "usingComponents" : true
}, },
"mp-alipay": { "mp-alipay" : {
"usingComponents": true "usingComponents" : true
}, },
"mp-baidu": { "mp-baidu" : {
"usingComponents": true "usingComponents" : true
}, },
"mp-toutiao": { "mp-toutiao" : {
"usingComponents": true "usingComponents" : true
}, },
"uniStatistics": { "uniStatistics" : {
"enable": false "enable" : false
}, },
"vueVersion": "3" "vueVersion" : "3"
} }

211
src/pages/myElection/index.vue

@ -1,156 +1,66 @@
<template> <template>
<view class="container"> <view class="container">
<view v-for="(item, index) in electionList" :key="index" class="election-item"> <scroll-view class="scroll-view" scroll-y @scrolltolower="loadMore" :show-scrollbar="false">
<view class="year-title"> <view v-for="(item, index) in electionList" :key="index" class="election-item">
<view class="headpart"> <view class="year-title">
<text class="title">{{ item.title }}</text> <view class="headpart">
<view <text class="title">{{ item.title }}</text>
class="type" <view
:style=" class="type"
item.type == '投票中' :style="
? 'background: #DBEAFE;color: #3B82F6;' item.type == '投票中'
: item.type == '当选' ? 'background: #DBEAFE;color: #3B82F6;'
? 'background: #DCFCE7;color: #10B981' : item.type == '当选'
: 'background: #F3F4F6;color: #4B5563' ? 'background: #DCFCE7;color: #10B981'
" : 'background: #F3F4F6;color: #4B5563'
> "
{{ item.type }} >
{{ item.type }}
</view>
</view> </view>
</view> </view>
</view> <view class="flex-center-between" style="display: flex">
<view class="flex-center-between" style="display: flex"> <view style="display: grid">
<view style="display: grid"> <view
<view v-for="(candidate, cIndex) in item.candidates.slice(0, expandedStates[index] ? item.candidates.length : 1)"
v-for="(candidate, cIndex) in item.candidates.slice(0, expandedStates[index] ? item.candidates.length : 1)" :key="cIndex"
:key="cIndex" class="candidate-item"
class="candidate-item" >
> <view class="info-section">
<view class="info-section"> <view style="display: flex; align-items: center">
<view style="display: flex; align-items: center"> <img style="width: 96rpx; height: 96rpx; border-radius: 50%" :src="item.img" alt="" />
<img style="width: 96rpx; height: 96rpx; border-radius: 50%" :src="item.img" alt="" /> <view style="margin-left: 24rpx; display: grid">
<view style="margin-left: 24rpx; display: grid"> <text class="name">{{ candidate.name }}</text>
<text class="name">{{ candidate.name }}</text> <text class="college">{{ candidate.college }}</text>
<text class="college">{{ candidate.college }}</text> </view>
</view> </view>
</view> <view style="display: flex; margin-top: 24rpx">
<view style="display: flex; margin-top: 24rpx"> 我的选择
我的选择 <view :class="['choice-tag', choiceClass(candidate.choice)]">
<view :class="['choice-tag', choiceClass(candidate.choice)]"> {{ choiceText(candidate.choice) }}
{{ choiceText(candidate.choice) }} </view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</view> <view class="expand-btn" @click="toggleExpand(index)">
<view class="expand-btn" @click="toggleExpand(index)"> <text :class="['arrow', expandedStates[index] ? 'up' : 'down']"></text>
<text :class="['arrow', expandedStates[index] ? 'up' : 'down']"></text> </view>
</view> </view>
</view> </view>
</view> </scroll-view>
</view> </view>
</template> </template>
<script setup> <script setup>
import { ref, watch } from 'vue' import { ref, watch } from 'vue'
import { getMyvote } from '../../api/votingElection'
const electionList = ref([ const electionList = ref([])
{ const page = ref(1)
type: '投票中', const pageSize = ref(10)
title: '2024学生会主席选举', const loading = ref(false)
candidates: [ const noMoreData = ref(false)
{
img: '../../static/redpacket.png',
name: '陈思远',
college: '计算机科学与技术学院',
choice: 1
},
{
img: '../../static/redpacket.png',
name: '陈思远2号',
college: '计算机科学与技术学院',
choice: 0
},
{
img: '../../static/redpacket.png',
name: '陈思远2号',
college: '计算机科学与技术学院',
choice: 2
}
]
},
{
type: '投票中',
title: '2024学生会主席选举',
candidates: [
{
img: '../../static/redpacket.png',
name: '陈思远',
college: '计算机科学与技术学院',
choice: 1
},
{
img: '../../static/redpacket.png',
name: '陈思远2号',
college: '计算机科学与技术学院',
choice: 0
},
{
img: '../../static/redpacket.png',
name: '陈思远2号',
college: '计算机科学与技术学院',
choice: 2
}
]
},
{
type: '投票中',
title: '2024学生会主席选举',
candidates: [
{
img: '../../static/redpacket.png',
name: '陈思远',
college: '计算机科学与技术学院',
choice: 1
},
{
img: '../../static/redpacket.png',
name: '陈思远2号',
college: '计算机科学与技术学院',
choice: 0
},
{
img: '../../static/redpacket.png',
name: '陈思远2号',
college: '计算机科学与技术学院',
choice: 2
}
]
},
{
type: '当选',
title: '2023优秀班干部评选',
candidates: [
{
img: '../../static/redpacket.png',
name: '李雨晴',
college: '工商管理学院',
choice: 0
}
]
},
{
type: '未当选',
title: '2023最佳社团负责人',
candidates: [
{
img: '../../static/redpacket.png',
name: '王浩然',
college: '艺术设计学院',
choice: 2
}
]
}
])
// //
const expandedStates = ref([]) const expandedStates = ref([])
@ -190,6 +100,35 @@ const choiceText = (choice) => {
}[choice] || '' }[choice] || ''
) )
} }
//
const getList = async () => {
try {
loading.value = true
//
const mockData = await getMyvote()
//
dataList.value = [...dataList.value, ...mockData]
//
noMoreData.value = mockData.length < pageSize.value
} finally {
loading.value = false
}
}
//
const loadMore = () => {
if (loading.value || noMoreData.value) return
page.value += 1
getList()
}
onMounted(() => {
getList()
})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

147
src/pages/votingElection/index.vue

@ -1,82 +1,70 @@
<script setup lang="ts"> <script setup lang="ts">
import { getCategoryData } from '../../api/votingElection' 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 doSearch = (_formData: { page: number; limit: number }, onSuccess: Function) => {
// const submitData = { ...formData } getVoteprogress().then((res) => {
// listApi(submitData, userStore.useType).then((res) => { xjList.value = res.data
// const { data } = res as { data: { data: any; total: number } } res.data.data = res.data.candidate
// onSuccess({ data }) // 2.
// }) delete res.data.candidate
res.data.total = res.data.candidate?.length
onSuccess({ const { data } = res as { data: { data: any; total: number } }
data: { onSuccess({ data })
data: [
{
id: 1,
img: '',
name: '陈志远',
class: '现任财务总监',
yijian: ''
},
{
id: 2,
img: '',
name: '陈志远',
class: '现任财务总监',
yijian: ''
},
{
id: 3,
img: '',
name: '陈志远',
class: '现任财务总监',
yijian: ''
},
{
id: 4,
img: '',
name: '陈志远',
class: '现任财务总监',
yijian: ''
},
{
id: 5,
img: '',
name: '陈志远',
class: '现任财务总监',
yijian: ''
}
],
total: 0
}
}) })
} }
const buttlist = ref([ const buttlist = ref([
{ {
type: 'agree', type: '1',
butname: '同意' butname: '同意'
}, },
{ {
type: 'disagree', type: '2',
butname: '反对' butname: '反对'
}, },
{ {
type: 'neutral', type: '3',
butname: '弃权' butname: '弃权'
} }
]) ])
const params = ref([])
const selectBut = (data: any, cardid: any, type: string, butname: string) => { const selectBut = (data: any, cardid: any, type: string, butname: string) => {
const target = data.find((card: { id: any }) => card.id === cardid) 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({ uni.showModal({
title: '您本轮选举投' + butname + '票', title: '您本轮选举全投同意票',
content: '确定吗?', content: '确定吗?',
success: function (res) { success: function (res) {
if (res.confirm) { if (res.confirm) {
if (target) { xjList.value.data?.forEach((ele: { vote_result: number }) => {
target.yijian = target.yijian === type ? null : type ele.vote_result = 1
} })
params.value = xjList.value.data
submit()
} else if (res.cancel) { } else if (res.cancel) {
console.log('用户点击取消') console.log('用户点击取消')
} }
@ -84,33 +72,52 @@ const selectBut = (data: any, cardid: any, type: string, butname: string) => {
}) })
} }
onShow(() => { function extractTwoProps(arr: any, key1: string, key2: string) {
getCategoryData().then((res) => { return arr.map(({ [key1]: prop1, [key2]: prop2 }) => ({
console.log(res, 55555555555) [key1]: prop1,
}) [key2]: prop2
}) }))
}
const submit = () => {
let param = {
openid: userStore.openId,
id: xjList.value.id,
candidate: JSON.stringify(extractTwoProps(params.value, 'id', 'vote_result'))
}
if (param.candidate === '[]') {
uni.showToast({
title: '未选举',
icon: 'none', // 'success', 'loading', 'none'
duration: 1500 // ms
})
} else {
voteMember(param).then((res) => {
console.log(res, 555555555555555)
})
}
}
</script> </script>
<template> <template>
<!-- 你的页面内容 --> <!-- 你的页面内容 -->
<view class="box"> <view class="box">
<view class="headpart"> <view class="headpart">
<view class="title">2024年度董事会成员选举</view> <view class="title">{{ xjList.title }}</view>
<view class="time">投票开始时间2024年3月15日 18:00</view> <view class="time">投票开始时间{{ xjList.start_time }}</view>
<view class="time">投票截止时间2024年3月15日 18:00</view> <view class="time">投票截止时间{{ xjList.end_time }}</view>
</view> </view>
<ex-list ref="reListRef" custom-list-type="custom" :on-form-search="doSearch"> <ex-list ref="reListRef" custom-list-type="custom" :on-form-search="doSearch">
<template v-slot="{ data }"> <template v-slot="{ data }">
<view class="tppart"> <view class="tppart">
<view class="tpone" v-for="(row, index) of data" :key="'tpone' + index"> <view class="tpone" v-for="(row, index) of data" :key="'tpone' + index">
<view class="topp"> <view class="topp">
<img style="width: 96rpx; height: 96rpx; border-radius: 50%" :src="row.img" alt="" /> <img style="width: 96rpx; height: 96rpx; border-radius: 50%" :src="row.photo" alt="" />
<view class="rightpart"> <view class="rightpart">
<view class="name"> <view class="name">
{{ row.name }} {{ row.name }}
</view> </view>
<view class="class"> <view class="class">
{{ row.class }} {{ row.position }}
</view> </view>
</view> </view>
</view> </view>
@ -120,7 +127,7 @@ onShow(() => {
v-for="(item, ele) in buttlist" 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.yijian === item.type }" :class="{ active: row.vote_result === item.type }"
> >
{{ item.butname }} {{ item.butname }}
</view> </view>
@ -130,8 +137,8 @@ onShow(() => {
</template> </template>
</ex-list> </ex-list>
<view class="bottbutton"> <view class="bottbutton">
<view class="qbty">全部同意</view> <view class="qbty" @click="allChange">全部同意</view>
<view class="tjtp">提交投票</view> <view class="tjtp" @click="submit">提交投票</view>
</view> </view>
</view> </view>
</template> </template>

Loading…
Cancel
Save