Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加单次中将人数 #27

Open
longjilidell opened this issue Dec 9, 2024 · 3 comments
Open

增加单次中将人数 #27

longjilidell opened this issue Dec 9, 2024 · 3 comments

Comments

@longjilidell
Copy link

尊敬的作者您好:
请问怎么增加某个奖品单次的中奖人数至15人/次,单次10人少了,
可否给予指导

@LOG1997
Copy link
Owner

LOG1997 commented Dec 10, 2024

这个暂时就是限制最多10人,因为单次10人容易排版

@longjilidell
Copy link
Author

longjilidell commented Dec 10, 2024 via email

@LOG1997
Copy link
Owner

LOG1997 commented Dec 10, 2024

这部分是设置抽取人数的代码,把抽取到的人push到luckyTargets里面——

const startLottery = () => {
if (!canOperate.value) {
return
}
// 验证是否已抽完全部奖项
if (currentPrize.value.isUsed || !currentPrize.value) {
toast.open({
message: '抽奖抽完了',
type: 'warning',
position: 'top-right',
duration: 10000
})
return
}
personPool.value = currentPrize.value.isAll ? notThisPrizePersonList.value : notPersonList.value
// 验证抽奖人数是否还够
if (personPool.value.length < currentPrize.value.count - currentPrize.value.isUsedCount) {
toast.open({
message: '抽奖人数不够',
type: 'warning',
position: 'top-right',
duration: 10000
})
return;
}
luckyCount.value = 10
// 自定义抽奖个数
let leftover = currentPrize.value.count - currentPrize.value.isUsedCount
const customCount = currentPrize.value.separateCount
if (customCount && customCount.enable && customCount.countList.length > 0) {
for (let i = 0; i < customCount.countList.length; i++) {
if (customCount.countList[i].isUsedCount < customCount.countList[i].count) {
leftover = customCount.countList[i].count - customCount.countList[i].isUsedCount
break;
}
}
}
leftover < luckyCount.value ? luckyCount.value = leftover : luckyCount
for (let i = 0; i < luckyCount.value; i++) {
if (personPool.value.length > 0) {
const randomIndex = Math.round(Math.random() * (personPool.value.length - 1))
luckyTargets.value.push(personPool.value[randomIndex])
personPool.value.splice(randomIndex, 1)
}
}
toast.open({
message: `现在抽取${currentPrize.value.name} ${leftover}人`,
type:'default',
position: 'top-right',
duration: 8000
})
currentStatus.value = 2
rollBall(10, 3000)
}

这部分是设置抽取到的人数排版的部分,主要是设置各个卡片的坐标、大小、角度等参数——
const stopLottery = async () => {
if (!canOperate.value) {
return
}
clearInterval(intervalTimer.value)
intervalTimer.value = null
canOperate.value = false
rollBall(0, 1)
const windowSize = { width: window.innerWidth, height: window.innerHeight }
luckyTargets.value.forEach((person: IPersonConfig, index: number) => {
let cardIndex = selectCard(luckyCardList.value, tableData.value.length, person.id)
luckyCardList.value.push(cardIndex)
let item = objects.value[cardIndex]
const { xTable, yTable } = useElementPosition(item, rowCount.value, { width: cardSize.value.width * 2, height: cardSize.value.height * 2 }, windowSize, index)
new TWEEN.Tween(item.position)
.to({
x: xTable,
y: yTable,
z: 1000
}, 1200)
.easing(TWEEN.Easing.Exponential.InOut)
.onStart(() => {
item.element = useElementStyle(item.element, person, cardIndex, patternList.value, patternColor.value, luckyColor.value, { width: cardSize.value.width * 2, height: cardSize.value.height * 2 }, textSize.value * 2, 'lucky')
})
.start()
.onComplete(() => {
canOperate.value = true
currentStatus.value = 3
})
new TWEEN.Tween(item.rotation)
.to({
x: 0,
y: 0,
z: 0
}, 900)
.easing(TWEEN.Easing.Exponential.InOut)
.start()
.onComplete(() => {
confettiFire()
resetCamera()
})
})
}

请问控制单次抽奖人数上限的代码部分在哪里呢,排版我想尝试调整一下

On Tue, Dec 10, 2024 at 9:37 AM LOG1997 @.> wrote: 这个暂时就是限制最多10人,因为单次10人容易排版 — Reply to this email directly, view it on GitHub <#27 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/BFOR7XVEK2CTA6R7EFHMIYD2EZAUZAVCNFSM6AAAAABTH55D4OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMZQGAYDGMJVGM . You are receiving this because you authored the thread.Message ID: @.>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants