|
|
@ -24,12 +24,15 @@
|
|
|
|
<script setup>
|
|
|
|
<script setup>
|
|
|
|
import { ref, onUnmounted } from 'vue'
|
|
|
|
import { ref, onUnmounted } from 'vue'
|
|
|
|
import { useRouter } from 'vue-router'
|
|
|
|
import { useRouter } from 'vue-router'
|
|
|
|
|
|
|
|
import axios from 'axios'
|
|
|
|
import RollingNumber from '@/components/scrollingNumber.vue'
|
|
|
|
import RollingNumber from '@/components/scrollingNumber.vue'
|
|
|
|
|
|
|
|
|
|
|
|
const router = useRouter()
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
|
|
|
|
|
|
const isScrolling = ref(true)
|
|
|
|
const isScrolling = ref(false)
|
|
|
|
const stopNumbers = ref([1, 0, 1, 1, 4, 5, 1, 4, 1]) // 每个组件的 stopNumber 值
|
|
|
|
const stopNumbers = ref([1, 0, 1, 1, 4, 5, 1, 4, 1]) // 每个组件的 stopNumber 值
|
|
|
|
|
|
|
|
const stopName = ref('')
|
|
|
|
|
|
|
|
const studentScore = ref(0)
|
|
|
|
|
|
|
|
|
|
|
|
// 生成每个组件的随机 duration 值(80-120)
|
|
|
|
// 生成每个组件的随机 duration 值(80-120)
|
|
|
|
const durations = ref(
|
|
|
|
const durations = ref(
|
|
|
@ -40,9 +43,33 @@ const completedRolls = ref(new Array(stopNumbers.value.length).fill(false))
|
|
|
|
const confirmed = ref(false)
|
|
|
|
const confirmed = ref(false)
|
|
|
|
const isButtonPressed = ref(false)
|
|
|
|
const isButtonPressed = ref(false)
|
|
|
|
|
|
|
|
|
|
|
|
const toggleScrolling = () => {
|
|
|
|
const toggleScrolling = async () => {
|
|
|
|
isButtonPressed.value = true
|
|
|
|
isButtonPressed.value = true
|
|
|
|
if (isScrolling.value == false) {
|
|
|
|
if (isScrolling.value == false) {
|
|
|
|
|
|
|
|
// 发起后端请求
|
|
|
|
|
|
|
|
axios
|
|
|
|
|
|
|
|
.get('http://localhost:8080/get-random', {})
|
|
|
|
|
|
|
|
.then(function (response) {
|
|
|
|
|
|
|
|
console.log(JSON.stringify(response.data))
|
|
|
|
|
|
|
|
// 确保User_id存在
|
|
|
|
|
|
|
|
if (response.data.data) {
|
|
|
|
|
|
|
|
const userId = response.data.data.User_id.toString()
|
|
|
|
|
|
|
|
.split('')
|
|
|
|
|
|
|
|
.map(Number)
|
|
|
|
|
|
|
|
stopNumbers.value = userId
|
|
|
|
|
|
|
|
stopName.value = response.data.data.User_name
|
|
|
|
|
|
|
|
studentScore.value = response.data.data.User_score
|
|
|
|
|
|
|
|
durations.value = stopNumbers.value.map(
|
|
|
|
|
|
|
|
() => Math.floor(Math.random() * (120 - 80 + 1)) + 80
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
console.error('User_id not found in response data')
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.catch(function (error) {
|
|
|
|
|
|
|
|
console.log(error)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
isButtonPressed.value = false
|
|
|
|
isButtonPressed.value = false
|
|
|
|
}, 10)
|
|
|
|
}, 10)
|
|
|
@ -64,10 +91,21 @@ const handleRollCompleted = (index) => {
|
|
|
|
isButtonPressed.value = false // 确认弹窗出现后,重置按钮按下状态
|
|
|
|
isButtonPressed.value = false // 确认弹窗出现后,重置按钮按下状态
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
!confirmed.value &&
|
|
|
|
!confirmed.value &&
|
|
|
|
confirm(`抽到了: ${stopNumbers.value.join('')},确定后跳转`)
|
|
|
|
confirm(
|
|
|
|
|
|
|
|
`抽到了: ${stopNumbers.value.join('')}, ${stopName.value},确定后跳转`
|
|
|
|
|
|
|
|
)
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
confirmed.value = true
|
|
|
|
confirmed.value = true
|
|
|
|
router.push('/rating')
|
|
|
|
confirmed.value = true
|
|
|
|
|
|
|
|
// 通过 query 参数传递
|
|
|
|
|
|
|
|
router.push({
|
|
|
|
|
|
|
|
path: '/rating',
|
|
|
|
|
|
|
|
query: {
|
|
|
|
|
|
|
|
stopNumbers: stopNumbers.value.join(''),
|
|
|
|
|
|
|
|
stopName: stopName.value,
|
|
|
|
|
|
|
|
studentScore: studentScore.value
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 800)
|
|
|
|
}, 800)
|
|
|
|
}
|
|
|
|
}
|
|
|
|