Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yma16
可视化 csdn 数据
提交
164a0a18
可
可视化 csdn 数据
项目概览
yma16
/
可视化 csdn 数据
该项目与 Fork 源项目分叉
Fork自
inscode / VueJS
通知
17
Star
15
Fork
10
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
可
可视化 csdn 数据
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
164a0a18
编写于
12月 27, 2023
作者:
Q
qq_38870145
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Wed Dec 27 12:12:00 CST 2023 inscode
上级
8d09aba4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
0 addition
and
116 deletion
+0
-116
src/components/draw/Draw.vue
src/components/draw/Draw.vue
+0
-116
未找到文件。
src/components/draw/Draw.vue
浏览文件 @
164a0a18
<
template
>
<div>
<!-- 抽奖用户 列表 -->
<div
v-for=
"item in state.list"
:key=
"item.id"
style=
"display: inline-block;padding:20px"
>
<div
style=
"display: inline-block;text-align: center;"
>
<div>
{{
item
.
name
}}
</div>
<div>
<a-avatar
:size=
"
{ xs: 24, sm: 32, md: 40, lg: 64, xl: 80, xxl: 100 }">
<template
#icon
>
<img
:src=
"item.img"
>
</
template
>
</a-avatar>
</div>
</div>
</div>
<!-- 抽奖用户 随机旋转的用户-->
<!-- 0.5s 游戏开始不断轮播用户头像 -->
<div
style=
"display: flex;justify-content: center;align-items: center;margin-top:50px"
v-if=
"state.gameStatus !== 'init'"
>
<div
style=
"display: inline-block;text-align: center;"
>
<a-card
hoverable
style=
"width: 240px"
>
<
template
#cover
>
<img
:src=
"state.currentPerson?.img"
>
</
template
>
<a-card-meta
:title=
"state.currentPerson?.name"
>
<
template
#description
>
抽奖中 角色id:
{{
state
.
currentPerson
?.
id
}}
</
template
>
</a-card-meta>
</a-card>
</div>
</div>
<!-- 中奖结束弹框 -->
<a-modal
v-model:open=
"state.openModal"
title=
"恭喜你中奖"
:footer=
"null"
@
afterClose=
"afterCloseModal"
>
<p>
中奖用户名称:{{ state.currentPerson?.name }}
</p>
<p>
中奖用户id:{{ state.currentPerson?.id }}
</p>
<p><img
:src=
"state.currentPerson?.img"
></p>
</a-modal>
<!-- 开始游戏按钮 -->
<div
style=
"position:absolute;bottom:50px;text-align: center;width:100%"
>
<a-button
type=
"primary"
@
click=
"startGameBtn"
v-if=
"state.gameStatus === 'init'"
>
开始抽奖
</a-button>
<a-button
type=
"primary"
disabled
v-if=
"state.gameStatus === 'run'"
>
进行中
</a-button>
<a-button
type=
"primary"
@
click=
"restartGameBtn"
v-if=
"state.gameStatus === 'end'"
>
重新开始
</a-button>
</div>
</div>
</template>
<
script
setup
>
import
{
reactive
,
onMounted
}
from
'
vue
'
const
state
=
reactive
({
list
:
[],
currentPerson
:
{
name
:
''
,
img
:
''
,
id
:
''
},
gameStatus
:
'
init
'
,
// init 初始化 状态 run 运行 状态 end 结束状态
count
:
100
,
displayCount
:
0
,
openModal
:
false
})
// mock 用户数据
const
mockUserData
=
(
n
)
=>
{
let
data
=
[]
for
(
let
i
=
0
;
i
<
n
;
++
i
)
{
data
.
push
({
img
:
`https://t.mwm.moe/pc/?ts=
${
i
+
9
}
`
,
// 随机头像
name
:
'
角色
'
+
i
,
id
:
i
})
}
state
.
list
=
data
console
.
log
(
state
.
list
)
}
// 延时 delay
const
sleep
=
(
delay
)
=>
new
Promise
((
resolve
)
=>
setTimeout
(
resolve
,
delay
))
// 开始抽奖
const
startGameBtn
=
async
()
=>
{
let
n
=
state
.
count
while
(
n
--
)
{
state
.
displayCount
=
n
await
sleep
(
20
)
const
max
=
state
.
list
.
length
-
1
;
const
min
=
0
;
const
randomIndex
=
Math
.
floor
(
Math
.
random
()
*
(
max
-
min
))
+
min
;
state
.
currentPerson
=
state
.
list
[
randomIndex
]
console
.
log
(
'
randomIndex
'
,
randomIndex
)
console
.
log
(
'
state.currentPerson
'
,
state
.
currentPerson
)
state
.
gameStatus
=
'
run
'
}
state
.
gameStatus
=
'
end
'
state
.
openModal
=
true
}
const
afterCloseModal
=
()
=>
{
state
.
openModal
=
false
}
// 重新开始抽奖
const
restartGameBtn
=
()
=>
{
startGameBtn
()
}
onMounted
(()
=>
{
mockUserData
(
13
)
})
</
script
>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录