调整头像显示

This commit is contained in:
ywyonui 2025-06-29 15:28:57 +08:00
parent 9e68d93eaa
commit ee2e2fc16c
6 changed files with 236 additions and 238 deletions

View File

@ -75,3 +75,31 @@ export const xsKsccApi = async (params: any) => {
export const xsKscjApi = async (params: any) => {
return await get("/mobile/jz/kscj", params);
};
/**
*
*/
export const jzXkQkjApi = async (params: any) => {
return await post("/mobile/jz/xk/qk", params);
};
/**
*
*/
export const jzXkFqJfjApi = async (params: any) => {
return await post("/mobile/jz/xk/fqjf", params);
};
/**
* 退
*/
export const jzXkTkjApi = async (params: any) => {
return await post("/mobile/jz/xk/tk", params);
};
/**
*
*/
export const jzXkJfCxjApi = async (params: any) => {
return await post("/mobile/jz/xk/jfcx", params);
};

View File

@ -6,23 +6,15 @@
</view>
<view class="date-tabs">
<view
v-for="(day, index) in rqList"
:key="index"
:class="['date-tab-item', { active: curRqIndex === index }]"
@click="selectDay(index)"
>
<view v-for="(day, index) in rqList" :key="index" :class="['date-tab-item', { active: curRqIndex === index }]"
@click="selectDay(index)">
<text class="weekday">{{ day.zjmc }}</text>
<text class="date">{{ day.rqmc }}</text>
</view>
</view>
<view class="schedule-body">
<view
v-for="(sj, index) in sjList"
:key="index"
class="schedule-row"
>
<view v-for="(sj, index) in sjList" :key="index" class="schedule-row">
<view class="time-slot">
<text class="slot-name">{{ sj.mc }}</text>
<text class="slot-time">{{ sj.kssj }}-{{ sj.jssj }}</text>
@ -30,11 +22,8 @@
<view class="course-container">
<template v-if="sj.pkkbList && sj.pkkbList.length > 0">
<view
v-for="(pkkb, pkkbIndex) in sj.pkkbList"
:key="pkkbIndex"
:class="['course-card', getCourseColorClass(pkkb.pkName)]"
>
<view v-for="(pkkb, pkkbIndex) in sj.pkkbList" :key="pkkbIndex"
:class="['course-card', getCourseColorClass(pkkb.pkName)]">
<text class="course-subject">{{ pkkb.pkName }}</text>
<text class="course-class">{{ pkkb.jsName }}</text>
</view>
@ -57,20 +46,11 @@
<text class="title">选择周</text>
</view>
<view class="week-list">
<scroll-view
scroll-y
style="max-height: 60vh"
:scroll-top="targetScrollTop"
>
<view
v-for="(zc, index) in zcList"
:key="index"
:class="[
'week-item',
{ active: zc.djz === curZc.djz },
]"
@click="selectWeek(zc)"
>
<scroll-view scroll-y style="max-height: 60vh" :scroll-top="targetScrollTop">
<view v-for="(zc, index) in zcList" :key="index" :class="[
'week-item',
{ active: zc.djz === curZc.djz },
]" @click="selectWeek(zc)">
<text>{{ zc.mc }}</text>
<text v-if="zc.djz === curZc.djz" class="current-tag">当前周</text>
</view>
@ -88,7 +68,6 @@ 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();
@ -170,24 +149,24 @@ const selectDay = (index: number) => {
curRqIndex.value = index;
drpkkbApi({
bjId: getCurXs.bjId,
xqId: xqId,
rq: "",
// rq: rqList.value[index].rq, //
zj: rqList.value[index].zj
bjId: getCurXs.bjId,
xqId: xqId,
rq: "",
// rq: rqList.value[index].rq, //
zj: rqList.value[index].zj
}).then(res => {
// result
if (res && res.resultCode === 1) {
sjList.value = res.result;
sjList.value = res.result;
} else {
//
console.warn("检查报名状态接口返回错误:", res);
}
})
.catch((error) => {
//
console.error("调用检查报名状态接口失败:", error);
});
.catch((error) => {
//
console.error("调用检查报名状态接口失败:", error);
});
};
@ -206,20 +185,20 @@ onMounted(async () => {
dqpkApi().then(res => {
// result
if (res && res.resultCode === 1) {
xqId = res.result.pksz.xqId;
xqId = res.result.pksz.xqId;
zcList.value = res.result.zcList;
sjList.value = res.result.sjList;
sjList.value = res.result.sjList;
//
selectWeek(zcList.value.find((zc: any) => zc.djz === curZcNum.value));
selectWeek(zcList.value.find((zc: any) => zc.djz === curZcNum.value));
} else {
//
console.warn("检查获取当前学期课表周次相关信息接口返回错误:", res);
}
})
.catch((error) => {
//
console.error("调用获取当前学期课表周次相关信息接口失败:", error);
});
.catch((error) => {
//
console.error("调用获取当前学期课表周次相关信息接口失败:", error);
});
});
</script>
@ -363,14 +342,17 @@ onMounted(async () => {
background-color: #ffebee;
border-left: 3px solid #f44336;
}
&.color-phys {
background-color: #e3f2fd;
border-left: 3px solid #2196f3;
}
&.color-math {
background-color: #e8f5e9;
border-left: 3px solid #4caf50;
}
&.color-other {
background-color: #f5f5f5;
border-left: 3px solid #9e9e9e;

View File

@ -14,7 +14,7 @@
<view class="student-selector-bar" @click="clickShowXsSelector">
<view class="user-avatar">
<image
:src="curXs.avatar || '/static/base/home/11222.png'"
:src="curXs.xstxUrl || '/static/base/home/11222.png'"
class="w-full h-full"
></image>
</view>
@ -95,7 +95,7 @@
>
<view class="student-avatar">
<image
:src="xs.avatar || '/static/base/home/11222.png'"
:src="xs.xstxUrl || '/static/base/home/11222.png'"
class="w-full h-full"
></image>
</view>

View File

@ -14,17 +14,17 @@
<view class="student-selector-bar" @click="showStudentSelector">
<view class="user-avatar">
<image
:src="currentStudent.avatar || '/static/base/home/11222.png'"
:src="curXs.xstxUrl || '/static/base/home/11222.png'"
class="w-full h-full"
></image>
</view>
<view class="student-info">
<text class="student-name">{{ currentStudent.xm }}</text>
<text class="student-name">{{ curXs.xm }}</text>
<text class="student-class"
>{{ currentStudent.njmc }} {{ currentStudent.bjmc }}</text
>{{ curXs.njmc }} {{ curXs.bjmc }}</text
>
</view>
<view class="switch-btn" v-if="studentList.length > 1">切换</view>
<view class="switch-btn" v-if="xsList.length > 1">切换</view>
</view>
<view class="countdown-section">
<template v-if="!isEnrollmentEnded">
@ -59,9 +59,9 @@
<!-- 可滚动的内容区域 -->
<view class="scrollable-content">
<!-- 课程网格列表 -->
<view class="course-grid" v-if="courseListData.length > 0">
<view class="course-grid" v-if="xkkcList.length > 0">
<view
v-for="(course, index) in courseListData"
v-for="(course, index) in xkkcList"
:key="course.id || index"
class="course-item"
:class="{ selected: course.isSelected }"
@ -124,28 +124,28 @@
</view>
<view class="student-list">
<view
v-for="(student, index) in studentList"
v-for="(xs, index) in xsList"
:key="index"
class="student-item"
:class="{
'student-item-active': currentStudent.id === student.id,
'student-item-active': curXs.id === xs.id,
}"
@click="switchStudent(student)"
@click="switchXs(xs)"
>
<view class="student-avatar">
<image
:src="student.avatar || '/static/base/home/11222.png'"
:src="xs.xstxUrl || '/static/base/home/11222.png'"
class="w-full h-full"
></image>
</view>
<view class="student-info">
<text class="student-name">{{ student.xm }}</text>
<text class="student-name">{{ xs.xm }}</text>
<text class="student-class"
>{{ student.njmc }} {{ student.bjmc }}</text
>{{ xs.njmc }} {{ xs.bjmc }}</text
>
</view>
<u-icon
v-if="currentStudent.id === student.id"
v-if="curXs.id === xs.id"
name="checkmark"
color="#409EFF"
size="20"
@ -198,19 +198,15 @@ let countdownTimer: number | null = null;
const remainTime = ref("00:00:00");
//
const studentList = computed(() => {
const xsList = computed(() => {
return getUser.xsList;
});
const currentStudent = ref();
const curXs = ref<any>({});
//
const showSelector = ref(false);
if (studentList.value.length > 1) {
showSelector.value = true;
}
const kcData = ref();
const kcStatus = ref(false);
@ -220,13 +216,13 @@ const isEnrollmentEnded = ref(false);
//
let pollTimer: number | null = null;
const courseInfo = ref({});
const curXkkc = ref({});
//
function checkStudentEnrollmentApi(student: any): Promise<boolean> {
function checkStudentEnrollmentApi(xs: any): Promise<boolean> {
return new Promise((resolve, reject) => {
if (!student || !student.id || !student.njId) {
console.error("学生信息不完整:", student);
if (!xs || !xs.id || !xs.njId) {
console.error("学生信息不完整:", xs);
resolve(false);
return;
}
@ -240,8 +236,8 @@ function checkStudentEnrollmentApi(student: any): Promise<boolean> {
//
xkXkqdApi({
njId: student.njId,
xsId: student.id,
njId: xs.njId,
xsId: xs.id,
xklxId: "816059832", // ID
xkId: kcData.value.id,
})
@ -253,7 +249,7 @@ function checkStudentEnrollmentApi(student: any): Promise<boolean> {
setData({
...getData,
kcData,
studentInfo: student,
studentInfo: xs,
enrolledCourse: res.result,
});
resolve(res.result.length > 0); //
@ -288,12 +284,12 @@ const pollEnrollmentCount = () => {
const updateEnrollmentCount = (
data: Array<{ xkkcId: string; bmrs: number }>
) => {
if (!Array.isArray(courseListData.value) || courseListData.value.length === 0)
if (!Array.isArray(xkkcList.value) || xkkcList.value.length === 0)
return;
let hasUpdates = false;
courseListData.value.forEach((course) => {
xkkcList.value.forEach((course) => {
const newCount = data.find((item) => item.xkkcId === course.id);
if (newCount && course.ybmr !== newCount.bmrs) {
course.ybmr = newCount.bmrs;
@ -303,7 +299,7 @@ const updateEnrollmentCount = (
//
if (hasUpdates) {
courseListData.value = [...courseListData.value];
xkkcList.value = [...xkkcList.value];
}
};
@ -329,8 +325,11 @@ const stopPolling = () => {
//
onMounted(() => {
if (xsList.value.length > 0 && xsList.value.length === 1) {
showSelector.value = true;
}
//
watch(courseListData, (newVal) => {
watch(xkkcList, (newVal) => {
if (newVal.length > 0 && !pollTimer) {
startPolling();
}
@ -338,11 +337,11 @@ onMounted(() => {
});
//
const checkInitialEnrollment = (currentStudent: any) => {
if (!currentStudent) return;
const checkInitialEnrollment = (curXs: any) => {
if (!curXs) return;
// 使API
checkStudentEnrollmentApi(currentStudent)
checkStudentEnrollmentApi(curXs)
.then((isEnrolled) => {
if (isEnrolled) {
uni.hideLoading();
@ -358,14 +357,14 @@ const checkInitialEnrollment = (currentStudent: any) => {
};
//
const loadCourseList = (currentStudent: any) => {
if (!currentStudent) {
const loadXkList = (curXs: any) => {
if (!curXs) {
uni.hideLoading();
return;
}
xkListApi({
njId: currentStudent.njId,
njId: curXs.njId,
xklxId: "816059832",
})
.then((res) => {
@ -397,7 +396,7 @@ const loadCourseList = (currentStudent: any) => {
}
//
checkInitialEnrollment(currentStudent);
checkInitialEnrollment(curXs);
} else {
uni.reLaunch({
url: "/pages/base/course-selection/notopen",
@ -411,25 +410,16 @@ const loadCourseList = (currentStudent: any) => {
});
};
if (studentList.value.length > 0 && studentList.value.length === 1) {
currentStudent.value = studentList.value[0];
//
uni.showLoading({
title: "加载中...",
});
loadCourseList(currentStudent.value);
}
//
function showStudentSelector() {
if (studentList.value.length > 1) {
const showStudentSelector = () => {
if (xsList.value.length > 1) {
showSelector.value = true;
}
}
//
function switchStudent(student: any) {
currentStudent.value = student;
const switchXs = (xs: any) => {
curXs.value = xs;
showSelector.value = false;
//
@ -439,12 +429,12 @@ function switchStudent(student: any) {
//
uni.showToast({
title: `已切换到${student.xm}`,
title: `已切换到${xs.xm}`,
icon: "none",
});
//
loadCourseList(student);
loadXkList(xs);
}
//
@ -535,26 +525,26 @@ const displayCourseList = computed(() => {
});
//
const courseListData = ref<any[]>([]);
const xkkcList = ref<any[]>([]);
//
const selectedCoursesCount = computed(() => {
return courseListData.value.filter((course: any) => course.isSelected).length;
return xkkcList.value.filter((course: any) => course.isSelected).length;
});
//
watch(
displayCourseList,
(newVal) => {
courseListData.value = JSON.parse(JSON.stringify(newVal));
xkkcList.value = JSON.parse(JSON.stringify(newVal));
// courseInfo
// curXkkc
const selectedCourseIds = uni.getStorageSync("selectedCourseIds") || [];
if (selectedCourseIds.length > 0) {
const selectedCourses = newVal.filter((course: any) =>
selectedCourseIds.includes(course.id)
);
courseInfo.value = selectedCourses;
curXkkc.value = selectedCourses;
}
},
{ immediate: true }
@ -571,30 +561,30 @@ const toggleSelection = (course: any) => {
return;
}
const courseIndex = courseListData.value.findIndex(
const courseIndex = xkkcList.value.findIndex(
(item) => item.id === course.id
);
if (courseIndex === -1) return;
//
courseListData.value[courseIndex].isSelected =
!courseListData.value[courseIndex].isSelected;
xkkcList.value[courseIndex].isSelected =
!xkkcList.value[courseIndex].isSelected;
// ID
const selectedCourseIds = courseListData.value
const selectedCourseIds = xkkcList.value
.filter((item: any) => item.isSelected)
.map((item: any) => item.id);
// ID
uni.setStorageSync("selectedCourseIds", selectedCourseIds);
// courseInfo
courseInfo.value = courseListData.value.filter(
// curXkkc
curXkkc.value = xkkcList.value.filter(
(item: any) => item.isSelected
);
//
if (courseListData.value[courseIndex].isSelected) {
if (xkkcList.value[courseIndex].isSelected) {
uni.showToast({
title: `已选择 ${course.kcmc}`,
icon: "none",
@ -649,7 +639,7 @@ const submitRegistration = () => {
return;
}
const selectedCourses = courseListData.value.filter(
const selectedCourses = xkkcList.value.filter(
(course: any) => course.isSelected
);
@ -678,7 +668,7 @@ const submitRegistration = () => {
uni.showModal({
title: "确认报名",
content: `您确定要为${currentStudent.value.xm}报名以下课程吗?\n\n${courseNames}`,
content: `您确定要为${curXs.value.xm}报名以下课程吗?\n\n${courseNames}`,
success: async (res) => {
if (res.confirm) {
uni.showLoading({
@ -691,7 +681,7 @@ const submitRegistration = () => {
.join(",");
const res = await xkAddXkqdApi({
xsId: currentStudent.value.id,
xsId: curXs.value.id,
xkkcId: selectedCourseIds,
qmFile: sign_file,
xklxId: "816059832",
@ -701,7 +691,7 @@ const submitRegistration = () => {
setData({
...getData,
kcData,
studentInfo: currentStudent.value,
studentInfo: curXs.value,
enrolledCourse: res.result,
});
uni.showToast({

View File

@ -133,10 +133,8 @@
<script setup lang="ts">
import { ref } from "vue";
import { cmsArticlePageApi } from "@/api/base/server";
import { imagUrl } from "@/utils";
import { useUserStore } from "@/store/modules/user";
import { useDataStore } from "@/store/modules/data";
import { get } from "lodash";
const { getUser, setCurXs, getCurXs } = useUserStore();
const { setData, getAppCode } = useDataStore();
@ -282,12 +280,7 @@ const getArticleList = async () => {
onMounted(async () => {
xsList.value = getUser.xsList;
for (let i = 0; i < xsList.value.length; i++) {
const xs = xsList.value[i];
xs.xstxUrl = imagUrl(xs.xstx) || "";
}
curXs.value = getCurXs;
curXs.value.xstxUrl = imagUrl(getCurXs.xstx) || "";
getArticleList();
});
</script>

View File

@ -1,118 +1,123 @@
import {defineStore} from "pinia";
import {authenticationApi, loginCode, loginPass, weChatLogin} from "@/api/system/login";
import {AUTH_KEY} from "@/config";
import { defineStore } from "pinia";
import { authenticationApi, loginCode, loginPass, weChatLogin } from "@/api/system/login";
import { AUTH_KEY } from "@/config";
import { imagUrl } from "@/utils";
interface UserState {
userdata: any;
curXs: any;
token: string;
auth: string[]
userdata: any;
curXs: any;
token: string;
auth: string[]
}
export const useUserStore = defineStore({
id: "app-user",
state: (): UserState => ({
//用户数据
userdata: '',
// 当前学生
curXs: {},
// token
token: '',
//用户注册信息
auth: [],
}),
getters: {
getToken(): string {
return this.token;
},
getUser(): any {
return this.userdata;
},
getCurXs(): any {
return this.curXs;
},
getAuth(): string[] {
return this.auth;
}
id: "app-user",
state: (): UserState => ({
//用户数据
userdata: '',
// 当前学生
curXs: {},
// token
token: '',
//用户注册信息
auth: [],
}),
getters: {
getToken(): string {
return this.token;
},
actions: {
setToken(token: string) {
this.token = token
},
setUser(data: any) {
this.userdata = data;
},
setCurXs(data: any) {
Object.assign(this.curXs, data);
},
setAuth(data: string[]) {
this.auth = data;
},
/**
* @description:
*/
async codeLogin(params: { phone: number | string, code: number | string }) {
try {
const {result} = await loginCode({phone: params.phone, code: params.code});
this.afterLoginAction(result)
} catch (e) {
console.log(e)
}
},
/**
* @description:
*/
async passwordLogin(params: { name: string, password: string }) {
try {
const {result} = await loginPass({username: params.name, password: params.password});
this.afterLoginAction(result)
} catch (e) {
getUser(): any {
return this.userdata;
},
getCurXs(): any {
return this.curXs;
},
getAuth(): string[] {
return this.auth;
}
},
actions: {
setToken(token: string) {
this.token = token
},
setUser(data: any) {
this.userdata = data;
},
setCurXs(data: any) {
Object.assign(this.curXs, data);
},
setAuth(data: string[]) {
this.auth = data;
},
/**
* @description:
*/
async codeLogin(params: { phone: number | string, code: number | string }) {
try {
const { result } = await loginCode({ phone: params.phone, code: params.code, openId: '' });
this.afterLoginAction(result)
} catch (e) {
console.log(e)
}
},
/**
* @description:
*/
async passwordLogin(params: { name: string, password: string }) {
try {
const { result } = await loginPass({ username: params.name, password: params.password, openId: '' });
this.afterLoginAction(result)
} catch (e) {
}
},
/**
* @description:
*/
async weChatLogin(params: { code: string }) {
try {
const {result} = await weChatLogin({code: params.code})
this.afterLoginAction(result)
} catch (e) {
console.log(e)
}
},
/**
* @description:
*/
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])
}
authenticationApi({userId: value.userId}).then(({result}) => {
if (result) {
this.setAuth(result)
}
})
},
/**
* @description:
*/
logout() {
this.setToken('')
this.setUser('')
this.setCurXs({})
this.setAuth([])
},
}
},
persist: {
enabled: true,
detached: true,
H5Storage: localStorage
/**
* @description:
*/
async weChatLogin(params: { code: string }) {
try {
const { result } = await weChatLogin({ code: params.code })
this.afterLoginAction(result)
} catch (e) {
console.log(e)
}
},
/**
* @description:
*/
afterLoginAction(value: any) {
this.setUser(value)
if (value.xsList && value.xsList.length > 0) {
for (let i = 0; i < value.xsList.length; i++) {
const xs = value.xsList[i];
xs.xstxUrl = imagUrl(xs.xstx) || "";
}
this.setCurXs(value.xsList[0])
} else {
this.setCurXs({})
}
if (value[AUTH_KEY]) {
this.setToken(value[AUTH_KEY])
}
authenticationApi({ userId: value.userId }).then(({ result }) => {
if (result) {
this.setAuth(result)
}
})
},
/**
* @description:
*/
logout() {
this.setToken('')
this.setUser('')
this.setCurXs({})
this.setAuth([])
},
},
persist: {
enabled: true,
detached: true,
H5Storage: localStorage
},
});