|
|
|
@ -1,71 +1,53 @@ |
|
|
|
<script setup lang="ts"> |
|
|
|
import { getVoteprogress, voteMember, getMember_mobile, getIs_sign } from '../../api/votingElection' |
|
|
|
import useUserStore from '@/store/user' |
|
|
|
import { isEmptyObject } from '@/utils/common' |
|
|
|
import { getVoteprogress, voteMember, getMember_mobile, getIs_sign } from '../../api/votingElection' |
|
|
|
import useUserStore from '@/store/user' |
|
|
|
import { isEmptyObject } from '@/utils/common' |
|
|
|
import { getSign, getmemberMobileGet } from '@/api/login' |
|
|
|
|
|
|
|
const userStore = useUserStore() |
|
|
|
const userStore = useUserStore() |
|
|
|
|
|
|
|
const showDialogRef = ref() |
|
|
|
const showDialogRef = ref() |
|
|
|
|
|
|
|
const reListRef = ref() |
|
|
|
|
|
|
|
const xjList = ref<any>({}) |
|
|
|
const xjList = ref<any>({}) |
|
|
|
const params = ref<any>([]) |
|
|
|
|
|
|
|
const isButton = ref(true) |
|
|
|
|
|
|
|
|
|
|
|
onLoad(() => { |
|
|
|
// if(options.meetId){ |
|
|
|
// getmemberMobileGet({ openid: userStore.openId, mobile: userStore.mobile, meetId: userStore.meetId}).then((res: any)=> { |
|
|
|
// console.log(res.data.length,666666666666); |
|
|
|
// if(res.data.length === 0) { |
|
|
|
// uni.reLaunch({ url: '/pages/mine/index?meetId='+ userStore.meetId }) |
|
|
|
// } else { |
|
|
|
// userStore.userInfo = res.data |
|
|
|
// getSign({ openid: userStore.openId, meetId: userStore.meetId }) |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// } |
|
|
|
if(userStore.userInfo.length !== 0) { |
|
|
|
getSign({ openid: userStore.openId, meetId: userStore.meetId }) |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
onLoad(() => { |
|
|
|
getVoteprogress(userStore.meetId).then((res : any) => { |
|
|
|
xjList.value = res.data |
|
|
|
params.value = res.data.candidate |
|
|
|
}) |
|
|
|
|
|
|
|
const doSearch = (_formData: { page: number; limit: number }, onSuccess: Function) => { |
|
|
|
setTimeout(()=> { |
|
|
|
getVoteprogress(userStore.meetId).then((res) => { |
|
|
|
const { data } = res as { data: { candidate: any[] } } |
|
|
|
xjList.value = data || {} |
|
|
|
onSuccess({ |
|
|
|
data: { |
|
|
|
data: data.candidate || [], |
|
|
|
total: (data.candidate || []).length |
|
|
|
if (userStore.userInfo.length !== 0) { |
|
|
|
getSign({ openid: userStore.openId, meetId: userStore.meetId }) |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
},1000) |
|
|
|
} |
|
|
|
|
|
|
|
const buttlist = ref([ |
|
|
|
|
|
|
|
const buttlist = ref([ |
|
|
|
{ |
|
|
|
type: '1', |
|
|
|
type: 1, |
|
|
|
butname: '同意' |
|
|
|
}, |
|
|
|
{ |
|
|
|
type: '2', |
|
|
|
type: 2, |
|
|
|
butname: '反对' |
|
|
|
}, |
|
|
|
{ |
|
|
|
type: '3', |
|
|
|
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) |
|
|
|
const selectBut = (data : any, cardid : any, type : number, butname : string) => { |
|
|
|
console.log(isButton.value); |
|
|
|
if (isButton.value) { |
|
|
|
const target = data.find((card : { id : any }) => card.id === cardid) |
|
|
|
uni.showModal({ |
|
|
|
title: '您本轮选举投' + butname + '票', |
|
|
|
content: '确定吗?', |
|
|
|
@ -73,44 +55,45 @@ const selectBut = (data: any, cardid: any, type: string, butname: string) => { |
|
|
|
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 |
|
|
|
params.value.forEach((ele : { id : any }) => { |
|
|
|
if (ele.id === target.id) { |
|
|
|
ele = target |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
const allChange = () => { |
|
|
|
} |
|
|
|
const allChange = () => { |
|
|
|
uni.showModal({ |
|
|
|
title: '您本轮选举全投同意票', |
|
|
|
content: '确定吗?', |
|
|
|
success: function (res) { |
|
|
|
if (res.confirm) { |
|
|
|
xjList.value.candidate?.forEach((ele: { vote_result: number }) => { |
|
|
|
params.value.forEach((ele : { vote_result : number }) => { |
|
|
|
ele.vote_result = 1 |
|
|
|
}) |
|
|
|
params.value = xjList.value.candidate |
|
|
|
submit() |
|
|
|
} else if (res.cancel) { |
|
|
|
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 }) => ({ |
|
|
|
[key1]: prop1, |
|
|
|
[key2]: prop2 |
|
|
|
})) |
|
|
|
} |
|
|
|
const submit = () => { |
|
|
|
} |
|
|
|
const submit = () => { |
|
|
|
const allHaveProperty = params.value.every((item : any) => 'vote_result' in item); |
|
|
|
if (allHaveProperty) { |
|
|
|
let param = { |
|
|
|
openid: userStore.openId, |
|
|
|
id: xjList.value.id, |
|
|
|
@ -123,15 +106,26 @@ const submit = () => { |
|
|
|
duration: 1500 // 持续时长,单位ms |
|
|
|
}) |
|
|
|
} else { |
|
|
|
voteMember(param).then((res) => { |
|
|
|
voteMember(param).then((res : any) => { |
|
|
|
if (res.code === 1) { |
|
|
|
uni.showToast({ title: res.msg, icon: 'success', duration: 1000 }) |
|
|
|
isButton.value = false |
|
|
|
} |
|
|
|
else if (res.msg === '您已投票') { |
|
|
|
console.log(res.msg); |
|
|
|
isButton.value = false |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
uni.showToast({ title: '有未选投票', icon: 'fail', duration: 1000 }) |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const onConfirm = () => uni.reLaunch({ url: '/pages/mine/index?meetId='+ userStore.meetId }) |
|
|
|
const onConfirm = () => uni.reLaunch({ url: '/pages/mine/index?meetId=' + userStore.meetId }) |
|
|
|
|
|
|
|
onShow(() => { |
|
|
|
onShow(() => { |
|
|
|
nextTick(() => { |
|
|
|
if (userStore.mobile === '') { |
|
|
|
uni.navigateTo({ |
|
|
|
@ -142,12 +136,10 @@ onShow(() => { |
|
|
|
} else if (!userStore.showtoast) { |
|
|
|
userStore.showtoast = true |
|
|
|
uni.showToast({ title: '登录成功!', icon: 'success', duration: 1000 }) |
|
|
|
setTimeout(() => reListRef.value.refreshFn(), 1100) |
|
|
|
} else { |
|
|
|
reListRef.value.refreshFn() |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
</script> |
|
|
|
|
|
|
|
<template> |
|
|
|
@ -158,36 +150,30 @@ onShow(() => { |
|
|
|
<view class="time">投票开始时间:{{ xjList.start_time }}</view> |
|
|
|
<view class="time">投票截止时间:{{ xjList.end_time }}</view> |
|
|
|
</view> |
|
|
|
<ex-list ref="reListRef" custom-list-type="custom" :on-form-search="doSearch" :is-perform-search="false"> |
|
|
|
<template v-slot="{ data }"> |
|
|
|
|
|
|
|
<view class="tppart"> |
|
|
|
<view class="tpone" v-for="(row, index) of data" :key="'tpone' + index"> |
|
|
|
<view class="tpone" v-for="(row, index) of params" :key="row.id + index"> |
|
|
|
<view class="topp"> |
|
|
|
<img style="width: 96rpx; height: 96rpx; border-radius: 50%" :src="row.photo" alt="" /> |
|
|
|
<text class="number">{{row.num}}</text> |
|
|
|
<!-- <img style="width: 96rpx; height: 96rpx; border-radius: 50%;margin-left: 10rpx;" :src="row.photo" alt="" /> --> |
|
|
|
<view class="rightpart"> |
|
|
|
<view class="name"> |
|
|
|
{{ row.name }} |
|
|
|
</view> |
|
|
|
<view class="class"> |
|
|
|
<!-- <view class="class"> |
|
|
|
{{ row.position }} |
|
|
|
</view> |
|
|
|
</view> --> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="bottomp"> |
|
|
|
<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 }" |
|
|
|
> |
|
|
|
<view class="minbut" v-for="(item, index) in buttlist" :key="index" |
|
|
|
@click="selectBut(params, row.id, item.type, item.butname)" |
|
|
|
:class="{ active: row.vote_result === item.type }"> |
|
|
|
{{ item.butname }} |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
</ex-list> |
|
|
|
<view class="bottbutton"> |
|
|
|
<view class="qbty" @click="allChange">全部同意</view> |
|
|
|
<view class="tjtp" @click="submit">提交投票</view> |
|
|
|
@ -203,7 +189,7 @@ onShow(() => { |
|
|
|
</template> |
|
|
|
|
|
|
|
<style scoped lang="scss"> |
|
|
|
.box { |
|
|
|
.box { |
|
|
|
width: 100%; |
|
|
|
background-color: #f9fafb; |
|
|
|
|
|
|
|
@ -230,7 +216,7 @@ onShow(() => { |
|
|
|
|
|
|
|
.tppart { |
|
|
|
width: 100%; |
|
|
|
max-height: 69vh; |
|
|
|
max-height: calc(100vh - 400rpx); |
|
|
|
overflow-y: auto; |
|
|
|
display: grid; |
|
|
|
justify-items: center; |
|
|
|
@ -252,6 +238,16 @@ onShow(() => { |
|
|
|
|
|
|
|
.topp { |
|
|
|
display: flex; |
|
|
|
align-items: center; |
|
|
|
|
|
|
|
.number { |
|
|
|
font-family: Roboto; |
|
|
|
font-size: 28rpx; |
|
|
|
font-weight: 500; |
|
|
|
line-height: 42rpx; |
|
|
|
letter-spacing: normal; |
|
|
|
color: #000000; |
|
|
|
} |
|
|
|
|
|
|
|
.rightpart { |
|
|
|
margin-left: 32rpx; |
|
|
|
@ -433,13 +429,14 @@ onShow(() => { |
|
|
|
bottom: 0; |
|
|
|
border-top: 2rpx solid #ebebec; |
|
|
|
} |
|
|
|
} |
|
|
|
.nodata { |
|
|
|
margin-top: 43px; |
|
|
|
} |
|
|
|
|
|
|
|
.nodata { |
|
|
|
margin-top: 86rpx; |
|
|
|
font-family: Source Han Sans; |
|
|
|
font-size: 18px; |
|
|
|
font-size: 36rpx; |
|
|
|
font-weight: 500; |
|
|
|
letter-spacing: normal; |
|
|
|
color: #34343f; |
|
|
|
} |
|
|
|
} |
|
|
|
</style> |