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 class="year-title">
<view class="headpart">
<text class="title">{{ item.title }}</text>
<text class="title">{{ item.vote_title }}</text>
<view
class="type"
:style="
item.type == '投票中'
item.vote_title == 1
? 'background: #DBEAFE;color: #3B82F6;'
: item.type == '当选'
: item.vote_title == 2
? 'background: #DCFCE7;color: #10B981'
: 'background: #F3F4F6;color: #4B5563'
"
>
{{ item.type }}
{{ item.vote_title==1?'未开始':(item.vote_title==2?'进行中':'已结束') }}
</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
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"
class="candidate-item"
>
<view class="info-section">
<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">
<text class="name">{{ candidate.name }}</text>
<text class="college">{{ candidate.college }}</text>
<text class="college">{{ candidate.position }}</text>
</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)]">
{{ choiceText(candidate.choice) }}
<view :class="['choice-tag', choiceClass(candidate.vote_result)]">
{{ choiceText(candidate.vote_result) }}
</view>
</view>
</view>
@ -84,9 +84,9 @@ const choiceClass = (choice) => {
switch (choice) {
case 1:
return 'agree'
case 0:
return 'oppose'
case 2:
return 'oppose'
case 3:
return 'abstain'
default:
return ''
@ -97,8 +97,8 @@ const choiceText = (choice) => {
return (
{
1: '同意',
0: '反对',
2: '弃权'
2: '反对',
3: '弃权'
}[choice] || ''
)
}
@ -114,16 +114,14 @@ const getList = async () => {
limit: pageSize.value
}
//
const mockData = await getMyvote(param).then((res)=> {
console.log(res,66666666666);
})
const mockData = await getMyvote(param)
//
// electionList.value = [...electionList.value, ...mockData]
electionList.value.push(mockData)
electionList.value = [...electionList.value, ...mockData.data.data]
// electionList.value.push(mockData)
//
// noMoreData.value = mockData.length < pageSize.value
noMoreData.value = mockData.data.data.length < pageSize.value
} finally {
loading.value = false
}
@ -173,7 +171,7 @@ onShow(() => {
.title {
font-family: Roboto;
font-size: 32rpx;
font-weight: 500;
font-weight: 800;
letter-spacing: normal;
color: #000000;
}

2
src/pages/votingElection/index.vue

@ -66,7 +66,7 @@
xjList.value.data?.forEach((ele : { vote_result : number }) => {
ele.vote_result = 1
})
params.value = xjList.value.data
params.value = xjList.value.candidate
submit()
} else if (res.cancel) {
console.log('用户点击取消')

Loading…
Cancel
Save