|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
<script setup>
|
|
|
|
|
import {onMounted, ref, watch} from 'vue'
|
|
|
|
|
import {onMounted, ref, watch, reactive} from 'vue'
|
|
|
|
|
import {ElMessage, ElNotification} from 'element-plus'
|
|
|
|
|
import {listStudent, rollCall, updatePoints} from "@/api/student.js";
|
|
|
|
|
|
|
|
|
@ -9,11 +9,28 @@ const cards = ref([])
|
|
|
|
|
const canSelect = ref(true)
|
|
|
|
|
const isResetting = ref(false)
|
|
|
|
|
const dialogVisible = ref(false)
|
|
|
|
|
const dialogVisible2 = ref(false)
|
|
|
|
|
const cardResult = ref({})
|
|
|
|
|
const studentTable = ref([])
|
|
|
|
|
const avatarUrl = ref('https://api.aspark.cc')
|
|
|
|
|
const avatarKey = ref(0)
|
|
|
|
|
const pointChange = ref(0)
|
|
|
|
|
const pointChange2 = ref(0)
|
|
|
|
|
const randomEvents = ref([
|
|
|
|
|
{
|
|
|
|
|
title: "放他一马",
|
|
|
|
|
content: "有时候,放他一马,不是因为不在乎,而是因为明白,强求的结果只会让彼此更痛。放手的瞬间,心中隐隐作痛,却只能默默接受这无法改变的结局。(放过该同学,本次点名无效,请重新点名)"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "天选之子",
|
|
|
|
|
content: "成为天选之子,看似幸运加身,实则背负孤独。所有人羡慕你的光环,却无人懂得你走过的黑暗。被命运选中,不是因为强大,而是因为只能独自面对那些无人能解的重担。(同学化身天选之子,本次点名积分 +10 )"
|
|
|
|
|
}
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
const currentRandomEvent = ref({
|
|
|
|
|
title: '',
|
|
|
|
|
content: ''
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 洗牌
|
|
|
|
@ -84,6 +101,7 @@ const selectCard = (index) => {
|
|
|
|
|
|
|
|
|
|
const handleRestart = () => {
|
|
|
|
|
dialogVisible.value = false
|
|
|
|
|
dialogVisible2.value = false
|
|
|
|
|
if (isResetting.value) return
|
|
|
|
|
isResetting.value = true
|
|
|
|
|
canSelect.value = false
|
|
|
|
@ -184,17 +202,36 @@ onMounted(() => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const handlePointsChange = async () => {
|
|
|
|
|
if (pointChange.value === 0) {
|
|
|
|
|
if (pointChange.value === 0 && pointChange2.value === 0) {
|
|
|
|
|
dialogVisible.value = false
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
const response = await updatePoints(cardResult.value.id, pointChange.value)
|
|
|
|
|
let response;
|
|
|
|
|
console.log(pointChange.value + ' ' + pointChange2.value)
|
|
|
|
|
if(pointChange2.value !== 0){
|
|
|
|
|
response = await updatePoints(cardResult.value.id, pointChange2.value)
|
|
|
|
|
pointChange2.value = 0
|
|
|
|
|
}else{
|
|
|
|
|
response = await updatePoints(cardResult.value.id, pointChange.value)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (response.code === 0) {
|
|
|
|
|
ElMessage.error('失败,原因:' + response.msg)
|
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
|
pointChange2.value = 10
|
|
|
|
|
}
|
|
|
|
|
dialogVisible2.value = true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
@ -278,6 +315,14 @@ const handlePointsChange = async () => {
|
|
|
|
|
>
|
|
|
|
|
<i class="iconfont yaya-xmark" style="font-size: 24px;"/>
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button
|
|
|
|
|
type="primary"
|
|
|
|
|
@click="luckThing"
|
|
|
|
|
class="round-button"
|
|
|
|
|
|
|
|
|
|
>
|
|
|
|
|
<i class="iconfont yaya-touzi" style="font-size: 24px;;" />
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button
|
|
|
|
|
type="success"
|
|
|
|
|
@click="handlePointsChange"
|
|
|
|
@ -289,6 +334,32 @@ const handlePointsChange = async () => {
|
|
|
|
|
<p class="profile-bio">Coding the World.</p>
|
|
|
|
|
</div>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
<el-dialog
|
|
|
|
|
v-model="dialogVisible2"
|
|
|
|
|
width="400px"
|
|
|
|
|
height="700px"
|
|
|
|
|
:align-center="true"
|
|
|
|
|
class="profile-dialog"
|
|
|
|
|
@close="handleRestart"
|
|
|
|
|
>
|
|
|
|
|
<div class="profile-content">
|
|
|
|
|
<!-- 显示随机事件的标题,原本头像位置替换为标题 -->
|
|
|
|
|
<h2 class="profile-name">{{ currentRandomEvent.title }}</h2>
|
|
|
|
|
|
|
|
|
|
<!-- 显示随机事件的内容,原来积分区域替换为内容展示 -->
|
|
|
|
|
<p class="point-change-label">{{ currentRandomEvent.content }}</p>
|
|
|
|
|
|
|
|
|
|
<div class="button-container">
|
|
|
|
|
<el-button
|
|
|
|
|
type="success"
|
|
|
|
|
@click="handlePointsChange"
|
|
|
|
|
class="round-button"
|
|
|
|
|
>
|
|
|
|
|
<i class="iconfont yaya-duigou" style="font-size: 24px;" />
|
|
|
|
|
</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|