|
|
|
@ -7,6 +7,7 @@ import {listStudent, rollCall, updatePoints} from "@/api/student.js";
|
|
|
|
|
const loading = ref(false)
|
|
|
|
|
const cards = ref([])
|
|
|
|
|
const canSelect = ref(true)
|
|
|
|
|
const disableClick = ref(false)
|
|
|
|
|
const isResetting = ref(false)
|
|
|
|
|
const dialogVisible = ref(false)
|
|
|
|
|
const dialogVisible2 = ref(false)
|
|
|
|
@ -16,6 +17,7 @@ const avatarUrl = ref('https://api.aspark.cc')
|
|
|
|
|
const avatarKey = ref(0)
|
|
|
|
|
const pointChange = ref(0)
|
|
|
|
|
const pointChange2 = ref(0)
|
|
|
|
|
const nothingToDo = ref(false)
|
|
|
|
|
const randomEvents = ref([
|
|
|
|
|
{
|
|
|
|
|
title: "放他一马",
|
|
|
|
@ -24,6 +26,10 @@ const randomEvents = ref([
|
|
|
|
|
{
|
|
|
|
|
title: "天选之子",
|
|
|
|
|
content: "成为天选之子,看似幸运加身,实则背负孤独。所有人羡慕你的光环,却无人懂得你走过的黑暗。被命运选中,不是因为强大,而是因为只能独自面对那些无人能解的重担。(同学化身天选之子,本次点名积分 +10 )"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "无事发生",
|
|
|
|
|
content: "有时候,无事发生比风浪更让人心酸。日子在静默中悄然滑过,没有意外,也没有惊喜,连时间都像失去了温度。原以为平静是安全的,却不知这无声的流逝中,埋藏着无数未曾到来的期望和悄然消散的热情。"
|
|
|
|
|
}
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
@ -104,8 +110,7 @@ const handleRestart = () => {
|
|
|
|
|
dialogVisible2.value = false
|
|
|
|
|
if (isResetting.value) return
|
|
|
|
|
isResetting.value = true
|
|
|
|
|
canSelect.value = false
|
|
|
|
|
|
|
|
|
|
disableClick.value = false
|
|
|
|
|
cards.value.forEach(card => {
|
|
|
|
|
card.isFlipped = false
|
|
|
|
|
})
|
|
|
|
@ -207,7 +212,7 @@ const handlePointsChange = async () => {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
let response;
|
|
|
|
|
console.log(pointChange.value + ' ' + pointChange2.value)
|
|
|
|
|
// console.log(pointChange.value + ' ' + pointChange2.value)
|
|
|
|
|
if(pointChange2.value !== 0){
|
|
|
|
|
response = await updatePoints(cardResult.value.id, pointChange2.value)
|
|
|
|
|
pointChange2.value = 0
|
|
|
|
@ -221,17 +226,33 @@ const handlePointsChange = async () => {
|
|
|
|
|
dialogVisible.value = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const luckThing = () => {
|
|
|
|
|
const lens = randomEvents.value.length
|
|
|
|
|
const randomIndex = Math.floor(Math.random() * lens);
|
|
|
|
|
currentRandomEvent.value = randomEvents.value[randomIndex]
|
|
|
|
|
if (randomIndex === 1) {
|
|
|
|
|
disableClick.value = true
|
|
|
|
|
const lens = 3
|
|
|
|
|
let randomIndex = Math.floor((Date.now() * Math.random()) % lens);
|
|
|
|
|
console.log(randomIndex)
|
|
|
|
|
if (randomIndex === 1) {
|
|
|
|
|
pointChange2.value = 10
|
|
|
|
|
} else if (randomIndex >= 2) {
|
|
|
|
|
nothingToDo.value = true
|
|
|
|
|
randomIndex = 2
|
|
|
|
|
}
|
|
|
|
|
currentRandomEvent.value = randomEvents.value[randomIndex]
|
|
|
|
|
dialogVisible2.value = true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleRandomEvents = () => {
|
|
|
|
|
console.log(disableClick.value)
|
|
|
|
|
console.log()
|
|
|
|
|
if (!nothingToDo.value) {
|
|
|
|
|
handleRestart()
|
|
|
|
|
handlePointsChange()
|
|
|
|
|
} else {
|
|
|
|
|
dialogVisible2.value = false
|
|
|
|
|
nothingToDo.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
@ -319,7 +340,7 @@ const luckThing = () => {
|
|
|
|
|
type="primary"
|
|
|
|
|
@click="luckThing"
|
|
|
|
|
class="round-button"
|
|
|
|
|
|
|
|
|
|
:disabled="disableClick"
|
|
|
|
|
>
|
|
|
|
|
<i class="iconfont yaya-touzi" style="font-size: 24px;;" />
|
|
|
|
|
</el-button>
|
|
|
|
@ -340,7 +361,7 @@ const luckThing = () => {
|
|
|
|
|
height="700px"
|
|
|
|
|
:align-center="true"
|
|
|
|
|
class="profile-dialog"
|
|
|
|
|
@close="handleRestart"
|
|
|
|
|
@close="handleRandomEvents"
|
|
|
|
|
>
|
|
|
|
|
<div class="profile-content">
|
|
|
|
|
<!-- 显示随机事件的标题,原本头像位置替换为标题 -->
|
|
|
|
@ -352,7 +373,7 @@ const luckThing = () => {
|
|
|
|
|
<div class="button-container">
|
|
|
|
|
<el-button
|
|
|
|
|
type="success"
|
|
|
|
|
@click="handlePointsChange"
|
|
|
|
|
@click="dialogVisible2 = false"
|
|
|
|
|
class="round-button"
|
|
|
|
|
>
|
|
|
|
|
<i class="iconfont yaya-duigou" style="font-size: 24px;" />
|
|
|
|
|