Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lottery
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hewenhao
lottery
Commits
1062f014
Commit
1062f014
authored
Aug 29, 2022
by
rookie0701
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 添加抽奖结果音乐
parent
574a0fd0
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
168 additions
and
59 deletions
+168
-59
App.vue
src/App.vue
+29
-11
begin.mp3
src/assets/begin.mp3
+0
-0
bg.mp3
src/assets/bg.mp3
+0
-0
result.mp3
src/assets/result.mp3
+0
-0
ImportAudio.vue
src/components/ImportAudio.vue
+37
-8
LotteryResult.vue
src/components/LotteryResult.vue
+49
-17
Result.vue
src/components/Result.vue
+26
-21
Tool.vue
src/components/Tool.vue
+26
-2
index.js
src/helper/index.js
+1
-0
No files found.
src/App.vue
View file @
1062f014
...
...
@@ -75,7 +75,7 @@
<el-button
class=
"audio"
type=
"text"
v-if=
"audioSrc"
v-if=
"audioSrc
&& enableAudio
"
@
click=
"playAudio(!audioPlaying)"
>
<img
v-if=
"audioPlaying"
src=
"~@/assets/voice-on.svg"
class=
"voice-icon"
/>
...
...
@@ -103,6 +103,7 @@
controls
autoplay
hidden
v-if=
"enableAudio"
style=
"display: none"
loop
@
play=
"playHandler"
...
...
@@ -120,6 +121,7 @@ import Publicity from '@/components/Publicity'
import
Tool
from
'@/components/Tool'
import
bgaudio
from
'@/assets/bg.mp3'
import
beginaudio
from
'@/assets/begin.mp3'
import
resultaudio
from
'@/assets/result.mp3'
import
{
getData
,
configField
,
...
...
@@ -128,7 +130,8 @@ import {
conversionCategoryName
,
listField
,
BEGIN_AUDIO_ID
,
BG_AUDIO_ID
BG_AUDIO_ID
,
RESULT_AUDIO_ID
}
from
'@/helper/index'
import
{
luckydrawHandler
}
from
'@/helper/algorithm'
import
Result
from
'@/components/Result'
...
...
@@ -158,6 +161,11 @@ export default {
this
.
photos
.
find
(
c
=>
c
.
id
===
BEGIN_AUDIO_ID
)?.
value
??
beginaudio
)
},
resultaudio
()
{
return
(
this
.
photos
.
find
(
c
=>
c
.
id
===
RESULT_AUDIO_ID
)?.
value
??
resultaudio
)
},
resCardStyle
()
{
const
style
=
{
fontSize
:
'30px'
}
const
{
number
}
=
this
.
config
...
...
@@ -221,9 +229,10 @@ export default {
audioSrc
()
{
if
(
this
.
currentAudioType
===
'bg'
)
{
return
this
.
bgaudio
}
else
{
return
this
.
begin
audio
}
else
if
(
this
.
currentAudioType
===
'result'
)
{
return
this
.
result
audio
}
return
this
.
beginaudio
}
},
created
()
{
...
...
@@ -268,7 +277,8 @@ export default {
category
:
''
,
audioPlaying
:
false
,
currentAudioType
:
'bg'
,
lotteryResultVisible
:
false
lotteryResultVisible
:
false
,
enableAudio
:
false
}
},
watch
:
{
...
...
@@ -284,13 +294,25 @@ export default {
handler
()
{
this
.
loadAudio
()
}
},
showRes
(
val
)
{
if
(
val
)
{
this
.
currentAudioType
=
'result'
}
else
{
this
.
currentAudioType
=
'bg'
}
}
},
mounted
()
{
boot
().
then
(()
=>
{
this
.
startTagCanvas
()
setTimeout
(()
=>
{
this
.
getPhoto
()
setTimeout
(
async
()
=>
{
try
{
await
this
.
getPhoto
()
}
finally
{
this
.
enableAudio
=
true
}
},
1000
)
window
.
addEventListener
(
'resize'
,
this
.
_debounceResize
,
{
capture
:
false
,
passive
:
false
})
})
...
...
@@ -363,8 +385,6 @@ export default {
toggle
(
form
)
{
const
{
config
}
=
this
if
(
this
.
running
)
{
this
.
currentAudioType
=
'bg'
window
.
TagCanvas
.
SetSpeed
(
'rootcanvas'
,
getRandomSpeed
(
0.1
,
0.04
))
this
.
showRes
=
true
this
.
running
=
!
this
.
running
...
...
@@ -396,8 +416,6 @@ export default {
)
this
.
resArr
=
resArr
console
.
log
(
resArr
,
111111
)
this
.
category
=
category
if
(
!
this
.
result
[
category
])
{
this
.
$set
(
this
.
result
,
category
,
[])
...
...
src/assets/begin.mp3
View file @
1062f014
No preview for this file type
src/assets/bg.mp3
View file @
1062f014
No preview for this file type
src/assets/result.mp3
0 → 100644
View file @
1062f014
File added
src/components/ImportAudio.vue
View file @
1062f014
...
...
@@ -5,7 +5,7 @@
class=
"c-Importaudio"
title=
"导入音频"
>
<el-form
label-width=
"1
4
0px"
>
<el-form
label-width=
"1
6
0px"
>
<el-form-item
label=
"背景音乐"
>
<el-upload
class=
"upload-demo"
...
...
@@ -32,6 +32,19 @@
</el-upload>
</el-form-item>
<el-form-item
label=
"抽奖结果音乐"
>
<el-upload
class=
"upload-demo"
ref=
"upload"
:on-change=
"($event) => inputChange($event, 'result')"
action=
""
:show-file-list=
"false"
accept=
".mp3,.wav,.aac"
:auto-upload=
"false"
>
<el-input
slot=
"trigger"
type=
"primary"
:value=
"resultName"
style=
"text-align: center;width:360px"
/>
</el-upload>
</el-form-item>
<el-form-item
label=
" "
>
<div
class=
"tips"
>
<div
class=
"a"
>
支持mp3、wav、aac, 大小不超过10MB。
</div>
...
...
@@ -51,7 +64,7 @@
</template>
<
script
>
import
ArtDialog
from
'./ArtDialog.vue'
import
{
BG_AUDIO_ID
,
BEGIN_AUDIO_ID
}
from
'@/helper'
import
{
BG_AUDIO_ID
,
BEGIN_AUDIO_ID
,
RESULT_AUDIO_ID
}
from
'@/helper'
import
{
database
,
DB_STORE_NAME
}
from
'@/helper/db'
export
default
{
...
...
@@ -73,6 +86,8 @@ export default {
value
:
''
,
bgValue
:
''
,
beginValue
:
''
,
resultValue
:
''
,
resultName
:
'点击选择音频'
,
bgName
:
'点击选择音频'
,
beginName
:
'点击选择音频'
}
...
...
@@ -101,15 +116,17 @@ export default {
}
},
async
saveHandler
()
{
const
{
beginValue
,
bgValue
}
=
this
if
(
!
beginValue
||
!
bgValue
)
{
const
{
beginValue
,
bgValue
,
resultValue
}
=
this
if
(
!
beginValue
||
!
bgValue
||
!
resultValue
)
{
return
this
.
$message
.
error
(
'请选择音频'
)
}
const
id1
=
BG_AUDIO_ID
const
id2
=
BEGIN_AUDIO_ID
const
[
Data1
,
Data2
]
=
await
Promise
.
all
([
const
id3
=
RESULT_AUDIO_ID
const
[
Data1
,
Data2
,
Data3
]
=
await
Promise
.
all
([
database
.
get
(
DB_STORE_NAME
,
id1
),
database
.
get
(
DB_STORE_NAME
,
id2
)
database
.
get
(
DB_STORE_NAME
,
id2
),
database
.
get
(
DB_STORE_NAME
,
id3
)
])
const
param1
=
{
...
...
@@ -122,6 +139,11 @@ export default {
value
:
beginValue
}
const
param3
=
{
id
:
id2
,
value
:
resultValue
}
Promise
.
all
([
database
[
Data1
?
'edit'
:
'add'
](
DB_STORE_NAME
,
...
...
@@ -132,14 +154,21 @@ export default {
DB_STORE_NAME
,
Data2
?
id2
:
param2
,
Data2
?
param2
:
null
),
database
[
Data3
?
'edit'
:
'add'
](
DB_STORE_NAME
,
Data3
?
id3
:
param3
,
Data3
?
param3
:
null
)
])
.
then
(([
res1
,
res2
])
=>
{
if
(
res1
&&
res2
)
{
.
then
(([
res1
,
res2
,
res3
])
=>
{
if
(
res1
&&
res2
&&
res3
)
{
this
.
bgValue
=
''
this
.
beginValue
=
''
this
.
resultValue
=
''
this
.
bgName
=
'点击选择音频'
this
.
beginName
=
'点击选择音频'
this
.
resultName
=
'点击选择音频'
this
.
$emit
(
'update:visible'
,
false
)
this
.
$emit
(
'getAudio'
)
...
...
src/components/LotteryResult.vue
View file @
1062f014
...
...
@@ -81,29 +81,42 @@ export default {
return
compose
(
this
.
resultList
||
[],
this
.
list
||
[],
this
.
photos
||
[])
},
shouldShowPhoto
()
{
const
{
composedList
}
=
this
const
len
=
composedList
.
length
const
len2
=
composedList
.
filter
(
c
=>
c
.
avatar
).
length
if
(
len
<
5
)
{
return
len2
>
0
return
true
// const { composedList } = this
// const len = composedList.length
// const len2 = composedList.filter(c => c.avatar).length
// if (len
<
5
)
{
// return len2 > 0
// }
// return len2 * 2 >= len
}
},
watch
:
{
'$attrs.visible'
(
val
)
{
if
(
!
val
)
{
this
.
_confetti
?.
reset
()
}
return
len2
*
2
>=
len
}
},
methods
:
{
applise
()
{
const
myConfetti
=
confetti
.
create
(
this
.
$refs
.
canvas
,
{
resize
:
true
,
useWorker
:
true
})
const
myConfetti
=
(
this
.
_confetti
=
confetti
.
create
(
this
.
$refs
.
canvas
,
{
resize
:
true
,
useWorker
:
true
})
)
const
colors
=
[
'#FF0000'
,
'#FF7F00'
,
'#FFFF00'
,
'#00FF00'
,
'#00FFFF'
,
'#0000FF'
,
'#8B00FF'
]
const
len
=
this
.
composedList
.
length
if
(
len
>
0
&&
len
<
5
)
{
const
end
=
Date
.
now
()
+
(
5
*
1000
);
(
function
frame
()
{
let
count
=
3
let
end
=
Date
.
now
()
+
(
5
*
1000
)
const
frame
=
()
=>
{
if
(
count
<
1
)
return
if
(
!
this
.
$attrs
.
visible
)
return
myConfetti
({
particleCount
:
2
,
angle
:
60
,
...
...
@@ -121,11 +134,22 @@ export default {
if
(
Date
.
now
()
<
end
)
{
requestAnimationFrame
(
frame
)
}
else
{
setTimeout
(()
=>
{
end
=
Date
.
now
()
+
(
5
*
1000
)
frame
()
count
-=
1
},
4000
)
}
}())
}
frame
()
}
else
if
(
len
>
3
)
{
const
end
=
Date
.
now
()
+
(
5
*
1000
);
(
function
frame
()
{
let
count
=
3
let
end
=
Date
.
now
()
+
(
5
*
1000
)
const
frame
=
()
=>
{
if
(
count
<
1
)
return
if
(
!
this
.
$attrs
.
visible
)
return
myConfetti
({
particleCount
:
7
,
spread
:
160
,
...
...
@@ -136,8 +160,16 @@ export default {
if
(
Date
.
now
()
<
end
)
{
requestAnimationFrame
(
frame
)
}
else
{
setTimeout
(()
=>
{
end
=
Date
.
now
()
+
(
5
*
1000
)
frame
()
count
-=
1
},
4000
)
}
}())
}
frame
()
}
}
}
...
...
src/components/Result.vue
View file @
1062f014
...
...
@@ -16,26 +16,28 @@
</span>
</div>
<el-scrollbar
class=
"cc-container"
:wrap-style=
"'max-height:700px;'"
>
<div
v-for=
"(item, index) in resultList"
:key=
"index"
class=
"listrow"
>
<span
class=
"name"
:class=
"
{ 'is-empty': item.value
&&
item.value.length === 0 }">
{{
item
.
name
}}
</span>
<div
class=
"value"
>
<span
v-if=
"item.value && item.value.length === 0"
>
暂未抽奖
<div
class=
"xx-list0-wrap"
>
<div
v-for=
"(item, index) in resultList"
:key=
"index"
class=
"listrow"
>
<span
class=
"name"
:class=
"
{ 'is-empty': item.value
&&
item.value.length === 0 }">
{{
item
.
name
}}
</span>
<div
class=
"card"
v-for=
"(data, j) in item.value"
:key=
"j"
@
click=
"deleteRes(data.index, item)"
>
{{
data
.
name
||
data
.
index
}}
<img
src=
"~@/assets/delete-icon.svg"
/>
<div
class=
"value"
>
<span
v-if=
"item.value && item.value.length === 0"
>
暂未抽奖
</span>
<div
class=
"card"
v-for=
"(data, j) in item.value"
:key=
"j"
@
click=
"deleteRes(data.index, item)"
>
{{
data
.
name
||
data
.
index
}}
<img
src=
"~@/assets/delete-icon.svg"
/>
</div>
</div>
</div>
</div>
...
...
@@ -110,6 +112,9 @@ export default {
</
script
>
<
style
lang=
"scss"
>
.c-Result
{
.xx-list0-wrap
{
padding-top
:
10px
;
}
.cc-container
{
.el-scrollbar__bar.is-horizontal
{
display
:
none
;
...
...
@@ -163,8 +168,8 @@ export default {
img
{
display
:
none
;
position
:
absolute
;
right
:
-
3
px
;
top
:
-
3
px
;
right
:
-
6
px
;
top
:
-
6
px
;
width
:
24px
;
height
:
24px
;
}
...
...
src/components/Tool.vue
View file @
1062f014
...
...
@@ -125,13 +125,14 @@
class=
"c-removeoptions"
title=
"重置"
>
<el-form
ref=
"form"
:model=
"removeInfo"
label-width=
"1
2
0px"
>
<el-form
ref=
"form"
:model=
"removeInfo"
label-width=
"1
6
0px"
>
<el-form-item
label=
"重置选项"
>
<el-radio-group
v-model=
"removeInfo.type"
class=
"xx-group"
>
<el-radio
border
:label=
"0"
>
重置全部数据
</el-radio>
<el-radio
border
:label=
"1"
>
重置抽奖配置
</el-radio>
<el-radio
border
:label=
"2"
>
重置名单
</el-radio>
<el-radio
border
:label=
"3"
>
重置照片
</el-radio>
<el-radio
border
:label=
"5"
>
重置音频
</el-radio>
<el-radio
border
:label=
"4"
>
重置抽奖结果
</el-radio>
</el-radio-group>
</el-form-item>
...
...
@@ -155,7 +156,10 @@ import {
listField
,
resultField
,
newLotteryField
,
conversionCategoryName
conversionCategoryName
,
BG_AUDIO_ID
,
BEGIN_AUDIO_ID
,
RESULT_AUDIO_ID
}
from
'@/helper/index'
import
Importphoto
from
'./Importphoto'
import
ImportAudio
from
'./ImportAudio'
...
...
@@ -266,6 +270,16 @@ export default {
removeData
(
resultField
)
this
.
$store
.
commit
(
'setClearResult'
)
break
case
5
:
{
Promise
.
all
([
database
.
del
(
DB_STORE_NAME
,
BG_AUDIO_ID
),
database
.
del
(
DB_STORE_NAME
,
BEGIN_AUDIO_ID
),
database
.
del
(
DB_STORE_NAME
,
RESULT_AUDIO_ID
)
]).
then
(()
=>
{
this
.
$store
.
commit
(
'setClearPhotos'
)
})
break
}
default
:
break
}
...
...
@@ -493,12 +507,22 @@ export default {
color
:
#60698B
;
line-height
:
33px
;
margin-top
:
8px
;
margin-right
:
10px
}
.el-radio.is-bordered
+
.el-radio.is-bordered
{
margin-left
:
0px
;
}
.el-radio.is-bordered
{
margin-bottom
:
10px
;
.el-radio__inner
{
width
:
24px
;
height
:
24px
;
&
:
:
after
{
width
:
10px
;
height
:
10px
;
}
}
}
}
</
style
>
src/helper/index.js
View file @
1062f014
...
...
@@ -56,3 +56,4 @@ export function conversionCategoryName (key) {
export
const
BG_AUDIO_ID
=
919999998
export
const
BEGIN_AUDIO_ID
=
919999999
export
const
RESULT_AUDIO_ID
=
919999997
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment