调整课表查询
This commit is contained in:
parent
22c3a2bb4a
commit
05a03e5b2e
@ -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);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
33
src/pages/base/class-schedule/data.config.ts
Normal file
33
src/pages/base/class-schedule/data.config.ts
Normal 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[]; // 排课课表列表
|
||||
}
|
||||
@ -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>
|
||||
|
||||
|
||||
724
src/pages/base/grades/list.vue
Normal file
724
src/pages/base/grades/list.vue
Normal 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>
|
||||
@ -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>
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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])
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user