岳鹏龙 1 year ago
parent
commit
768d90416a
  1. 7
      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. 5
      src/pages/myElection/index.vue
  6. 48
      src/pages/votingElection/index.vue
  7. 2
      src/store/user.ts

7
src/api/votingElection.ts

@ -1,12 +1,10 @@
import { request } from '@/utils/http'
// 获取投票选举(正在进行)
export function getVoteprogress() {
return request.http({
url: '/api/vote_progress',
method: "GET"
method: 'GET'
})
}
@ -22,8 +20,7 @@ export function voteMember(data: any) {
export function getMyvote(data: any) {
return request.http({
url: '/api/my_vote',
method: "GET",
method: 'GET',
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(() => {
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(() => {
reset()
userStore.getUserInfo()
uni.showToast({ title: '绑定成功', icon: 'none' })
uni.showToast({ title: '签到成功,等待投票!', icon: 'none' })
})
}
@ -79,7 +79,6 @@ const save = () => {
onShow(() => {
reset()
getAdminPhone().then((res) => {
const { data } = res as { data: string }
amdinPhone.value = data || ''

5
src/pages/myElection/index.vue

@ -15,7 +15,7 @@
: 'background: #F3F4F6;color: #4B5563'
"
>
{{ item.vote_title==1?'未开始':(item.vote_title==2?'进行中':'已结束') }}
{{ item.vote_title == 1 ? '未开始' : item.vote_title == 2 ? '进行中' : '已结束' }}
</view>
</view>
</view>
@ -34,7 +34,7 @@
<text class="college">{{ candidate.position }}</text>
</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)]">
{{ choiceText(candidate.vote_result) }}
@ -137,7 +137,6 @@ const loadMore = () => {
onShow(() => {
getList()
})
</script>
<style scoped lang="scss">

48
src/pages/votingElection/index.vue

@ -94,16 +94,25 @@
duration: 1500 // ms
})
} else {
voteMember(param).then((res) => {
console.log(res, 555555555555555)
})
voteMember(param)
}
}
const showDialog = ref(false)
const navto = (url: string, mode: pageMode = 'navigateTo') => uni.$util.goToPage({ url: url ?? 'pages/index/index', mode })
const isEmptyObject = (obj: any) => {
if (obj == null) return true
if (typeof obj !== 'object' || Array.isArray(obj)) return true
return Reflect.ownKeys(obj).length === 0
}
onShow(() => {
if (userStore.mobile === '') {
uni.navigateTo({
url: '/pages/login/login'
})
} else if (isEmptyObject(userStore.userInfo)) {
showDialog.value = true
}
})
</script>
@ -132,9 +141,13 @@
</view>
</view>
<view class="bottomp">
<view class="minbut" v-for="(item, ele) in buttlist" :key="ele"
<view
class="minbut"
v-for="(item, ele) in buttlist"
:key="ele"
@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 }}
</view>
</view>
@ -147,12 +160,25 @@
<view class="tjtp" @click="submit">提交投票</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 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>
<u-modal
title="提示"
:show="showDialog"
width="650rpx"
:confirm-color="'#2979ff'"
:cancel-color="'#606266'"
:show-confirm-button="true"
:show-cancel-button="false"
:close-on-click-overlay="true"
@confirm="navto('pages/mine/index', 'reLaunch')"
@cancel="showDialog = false"
@close="showDialog = false"
>
请您签到之后再进行投票
</u-modal>
</template>
<style scoped lang="scss">
@ -393,6 +419,6 @@
font-size: 18px;
font-weight: 500;
letter-spacing: normal;
color: #34343F;
color: #34343f;
}
</style>

2
src/store/user.ts

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

Loading…
Cancel
Save