Browse Source

对接接口

dev
岳鹏龙 1 year ago
parent
commit
6cb86ff9f0
  1. 42
      src/pages/myElection/index.vue
  2. 2
      src/pages/votingElection/index.vue

42
src/pages/myElection/index.vue

@ -4,40 +4,40 @@
<view v-for="(item, index) in electionList" :key="index" class="election-item"> <view v-for="(item, index) in electionList" :key="index" class="election-item">
<view class="year-title"> <view class="year-title">
<view class="headpart"> <view class="headpart">
<text class="title">{{ item.title }}</text> <text class="title">{{ item.vote_title }}</text>
<view <view
class="type" class="type"
:style=" :style="
item.type == '投票中' item.vote_title == 1
? 'background: #DBEAFE;color: #3B82F6;' ? 'background: #DBEAFE;color: #3B82F6;'
: item.type == '当选' : item.vote_title == 2
? 'background: #DCFCE7;color: #10B981' ? 'background: #DCFCE7;color: #10B981'
: 'background: #F3F4F6;color: #4B5563' : 'background: #F3F4F6;color: #4B5563'
" "
> >
{{ item.type }} {{ item.vote_title==1?'未开始':(item.vote_title==2?'进行中':'已结束') }}
</view> </view>
</view> </view>
</view> </view>
<view class="flex-center-between" style="display: flex"> <view class="flex-center-between" style="display: flex" v-show="expandedStates[index]">
<view style="display: grid"> <view style="display: grid">
<view <view
v-for="(candidate, cIndex) in item.candidates.slice(0, expandedStates[index] ? item.candidates.length : 1)" v-for="(candidate, cIndex) in item.candidate.slice(0, expandedStates[index] ? cIndex : 1)"
:key="cIndex" :key="cIndex"
class="candidate-item" class="candidate-item"
> >
<view class="info-section"> <view class="info-section">
<view style="display: flex; align-items: center"> <view style="display: flex; align-items: center">
<img style="width: 96rpx; height: 96rpx; border-radius: 50%" :src="item.img" alt="" /> <img style="width: 96rpx; height: 96rpx; border-radius: 50%" :src="item.photo" alt="" />
<view style="margin-left: 24rpx; display: grid"> <view style="margin-left: 24rpx; display: grid">
<text class="name">{{ candidate.name }}</text> <text class="name">{{ candidate.name }}</text>
<text class="college">{{ candidate.college }}</text> <text class="college">{{ candidate.position }}</text>
</view> </view>
</view> </view>
<view style="display: flex; margin-top: 24rpx"> <view style="display: flex; margin-top: 24rpx;font-family: Roboto;font-size: 14px;color: #4B5563;">
我的选择 我的选择
<view :class="['choice-tag', choiceClass(candidate.choice)]"> <view :class="['choice-tag', choiceClass(candidate.vote_result)]">
{{ choiceText(candidate.choice) }} {{ choiceText(candidate.vote_result) }}
</view> </view>
</view> </view>
</view> </view>
@ -84,9 +84,9 @@ const choiceClass = (choice) => {
switch (choice) { switch (choice) {
case 1: case 1:
return 'agree' return 'agree'
case 0:
return 'oppose'
case 2: case 2:
return 'oppose'
case 3:
return 'abstain' return 'abstain'
default: default:
return '' return ''
@ -97,8 +97,8 @@ const choiceText = (choice) => {
return ( return (
{ {
1: '同意', 1: '同意',
0: '反对', 2: '反对',
2: '弃权' 3: '弃权'
}[choice] || '' }[choice] || ''
) )
} }
@ -114,16 +114,14 @@ const getList = async () => {
limit: pageSize.value limit: pageSize.value
} }
// //
const mockData = await getMyvote(param).then((res)=> { const mockData = await getMyvote(param)
console.log(res,66666666666);
})
// //
// electionList.value = [...electionList.value, ...mockData] electionList.value = [...electionList.value, ...mockData.data.data]
electionList.value.push(mockData) // electionList.value.push(mockData)
// //
// noMoreData.value = mockData.length < pageSize.value noMoreData.value = mockData.data.data.length < pageSize.value
} finally { } finally {
loading.value = false loading.value = false
} }
@ -173,7 +171,7 @@ onShow(() => {
.title { .title {
font-family: Roboto; font-family: Roboto;
font-size: 32rpx; font-size: 32rpx;
font-weight: 500; font-weight: 800;
letter-spacing: normal; letter-spacing: normal;
color: #000000; color: #000000;
} }

2
src/pages/votingElection/index.vue

@ -66,7 +66,7 @@
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.data params.value = xjList.value.candidate
submit() submit()
} else if (res.cancel) { } else if (res.cancel) {
console.log('用户点击取消') console.log('用户点击取消')

Loading…
Cancel
Save