2 Commits

Author SHA1 Message Date
Ethereal 5136d5bef7 将pageSize改成1000000 3 weeks ago
Ethereal 50f70955a8 优化获奖名单列表 3 weeks ago
  1. 125
      src/views/choujiang/lottery/PrizePanel.vue

125
src/views/choujiang/lottery/PrizePanel.vue

@ -137,7 +137,7 @@
></div> ></div>
<ul class="winner-list"> <ul class="winner-list">
<li <li
v-for="(user, idx) in fakeWinners"
v-for="(user, idx) in paginatedWinners"
:key="idx" :key="idx"
style=" style="
display: flex; display: flex;
@ -150,6 +150,24 @@
<span>{{ user.prizeName }}</span> <span>{{ user.prizeName }}</span>
</li> </li>
</ul> </ul>
<!-- 分页控件 -->
<div class="pagination-controls">
<button
class="pagination-btn prev-btn"
@click="prevPage"
:disabled="currentPage === 1"
>
&lt;
</button>
<span class="page-info">{{ currentPage }} / {{ totalPages }}</span>
<button
class="pagination-btn next-btn"
@click="nextPage"
:disabled="currentPage === totalPages"
>
&gt;
</button>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -298,16 +316,62 @@ const fakeWinners = ref([]);
// fakeWinners.value = winners.value; // fakeWinners.value = winners.value;
console.log("fakeWinners", fakeWinners.value); console.log("fakeWinners", fakeWinners.value);
//
const currentPage = ref(1);
const pageSize = ref(16); // 20
const totalPages = ref(1);
//
const paginatedWinners = computed(() => {
const startIndex = (currentPage.value - 1) * pageSize.value;
const endIndex = startIndex + pageSize.value;
return fakeWinners.value.slice(startIndex, endIndex);
});
//
const calculateTotalPages = () => {
totalPages.value = Math.ceil(fakeWinners.value.length / pageSize.value);
if (totalPages.value === 0) totalPages.value = 1;
};
//
const prevPage = () => {
if (currentPage.value > 1) {
currentPage.value--;
}
};
//
const nextPage = () => {
if (currentPage.value < totalPages.value) {
currentPage.value++;
}
};
import { getGetPrizeUserListApi } from "../../../api/API"; import { getGetPrizeUserListApi } from "../../../api/API";
const updateWinners = async () => { const updateWinners = async () => {
try { try {
const response = await getGetPrizeUserListApi({ const response = await getGetPrizeUserListApi({
pageSize: 1000,
pageSize: 1000000,
pageNum: 1, pageNum: 1,
}); });
console.log("updatePrizeList response", response); console.log("updatePrizeList response", response);
fakeWinners.value = response.data.list;
// createTimeid
const sortedWinners = response.data.list.sort((a, b) => {
if (a.createTime && b.createTime) {
return new Date(b.createTime) - new Date(a.createTime);
}
// id
return (b.id || 0) - (a.id || 0);
});
fakeWinners.value = sortedWinners;
console.log("updateWinners fakeWinners", fakeWinners.value); console.log("updateWinners fakeWinners", fakeWinners.value);
//
currentPage.value = 1;
calculateTotalPages();
} catch (error) { } catch (error) {
console.error("updatePrizeList error", error); console.error("updatePrizeList error", error);
} }
@ -389,6 +453,7 @@ function getProgressPercent(prize) {
onMounted(() => { onMounted(() => {
updateWinners(); updateWinners();
calculateTotalPages();
}); });
</script> </script>
@ -605,6 +670,7 @@ onMounted(() => {
justify-content: center; justify-content: center;
} }
.winner-modal { .winner-modal {
height: 700px;
background: rgba(255, 210, 131, 0.8); background: rgba(255, 210, 131, 0.8);
border-radius: 12px; border-radius: 12px;
padding-top: 12px; padding-top: 12px;
@ -638,7 +704,7 @@ onMounted(() => {
cursor: pointer; cursor: pointer;
} }
.winner-list { .winner-list {
max-height: 260px;
height: 580px;
/* background: rgba(255, 210, 131, 0.8);/ */ /* background: rgba(255, 210, 131, 0.8);/ */
overflow-y: auto; overflow-y: auto;
padding: 0; padding: 0;
@ -653,7 +719,7 @@ onMounted(() => {
display: none; /* Chrome, Safari and Opera */ display: none; /* Chrome, Safari and Opera */
} }
.winner-list li { .winner-list li {
padding: 8px 0;
padding: 7px 0;
/* border-bottom: 1px solid #f2f2f2; */ /* border-bottom: 1px solid #f2f2f2; */
font-size: 17px; font-size: 17px;
color: #d84315; color: #d84315;
@ -719,7 +785,7 @@ onMounted(() => {
} }
.prize-panel-item.revealed-highlight { .prize-panel-item.revealed-highlight {
/* border: 3px solid #ff9800; */ /* border: 3px solid #ff9800; */
box-shadow: 0 0 16px 4px #ff9800aa;
box-shadow: 0 0 16px 4px #ff9800ff, 0 0 20px 6px #ffcc80ff;
transform: scale(1.03); transform: scale(1.03);
z-index: 2; z-index: 2;
transition: all 0.3s; transition: all 0.3s;
@ -756,4 +822,51 @@ onMounted(() => {
.prize-panel-item.disabled:hover::after { .prize-panel-item.disabled:hover::after {
opacity: 1; opacity: 1;
} }
/* 分页控件样式 */
.pagination-controls {
display: flex;
justify-content: center;
align-items: center;
gap: 15px;
margin-top: 15px;
padding: 10px 0;
}
.pagination-btn {
background: linear-gradient(90deg, #ff9800 0%, #ff5722 100%);
color: white;
border: none;
border-radius: 50%;
width: 35px;
height: 35px;
font-size: 18px;
font-weight: bold;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s ease;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.pagination-btn:hover:not(:disabled) {
transform: scale(1.1);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.pagination-btn:disabled {
background: #ccc;
cursor: not-allowed;
transform: none;
box-shadow: none;
}
.page-info {
font-size: 18px;
font-weight: bold;
color: #d84315;
min-width: 60px;
text-align: center;
}
</style> </style>
Loading…
Cancel
Save