岳鹏龙 1 year ago
parent
commit
768d90416a
  1. 13
      src/api/votingElection.ts
  2. 61
      src/components/ex-tags/ex-tags.vue
  3. 4
      src/pages/mine/add.vue
  4. 3
      src/pages/mine/index.vue
  5. 23
      src/pages/myElection/index.vue
  6. 822
      src/pages/votingElection/index.vue
  7. 2
      src/store/user.ts

13
src/api/votingElection.ts

@ -1,12 +1,10 @@
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'
}) })
} }
@ -19,11 +17,10 @@ export function voteMember(data: any) {
} }
// 获取我的选举 // 获取我的选举
export function getMyvote(data:any) { export function getMyvote(data: any) {
return request.http({ return request.http({
url: '/api/my_vote', url: '/api/my_vote',
method: "GET", method: 'GET',
data data
}) })
} }

61
src/components/ex-tags/ex-tags.vue

@ -1,61 +0,0 @@
<template>
<view class="tag_box flex-center-start" :style="{ '--borderColor': borderColor }">
<view class="border" :style="borderStyle" />
<text :style="{ color: labelColor }">{{ label }}</text>
<view class="flex1">
<slot></slot>
</view>
</view>
</template>
<script setup lang="ts">
interface tagsInt {
label: string
labelColor?: string
borderColor?: string
borderType?: 'round' | 'line'
}
const props = withDefaults(defineProps<tagsInt>(), {
label: '收益',
labelColor: '#616161',
borderColor: '#ff8d1a',
borderType: 'line'
})
const borderStyle = computed(() => {
if (props.borderType === 'line') {
return {
width: '8rpx',
height: '28rpx',
marginRight: '16rpx'
}
} else {
return {
width: '16rpx',
height: '16rpx',
marginRight: '13rpx'
}
}
})
</script>
<style scoped lang="scss">
.tag_box {
font-size: 28rpx;
font-weight: 400;
line-height: 40rpx;
--borderColor: #ff8d1a;
.border {
width: 8rpx;
height: 28rpx;
border-radius: 90rpx;
background-color: var(--borderColor);
}
> .flex1 {
padding-left: 20rpx;
}
}
</style>

4
src/pages/mine/add.vue

@ -31,7 +31,9 @@ const onSubmit = uni.$util.debounce(() => {
addAPi(formData).then(() => { addAPi(formData).then(() => {
uni.hideLoading() uni.hideLoading()
uni.switchTab({ url: '/pages/mine/index' }) uni.showToast({ title: '签到成功,等待投票!', icon: 'none' })
setTimeout(() => uni.switchTab({ url: '/pages/mine/index' }), 1000)
}) })
} }
}) })

3
src/pages/mine/index.vue

@ -38,7 +38,7 @@ const updateUserInfo = () => {
userStore.bindUser(list.value[activeKey.value].id as number).then(() => { userStore.bindUser(list.value[activeKey.value].id as number).then(() => {
reset() reset()
userStore.getUserInfo() userStore.getUserInfo()
uni.showToast({ title: '绑定成功', icon: 'none' }) uni.showToast({ title: '签到成功,等待投票!', icon: 'none' })
}) })
} }
@ -79,7 +79,6 @@ const save = () => {
onShow(() => { onShow(() => {
reset() reset()
getAdminPhone().then((res) => { getAdminPhone().then((res) => {
const { data } = res as { data: string } const { data } = res as { data: string }
amdinPhone.value = data || '' amdinPhone.value = data || ''

23
src/pages/myElection/index.vue

@ -15,7 +15,7 @@
: 'background: #F3F4F6;color: #4B5563' : 'background: #F3F4F6;color: #4B5563'
" "
> >
{{ item.vote_title==1?'未开始':(item.vote_title==2?'进行中':'已结束') }} {{ item.vote_title == 1 ? '未开始' : item.vote_title == 2 ? '进行中' : '已结束' }}
</view> </view>
</view> </view>
</view> </view>
@ -34,7 +34,7 @@
<text class="college">{{ candidate.position }}</text> <text class="college">{{ candidate.position }}</text>
</view> </view>
</view> </view>
<view style="display: flex; margin-top: 24rpx;font-family: Roboto;font-size: 14px;color: #4B5563;"> <view style="display: flex; margin-top: 24rpx; font-family: Roboto; font-size: 14px; color: #4b5563">
我的选择 我的选择
<view :class="['choice-tag', choiceClass(candidate.vote_result)]"> <view :class="['choice-tag', choiceClass(candidate.vote_result)]">
{{ choiceText(candidate.vote_result) }} {{ choiceText(candidate.vote_result) }}
@ -108,18 +108,18 @@ const getList = async () => {
try { try {
loading.value = true loading.value = true
let param = { let param = {
openid: userStore.openId, openid: userStore.openId,
page: page.value, page: page.value,
limit: pageSize.value limit: pageSize.value
} }
// //
const mockData = await getMyvote(param) const mockData = await getMyvote(param)
// //
electionList.value = [...electionList.value, ...mockData.data.data] electionList.value = [...electionList.value, ...mockData.data.data]
// electionList.value.push(mockData) // electionList.value.push(mockData)
// //
noMoreData.value = mockData.data.data.length < pageSize.value noMoreData.value = mockData.data.data.length < pageSize.value
} finally { } finally {
@ -137,7 +137,6 @@ const loadMore = () => {
onShow(() => { onShow(() => {
getList() getList()
}) })
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

822
src/pages/votingElection/index.vue

@ -1,398 +1,424 @@
<script setup lang="ts"> <script setup lang="ts">
import { getVoteprogress, voteMember } from '../../api/votingElection' 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<any>({}) 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) => {
const { data } = res as { data : { candidate : any[] } } const { data } = res as { data: { candidate: any[] } }
xjList.value = data || {} xjList.value = data || {}
onSuccess({ onSuccess({
data: { data: {
data: data.candidate || [], data: data.candidate || [],
total: (data.candidate || []).length total: (data.candidate || []).length
} }
}) })
}) })
} }
const buttlist = ref([ const buttlist = ref([
{ {
type: '1', type: '1',
butname: '同意' butname: '同意'
}, },
{ {
type: '2', type: '2',
butname: '反对' butname: '反对'
}, },
{ {
type: '3', type: '3',
butname: '弃权' butname: '弃权'
} }
]) ])
const params = ref([]) const params = ref([])
const selectBut = (data : any, cardid : any, type : string, butname : string) => { const selectBut = (data: any, cardid: any, type: string, butname: string) => {
if (cardid) { if (cardid) {
const target = data.find((card : { id : any }) => card.id === cardid) const target = data.find((card: { id: any }) => card.id === cardid)
uni.showModal({ uni.showModal({
title: '您本轮选举投' + butname + '票', title: '您本轮选举投' + butname + '票',
content: '确定吗?', content: '确定吗?',
success: function (res) { success: function (res) {
if (res.confirm) { if (res.confirm) {
if (target) { if (target) {
target.vote_result = type target.vote_result = type
} }
} else if (res.cancel) { } else if (res.cancel) {
console.log('用户点击取消') console.log('用户点击取消')
} }
} }
}) })
params.value.push(target) params.value.push(target)
} else { } else {
data.forEach((ele : { vote_result : number; id : any }) => { data.forEach((ele: { vote_result: number; id: any }) => {
ele.vote_result = 1 ele.vote_result = 1
}) })
} }
} }
const allChange = () => { const allChange = () => {
uni.showModal({ uni.showModal({
title: '您本轮选举全投同意票', title: '您本轮选举全投同意票',
content: '确定吗?', content: '确定吗?',
success: function (res) { success: function (res) {
if (res.confirm) { if (res.confirm) {
xjList.value.data?.forEach((ele : { vote_result : number }) => { xjList.value.data?.forEach((ele: { vote_result: number }) => {
ele.vote_result = 1 ele.vote_result = 1
}) })
params.value = xjList.value.candidate params.value = xjList.value.candidate
submit() submit()
} else if (res.cancel) { } else if (res.cancel) {
console.log('用户点击取消') console.log('用户点击取消')
} }
} }
}) })
} }
function extractTwoProps(arr : any, key1 : string, key2 : string) { function extractTwoProps(arr: any, key1: string, key2: string) {
return arr.map(({ [key1]: prop1, [key2]: prop2 }) => ({ return arr.map(({ [key1]: prop1, [key2]: prop2 }) => ({
[key1]: prop1, [key1]: prop1,
[key2]: prop2 [key2]: prop2
})) }))
} }
const submit = () => { const submit = () => {
let param = { let param = {
openid: userStore.openId, openid: userStore.openId,
id: xjList.value.id, id: xjList.value.id,
candidate: JSON.stringify(extractTwoProps(params.value, 'id', 'vote_result')) candidate: JSON.stringify(extractTwoProps(params.value, 'id', 'vote_result'))
} }
if (param.candidate === '[]') { if (param.candidate === '[]') {
uni.showToast({ uni.showToast({
title: '未选举', title: '未选举',
icon: 'none', // 'success', 'loading', 'none' icon: 'none', // 'success', 'loading', 'none'
duration: 1500 // ms duration: 1500 // ms
}) })
} else { } else {
voteMember(param).then((res) => { voteMember(param)
console.log(res, 555555555555555) }
}) }
}
} const showDialog = ref(false)
onShow(() => { const navto = (url: string, mode: pageMode = 'navigateTo') => uni.$util.goToPage({ url: url ?? 'pages/index/index', mode })
if (userStore.mobile === '') { const isEmptyObject = (obj: any) => {
uni.navigateTo({ if (obj == null) return true
url: '/pages/login/login' if (typeof obj !== 'object' || Array.isArray(obj)) return true
}) return Reflect.ownKeys(obj).length === 0
} }
})
</script> onShow(() => {
if (userStore.mobile === '') {
<template> uni.navigateTo({
<!-- 你的页面内容 --> url: '/pages/login/login'
<view class="box" v-if="xjList.length != 0"> })
<view class="headpart"> } else if (isEmptyObject(userStore.userInfo)) {
<view class="title">{{ xjList.title }}</view> showDialog.value = true
<view class="time">投票开始时间{{ xjList.start_time }}</view> }
<view class="time">投票截止时间{{ xjList.end_time }}</view> })
</view> </script>
<ex-list ref="reListRef" custom-list-type="custom" :on-form-search="doSearch">
<template v-slot="{ data }"> <template>
<view class="tppart"> <!-- 你的页面内容 -->
<view class="tpone" v-for="(row, index) of data" :key="'tpone' + index"> <view class="box" v-if="xjList.length != 0">
<view class="topp"> <view class="headpart">
<img style="width: 96rpx; height: 96rpx; border-radius: 50%" :src="row.photo" alt="" /> <view class="title">{{ xjList.title }}</view>
<view class="rightpart"> <view class="time">投票开始时间{{ xjList.start_time }}</view>
<view class="name"> <view class="time">投票截止时间{{ xjList.end_time }}</view>
{{ row.name }} </view>
</view> <ex-list ref="reListRef" custom-list-type="custom" :on-form-search="doSearch">
<view class="class"> <template v-slot="{ data }">
{{ row.position }} <view class="tppart">
</view> <view class="tpone" v-for="(row, index) of data" :key="'tpone' + index">
</view> <view class="topp">
</view> <img style="width: 96rpx; height: 96rpx; border-radius: 50%" :src="row.photo" alt="" />
<view class="bottomp"> <view class="rightpart">
<view class="minbut" v-for="(item, ele) in buttlist" :key="ele" <view class="name">
@click="selectBut(data, row.id, item.type, item.butname)" {{ row.name }}
:class="{ active: row.vote_result === item.type }"> </view>
{{ item.butname }} <view class="class">
</view> {{ row.position }}
</view> </view>
</view> </view>
</view> </view>
</template> <view class="bottomp">
</ex-list> <view
<view class="bottbutton"> class="minbut"
<view class="qbty" @click="allChange">全部同意</view> v-for="(item, ele) in buttlist"
<view class="tjtp" @click="submit">提交投票</view> :key="ele"
</view> @click="selectBut(data, row.id, item.type, item.butname)"
</view> :class="{ active: row.vote_result === item.type }"
<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="" /> {{ item.butname }}
<text class="nodata"> </view>
暂时没有选举 请刷新重试 </view>
</text> </view>
</view> </view>
</template> </template>
</ex-list>
<style scoped lang="scss"> <view class="bottbutton">
.box { <view class="qbty" @click="allChange">全部同意</view>
width: 100%; <view class="tjtp" @click="submit">提交投票</view>
background-color: #f9fafb; </view>
</view>
.headpart { <view style="display: grid; align-items: center; justify-content: center; width: 100%; height: 100vh; align-content: center" v-else>
width: 92%; <img style="width: 188px; height: 140px" src="@/static/img/Group.png" alt="" />
height: 194rpx; <text class="nodata">暂时没有选举 请刷新重试</text>
border-radius: 24rpx; </view>
background-color: #eff6ff; <u-modal
margin: 32rpx auto; title="提示"
padding: 20rpx 3%; :show="showDialog"
width="650rpx"
.title { :confirm-color="'#2979ff'"
color: #2563eb; :cancel-color="'#606266'"
font-size: 28rpx; :show-confirm-button="true"
margin-top: 16rpx; :show-cancel-button="false"
} :close-on-click-overlay="true"
@confirm="navto('pages/mine/index', 'reLaunch')"
.time { @cancel="showDialog = false"
margin-top: 16rpx; @close="showDialog = false"
color: #4b5563; >
font-size: 28rpx; 请您签到之后再进行投票
} </u-modal>
} </template>
.tppart { <style scoped lang="scss">
width: 100%; .box {
max-height: 69vh; width: 100%;
overflow-y: auto; background-color: #f9fafb;
display: grid;
justify-items: center; .headpart {
width: 92%;
.tpone { height: 194rpx;
width: 91%; border-radius: 24rpx;
height: 264rpx; background-color: #eff6ff;
padding: 20rpx 4%; margin: 32rpx auto;
box-sizing: border-box; padding: 20rpx 3%;
border-radius: 24rpx;
background: linear-gradient(0deg, rgba(0, 0, 0, 0.001), rgba(0, 0, 0, 0.001)), #ffffff; .title {
box-sizing: border-box; color: #2563eb;
border: 2rpx solid #f3f4f6; font-size: 28rpx;
box-shadow: margin-top: 16rpx;
0rpx 2rpx 4rpx -2rpx rgba(0, 0, 0, 0.1), }
0rpx 2rpx 6rpx 0rpx rgba(0, 0, 0, 0.1);
margin-top: 32rpx; .time {
display: grid; margin-top: 16rpx;
color: #4b5563;
.topp { font-size: 28rpx;
display: flex; }
}
.rightpart {
margin-left: 32rpx; .tppart {
display: grid; width: 100%;
justify-items: left; max-height: 69vh;
align-content: baseline; overflow-y: auto;
display: grid;
.name { justify-items: center;
font-family: Roboto;
font-size: 28rpx; .tpone {
font-weight: 500; width: 91%;
line-height: 42rpx; height: 264rpx;
letter-spacing: normal; padding: 20rpx 4%;
color: #000000; box-sizing: border-box;
margin-top: 7rpx; border-radius: 24rpx;
} background: linear-gradient(0deg, rgba(0, 0, 0, 0.001), rgba(0, 0, 0, 0.001)), #ffffff;
box-sizing: border-box;
.class { border: 2rpx solid #f3f4f6;
font-family: Roboto; box-shadow:
font-size: 28rpx; 0rpx 2rpx 4rpx -2rpx rgba(0, 0, 0, 0.1),
font-weight: normal; 0rpx 2rpx 6rpx 0rpx rgba(0, 0, 0, 0.1);
line-height: 40rpx; margin-top: 32rpx;
letter-spacing: normal; display: grid;
color: #6b7280;
margin-top: 7rpx; .topp {
} display: flex;
}
} .rightpart {
margin-left: 32rpx;
.bottomp { display: grid;
display: flex; justify-items: left;
justify-content: space-between; align-content: baseline;
gap: 0rpx 20rpx;
.name {
.minbut { font-family: Roboto;
flex: 1; font-size: 28rpx;
width: 190rpx; font-weight: 500;
height: 76rpx; line-height: 42rpx;
/* 自动布局 */ letter-spacing: normal;
display: flex; color: #000000;
justify-content: center; margin-top: 7rpx;
padding: 16rpx 32rpx; }
flex-wrap: wrap;
align-content: flex-start; .class {
border-radius: 8rpx; font-family: Roboto;
background: #ffffff; font-size: 28rpx;
box-sizing: border-box; font-weight: normal;
border: 2rpx solid #d1d5db; line-height: 40rpx;
font-family: Roboto; letter-spacing: normal;
font-size: 28rpx; color: #6b7280;
font-weight: normal; margin-top: 7rpx;
line-height: 40rpx; }
text-align: center; }
letter-spacing: normal; }
color: #4b5563;
} .bottomp {
display: flex;
.minbut.active { justify-content: space-between;
border: 2rpx solid #2563eb; gap: 0rpx 20rpx;
color: #2563eb;
} .minbut {
} flex: 1;
} width: 190rpx;
height: 76rpx;
.tpone:first-child { /* 自动布局 */
margin-top: 0; display: flex;
} justify-content: center;
} padding: 16rpx 32rpx;
flex-wrap: wrap;
.bottbutton { align-content: flex-start;
width: 100%; border-radius: 8rpx;
height: 10vh; background: #ffffff;
display: flex; box-sizing: border-box;
padding: 24rpx 32rpx; border: 2rpx solid #d1d5db;
gap: 0rpx 24rpx; font-family: Roboto;
flex-wrap: wrap; font-size: 28rpx;
align-content: flex-start; font-weight: normal;
background: #ffffff; line-height: 40rpx;
box-sizing: border-box; text-align: center;
border-width: 2rpx 0rpx 0rpx 0rpx; letter-spacing: normal;
border-style: solid; color: #4b5563;
border-color: #f3f4f6; }
position: fixed;
bottom: 0; .minbut.active {
border: 2rpx solid #2563eb;
.qbty { color: #2563eb;
width: 331rpx; }
height: 90rpx; }
/* 自动布局 */ }
display: flex;
box-sizing: border-box; .tpone:first-child {
justify-content: center; margin-top: 0;
padding: 24rpx 0rpx; }
gap: 0rpx 20rpx; }
flex-wrap: wrap;
border-radius: 8rpx; .bottbutton {
background: #eff6ff; width: 100%;
font-family: Roboto; height: 10vh;
font-size: 28rpx; display: flex;
font-weight: 500; padding: 24rpx 32rpx;
line-height: 42rpx; gap: 0rpx 24rpx;
text-align: center; flex-wrap: wrap;
letter-spacing: normal; align-content: flex-start;
color: #2563eb; background: #ffffff;
} box-sizing: border-box;
border-width: 2rpx 0rpx 0rpx 0rpx;
.tjtp { border-style: solid;
width: 331rpx; border-color: #f3f4f6;
height: 90rpx; position: fixed;
/* 自动布局 */ bottom: 0;
display: flex;
box-sizing: border-box; .qbty {
justify-content: center; width: 331rpx;
padding: 24rpx 0rpx; height: 90rpx;
gap: 0rpx 20rpx; /* 自动布局 */
flex-wrap: wrap; display: flex;
border-radius: 8rpx; box-sizing: border-box;
background: #2563eb; justify-content: center;
font-family: Roboto; padding: 24rpx 0rpx;
font-size: 28rpx; gap: 0rpx 20rpx;
font-weight: 500; flex-wrap: wrap;
line-height: 42rpx; border-radius: 8rpx;
text-align: center; background: #eff6ff;
letter-spacing: normal; font-family: Roboto;
color: #ffffff; font-size: 28rpx;
} font-weight: 500;
} line-height: 42rpx;
text-align: center;
.address-items { letter-spacing: normal;
padding: 20rpx 15rpx 32rpx 28rpx; color: #2563eb;
background-color: #fff; }
border-bottom: 2rpx solid #f5f5f5;
.tjtp {
.left { width: 331rpx;
flex: 1; height: 90rpx;
overflow: hidden; /* 自动布局 */
display: flex;
.name { box-sizing: border-box;
font-size: 28rpx; justify-content: center;
font-weight: 700; padding: 24rpx 0rpx;
color: #101010; gap: 0rpx 20rpx;
line-height: 40rpx; flex-wrap: wrap;
margin-right: 16rpx; border-radius: 8rpx;
} background: #2563eb;
font-family: Roboto;
.isdefault { font-size: 28rpx;
font-size: 20rpx; font-weight: 500;
font-weight: 400; line-height: 42rpx;
color: #fff; text-align: center;
padding: 4rpx 12rpx; letter-spacing: normal;
border-radius: 8rpx; color: #ffffff;
background: linear-gradient(90deg, #4778ff 0%, #4778ffb8 100%); }
} }
.info { .address-items {
width: 100%; padding: 20rpx 15rpx 32rpx 28rpx;
color: #666; background-color: #fff;
font-size: 24rpx; border-bottom: 2rpx solid #f5f5f5;
font-weight: 400;
margin-top: 12rpx; .left {
} flex: 1;
} overflow: hidden;
.right { .name {
width: 140rpx; font-size: 28rpx;
padding-left: 32rpx; font-weight: 700;
font-size: 24rpx; color: #101010;
font-weight: 400; line-height: 40rpx;
color: #4979ff; margin-right: 16rpx;
text-align: right; }
}
} .isdefault {
font-size: 20rpx;
.buts { font-weight: 400;
width: 100%; color: #fff;
height: 10vh; padding: 4rpx 12rpx;
background-color: F3F4F6; border-radius: 8rpx;
position: fixed; background: linear-gradient(90deg, #4778ff 0%, #4778ffb8 100%);
bottom: 0; }
border-top: 2rpx solid #ebebec;
} .info {
} width: 100%;
.nodata { color: #666;
margin-top: 43px; font-size: 24rpx;
font-family: Source Han Sans; font-weight: 400;
font-size: 18px; margin-top: 12rpx;
font-weight: 500; }
letter-spacing: normal; }
color: #34343F;
} .right {
</style> width: 140rpx;
padding-left: 32rpx;
font-size: 24rpx;
font-weight: 400;
color: #4979ff;
text-align: right;
}
}
.buts {
width: 100%;
height: 10vh;
background-color: F3F4F6;
position: fixed;
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>

2
src/store/user.ts

@ -36,7 +36,7 @@ export default defineStore(
.then((res) => { .then((res) => {
const { data } = res as { data: userInfoStoreInt } const { data } = res as { data: userInfoStoreInt }
userInfo.value = data userInfo.value = data || {}
resolve({ code: 1, data, message: 'SUCCESS' }) resolve({ code: 1, data, message: 'SUCCESS' })
}) })

Loading…
Cancel
Save