feat: 增加点名随机事件

frontend/dev
Spark 2 months ago
parent f58023dfef
commit cd92db66e4

@ -1,8 +1,8 @@
@font-face {
font-family: "iconfont"; /* Project id 4702540 */
src: url('iconfont.woff2?t=1728542908069') format('woff2'),
url('iconfont.woff?t=1728542908069') format('woff'),
url('iconfont.ttf?t=1728542908069') format('truetype');
src: url('iconfont.woff2?t=1728720001607') format('woff2'),
url('iconfont.woff?t=1728720001607') format('woff'),
url('iconfont.ttf?t=1728720001607') format('truetype');
}
.iconfont {
@ -13,6 +13,18 @@
-moz-osx-font-smoothing: grayscale;
}
.yaya-touzi:before {
content: "\e674";
}
.yaya-touzi1:before {
content: "\e601";
}
.yaya-touzi2:before {
content: "\e635";
}
.yaya-xmark:before {
content: "\e649";
}

File diff suppressed because one or more lines are too long

@ -5,6 +5,27 @@
"css_prefix_text": "yaya-",
"description": "",
"glyphs": [
{
"icon_id": "2119065",
"name": "骰子",
"font_class": "touzi",
"unicode": "e674",
"unicode_decimal": 58996
},
{
"icon_id": "11868243",
"name": "骰子",
"font_class": "touzi1",
"unicode": "e601",
"unicode_decimal": 58881
},
{
"icon_id": "30016060",
"name": "骰子",
"font_class": "touzi2",
"unicode": "e635",
"unicode_decimal": 58933
},
{
"icon_id": "35012394",
"name": "xmark",

@ -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>
@ -458,7 +529,7 @@ body .el-dialog {
flex: 1;
margin: 0 15px;
}
.slider-button {
width: 32px;
height: 32px;

Loading…
Cancel
Save