Browse Source

修改bug

dev
岳鹏龙 11 months ago
parent
commit
cd99668402
  1. 2
      src/api/user.ts
  2. 2
      src/pages.json
  3. 8
      src/pages/electionList/info.vue
  4. 61
      src/pages/mine/index.vue
  5. 117
      src/pages/votingElection/index.vue
  6. 20
      src/store/user.ts

2
src/api/user.ts

@ -31,7 +31,7 @@ export function getMember_mobile(data: any) {
}) })
} }
export function list(data: { name: string, meetId: string }) { export function list(data: any) {
return request.http({ return request.http({
url: '/api/member_name', url: '/api/member_name',
method: 'GET', method: 'GET',

2
src/pages.json

@ -57,7 +57,7 @@
"path": "pages/mine/index", "path": "pages/mine/index",
"style": { "style": {
"navigationBarTitleText": "个人信息", "navigationBarTitleText": "个人信息",
"enablePullDownRefresh": true "enablePullDownRefresh": false
} }
}, },
{ {

8
src/pages/electionList/info.vue

@ -60,16 +60,16 @@ onLoad((opt) => {
<view class="progress"> <view class="progress">
<view class="flex-center-between progress-text"> <view class="flex-center-between progress-text">
<text>同意</text> <text>同意</text>
<text class="b">{{ v.agree_num }} ({{ toFixed2(v.ageree_percent) }}%)</text> <text class="b">{{ v.agree_num }} ({{ toFixed2(v.agree_percent) }}%)</text>
</view> </view>
<u-line-progress :percentage="v.ageree_percent" height="8rpx" active-color="#2563EB" :show-text="false" /> <u-line-progress :percentage="v.agree_percent" height="8rpx" active-color="#2563EB" :show-text="false" />
</view> </view>
<view class="progress"> <view class="progress">
<view class="flex-center-between progress-text"> <view class="flex-center-between progress-text">
<text>反对</text> <text>反对</text>
<text class="e">{{ v.disagree_num }} ({{ toFixed2(v.giveup_percent) }}%)</text> <text class="e">{{ v.disagree_num }} ({{ toFixed2(v.disagree_percent) }}%)</text>
</view> </view>
<u-line-progress :percentage="v.giveup_percent" height="8rpx" active-color="#ef4444" :show-text="false" /> <u-line-progress :percentage="v.disagree_percent" height="8rpx" active-color="#ef4444" :show-text="false" />
</view> </view>
<view class="progress"> <view class="progress">
<view class="flex-center-between progress-text"> <view class="flex-center-between progress-text">

61
src/pages/mine/index.vue

@ -8,6 +8,7 @@ const userStore = useUserStore()
const isHandleUserInfo = computed(() => Object.keys(userStore.userInfo).length === 0) const isHandleUserInfo = computed(() => Object.keys(userStore.userInfo).length === 0)
const keyword = ref('') const keyword = ref('')
const keyword2 = ref('')
const list = ref<dateListtype[]>([]) const list = ref<dateListtype[]>([])
@ -19,35 +20,47 @@ const navto = (url: string, params = {}) => uni.$util.goToPage({ url, params })
const getList = uni.$util.throttle(() => { const getList = uni.$util.throttle((type) => {
console.log(keyword.value,keyword2.value);
if(type === 1) {
if (keyword.value === '') { if (keyword.value === '') {
uni.showToast({ title: '请输入姓名', icon: 'none' }) uni.showToast({ title: type==1?'请输入姓名':'请输入单位', icon: 'none' })
return return
} }
// uni.showLoading({ mask: true, title: '...' })
listApi({ name: keyword.value, meetId: userStore.meetId }) listApi({ name: keyword.value, meetId: userStore.meetId })
.then((res) => { .then((res) => {
const { data } = res as { data: dateListtype[] } const { data } = res as { data: dateListtype[] }
list.value = data || [] list.value = data || []
// uni.hideLoading()
}) })
.catch(() => uni.hideLoading()) } else {
if (keyword2.value === '') {
uni.showToast({ title: type==1?'请输入姓名':'请输入单位', icon: 'none' })
return
}
listApi({ work_unit: keyword2.value, meetId: userStore.meetId })
.then((res) => {
const { data } = res as { data: dateListtype[] }
list.value = data || []
})
}
}) })
const updateUserInfo = () => { const updateUserInfo = () => {
getSign({ openid: userStore.openId, meetId: userStore.meetId })
userStore.bindUser(list.value[activeKey.value].id as number).then(() => { userStore.bindUser(list.value[activeKey.value].id as number).then(() => {
reset() reset()
uni.showToast({ title: '提交成功,等待投票!', icon: 'none' }) uni.showToast({ title: '提交成功,等待投票!', icon: 'none' })
userStore.getUserInfo()
}) })
getSign({ openid: userStore.openId, meetId: userStore.meetId }) setTimeout(()=> {
userStore.getUserInfomobile()
},1000)
} }
const reset = () => { const reset = () => {
activeKey.value = 0 activeKey.value = 0
keyword.value = '' keyword.value = ''
keyword2.value = ''
list.value = [] list.value = []
} }
@ -99,7 +112,12 @@ onPullDownRefresh(() => userStore.getUserInfo())
<view class="userview-search box flex"> <view class="userview-search box flex">
<view class="userview-search-label">姓名</view> <view class="userview-search-label">姓名</view>
<input class="flex1" type="text" placeholder="请输入您的姓名" v-model="keyword" placeholder-class="placeholder" /> <input class="flex1" type="text" placeholder="请输入您的姓名" v-model="keyword" placeholder-class="placeholder" />
<view class="userview-search-bts" @click.stop="getList">搜索</view> <view class="userview-search-bts" @click="getList(1)">搜索</view>
</view>
<view class="userview-search box flex">
<view class="userview-search-label">单位</view>
<input class="flex1" type="text" placeholder="请输入您的单位" v-model="keyword2" placeholder-class="placeholder" />
<view class="userview-search-bts" @click="getList(2)">搜索</view>
</view> </view>
<block v-if="list.length > 0"> <block v-if="list.length > 0">
@ -127,7 +145,7 @@ onPullDownRefresh(() => userStore.getUserInfo())
<ex-empty v-show="list.length <= 0" /> <ex-empty v-show="list.length <= 0" />
<view class="flex-center-evenly"> <view class="flex-center-evenly">
<view class="bts plain" v-if="list.length > 0" @click.stop="updateUserInfo">确认信息</view> <view class="bts plain" v-if="list.length > 0" @click.stop="updateUserInfo">确认信息</view>
<view class="bts" @click="navto('pages/mine/add')">新建信息</view> <view :class="list.length > 0?'bts':'bts1'" @click="navto('pages/mine/add')">新建信息</view>
</view> </view>
</block> </block>
@ -174,13 +192,13 @@ onPullDownRefresh(() => userStore.getUserInfo())
<u-icon @click.stop="openPopup('work_unit', '工作单位')" name="edit-pen-fill" color="#2563EB" size="38rpx" /> <u-icon @click.stop="openPopup('work_unit', '工作单位')" name="edit-pen-fill" color="#2563EB" size="38rpx" />
</view> </view>
</view> </view>
<view class="flex-center-between userview-info-item"> <!-- <view class="flex-center-between userview-info-item">
<view class="userview-info-item-label">职位</view> <view class="userview-info-item-label">职位</view>
<view class="userview-info-item-content flex"> <view class="userview-info-item-content flex">
<text>{{ userStore.userInfo.position }}</text> <text>{{ userStore.userInfo.position }}</text>
<u-icon @click.stop="openPopup('position', '职位')" name="edit-pen-fill" color="#2563EB" size="38rpx" /> <u-icon @click.stop="openPopup('position', '职位')" name="edit-pen-fill" color="#2563EB" size="38rpx" />
</view> </view>
</view> </view> -->
</view> </view>
<view class="userview-info box admin"> <view class="userview-info box admin">
<view>* 姓名和电话信息需要管理员修改</view> <view>* 姓名和电话信息需要管理员修改</view>
@ -264,6 +282,7 @@ onPullDownRefresh(() => userStore.getUserInfo())
} }
&-bts { &-bts {
padding: 0 20rpx;
color: #2563eb; color: #2563eb;
} }
} }
@ -322,6 +341,22 @@ onPullDownRefresh(() => userStore.getUserInfo())
border: 1rpx solid #2563eb; border: 1rpx solid #2563eb;
background-color: #2563eb; background-color: #2563eb;
&.plain {
color: #2563eb;
background-color: #eff6ff;
}
}
.bts1 {
color: #2563eb;
font-size: 28rpx;
line-height: 40rpx;
text-align: center;
border-radius: 8rpx;
padding: 24rpx 80rpx;
letter-spacing: 4rpx;
// border: 1rpx solid #2563eb;
// background-color: #2563eb;
&.plain { &.plain {
color: #2563eb; color: #2563eb;
background-color: #eff6ff; background-color: #eff6ff;

117
src/pages/votingElection/index.vue

@ -8,63 +8,45 @@ 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(() => { onLoad(() => {
// if(options.meetId){ getVoteprogress(userStore.meetId).then((res : any) => {
// getmemberMobileGet({ openid: userStore.openId, mobile: userStore.mobile, meetId: userStore.meetId}).then((res: any)=> { xjList.value = res.data
// console.log(res.data.length,666666666666); params.value = res.data.candidate
// 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) { if (userStore.userInfo.length !== 0) {
getSign({ openid: userStore.openId, meetId: userStore.meetId }) getSign({ openid: userStore.openId, meetId: userStore.meetId })
} }
}) })
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
}
})
})
},1000)
}
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 selectBut = (data : any, cardid : any, type : number, butname : string) => {
const selectBut = (data: any, cardid: any, type: string, butname: string) => { console.log(isButton.value);
if (cardid) { if (isButton.value) {
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 + '票',
@ -73,16 +55,17 @@ const selectBut = (data: any, cardid: any, type: string, butname: string) => {
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.forEach((ele : { id : any }) => {
} else { if (ele.id === target.id) {
data.forEach((ele: { vote_result: number; id: any }) => { ele = target
ele.vote_result = 1 }
}) })
} }
} }
@ -92,11 +75,9 @@ const allChange = () => {
content: '确定吗?', content: '确定吗?',
success: function (res) { success: function (res) {
if (res.confirm) { if (res.confirm) {
xjList.value.candidate?.forEach((ele: { vote_result: number }) => { params.value.forEach((ele : { vote_result : number }) => {
ele.vote_result = 1 ele.vote_result = 1
}) })
params.value = xjList.value.candidate
submit()
} else if (res.cancel) { } else if (res.cancel) {
console.log('用户点击取消') console.log('用户点击取消')
} }
@ -111,6 +92,8 @@ function extractTwoProps(arr: any, key1: string, key2: string) {
})) }))
} }
const submit = () => { const submit = () => {
const allHaveProperty = params.value.every((item : any) => 'vote_result' in item);
if (allHaveProperty) {
let param = { let param = {
openid: userStore.openId, openid: userStore.openId,
id: xjList.value.id, id: xjList.value.id,
@ -123,10 +106,21 @@ const submit = () => {
duration: 1500 // ms duration: 1500 // ms
}) })
} else { } else {
voteMember(param).then((res) => { voteMember(param).then((res : any) => {
if (res.code === 1) {
uni.showToast({ title: res.msg, icon: 'success', duration: 1000 }) 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 })
@ -142,9 +136,7 @@ onShow(() => {
} else if (!userStore.showtoast) { } else if (!userStore.showtoast) {
userStore.showtoast = true userStore.showtoast = true
uni.showToast({ title: '登录成功!', icon: 'success', duration: 1000 }) uni.showToast({ title: '登录成功!', icon: 'success', duration: 1000 })
setTimeout(() => reListRef.value.refreshFn(), 1100)
} else { } else {
reListRef.value.refreshFn()
} }
}) })
}) })
@ -158,36 +150,30 @@ onShow(() => {
<view class="time">投票开始时间{{ xjList.start_time }}</view> <view class="time">投票开始时间{{ xjList.start_time }}</view>
<view class="time">投票截止时间{{ xjList.end_time }}</view> <view class="time">投票截止时间{{ xjList.end_time }}</view>
</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="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"> <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="rightpart">
<view class="name"> <view class="name">
{{ row.name }} {{ row.name }}
</view> </view>
<view class="class"> <!-- <view class="class">
{{ row.position }} {{ row.position }}
</view> </view> -->
</view> </view>
</view> </view>
<view class="bottomp"> <view class="bottomp">
<view <view class="minbut" v-for="(item, index) in buttlist" :key="index"
class="minbut" @click="selectBut(params, row.id, item.type, item.butname)"
v-for="(item, ele) in buttlist" :class="{ active: row.vote_result === item.type }">
:key="ele"
@click="selectBut(data, row.id, item.type, item.butname)"
:class="{ active: row.vote_result === item.type }"
>
{{ item.butname }} {{ item.butname }}
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</template>
</ex-list>
<view class="bottbutton"> <view class="bottbutton">
<view class="qbty" @click="allChange">全部同意</view> <view class="qbty" @click="allChange">全部同意</view>
<view class="tjtp" @click="submit">提交投票</view> <view class="tjtp" @click="submit">提交投票</view>
@ -230,7 +216,7 @@ onShow(() => {
.tppart { .tppart {
width: 100%; width: 100%;
max-height: 69vh; max-height: calc(100vh - 400rpx);
overflow-y: auto; overflow-y: auto;
display: grid; display: grid;
justify-items: center; justify-items: center;
@ -252,6 +238,16 @@ onShow(() => {
.topp { .topp {
display: flex; display: flex;
align-items: center;
.number {
font-family: Roboto;
font-size: 28rpx;
font-weight: 500;
line-height: 42rpx;
letter-spacing: normal;
color: #000000;
}
.rightpart { .rightpart {
margin-left: 32rpx; margin-left: 32rpx;
@ -434,10 +430,11 @@ onShow(() => {
border-top: 2rpx solid #ebebec; border-top: 2rpx solid #ebebec;
} }
} }
.nodata { .nodata {
margin-top: 43px; margin-top: 86rpx;
font-family: Source Han Sans; font-family: Source Han Sans;
font-size: 18px; font-size: 36rpx;
font-weight: 500; font-weight: 500;
letter-spacing: normal; letter-spacing: normal;
color: #34343f; color: #34343f;

20
src/store/user.ts

@ -2,7 +2,7 @@
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { getPrefixName } from '@/config' import { getPrefixName } from '@/config'
import { getOpenid } from '@/api/login' import { getOpenid } from '@/api/login'
import { infoForOpenid, bind as bindApi } from '@/api/user' import { infoForOpenid,getMember_mobile, bind as bindApi } from '@/api/user'
interface userInfoStoreInt { interface userInfoStoreInt {
[n: string]: any [n: string]: any
@ -47,6 +47,21 @@ export default defineStore(
}) })
} }
function getUserInfomobile() {
return new Promise<any>( (resolve, reject) => {
getMember_mobile({ openid: openId.value})
.then((res) => {
const { data } = res as { data: userInfoStoreInt }
userInfo.value = data || {}
resolve({ code: 1, data, message: 'SUCCESS' })
})
.catch((err) => {
reject(err)
})
})
}
function bindUser(id: number) { function bindUser(id: number) {
return new Promise<any>((resolve, reject) => { return new Promise<any>((resolve, reject) => {
bindApi({ id, openid: openId.value }) bindApi({ id, openid: openId.value })
@ -82,7 +97,8 @@ export default defineStore(
getopenid, getopenid,
bindUser, bindUser,
getUserInfo, getUserInfo,
logOut logOut,
getUserInfomobile
} }
}, },
{ {

Loading…
Cancel
Save