调整头像显示

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) => { export const xsKscjApi = async (params: any) => {
return await get("/mobile/jz/kscj", params); 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>
<view class="date-tabs"> <view class="date-tabs">
<view <view v-for="(day, index) in rqList" :key="index" :class="['date-tab-item', { active: curRqIndex === index }]"
v-for="(day, index) in rqList" @click="selectDay(index)">
:key="index"
:class="['date-tab-item', { active: curRqIndex === index }]"
@click="selectDay(index)"
>
<text class="weekday">{{ day.zjmc }}</text> <text class="weekday">{{ day.zjmc }}</text>
<text class="date">{{ day.rqmc }}</text> <text class="date">{{ day.rqmc }}</text>
</view> </view>
</view> </view>
<view class="schedule-body"> <view class="schedule-body">
<view <view v-for="(sj, index) in sjList" :key="index" class="schedule-row">
v-for="(sj, index) in sjList"
:key="index"
class="schedule-row"
>
<view class="time-slot"> <view class="time-slot">
<text class="slot-name">{{ sj.mc }}</text> <text class="slot-name">{{ sj.mc }}</text>
<text class="slot-time">{{ sj.kssj }}-{{ sj.jssj }}</text> <text class="slot-time">{{ sj.kssj }}-{{ sj.jssj }}</text>
@ -30,11 +22,8 @@
<view class="course-container"> <view class="course-container">
<template v-if="sj.pkkbList && sj.pkkbList.length > 0"> <template v-if="sj.pkkbList && sj.pkkbList.length > 0">
<view <view v-for="(pkkb, pkkbIndex) in sj.pkkbList" :key="pkkbIndex"
v-for="(pkkb, pkkbIndex) in sj.pkkbList" :class="['course-card', getCourseColorClass(pkkb.pkName)]">
:key="pkkbIndex"
:class="['course-card', getCourseColorClass(pkkb.pkName)]"
>
<text class="course-subject">{{ pkkb.pkName }}</text> <text class="course-subject">{{ pkkb.pkName }}</text>
<text class="course-class">{{ pkkb.jsName }}</text> <text class="course-class">{{ pkkb.jsName }}</text>
</view> </view>
@ -57,20 +46,11 @@
<text class="title">选择周</text> <text class="title">选择周</text>
</view> </view>
<view class="week-list"> <view class="week-list">
<scroll-view <scroll-view scroll-y style="max-height: 60vh" :scroll-top="targetScrollTop">
scroll-y <view v-for="(zc, index) in zcList" :key="index" :class="[
style="max-height: 60vh"
:scroll-top="targetScrollTop"
>
<view
v-for="(zc, index) in zcList"
:key="index"
:class="[
'week-item', 'week-item',
{ active: zc.djz === curZc.djz }, { active: zc.djz === curZc.djz },
]" ]" @click="selectWeek(zc)">
@click="selectWeek(zc)"
>
<text>{{ zc.mc }}</text> <text>{{ zc.mc }}</text>
<text v-if="zc.djz === curZc.djz" class="current-tag">当前周</text> <text v-if="zc.djz === curZc.djz" class="current-tag">当前周</text>
</view> </view>
@ -88,7 +68,6 @@ import "dayjs/locale/zh-cn";
import weekOfYear from "dayjs/plugin/weekOfYear"; import weekOfYear from "dayjs/plugin/weekOfYear";
import isoWeek from "dayjs/plugin/isoWeek"; import isoWeek from "dayjs/plugin/isoWeek";
import { dqpkApi, drpkkbApi } from "@/api/base/server"; import { dqpkApi, drpkkbApi } from "@/api/base/server";
import * as DataConfig from "data.config";
import { useUserStore } from "@/store/modules/user"; import { useUserStore } from "@/store/modules/user";
const { getCurXs } = useUserStore(); const { getCurXs } = useUserStore();
@ -363,14 +342,17 @@ onMounted(async () => {
background-color: #ffebee; background-color: #ffebee;
border-left: 3px solid #f44336; border-left: 3px solid #f44336;
} }
&.color-phys { &.color-phys {
background-color: #e3f2fd; background-color: #e3f2fd;
border-left: 3px solid #2196f3; border-left: 3px solid #2196f3;
} }
&.color-math { &.color-math {
background-color: #e8f5e9; background-color: #e8f5e9;
border-left: 3px solid #4caf50; border-left: 3px solid #4caf50;
} }
&.color-other { &.color-other {
background-color: #f5f5f5; background-color: #f5f5f5;
border-left: 3px solid #9e9e9e; border-left: 3px solid #9e9e9e;

View File

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

View File

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

View File

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

View File

@ -1,6 +1,7 @@
import {defineStore} from "pinia"; import { defineStore } from "pinia";
import {authenticationApi, loginCode, loginPass, weChatLogin} from "@/api/system/login"; import { authenticationApi, loginCode, loginPass, weChatLogin } from "@/api/system/login";
import {AUTH_KEY} from "@/config"; import { AUTH_KEY } from "@/config";
import { imagUrl } from "@/utils";
interface UserState { interface UserState {
userdata: any; userdata: any;
@ -53,7 +54,7 @@ export const useUserStore = defineStore({
*/ */
async codeLogin(params: { phone: number | string, code: number | string }) { async codeLogin(params: { phone: number | string, code: number | string }) {
try { try {
const {result} = await loginCode({phone: params.phone, code: params.code}); const { result } = await loginCode({ phone: params.phone, code: params.code, openId: '' });
this.afterLoginAction(result) this.afterLoginAction(result)
} catch (e) { } catch (e) {
console.log(e) console.log(e)
@ -64,7 +65,7 @@ export const useUserStore = defineStore({
*/ */
async passwordLogin(params: { name: string, password: string }) { async passwordLogin(params: { name: string, password: string }) {
try { try {
const {result} = await loginPass({username: params.name, password: params.password}); const { result } = await loginPass({ username: params.name, password: params.password, openId: '' });
this.afterLoginAction(result) this.afterLoginAction(result)
} catch (e) { } catch (e) {
@ -75,7 +76,7 @@ export const useUserStore = defineStore({
*/ */
async weChatLogin(params: { code: string }) { async weChatLogin(params: { code: string }) {
try { try {
const {result} = await weChatLogin({code: params.code}) const { result } = await weChatLogin({ code: params.code })
this.afterLoginAction(result) this.afterLoginAction(result)
} catch (e) { } catch (e) {
console.log(e) console.log(e)
@ -87,6 +88,10 @@ export const useUserStore = defineStore({
afterLoginAction(value: any) { afterLoginAction(value: any) {
this.setUser(value) this.setUser(value)
if (value.xsList && value.xsList.length > 0) { 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]) this.setCurXs(value.xsList[0])
} else { } else {
this.setCurXs({}) this.setCurXs({})
@ -94,7 +99,7 @@ export const useUserStore = defineStore({
if (value[AUTH_KEY]) { if (value[AUTH_KEY]) {
this.setToken(value[AUTH_KEY]) this.setToken(value[AUTH_KEY])
} }
authenticationApi({userId: value.userId}).then(({result}) => { authenticationApi({ userId: value.userId }).then(({ result }) => {
if (result) { if (result) {
this.setAuth(result) this.setAuth(result)
} }