no99 1 month ago
parent
commit
1aace8a704
  1. 2
      package.json
  2. 7
      src/style.css
  3. 63
      src/views/DZP.vue

2
package.json

@ -4,7 +4,7 @@
"version": "0.0.0", "version": "0.0.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite",
"dev": "vite --host",
"build": "vite build", "build": "vite build",
"preview": "vite preview" "preview": "vite preview"
}, },

7
src/style.css

@ -33,6 +33,7 @@ body {
h1 { h1 {
font-size: 3.2em; font-size: 3.2em;
line-height: 1.1; line-height: 1.1;
margin: 0;
} }
button { button {
@ -58,12 +59,6 @@ button:focus-visible {
padding: 2em; padding: 2em;
} }
#app {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}
@media (prefers-color-scheme: light) { @media (prefers-color-scheme: light) {
:root { :root {

63
src/views/DZP.vue

@ -1,6 +1,6 @@
<script setup> <script setup>
import { ref, onBeforeMount } from 'vue'
import { ref, onBeforeMount, computed } from 'vue'
const myLucky = ref() const myLucky = ref()
const wheelConfig = ref({ const wheelConfig = ref({
@ -21,32 +21,75 @@ const buttons = ref([{
fonts: [{ text: '开始', top: '-10px' }] fonts: [{ text: '开始', top: '-10px' }]
}]) }])
const prizeList=ref([1,3,5,0,2,4])
var index=0
function startCallback() { function startCallback() {
// play // play
myLucky.value.play() myLucky.value.play()
// //
setTimeout(() => { setTimeout(() => {
// 0 // 0
const index = 0
// stop // stop
myLucky.value.stop(index)
myLucky.value.stop(prizeList.value[index])
index=index+1;
}, 3000) }, 3000)
} }
const prize = ref(0)
// end // end
function endCallback(prize) {
console.log(prize)
function endCallback(prizeObj) {
console.log(prizeObj)
// alert('' + prizeObj.fonts[0].text)
prize.value = prizeObj.fonts[0].text
console.log(prize.value);
} }
const now = computed(() => {
return prize.value
})
</script> </script>
<template> <template>
<h1> 大转盘 </h1>
<div class="bk">
<h1 class="title"> 大转盘 </h1>
<div class="luckyWheel">
<div class="luckyWheel">
<LuckyWheel class="lucky" ref="myLucky" width="300px" height="300px" :default-config="wheelConfig"
:prizes="prizes" :blocks="blocks" :buttons="buttons" @start="startCallback" @end="endCallback" />
</div>
<div class="prize">
<h1>{{ now }}</h1>
</div>
<LuckyWheel class="lucky" ref="myLucky" width="300px" height="300px" :default-config="wheelConfig"
:prizes="prizes" :blocks="blocks" :buttons="buttons" @start="startCallback" @end="endCallback" />
</div> </div>
</template> </template>
<style scoped></style>
<style scoped>
.title {
display: flex;
justify-content: center;
align-items: center;
font-size: 30px;
}
.bk {
background-color: #8a9bf3;
width: 100vw;
height: 100vh;
}
.luckyWheel {
display: flex;
justify-content: center;
align-items: center;
}
.prize {
display: flex;
justify-content: center;
align-items: center;
}
</style>
Loading…
Cancel
Save