调整课表查询

This commit is contained in:
ywyonui 2025-06-14 22:28:04 +08:00
parent 22c3a2bb4a
commit 05a03e5b2e
9 changed files with 909 additions and 385 deletions

View File

@ -28,3 +28,19 @@ export const xkxkbmInfoApi = async (params: any) => {
export const xkqddeleteApi = async (params: any) => {
return await post("/api/xkqd/delete?ids=" + params.ids);
};
/**
*
*/
export const dqpkApi = async () => {
return await get("/mobile/jz/pkkb/dqpk" );
};
/**
*
*/
export const drpkkbApi = async (params: any) => {
return await get("/mobile/jz/pkkb/drpkkb", params);
};

View File

@ -127,7 +127,14 @@
}
},
{
"path": "pages/base/grades/index",
"path": "pages/base/grades/list",
"style": {
"navigationBarTitleText": "考试列表",
"enablePullDownRefresh": false
}
},
{
"path": "pages/base/grades/detail",
"style": {
"navigationBarTitleText": "成绩查询",
"enablePullDownRefresh": false

View File

@ -0,0 +1,33 @@
/**
*
*/
export interface DrVo {
zj: number; // 周几(数字表示)
zjmc: string; // 周几名称(中文显示)
rq: Date; // 日期对象
rqmc: string; // 日期显示名称HH:mm格式
}
/**
*
*/
export interface ZcVo {
djz: number; // 第几周
mc: string; // 显示名称2025年 第18周05-01至05-07
ksrq: string; // 开始日期MM-DD格式
jsrq: string; // 结束日期MM-DD格式
drList: DrVo[]; // 这周的单日信息列表
}
/**
*
*/
export interface SjVo {
djj: number; // 全局第几节
pksjId: string; // 排课时间
mc: string; // 显示名称(如 "早1", "上2"
kssj: string; // 开始时间HH:mm格式
jssj: string; // 结束时间HH:mm格式
// pkkbList: Pkkb[]; // 排课课表列表
}

View File

@ -1,42 +1,42 @@
<template>
<view class="schedule-page">
<view class="week-selector" @click="openWeekPicker">
<text>{{ weekInfo.displayText }}</text>
<text>{{ curZc.mc }}</text>
<uni-icons type="right" size="16" color="#fff"></uni-icons>
</view>
<view class="date-tabs">
<view
v-for="(day, index) in weekDates"
v-for="(day, index) in rqList"
:key="index"
:class="['date-tab-item', { active: selectedDayIndex === index }]"
:class="['date-tab-item', { active: curRqIndex === index }]"
@click="selectDay(index)"
>
<text class="weekday">{{ day.weekday }}</text>
<text class="date">{{ day.dateMMDD }}</text>
<text class="weekday">{{ day.zjmc }}</text>
<text class="date">{{ day.rqmc }}</text>
</view>
</view>
<view class="schedule-body">
<view
v-for="(timeSlot, index) in scheduleData"
v-for="(sj, index) in sjList"
:key="index"
class="schedule-row"
>
<view class="time-slot">
<text class="slot-name">{{ timeSlot.name }}</text>
<text class="slot-time">{{ timeSlot.timeRange }}</text>
<text class="slot-name">{{ sj.mc }}</text>
<text class="slot-time">{{ sj.kssj }}-{{ sj.jssj }}</text>
</view>
<view class="course-container">
<template v-if="timeSlot.subjects && timeSlot.subjects.length > 0">
<template v-if="sj.pkkbList && sj.pkkbList.length > 0">
<view
v-for="(course, courseIndex) in timeSlot.subjects"
:key="courseIndex"
:class="['course-card', getCourseColorClass(course.subject)]"
v-for="(pkkb, pkkbIndex) in sj.pkkbList"
:key="pkkbIndex"
:class="['course-card', getCourseColorClass(pkkb.pkName)]"
>
<text class="course-subject">{{ course.subject }}</text>
<text class="course-class">{{ course.class }}</text>
<text class="course-subject">{{ pkkb.pkName }}</text>
<text class="course-class">{{ pkkb.jsName }}</text>
</view>
</template>
<view v-else class="empty-course">
@ -63,16 +63,16 @@
:scroll-top="targetScrollTop"
>
<view
v-for="(week, index) in availableWeeks"
v-for="(zc, index) in zcList"
:key="index"
:class="[
'week-item',
{ active: week.displayText === weekInfo.displayText },
{ active: zc.djz === curZc.djz },
]"
@click="selectWeek(week)"
@click="selectWeek(zc)"
>
<text>{{ week.displayText }}</text>
<text v-if="isCurrentWeek(week)" class="current-tag">当前周</text>
<text>{{ zc.mc }}</text>
<text v-if="zc.djz === curZc.djz" class="current-tag">当前周</text>
</view>
</scroll-view>
</view>
@ -87,324 +87,43 @@ import dayjs from "dayjs";
import "dayjs/locale/zh-cn";
import weekOfYear from "dayjs/plugin/weekOfYear";
import isoWeek from "dayjs/plugin/isoWeek";
import { dqpkApi, drpkkbApi } from "@/api/base/server";
import * as DataConfig from "data.config";
import { useUserStore } from "@/store/modules/user";
const { getCurXs } = useUserStore();
dayjs.locale("zh-cn");
dayjs.extend(weekOfYear);
dayjs.extend(isoWeek);
interface Course {
subject: string;
class: string;
}
let xqId = '';
interface TimeSlot {
name: string;
timeRange: string;
subjects?: Course[];
}
interface WeekInfo {
weekNumber: number;
startDate: string;
endDate: string;
displayText: string;
}
interface WeekDay {
dateFull: string;
dateMMDD: string;
weekday: string;
}
//
interface CombinedClass {
id: string; // 'g1c101'
name: string; // ' 01'
}
const combinedClassList = ref<CombinedClass[]>([]);
//
const selectedCombinedClassId = ref<string>("");
const selectedCombinedClassIndex = ref(-1);
const combinedClassRange = computed(() =>
combinedClassList.value.map((c) => c.name)
);
const selectedCombinedClassName = computed(() => {
const cls = combinedClassList.value.find(
(c) => c.id === selectedCombinedClassId.value
);
return cls ? cls.name : "";
});
//
const fetchCombinedClassList = async () => {
console.log("Fetching combined class list from backend...");
isLoading.value = true; // loading
await new Promise((resolve) => setTimeout(resolve, 300)); //
//
combinedClassList.value = [
{ id: "g1c101", name: "一年级 01班" },
{ id: "g1c102", name: "一年级 02班" },
{ id: "g2c201", name: "二年级 01班" },
{ id: "g2c202", name: "二年级 02班" },
{ id: "g2c203", name: "二年级 03班" },
{ id: "g3c301", name: "三年级 01班" },
];
console.log("Combined class list loaded:", combinedClassList.value);
isLoading.value = false;
};
//
const onCombinedClassChange = (e: any) => {
const index = parseInt(e.detail.value);
selectedCombinedClassIndex.value = index;
const selectedClass = combinedClassList.value[index];
if (selectedClass && selectedClass.id !== selectedCombinedClassId.value) {
selectedCombinedClassId.value = selectedClass.id;
//
fetchScheduleData();
}
};
//
const curZcNum = ref(dayjs().isoWeek());
//
const curZc = ref<any>({});
//
const curRqIndex = ref(0)
//
const zcList = ref<any>([])
//
const rqList = ref<any>([])
//
const sjList = ref<any>([])
const isLoading = ref(false);
const currentDate = ref(dayjs());
const selectedDayIndex = ref(0);
const scheduleData = ref<TimeSlot[]>([]);
//
const showWeekPicker = ref(false);
const weekPopup = ref<any>(null);
const weekInfo = reactive<WeekInfo>({
weekNumber: 0,
startDate: "",
endDate: "",
displayText: "",
});
const weekDates = ref<WeekDay[]>([]);
const selectedWeekNumber = ref(0);
const availableWeeks = ref<WeekInfo[]>([]);
//
const currentWeekMonday = computed(() => currentDate.value.isoWeekday(1));
//
const initializeCurrentWeekInfo = () => {
const now = dayjs();
currentDate.value = now; // Ensure currentDate is today
const monday = now.isoWeekday(1);
const friday = monday.add(4, "day");
const year = monday.year();
const weekNum = monday.isoWeek();
weekInfo.weekNumber = weekNum;
weekInfo.startDate = monday.format("MM.DD");
weekInfo.endDate = friday.format("MM.DD");
weekInfo.displayText = `${year}年 第${weekNum}周 (${monday.format(
"MM.DD"
)}-${friday.format("MM.DD")})`;
selectedWeekNumber.value = weekNum;
};
// -
const generateAvailableWeeks = () => {
const weeks: WeekInfo[] = [];
const currentYear = dayjs().year();
for (let weekNum = 1; weekNum <= 53; weekNum++) {
const monday = dayjs().year(currentYear).isoWeek(weekNum).isoWeekday(1);
if (monday.isoWeekYear() === currentYear) {
const friday = monday.add(4, "day");
const actualWeekNum = monday.isoWeek();
weeks.push({
weekNumber: actualWeekNum,
startDate: monday.format("MM.DD"),
endDate: friday.format("MM.DD"),
displayText: `${currentYear}年 第${actualWeekNum}周 (${monday.format(
"MM.DD"
)}-${friday.format("MM.DD")})`,
});
}
}
const uniqueWeeks = weeks.filter(
(week, index, self) =>
index === self.findIndex((w) => w.weekNumber === week.weekNumber)
);
availableWeeks.value = uniqueWeeks;
console.log("Generated weeks:", availableWeeks.value);
};
//
const isCurrentWeek = (week: WeekInfo) => {
return dayjs().isoWeek() === week.weekNumber;
};
// tabs
const updateWeekDates = () => {
const monday = currentDate.value.isoWeekday(1);
const dates: WeekDay[] = [];
const weekdaysZh = ["周一", "周二", "周三", "周四", "周五"];
for (let i = 0; i < 5; i++) {
const day = monday.add(i, "day");
dates.push({
dateFull: day.format("YYYY-MM-DD"),
dateMMDD: day.format("M/DD"),
weekday: weekdaysZh[i],
});
}
weekDates.value = dates;
//
const todayWeekday = dayjs().isoWeekday();
if (currentDate.value.isSame(dayjs(), "isoWeek")) {
if (todayWeekday >= 1 && todayWeekday <= 5) {
selectedDayIndex.value = todayWeekday - 1;
} else {
selectedDayIndex.value = 0; //
}
} else {
selectedDayIndex.value = 0; //
}
};
//
const fetchScheduleData = async () => {
//
if (!selectedCombinedClassId.value) {
console.log("请先选择班级");
scheduleData.value = []; //
isLoading.value = false;
return;
}
console.log(
`正在获取 ${selectedCombinedClassName.value}${weekInfo.weekNumber}周 课表数据...`
);
isLoading.value = true;
// --- API ---
// selectedCombinedClassId.value weekInfo
await new Promise((resolve) => setTimeout(resolve, 500)); //
const timeSlotTemplates = [
{ name: "上1", timeRange: "08:00-08:45" },
{ name: "上2", timeRange: "08:55-09:40" },
{ name: "上3", timeRange: "10:00-10:45" },
{ name: "上4", timeRange: "10:55-11:40" },
{ name: "下1", timeRange: "14:00-14:45" },
{ name: "下2", timeRange: "14:55-15:40" },
{ name: "下3", timeRange: "16:00-16:45" },
{ name: "下4", timeRange: "16:55-17:40" },
];
const mockData: TimeSlot[] = [];
const isOddWeek = weekInfo.weekNumber % 2 === 1;
console.log(`模拟生成 ${selectedCombinedClassId.value} 的课表`);
for (const slot of timeSlotTemplates) {
const subjectsForDay = generateSubjectsForDay(
slot.name,
selectedDayIndex.value,
isOddWeek,
selectedCombinedClassId.value // ID
);
mockData.push({
name: slot.name,
timeRange: slot.timeRange,
subjects: subjectsForDay,
});
}
scheduleData.value = mockData;
isLoading.value = false;
console.log("课表数据加载完成:", scheduleData.value);
};
// ID
const generateSubjectsForDay = (
slotName: string,
dayIndex: number,
isOddWeek: boolean,
combinedClassId: string // 使ID
): Course[] => {
const subjects: Course[] = [];
// combinedClassId
const className =
combinedClassList.value.find((c) => c.id === combinedClassId)?.name ||
combinedClassId;
if (combinedClassId === "g1c101") {
if (dayIndex === 0) {
//
if (slotName === "上1" || slotName === "上2") {
subjects.push({
subject: isOddWeek ? "语文" : "数学",
class: `(${className})`,
});
} else if (slotName === "上3") {
subjects.push({ subject: "体育", class: `(${className})` });
}
}
} else if (combinedClassId === "g2c201") {
if (dayIndex === 1 && slotName === "上2") {
subjects.push({ subject: "英语", class: `(${className})` });
}
} else {
//
if (dayIndex === 3 && slotName === "下1") {
subjects.push({ subject: "科学", class: `(${className})` });
}
}
//
if (subjects.length === 0 && dayIndex === 4 && slotName === "下4") {
subjects.push({ subject: "班会", class: `(${className})` });
}
return subjects;
};
//
const selectDay = (index: number) => {
selectedDayIndex.value = index;
fetchScheduleData();
};
//
const ESTIMATED_WEEK_ITEM_HEIGHT = 53.5; // px ()
const targetScrollTop = ref(0); // scroll-top
//
const openWeekPicker = async () => {
showWeekPicker.value = true;
//
if (availableWeeks.value.length === 0) {
console.warn("Available weeks list is empty.");
// generateAvailableWeeks(); //
}
//
const currentIndex = availableWeeks.value.findIndex(
(week) => week.weekNumber === weekInfo.weekNumber
);
if (currentIndex !== -1) {
// 使
const calculatedScrollTop = currentIndex * ESTIMATED_WEEK_ITEM_HEIGHT;
// nextTick
await nextTick();
targetScrollTop.value = calculatedScrollTop;
} else {
//
await nextTick();
targetScrollTop.value = 0; // 0
}
//
await nextTick();
if (weekPopup.value) {
@ -412,7 +131,7 @@ const openWeekPicker = async () => {
} else {
console.error("Week popup ref is not available.");
}
};
}
//
const closeWeekPicker = () => {
@ -429,32 +148,46 @@ const popupChange = (e: { show: boolean }) => {
};
//
const selectWeek = (week: WeekInfo) => {
if (week.displayText === weekInfo.displayText) {
const selectWeek = (zc: any) => {
if (zc.djz === curZc.value.djz) {
//
closeWeekPicker();
return;
}
//
Object.assign(weekInfo, week);
// currentDate
const selectedYear = parseInt(week.displayText.substring(0, 4));
const selectedIsoWeek = week.weekNumber;
currentDate.value = dayjs()
.year(selectedYear)
.isoWeek(selectedIsoWeek)
.isoWeekday(1);
// tabs
updateWeekDates();
//
Object.assign(curZc.value, zc);
Object.assign(rqList.value, curZc.value.drList);
//
closeWeekPicker();
//
selectDay(0);
};
//
fetchScheduleData();
//
const selectDay = (index: number) => {
curRqIndex.value = index;
drpkkbApi({
bjId: getCurXs.bjId,
xqId: xqId,
rq: rqList.value[index].rq
}).then(res => {
// result
if (res && res.resultCode === 1) {
sjList.value = res.result;
} else {
//
console.warn("检查报名状态接口返回错误:", res);
}
})
.catch((error) => {
//
console.error("调用检查报名状态接口失败:", error);
});
};
//
@ -468,23 +201,23 @@ const getCourseColorClass = (subject: string | undefined): string => {
onMounted(async () => {
// Make onMounted async
initializeCurrentWeekInfo();
generateAvailableWeeks();
updateWeekDates();
//
await fetchCombinedClassList();
// ()
if (combinedClassList.value.length > 0) {
selectedCombinedClassId.value = combinedClassList.value[0].id;
selectedCombinedClassIndex.value = 0;
//
await fetchScheduleData();
} else {
console.warn("No classes available to display schedule for.");
//
}
dqpkApi().then(res => {
// result
if (res && res.resultCode === 1) {
xqId = res.result.pksz.xqId;
zcList.value = res.result.zcList;
sjList.value = res.result.sjList;
//
selectWeek(zcList.value.find((zc: any) => zc.djz === curZcNum.value));
} else {
//
console.warn("检查获取当前学期课表周次相关信息接口返回错误:", res);
}
})
.catch((error) => {
//
console.error("调用获取当前学期课表周次相关信息接口失败:", error);
});
});
</script>

View File

@ -0,0 +1,724 @@
<template>
<view class="grades-page flex flex-col">
<!-- 顶部蓝色背景 -->
<view class="blue-header">
<view class="header-content">
<text class="title">2024学年第一学期二年级期中</text>
<text class="subtitle">教学质量监测成绩报告</text>
<view class="color-bar"></view>
<text class="total-score">全科满分700分</text>
<text class="grade">A</text>
<view class="grade-info">
<text class="grade-explanation" @click="showGradeInfo">等级说明</text>
<view class="grade-box">
<text class="grade-label">区域等级</text>
<text class="grade-value">相对较好</text>
</view>
</view>
</view>
</view>
<!-- 白色内容区 -->
<view class="flex-1" style="background-color: #f6f6f6; position: relative">
<view class="content-area">
<!-- 选项卡 -->
<view class="tabs">
<view
class="tab-item"
:class="{ active: activeTab === 'diagnosis' }"
@click="switchTab('diagnosis')"
>
<text>学科诊断</text>
</view>
<view
class="tab-item"
:class="{ active: activeTab === 'scores' }"
@click="switchTab('scores')"
>
<text>学科成绩</text>
</view>
<view
class="tab-item"
:class="{ active: activeTab === 'trend' }"
@click="switchTab('trend')"
>
<text>分数趋势</text>
</view>
</view>
<!-- 学科成绩视图 -->
<view class="score-view flex-1 po-re" v-if="activeTab === 'scores'">
<view class="po-ab inset-0 px-15" style="overflow: auto">
<view
class="subject-item"
v-for="(subject, index) in subjects"
:key="index"
>
<view class="subject-header">
<text class="subject-name"
>{{ subject.name }}(满分{{ subject.fullScore }})</text
>
</view>
<view class="subject-body">
<text class="subject-grade">{{ subject.grade }}</text>
<text class="detail-btn">详情</text>
</view>
</view>
</view>
</view>
<!-- 分数趋势视图 -->
<view class="trend-view" v-if="activeTab === 'trend'">
<!-- 图表占位区域 -->
<view class="radar-placeholder" id="chart-container1">
<canvas
style="width: 100%; height: 100%"
canvas-id="trendCanvas"
id="trendCanvas"
class="charts"
/>
</view>
</view>
<!-- 学科诊断视图 -->
<view class="diagnosis-view flex-1 po-re" v-if="activeTab === 'diagnosis'">
<view class="po-ab inset-0 p-15" style="overflow: auto">
<view class="radar-placeholder" id="chart-container">
<canvas
style="width: 100%; height: 100%"
canvas-id="radarCanvas"
id="radarCanvas"
class="charts"
/>
</view>
<!-- 诊断评语 -->
<view class="diagnosis-comment">
<text class="comment-title">尊敬的家长您好</text>
<text class="comment-text"
>向您祝贺朱信权同学本次考试成绩位于较优秀之列</text
>
<text class="comment-text"
>这次考试中道德与法治学科表现最优秀继续保持学科优势相对来说英语学科表现最弱不过也有27道题的答题表现超出同层次的平均</text
>
</view>
</view>
</view>
</view>
<!-- 等级说明弹窗 -->
<u-popup
:show="gradeInfoPopupVisible"
mode="center"
round="10"
:closeable="true"
@close="hideGradeInfo"
>
<view class="grade-info-popup">
<view class="popup-header">
<text class="popup-title">等级说明</text>
<u-icon
name="close"
size="20"
color="#999"
@click="hideGradeInfo"
></u-icon>
</view>
<view class="popup-content">
<view
class="grade-item"
v-for="(item, index) in gradeInfoList"
:key="index"
>
<view
class="grade-label"
:style="{ backgroundColor: item.color }"
>{{ item.grade }}</view
>
<view class="grade-desc">
<text class="grade-title">{{ item.desc }}</text>
<text class="grade-detail">{{ item.description }}</text>
</view>
</view>
</view>
</view>
</u-popup>
</view>
</view>
</template>
<script setup lang="ts">
import { ref, onMounted, watch, nextTick } from "vue";
import { navigateBack } from "@/utils/uniapp";
import uCharts from "@/components/charts/u-charts.js";
//
const activeTab = ref("scores");
//
function switchTab(tab: string) {
activeTab.value = tab;
}
//
const subjects = ref([
{ name: "语文", fullScore: 98, grade: "B" },
{ name: "数学", fullScore: 96, grade: "A" },
{ name: "英语", fullScore: 98, grade: "A" },
{ name: "科学", fullScore: 94, grade: "A" },
{ name: "音乐", fullScore: 93, grade: "A" },
{ name: "美术", fullScore: 93, grade: "A" },
{ name: "体育", fullScore: 93, grade: "A" },
]);
//
const radarData = {
categories: ["语文", "数学", "英语", "科学", "音乐", "美术", "体育"],
series: [{ name: "分数", data: [85, 90, 88, 92, 86, 91, 89] }],
};
//
const trendData = {
categories: ["01-04", "02-04", "03-04", "04-04", "05-04"],
series: [
{
name: "成绩趋势",
data: [84, 81, 89, 92, 99],
},
],
};
//
const drawRadarChart = () => {
nextTick(() => {
try {
//
const query = uni.createSelectorQuery();
query
.select("#chart-container")
.boundingClientRect((data) => {
if (!data) {
console.error("未找到雷达图容器");
return;
}
//
const rect = data as any;
const canvasWidth = rect.width || 300;
const canvasHeight = rect.height || 300;
const ctx = uni.createCanvasContext("radarCanvas");
//
const options = {
type: "radar",
context: ctx,
width: canvasWidth,
height: canvasHeight,
categories: radarData.categories,
series: radarData.series,
animation: true,
background: "#FFFFFF",
padding: [10, 10, 10, 10],
dataLabel: false,
legend: {
show: false,
},
extra: {
radar: {
gridType: "radar",
gridColor: "#CCCCCC",
gridCount: 3,
opacity: 0.2,
labelShow: true,
},
},
};
new uCharts(options);
})
.exec();
} catch (error) {
console.error("绘制雷达图出错:", error);
}
});
};
//
const drawTrendChart = () => {
nextTick(() => {
try {
//
const query = uni.createSelectorQuery();
query
.select("#chart-container1")
.boundingClientRect((data) => {
if (!data) {
console.error("未找到趋势图容器");
return;
}
//
const rect = data as any;
const canvasWidth = rect.width || 300;
const canvasHeight = rect.height || 300;
const ctx = uni.createCanvasContext("trendCanvas");
// 线
const options = {
type: "line",
context: ctx,
width: canvasWidth,
height: canvasHeight,
categories: trendData.categories,
series: trendData.series,
animation: true,
background: "#FFFFFF",
padding: [15, 15, 0, 15],
dataLabel: true,
dataPointShape: true,
enableScroll: false,
legend: {
show: false,
},
xAxis: {
disableGrid: true,
axisLine: true,
axisLineColor: "#CCCCCC",
},
yAxis: {
gridType: "dash",
dashLength: 2,
data: [
{
min: 80,
max: 100,
},
],
},
extra: {
line: {
type: "straight",
width: 2,
},
},
};
new uCharts(options);
})
.exec();
} catch (error) {
console.error("绘制趋势图出错:", error);
}
});
};
//
watch(activeTab, (newValue) => {
if (newValue === "diagnosis") {
setTimeout(drawRadarChart, 50);
} else if (newValue === "trend") {
setTimeout(drawTrendChart, 50);
}
});
onMounted(() => {
//
// DOM
setTimeout(() => {
if (activeTab.value === "diagnosis") {
drawRadarChart();
} else if (activeTab.value === "trend") {
drawTrendChart();
}
}, 300);
});
//
const gradeInfoPopupVisible = ref(false);
//
const gradeInfoList = ref([
{
grade: "A+",
color: "#FF6B6B",
desc: "优异",
description: "超过90%同学,处于年级前列",
},
{
grade: "A",
color: "#4D96FF",
desc: "相对较好",
description: "超过80%同学,表现良好",
},
{
grade: "B",
color: "#6BCB77",
desc: "良好",
description: "超过60%同学,达到年级中上水平",
},
{
grade: "C",
color: "#FFD93D",
desc: "一般",
description: "达到年级平均水平",
},
{
grade: "D",
color: "#B8B8B8",
desc: "待提高",
description: "未达到年级平均水平,需要加强",
},
]);
//
function showGradeInfo() {
gradeInfoPopupVisible.value = true;
}
//
function hideGradeInfo() {
gradeInfoPopupVisible.value = false;
}
</script>
<style lang="scss" scoped>
.grades-page {
background-color: #f8f8f8;
height: 100%;
}
/* 顶部蓝色背景 */
.blue-header {
background-color: #2672ff;
padding: 15px 15px 50px 15px;
position: relative;
color: white;
box-sizing: border-box;
.back-icon {
position: absolute;
top: 15px;
left: 15px;
}
.more-icon {
position: absolute;
top: 15px;
right: 15px;
}
.header-content {
padding-top: 30px;
display: flex;
flex-direction: column;
align-items: center;
.title {
font-size: 20px;
font-weight: 500;
text-align: center;
}
.subtitle {
font-size: 20px;
font-weight: 500;
margin-bottom: 15px;
text-align: center;
}
.color-bar {
width: 180px;
height: 15px;
background: linear-gradient(
to right,
#29b6f6,
#4caf50,
#ff9800,
#f57c00,
#ffab91,
#ffe0b2
);
border-radius: 15px;
margin-bottom: 15px;
}
.total-score {
font-size: 16px;
margin-bottom: 10px;
}
.grade {
font-size: 50px;
font-weight: bold;
margin-bottom: 15px;
}
.grade-info {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
.grade-explanation {
font-size: 14px;
margin-right: 15px;
position: relative;
padding-bottom: 2px;
&::after {
content: "";
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 1px;
background-color: rgba(255, 255, 255, 0.7);
}
}
.grade-box {
background-color: rgba(255, 255, 255, 0.2);
padding: 8px 20px;
border-radius: 6px;
display: flex;
flex-direction: column;
align-items: center;
.grade-label {
font-size: 14px;
margin-bottom: 5px;
}
.grade-value {
font-size: 16px;
font-weight: 500;
}
}
}
}
}
/* 内容区域 */
.content-area {
border-top-left-radius: 20px;
border-top-right-radius: 20px;
background-color: white;
overflow: hidden;
position: absolute;
z-index: 3;
top: -70rpx;
left: 30rpx;
right: 30rpx;
bottom: 30rpx;
display: flex;
flex-direction: column;
/* 选项卡 */
.tabs {
display: flex;
border-bottom: 1px solid #ebeef5;
.tab-item {
flex: 1;
text-align: center;
padding: 15px 0;
position: relative;
color: #606266;
font-size: 15px;
&.active {
color: #1976d2;
font-weight: 500;
&::after {
content: "";
position: absolute;
bottom: 0;
left: 25%;
width: 50%;
height: 2px;
background-color: #1976d2;
}
}
}
}
/* 学科成绩视图 */
.score-view {
padding: 15px;
.subject-item {
padding-top: 30rpx;
.subject-header {
margin-bottom: 5px;
.subject-name {
font-size: 15px;
color: #606266;
}
}
.subject-body {
display: flex;
align-items: center;
justify-content: space-between;
border-bottom: 1px solid #ebeef5;
padding-bottom: 15px;
.subject-grade {
font-size: 24px;
font-weight: bold;
}
.detail-btn {
font-size: 14px;
color: #909399;
}
}
}
}
/* 分数趋势视图 */
.trend-view {
padding: 15px;
height: 100%;
.chart-placeholder {
height: 300px;
background-color: #f8f8f8;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
.placeholder-text {
color: #909399;
font-size: 16px;
}
}
}
.radar-placeholder {
height: 300px;
background-color: #f8f8f8;
border-radius: 8px;
margin-bottom: 20px;
display: flex;
align-items: center;
justify-content: center;
.placeholder-text {
color: #909399;
font-size: 16px;
}
}
/* 学科诊断视图 */
.diagnosis-view {
padding: 15px;
.diagnosis-comment {
padding: 15px;
border-radius: 8px;
background-color: #f8f8f8;
.comment-title {
font-size: 16px;
font-weight: 500;
color: #303133;
margin-bottom: 10px;
display: block;
}
.comment-text {
font-size: 14px;
color: #606266;
line-height: 1.6;
margin-bottom: 10px;
display: block;
}
}
}
}
/* 等级说明弹窗 */
.grade-info-popup {
width: 280px;
background-color: #fff;
border-radius: 10px;
overflow: hidden;
.popup-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 15px;
border-bottom: 1px solid #f2f2f2;
.popup-title {
font-size: 16px;
font-weight: 500;
color: #333;
}
}
.popup-content {
padding: 10px 15px 20px;
max-height: 60vh;
overflow-y: auto;
.grade-item {
display: flex;
align-items: flex-start;
margin-bottom: 12px;
padding: 8px;
border-radius: 6px;
transition: all 0.3s;
&:last-child {
margin-bottom: 0;
}
&:hover {
background-color: #f9f9f9;
}
.grade-label {
width: 24px;
height: 24px;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
color: #fff;
font-size: 14px;
font-weight: bold;
margin-right: 12px;
flex-shrink: 0;
}
.grade-desc {
flex: 1;
.grade-title {
font-size: 14px;
font-weight: 500;
color: #333;
display: block;
margin-bottom: 4px;
}
.grade-detail {
font-size: 12px;
color: #666;
line-height: 1.4;
}
}
}
}
}
</style>

View File

@ -2,17 +2,17 @@
<view class="home-page">
<view class="content-container">
<!-- 用户信息卡片 -->
<view class="user-info-card">
<view class="user-info-card" v-if="currentStudent">
<view class="user-content">
<view class="user-avatar">
<image :src="currentStudent.avatar || '/static/base/home/11222.png'" class="avatar-img"></image>
<image :src="currentStudent.xstx || '/static/base/home/11222.png'" class="avatar-img"></image>
<view class="avatar-ring"></view>
</view>
<view class="user-details">
<text class="user-name">{{ currentStudent.name }}</text>
<text class="user-name">{{ currentStudent.xm }}</text>
<view class="user-class-container">
<view class="class-tag">
<text class="user-class">{{ currentStudent.grade }} {{ currentStudent.class }}</text>
<text class="user-class">{{ currentStudent.njmc }} {{ currentStudent.bjmc }}</text>
</view>
</view>
</view>
@ -113,11 +113,11 @@
@click="switchStudent(student)"
>
<view class="student-avatar">
<image :src="student.avatar || '/static/base/home/11222.png'" class="avatar-img"></image>
<image :src="student.xstx || '/static/base/home/11222.png'" class="avatar-img"></image>
</view>
<view class="student-info">
<text class="student-name">{{ student.name }}</text>
<text class="student-class">{{ student.grade }} {{ student.class }}</text>
<text class="student-name">{{ student.xm }}</text>
<text class="student-class">{{ student.njmc }} {{ student.bjmc }}</text>
</view>
<view class="check-icon" v-if="currentStudent.id === student.id">
<u-icon name="checkmark" color="#4A90E2" size="18"></u-icon>
@ -132,6 +132,9 @@
<script setup lang="ts">
import { navigateTo } from "@/utils/uniapp";
import { ref } from "vue";
import { useUserStore } from "@/store/modules/user";
const { getUser, setCurXs, getCurXs } = useUserStore();
//
const menuItems = ref([
{
@ -142,7 +145,7 @@ const menuItems = ref([
{
title: "成绩查询",
icon: "/static/base/home/file-search-line.png",
path: "/pages/base/grades/index",
path: "/pages/base/grades/detail",
},
// {
// title: "线",
@ -198,29 +201,15 @@ const announcements = ref([
const studentList = ref([
{
id: "1",
name: "陶亦菲",
grade: "2年级",
class: "01班",
avatar: "/static/base/home/11222.png",
},
{
id: "2",
name: "张小明",
grade: "4年级",
class: "03班",
avatar: "",
},
{
id: "3",
name: "王小红",
grade: "1年级",
class: "02班",
avatar: "",
},
xm: "陶亦菲",
njmc: "2年级",
bjmc: "01班",
xstx: "/static/base/home/11222.png",
}
]);
//
const currentStudent = ref(studentList.value[0]);
let currentStudent = ref(studentList.value[0]);
//
const showSelector = ref(false);
@ -244,6 +233,8 @@ function showStudentSelector() {
function switchStudent(student: any) {
currentStudent.value = student;
showSelector.value = false;
//
setCurXs(student);
//
uni.showToast({
@ -251,6 +242,11 @@ function switchStudent(student: any) {
icon: "none",
});
}
onMounted(async () => {
studentList.value = getUser.xsList;
currentStudent = getCurXs;
});
</script>
<style lang="scss" scoped>

View File

@ -40,6 +40,7 @@ onLoad(async (data: any) => {
.then(async (res) => {
if (res.resultCode == 1) {
if (res.result) {
console.log(res.result);
afterLoginAction(res.result);
toHome(data);
} else {

View File

@ -4,6 +4,7 @@ import {AUTH_KEY} from "@/config";
interface UserState {
userdata: any;
curXs: any;
token: string;
auth: string[]
}
@ -13,6 +14,8 @@ export const useUserStore = defineStore({
state: (): UserState => ({
//用户数据
userdata: '',
// 当前学生
curXs: {},
// token
token: '',
//用户注册信息
@ -25,6 +28,9 @@ export const useUserStore = defineStore({
getUser(): any {
return this.userdata;
},
getCurXs(): any {
return this.curXs;
},
getAuth(): string[] {
return this.auth;
}
@ -36,6 +42,9 @@ export const useUserStore = defineStore({
setUser(data: any) {
this.userdata = data;
},
setCurXs(data: any) {
Object.assign(this.curXs, data);
},
setAuth(data: string[]) {
this.auth = data;
},
@ -77,6 +86,11 @@ export const useUserStore = defineStore({
*/
afterLoginAction(value: any) {
this.setUser(value)
if (value.xsList && value.xsList.length > 0) {
this.setCurXs(value.xsList[0])
} else {
this.setCurXs({})
}
if (value[AUTH_KEY]) {
this.setToken(value[AUTH_KEY])
}