Browse Source

修改BUG

dev
沈明 1 year ago
parent
commit
bd3ce2d0ce
  1. 13
      src/api/votingElection.ts
  2. 61
      src/components/ex-tags/ex-tags.vue
  3. 1
      src/pages/mine/index.vue
  4. 23
      src/pages/myElection/index.vue
  5. 824
      src/pages/votingElection/index.vue
  6. 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>

1
src/pages/mine/index.vue

@ -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">

824
src/pages/votingElection/index.vue

@ -1,398 +1,426 @@
<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"> }
<view class="title">{{ xjList.title }}</view>
<view class="time">投票开始时间{{ xjList.start_time }}</view> if (isEmptyObject(userStore.userInfo)) {
<view class="time">投票截止时间{{ xjList.end_time }}</view> showDialog.value = true
</view> }
<ex-list ref="reListRef" custom-list-type="custom" :on-form-search="doSearch"> })
<template v-slot="{ data }"> </script>
<view class="tppart">
<view class="tpone" v-for="(row, index) of data" :key="'tpone' + index"> <template>
<view class="topp"> <!-- 你的页面内容 -->
<img style="width: 96rpx; height: 96rpx; border-radius: 50%" :src="row.photo" alt="" /> <view class="box" v-if="xjList.length != 0">
<view class="rightpart"> <view class="headpart">
<view class="name"> <view class="title">{{ xjList.title }}</view>
{{ row.name }} <view class="time">投票开始时间{{ xjList.start_time }}</view>
</view> <view class="time">投票截止时间{{ xjList.end_time }}</view>
<view class="class"> </view>
{{ row.position }} <ex-list ref="reListRef" custom-list-type="custom" :on-form-search="doSearch">
</view> <template v-slot="{ data }">
</view> <view class="tppart">
</view> <view class="tpone" v-for="(row, index) of data" :key="'tpone' + index">
<view class="bottomp"> <view class="topp">
<view class="minbut" v-for="(item, ele) in buttlist" :key="ele" <img style="width: 96rpx; height: 96rpx; border-radius: 50%" :src="row.photo" alt="" />
@click="selectBut(data, row.id, item.type, item.butname)" <view class="rightpart">
:class="{ active: row.vote_result === item.type }"> <view class="name">
{{ item.butname }} {{ row.name }}
</view> </view>
</view> <view class="class">
</view> {{ row.position }}
</view> </view>
</template> </view>
</ex-list> </view>
<view class="bottbutton"> <view class="bottomp">
<view class="qbty" @click="allChange">全部同意</view> <view
<view class="tjtp" @click="submit">提交投票</view> class="minbut"
</view> v-for="(item, ele) in buttlist"
</view> :key="ele"
<view style="display: grid;align-items: center;justify-content: center;width: 100%;height: 100vh;align-content: center;" v-else> @click="selectBut(data, row.id, item.type, item.butname)"
<img style="width: 188px;height: 140px;" src="@/static/img/Group.png" alt="" /> :class="{ active: row.vote_result === item.type }"
<text class="nodata"> >
暂时没有选举 请刷新重试 {{ item.butname }}
</text> </view>
</view> </view>
</template> </view>
</view>
<style scoped lang="scss"> </template>
.box { </ex-list>
width: 100%; <view class="bottbutton">
background-color: #f9fafb; <view class="qbty" @click="allChange">全部同意</view>
<view class="tjtp" @click="submit">提交投票</view>
.headpart { </view>
width: 92%; </view>
height: 194rpx; <view style="display: grid; align-items: center; justify-content: center; width: 100%; height: 100vh; align-content: center" v-else>
border-radius: 24rpx; <img style="width: 188px; height: 140px" src="@/static/img/Group.png" alt="" />
background-color: #eff6ff; <text class="nodata">暂时没有选举 请刷新重试</text>
margin: 32rpx auto; </view>
padding: 20rpx 3%; <u-modal
title="提示"
.title { :show="showDialog"
color: #2563eb; width="650rpx"
font-size: 28rpx; :confirm-color="'#2979ff'"
margin-top: 16rpx; :cancel-color="'#606266'"
} :show-confirm-button="true"
:show-cancel-button="false"
.time { :close-on-click-overlay="true"
margin-top: 16rpx; @confirm="navto('pages/mine/index', 'reLaunch')"
color: #4b5563; @cancel="showDialog = false"
font-size: 28rpx; @close="showDialog = false"
} >
} 请您签到之后再进行投票
</u-modal>
.tppart { </template>
width: 100%;
max-height: 69vh; <style scoped lang="scss">
overflow-y: auto; .box {
display: grid; width: 100%;
justify-items: center; background-color: #f9fafb;
.tpone { .headpart {
width: 91%; width: 92%;
height: 264rpx; height: 194rpx;
padding: 20rpx 4%; border-radius: 24rpx;
box-sizing: border-box; background-color: #eff6ff;
border-radius: 24rpx; margin: 32rpx auto;
background: linear-gradient(0deg, rgba(0, 0, 0, 0.001), rgba(0, 0, 0, 0.001)), #ffffff; padding: 20rpx 3%;
box-sizing: border-box;
border: 2rpx solid #f3f4f6; .title {
box-shadow: color: #2563eb;
0rpx 2rpx 4rpx -2rpx rgba(0, 0, 0, 0.1), font-size: 28rpx;
0rpx 2rpx 6rpx 0rpx rgba(0, 0, 0, 0.1); margin-top: 16rpx;
margin-top: 32rpx; }
display: grid;
.time {
.topp { margin-top: 16rpx;
display: flex; color: #4b5563;
font-size: 28rpx;
.rightpart { }
margin-left: 32rpx; }
display: grid;
justify-items: left; .tppart {
align-content: baseline; width: 100%;
max-height: 69vh;
.name { overflow-y: auto;
font-family: Roboto; display: grid;
font-size: 28rpx; justify-items: center;
font-weight: 500;
line-height: 42rpx; .tpone {
letter-spacing: normal; width: 91%;
color: #000000; height: 264rpx;
margin-top: 7rpx; padding: 20rpx 4%;
} box-sizing: border-box;
border-radius: 24rpx;
.class { background: linear-gradient(0deg, rgba(0, 0, 0, 0.001), rgba(0, 0, 0, 0.001)), #ffffff;
font-family: Roboto; box-sizing: border-box;
font-size: 28rpx; border: 2rpx solid #f3f4f6;
font-weight: normal; box-shadow:
line-height: 40rpx; 0rpx 2rpx 4rpx -2rpx rgba(0, 0, 0, 0.1),
letter-spacing: normal; 0rpx 2rpx 6rpx 0rpx rgba(0, 0, 0, 0.1);
color: #6b7280; margin-top: 32rpx;
margin-top: 7rpx; display: grid;
}
} .topp {
} display: flex;
.bottomp { .rightpart {
display: flex; margin-left: 32rpx;
justify-content: space-between; display: grid;
gap: 0rpx 20rpx; justify-items: left;
align-content: baseline;
.minbut {
flex: 1; .name {
width: 190rpx; font-family: Roboto;
height: 76rpx; font-size: 28rpx;
/* 自动布局 */ font-weight: 500;
display: flex; line-height: 42rpx;
justify-content: center; letter-spacing: normal;
padding: 16rpx 32rpx; color: #000000;
flex-wrap: wrap; margin-top: 7rpx;
align-content: flex-start; }
border-radius: 8rpx;
background: #ffffff; .class {
box-sizing: border-box; font-family: Roboto;
border: 2rpx solid #d1d5db; font-size: 28rpx;
font-family: Roboto; font-weight: normal;
font-size: 28rpx; line-height: 40rpx;
font-weight: normal; letter-spacing: normal;
line-height: 40rpx; color: #6b7280;
text-align: center; margin-top: 7rpx;
letter-spacing: normal; }
color: #4b5563; }
} }
.minbut.active { .bottomp {
border: 2rpx solid #2563eb; display: flex;
color: #2563eb; justify-content: space-between;
} gap: 0rpx 20rpx;
}
} .minbut {
flex: 1;
.tpone:first-child { width: 190rpx;
margin-top: 0; height: 76rpx;
} /* 自动布局 */
} display: flex;
justify-content: center;
.bottbutton { padding: 16rpx 32rpx;
width: 100%; flex-wrap: wrap;
height: 10vh; align-content: flex-start;
display: flex; border-radius: 8rpx;
padding: 24rpx 32rpx; background: #ffffff;
gap: 0rpx 24rpx; box-sizing: border-box;
flex-wrap: wrap; border: 2rpx solid #d1d5db;
align-content: flex-start; font-family: Roboto;
background: #ffffff; font-size: 28rpx;
box-sizing: border-box; font-weight: normal;
border-width: 2rpx 0rpx 0rpx 0rpx; line-height: 40rpx;
border-style: solid; text-align: center;
border-color: #f3f4f6; letter-spacing: normal;
position: fixed; color: #4b5563;
bottom: 0; }
.qbty { .minbut.active {
width: 331rpx; border: 2rpx solid #2563eb;
height: 90rpx; color: #2563eb;
/* 自动布局 */ }
display: flex; }
box-sizing: border-box; }
justify-content: center;
padding: 24rpx 0rpx; .tpone:first-child {
gap: 0rpx 20rpx; margin-top: 0;
flex-wrap: wrap; }
border-radius: 8rpx; }
background: #eff6ff;
font-family: Roboto; .bottbutton {
font-size: 28rpx; width: 100%;
font-weight: 500; height: 10vh;
line-height: 42rpx; display: flex;
text-align: center; padding: 24rpx 32rpx;
letter-spacing: normal; gap: 0rpx 24rpx;
color: #2563eb; flex-wrap: wrap;
} align-content: flex-start;
background: #ffffff;
.tjtp { box-sizing: border-box;
width: 331rpx; border-width: 2rpx 0rpx 0rpx 0rpx;
height: 90rpx; border-style: solid;
/* 自动布局 */ border-color: #f3f4f6;
display: flex; position: fixed;
box-sizing: border-box; bottom: 0;
justify-content: center;
padding: 24rpx 0rpx; .qbty {
gap: 0rpx 20rpx; width: 331rpx;
flex-wrap: wrap; height: 90rpx;
border-radius: 8rpx; /* 自动布局 */
background: #2563eb; display: flex;
font-family: Roboto; box-sizing: border-box;
font-size: 28rpx; justify-content: center;
font-weight: 500; padding: 24rpx 0rpx;
line-height: 42rpx; gap: 0rpx 20rpx;
text-align: center; flex-wrap: wrap;
letter-spacing: normal; border-radius: 8rpx;
color: #ffffff; background: #eff6ff;
} font-family: Roboto;
} font-size: 28rpx;
font-weight: 500;
.address-items { line-height: 42rpx;
padding: 20rpx 15rpx 32rpx 28rpx; text-align: center;
background-color: #fff; letter-spacing: normal;
border-bottom: 2rpx solid #f5f5f5; color: #2563eb;
}
.left {
flex: 1; .tjtp {
overflow: hidden; width: 331rpx;
height: 90rpx;
.name { /* 自动布局 */
font-size: 28rpx; display: flex;
font-weight: 700; box-sizing: border-box;
color: #101010; justify-content: center;
line-height: 40rpx; padding: 24rpx 0rpx;
margin-right: 16rpx; gap: 0rpx 20rpx;
} flex-wrap: wrap;
border-radius: 8rpx;
.isdefault { background: #2563eb;
font-size: 20rpx; font-family: Roboto;
font-weight: 400; font-size: 28rpx;
color: #fff; font-weight: 500;
padding: 4rpx 12rpx; line-height: 42rpx;
border-radius: 8rpx; text-align: center;
background: linear-gradient(90deg, #4778ff 0%, #4778ffb8 100%); letter-spacing: normal;
} color: #ffffff;
}
.info { }
width: 100%;
color: #666; .address-items {
font-size: 24rpx; padding: 20rpx 15rpx 32rpx 28rpx;
font-weight: 400; background-color: #fff;
margin-top: 12rpx; border-bottom: 2rpx solid #f5f5f5;
}
} .left {
flex: 1;
.right { overflow: hidden;
width: 140rpx;
padding-left: 32rpx; .name {
font-size: 24rpx; font-size: 28rpx;
font-weight: 400; font-weight: 700;
color: #4979ff; color: #101010;
text-align: right; line-height: 40rpx;
} margin-right: 16rpx;
} }
.buts { .isdefault {
width: 100%; font-size: 20rpx;
height: 10vh; font-weight: 400;
background-color: F3F4F6; color: #fff;
position: fixed; padding: 4rpx 12rpx;
bottom: 0; border-radius: 8rpx;
border-top: 2rpx solid #ebebec; background: linear-gradient(90deg, #4778ff 0%, #4778ffb8 100%);
} }
}
.nodata { .info {
margin-top: 43px; width: 100%;
font-family: Source Han Sans; color: #666;
font-size: 18px; font-size: 24rpx;
font-weight: 500; font-weight: 400;
letter-spacing: normal; margin-top: 12rpx;
color: #34343F; }
} }
</style>
.right {
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