Commit 1062f014 authored by rookie0701's avatar rookie0701

feat: 添加抽奖结果音乐

parent 574a0fd0
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
<el-button <el-button
class="audio" class="audio"
type="text" type="text"
v-if="audioSrc" v-if="audioSrc && enableAudio"
@click="playAudio(!audioPlaying)" @click="playAudio(!audioPlaying)"
> >
<img v-if="audioPlaying" src="~@/assets/voice-on.svg" class="voice-icon" /> <img v-if="audioPlaying" src="~@/assets/voice-on.svg" class="voice-icon" />
...@@ -103,6 +103,7 @@ ...@@ -103,6 +103,7 @@
controls controls
autoplay autoplay
hidden hidden
v-if="enableAudio"
style="display: none" style="display: none"
loop loop
@play="playHandler" @play="playHandler"
...@@ -120,6 +121,7 @@ import Publicity from '@/components/Publicity' ...@@ -120,6 +121,7 @@ import Publicity from '@/components/Publicity'
import Tool from '@/components/Tool' import Tool from '@/components/Tool'
import bgaudio from '@/assets/bg.mp3' import bgaudio from '@/assets/bg.mp3'
import beginaudio from '@/assets/begin.mp3' import beginaudio from '@/assets/begin.mp3'
import resultaudio from '@/assets/result.mp3'
import { import {
getData, getData,
configField, configField,
...@@ -128,7 +130,8 @@ import { ...@@ -128,7 +130,8 @@ import {
conversionCategoryName, conversionCategoryName,
listField, listField,
BEGIN_AUDIO_ID, BEGIN_AUDIO_ID,
BG_AUDIO_ID BG_AUDIO_ID,
RESULT_AUDIO_ID
} from '@/helper/index' } from '@/helper/index'
import { luckydrawHandler } from '@/helper/algorithm' import { luckydrawHandler } from '@/helper/algorithm'
import Result from '@/components/Result' import Result from '@/components/Result'
...@@ -158,6 +161,11 @@ export default { ...@@ -158,6 +161,11 @@ export default {
this.photos.find(c => c.id === BEGIN_AUDIO_ID)?.value ?? beginaudio 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 () { resCardStyle () {
const style = { fontSize: '30px' } const style = { fontSize: '30px' }
const { number } = this.config const { number } = this.config
...@@ -221,9 +229,10 @@ export default { ...@@ -221,9 +229,10 @@ export default {
audioSrc () { audioSrc () {
if (this.currentAudioType === 'bg') { if (this.currentAudioType === 'bg') {
return this.bgaudio return this.bgaudio
} else { } else if (this.currentAudioType === 'result') {
return this.beginaudio return this.resultaudio
} }
return this.beginaudio
} }
}, },
created () { created () {
...@@ -268,7 +277,8 @@ export default { ...@@ -268,7 +277,8 @@ export default {
category: '', category: '',
audioPlaying: false, audioPlaying: false,
currentAudioType: 'bg', currentAudioType: 'bg',
lotteryResultVisible: false lotteryResultVisible: false,
enableAudio: false
} }
}, },
watch: { watch: {
...@@ -284,13 +294,25 @@ export default { ...@@ -284,13 +294,25 @@ export default {
handler () { handler () {
this.loadAudio() this.loadAudio()
} }
},
showRes (val) {
if (val) {
this.currentAudioType = 'result'
} else {
this.currentAudioType = 'bg'
}
} }
}, },
mounted () { mounted () {
boot().then(() => { boot().then(() => {
this.startTagCanvas() this.startTagCanvas()
setTimeout(() => { setTimeout(async () => {
this.getPhoto() try {
await this.getPhoto()
} finally {
this.enableAudio = true
}
}, 1000) }, 1000)
window.addEventListener('resize', this._debounceResize, { capture: false, passive: false }) window.addEventListener('resize', this._debounceResize, { capture: false, passive: false })
}) })
...@@ -363,8 +385,6 @@ export default { ...@@ -363,8 +385,6 @@ export default {
toggle (form) { toggle (form) {
const { config } = this const { config } = this
if (this.running) { if (this.running) {
this.currentAudioType = 'bg'
window.TagCanvas.SetSpeed('rootcanvas', getRandomSpeed(0.1, 0.04)) window.TagCanvas.SetSpeed('rootcanvas', getRandomSpeed(0.1, 0.04))
this.showRes = true this.showRes = true
this.running = !this.running this.running = !this.running
...@@ -396,8 +416,6 @@ export default { ...@@ -396,8 +416,6 @@ export default {
) )
this.resArr = resArr this.resArr = resArr
console.log(resArr, 111111)
this.category = category this.category = category
if (!this.result[category]) { if (!this.result[category]) {
this.$set(this.result, category, []) this.$set(this.result, category, [])
......
No preview for this file type
No preview for this file type
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
class="c-Importaudio" class="c-Importaudio"
title="导入音频" title="导入音频"
> >
<el-form label-width="140px"> <el-form label-width="160px">
<el-form-item label="背景音乐"> <el-form-item label="背景音乐">
<el-upload <el-upload
class="upload-demo" class="upload-demo"
...@@ -32,6 +32,19 @@ ...@@ -32,6 +32,19 @@
</el-upload> </el-upload>
</el-form-item> </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=" "> <el-form-item label=" ">
<div class="tips"> <div class="tips">
<div class="a">支持mp3、wav、aac, 大小不超过10MB。</div> <div class="a">支持mp3、wav、aac, 大小不超过10MB。</div>
...@@ -51,7 +64,7 @@ ...@@ -51,7 +64,7 @@
</template> </template>
<script> <script>
import ArtDialog from './ArtDialog.vue' 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' import { database, DB_STORE_NAME } from '@/helper/db'
export default { export default {
...@@ -73,6 +86,8 @@ export default { ...@@ -73,6 +86,8 @@ export default {
value: '', value: '',
bgValue: '', bgValue: '',
beginValue: '', beginValue: '',
resultValue: '',
resultName: '点击选择音频',
bgName: '点击选择音频', bgName: '点击选择音频',
beginName: '点击选择音频' beginName: '点击选择音频'
} }
...@@ -101,15 +116,17 @@ export default { ...@@ -101,15 +116,17 @@ export default {
} }
}, },
async saveHandler () { async saveHandler () {
const { beginValue, bgValue } = this const { beginValue, bgValue, resultValue } = this
if (!beginValue || !bgValue) { if (!beginValue || !bgValue || !resultValue) {
return this.$message.error('请选择音频') return this.$message.error('请选择音频')
} }
const id1 = BG_AUDIO_ID const id1 = BG_AUDIO_ID
const id2 = BEGIN_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, id1),
database.get(DB_STORE_NAME, id2) database.get(DB_STORE_NAME, id2),
database.get(DB_STORE_NAME, id3)
]) ])
const param1 = { const param1 = {
...@@ -122,6 +139,11 @@ export default { ...@@ -122,6 +139,11 @@ export default {
value: beginValue value: beginValue
} }
const param3 = {
id: id2,
value: resultValue
}
Promise.all([ Promise.all([
database[Data1 ? 'edit' : 'add']( database[Data1 ? 'edit' : 'add'](
DB_STORE_NAME, DB_STORE_NAME,
...@@ -132,14 +154,21 @@ export default { ...@@ -132,14 +154,21 @@ export default {
DB_STORE_NAME, DB_STORE_NAME,
Data2 ? id2 : param2, Data2 ? id2 : param2,
Data2 ? param2 : null Data2 ? param2 : null
),
database[Data3 ? 'edit' : 'add'](
DB_STORE_NAME,
Data3 ? id3 : param3,
Data3 ? param3 : null
) )
]) ])
.then(([res1, res2]) => { .then(([res1, res2, res3]) => {
if (res1 && res2) { if (res1 && res2 && res3) {
this.bgValue = '' this.bgValue = ''
this.beginValue = '' this.beginValue = ''
this.resultValue = ''
this.bgName = '点击选择音频' this.bgName = '点击选择音频'
this.beginName = '点击选择音频' this.beginName = '点击选择音频'
this.resultName = '点击选择音频'
this.$emit('update:visible', false) this.$emit('update:visible', false)
this.$emit('getAudio') this.$emit('getAudio')
......
...@@ -81,29 +81,42 @@ export default { ...@@ -81,29 +81,42 @@ export default {
return compose(this.resultList || [], this.list || [], this.photos || []) return compose(this.resultList || [], this.list || [], this.photos || [])
}, },
shouldShowPhoto () { shouldShowPhoto () {
const { composedList } = this return true
const len = composedList.length // const { composedList } = this
const len2 = composedList.filter(c => c.avatar).length // const len = composedList.length
if (len < 5) { // const len2 = composedList.filter(c => c.avatar).length
return len2 > 0 // if (len < 5) {
// return len2 > 0
// }
// return len2 * 2 >= len
}
},
watch: {
'$attrs.visible' (val) {
if (!val) {
this._confetti?.reset()
} }
return len2 * 2 >= len
} }
}, },
methods: { methods: {
applise () { applise () {
const myConfetti = confetti.create(this.$refs.canvas, { const myConfetti = (
resize: true, this._confetti = confetti.create(this.$refs.canvas, {
useWorker: true resize: true,
}) useWorker: true
})
)
const colors = ['#FF0000', '#FF7F00', '#FFFF00', '#00FF00', '#00FFFF', '#0000FF', '#8B00FF'] const colors = ['#FF0000', '#FF7F00', '#FFFF00', '#00FF00', '#00FFFF', '#0000FF', '#8B00FF']
const len = this.composedList.length const len = this.composedList.length
if (len > 0 && len < 5) { if (len > 0 && len < 5) {
const end = Date.now() + (5 * 1000); let count = 3
(function frame () { let end = Date.now() + (5 * 1000)
const frame = () => {
if (count < 1) return
if (!this.$attrs.visible) return
myConfetti({ myConfetti({
particleCount: 2, particleCount: 2,
angle: 60, angle: 60,
...@@ -121,11 +134,22 @@ export default { ...@@ -121,11 +134,22 @@ export default {
if (Date.now() < end) { if (Date.now() < end) {
requestAnimationFrame(frame) requestAnimationFrame(frame)
} else {
setTimeout(() => {
end = Date.now() + (5 * 1000)
frame()
count -= 1
}, 4000)
} }
}()) }
frame()
} else if (len > 3) { } else if (len > 3) {
const end = Date.now() + (5 * 1000); let count = 3
(function frame () { let end = Date.now() + (5 * 1000)
const frame = () => {
if (count < 1) return
if (!this.$attrs.visible) return
myConfetti({ myConfetti({
particleCount: 7, particleCount: 7,
spread: 160, spread: 160,
...@@ -136,8 +160,16 @@ export default { ...@@ -136,8 +160,16 @@ export default {
if (Date.now() < end) { if (Date.now() < end) {
requestAnimationFrame(frame) requestAnimationFrame(frame)
} else {
setTimeout(() => {
end = Date.now() + (5 * 1000)
frame()
count -= 1
}, 4000)
} }
}()) }
frame()
} }
} }
} }
......
...@@ -16,26 +16,28 @@ ...@@ -16,26 +16,28 @@
</span> </span>
</div> </div>
<el-scrollbar class="cc-container" :wrap-style="'max-height:700px;'"> <el-scrollbar class="cc-container" :wrap-style="'max-height:700px;'">
<div <div class="xx-list0-wrap">
v-for="(item, index) in resultList" <div
:key="index" v-for="(item, index) in resultList"
class="listrow" :key="index"
> class="listrow"
<span class="name" :class="{ 'is-empty': item.value && item.value.length === 0 }"> >
{{ item.name }} <span class="name" :class="{ 'is-empty': item.value && item.value.length === 0 }">
</span> {{ item.name }}
<div class="value">
<span v-if="item.value && item.value.length === 0">
暂未抽奖
</span> </span>
<div <div class="value">
class="card" <span v-if="item.value && item.value.length === 0">
v-for="(data, j) in item.value" 暂未抽奖
:key="j" </span>
@click="deleteRes(data.index, item)" <div
> class="card"
{{ data.name || data.index }} v-for="(data, j) in item.value"
<img src="~@/assets/delete-icon.svg" /> :key="j"
@click="deleteRes(data.index, item)"
>
{{ data.name || data.index }}
<img src="~@/assets/delete-icon.svg" />
</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -110,6 +112,9 @@ export default { ...@@ -110,6 +112,9 @@ export default {
</script> </script>
<style lang="scss"> <style lang="scss">
.c-Result { .c-Result {
.xx-list0-wrap {
padding-top: 10px;
}
.cc-container { .cc-container {
.el-scrollbar__bar.is-horizontal { .el-scrollbar__bar.is-horizontal {
display: none; display: none;
...@@ -163,8 +168,8 @@ export default { ...@@ -163,8 +168,8 @@ export default {
img { img {
display: none; display: none;
position: absolute; position: absolute;
right: -3px; right: -6px;
top: -3px; top: -6px;
width: 24px; width: 24px;
height: 24px; height: 24px;
} }
......
...@@ -125,13 +125,14 @@ ...@@ -125,13 +125,14 @@
class="c-removeoptions" class="c-removeoptions"
title="重置" title="重置"
> >
<el-form ref="form" :model="removeInfo" label-width="120px"> <el-form ref="form" :model="removeInfo" label-width="160px">
<el-form-item label="重置选项"> <el-form-item label="重置选项">
<el-radio-group v-model="removeInfo.type" class="xx-group"> <el-radio-group v-model="removeInfo.type" class="xx-group">
<el-radio border :label="0">重置全部数据</el-radio> <el-radio border :label="0">重置全部数据</el-radio>
<el-radio border :label="1">重置抽奖配置</el-radio> <el-radio border :label="1">重置抽奖配置</el-radio>
<el-radio border :label="2">重置名单</el-radio> <el-radio border :label="2">重置名单</el-radio>
<el-radio border :label="3">重置照片</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 border :label="4">重置抽奖结果</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
...@@ -155,7 +156,10 @@ import { ...@@ -155,7 +156,10 @@ import {
listField, listField,
resultField, resultField,
newLotteryField, newLotteryField,
conversionCategoryName conversionCategoryName,
BG_AUDIO_ID,
BEGIN_AUDIO_ID,
RESULT_AUDIO_ID
} from '@/helper/index' } from '@/helper/index'
import Importphoto from './Importphoto' import Importphoto from './Importphoto'
import ImportAudio from './ImportAudio' import ImportAudio from './ImportAudio'
...@@ -266,6 +270,16 @@ export default { ...@@ -266,6 +270,16 @@ export default {
removeData(resultField) removeData(resultField)
this.$store.commit('setClearResult') this.$store.commit('setClearResult')
break 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: default:
break break
} }
...@@ -493,12 +507,22 @@ export default { ...@@ -493,12 +507,22 @@ export default {
color: #60698B; color: #60698B;
line-height: 33px; line-height: 33px;
margin-top: 8px; margin-top: 8px;
margin-right: 10px
} }
.el-radio.is-bordered + .el-radio.is-bordered { .el-radio.is-bordered + .el-radio.is-bordered {
margin-left: 0px; margin-left: 0px;
} }
.el-radio.is-bordered { .el-radio.is-bordered {
margin-bottom: 10px; margin-bottom: 10px;
.el-radio__inner {
width: 24px;
height: 24px;
&::after {
width: 10px;
height: 10px;
}
}
} }
} }
</style> </style>
...@@ -56,3 +56,4 @@ export function conversionCategoryName (key) { ...@@ -56,3 +56,4 @@ export function conversionCategoryName (key) {
export const BG_AUDIO_ID = 919999998 export const BG_AUDIO_ID = 919999998
export const BEGIN_AUDIO_ID = 919999999 export const BEGIN_AUDIO_ID = 919999999
export const RESULT_AUDIO_ID = 919999997
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment