diff --git a/src/api/API.js b/src/api/API.js
index dc49aa7..abe6dfd 100644
--- a/src/api/API.js
+++ b/src/api/API.js
@@ -32,13 +32,13 @@ export function startLottery(data){
// 新增:每轮抽奖接口
export function drawLottery(data){
return request({
- url: '/lottery/draw',
+ url: '/lottery/start',
method: 'post',
data: {
gradeName: data.gradeName,
prizeName: data.prizeName,
- perWin: data.perWin,
- round: data.round
+ perWin: data.perWin
+ // round: data.round
}
})
}
\ No newline at end of file
diff --git a/src/assets/bg@2x.png b/src/assets/bg@2x.png
new file mode 100644
index 0000000..be7cf9e
Binary files /dev/null and b/src/assets/bg@2x.png differ
diff --git a/src/assets/qilin.webp b/src/assets/qilin.webp
new file mode 100644
index 0000000..15033cc
Binary files /dev/null and b/src/assets/qilin.webp differ
diff --git a/src/store/lottery.js b/src/store/lottery.js
index 10b065b..53e4900 100644
--- a/src/store/lottery.js
+++ b/src/store/lottery.js
@@ -6,6 +6,27 @@ export const useLotteryStore = defineStore('lottery', () => {
const lotteryState = ref('idle') // idle, ready, rotating, result
const lastRevealedIdx = ref(-1)
const waitingForNextReveal = ref(false)
+
+ //设置中奖人数列表
+ const winners = ref([])
+
+ // 添加用户列表管理
+ const allUsers = ref([])
+ const isUsersLoaded = ref(false)
+
+ function setWinners(list) {
+ // 如果是数组,则添加到现有数组中;如果是单个项目,则直接添加
+ if (Array.isArray(list)) {
+ winners.value = [...winners.value, ...list]
+ } else {
+ winners.value = [...winners.value, list]
+ }
+ }
+
+ function clearWinners() {
+ winners.value = []
+ }
+
function setLotteryState(state) {
lotteryState.value = state
}
@@ -18,12 +39,34 @@ export const useLotteryStore = defineStore('lottery', () => {
waitingForNextReveal.value = val
}
+ // 设置用户列表
+ function setAllUsers(users) {
+ allUsers.value = users
+ isUsersLoaded.value = true
+ }
+
+ // 获取随机用户名称
+ function getRandomUserName() {
+ if (allUsers.value.length > 0) {
+ const randomIndex = Math.floor(Math.random() * allUsers.value.length)
+ return allUsers.value[randomIndex]
+ }
+ return ""
+ }
+
return {
lotteryState,
setLotteryState,
lastRevealedIdx,
setLastRevealedIdx,
waitingForNextReveal,
- setWaitingForNextReveal
+ setWaitingForNextReveal,
+ winners,
+ setWinners,
+ clearWinners,
+ allUsers,
+ isUsersLoaded,
+ setAllUsers,
+ getRandomUserName
}
})
\ No newline at end of file
diff --git a/src/views/choujiang/index.vue b/src/views/choujiang/index.vue
index 894f7c3..6d41364 100644
--- a/src/views/choujiang/index.vue
+++ b/src/views/choujiang/index.vue
@@ -1,9 +1,7 @@