From d20202af6d87f5a9970342b91a17cff8336472ca Mon Sep 17 00:00:00 2001 From: ywyonui Date: Mon, 30 Jun 2025 23:44:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=80=89=E8=AF=BE=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/base/server.ts | 16 ++-- src/pages/base/club/index.vue | 4 +- src/pages/base/components/XkPicker/index.vue | 80 ++++++++++++------- src/pages/base/components/XkkcList/index.vue | 44 +++++++--- .../base/course-selection/club-selection.vue | 47 +++++++++-- src/pages/base/course-selection/index.vue | 46 +++++++++-- src/pages/base/interest-class/index.vue | 4 +- 7 files changed, 177 insertions(+), 64 deletions(-) diff --git a/src/api/base/server.ts b/src/api/base/server.ts index 5120982..a2e35fa 100644 --- a/src/api/base/server.ts +++ b/src/api/base/server.ts @@ -34,6 +34,11 @@ export const xkqddeleteApi = async (params: any) => { return await post("/api/xkqd/delete?ids=" + params.ids); }; +// 获取配置:家长端是否显示分钟数 +export const getJzdShowFs = async (params: any) => { + return await get("/api/comConfig/getJzdShowFs"); +}; + /** * 当前学期排课公共配置(排课设置、排课周次、排课时间) */ @@ -58,15 +63,15 @@ export const drpkkbApi = async (params: any) => { /** * 查询学生选课列表 */ -export const xsXkListApi = async (params: any) => { - return await get("/mobile/jz/xsxk/list", params); +export const xsKxApi = async (params: any) => { + return await get("/mobile/jz/xkkc/list", params); }; /** - * 查询学生选课列表 + * 学生已选课程列表 */ -export const xsXkkcListApi = async (params: any) => { - return await get("/mobile/jz/xkkc/list", params); +export const xsYxListApi = async (params: any) => { + return await get("/mobile/jz/xsxk/list", params); }; /** @@ -83,7 +88,6 @@ export const xsKscjApi = async (params: any) => { return await get("/mobile/jz/kscj", params); }; - /** * 家长抢课 */ diff --git a/src/pages/base/club/index.vue b/src/pages/base/club/index.vue index ddaea17..bede89c 100644 --- a/src/pages/base/club/index.vue +++ b/src/pages/base/club/index.vue @@ -4,7 +4,7 @@ - + @@ -12,7 +12,7 @@ - + diff --git a/src/pages/base/components/XkPicker/index.vue b/src/pages/base/components/XkPicker/index.vue index 9976bb9..94063ea 100644 --- a/src/pages/base/components/XkPicker/index.vue +++ b/src/pages/base/components/XkPicker/index.vue @@ -31,15 +31,17 @@ diff --git a/src/pages/base/components/XkkcList/index.vue b/src/pages/base/components/XkkcList/index.vue index 68c5fdf..1ff678e 100644 --- a/src/pages/base/components/XkkcList/index.vue +++ b/src/pages/base/components/XkkcList/index.vue @@ -43,11 +43,16 @@ import { ref, watch } from "vue"; import { useDataStore } from "@/store/modules/data"; const { setKcData } = useDataStore(); -// 接收外部传入属性 -const props = defineProps<{ +// 接收外部传入属性并设置默认值 +const props = withDefaults(defineProps<{ xk: any, canSelected: boolean, -}>(); + multiple: boolean, +}>(), { + xk: () => ({}), + canSelected: false, + multiple: false, +}); // 定义一个上级传入的emit响应事件用于接收数据变更 const emit = defineEmits(['change']) @@ -63,23 +68,37 @@ const toggleSelection = (xkkc: any) => { // 获取本地存储的已选课程ID数组 let selectedXkkcIds = uni.getStorageSync("selectedXkkcIds") || []; if (xkkc.isSelected) { - // 从已选数组中移除 - selectedXkkcIds = selectedXkkcIds.filter( - (id: string) => id !== xkkc.id - ); xkkc.isSelected = false; + if (props.multiple) { + // 如果是多选,则从已选数组中移除 + selectedXkkcIds = selectedXkkcIds.filter( + (id: string) => id !== xkkc.id + ); + } else { + // 如果是单选,则清空已选数组 + selectedXkkcIds = []; + } // xkkc.hasNum--; } else { // 如果是未选中,判断是否已选满 const maxNum = xkkc.maxNum || 0; const hasNum = xkkc.hasNum || 0; if (maxNum > hasNum) { - xkkc.isSelected = true; - // 添加到已选数组 - if (!selectedXkkcIds.includes(xkkc.id)) { - selectedXkkcIds.push(xkkc.id); - // xkkc.hasNum++; + if (props.multiple) { + // 如果是多选,则添加到已选数组 + if (!selectedXkkcIds.includes(xkkc.id)) { + selectedXkkcIds.push(xkkc.id); + // xkkc.hasNum++; + } + } else { + // 如果是单选,则清空已选数组并添加当前课程 + selectedXkkcIds = [xkkc.id]; + // 清理选中状态 + xkkcList.value.forEach((xkkc: any) => { + xkkc.isSelected = false; + }); } + xkkc.isSelected = true; } } // 更新本地存储 @@ -112,6 +131,7 @@ const switchXk = (xk: any) => { } } uni.setStorageSync("selectedXkkcIds", newSelectedXkkcIds); + emit("change", newSelectedXkkcIds); } // 监听当前学生信息变更 diff --git a/src/pages/base/course-selection/club-selection.vue b/src/pages/base/course-selection/club-selection.vue index d5c9486..fb91710 100644 --- a/src/pages/base/course-selection/club-selection.vue +++ b/src/pages/base/course-selection/club-selection.vue @@ -4,7 +4,7 @@ - + @@ -14,7 +14,7 @@ - + @@ -32,9 +32,13 @@ import XsPicker from "@/pages/base/components/XsPicker/index.vue" import XkPicker from "@/pages/base/components/XkPicker/index.vue" import XkCountdown from "@/pages/base/components/XkCountdown/index.vue" import XkkcList from "@/pages/base/components/XkkcList/index.vue" +import { jzXkQkjApi } from "@/api/base/server"; import { useUserStore } from "@/store/modules/user"; +import { useDataStore } from "@/store/modules/data"; -const { getCurXs } = useUserStore(); +const { getCurXs, getUser } = useUserStore(); +const { setData, getData } = useDataStore(); +const { sign_file } = getData; const curXs = computed(() => getCurXs); const curXk = ref({}); @@ -51,13 +55,44 @@ const xkTimeOver = (val: any) => { // 选中课程 const changeXkkc = (ids: any) => { - console.log(ids); selectedXkkcIds.value = ids; } // 提交选课 -const submit = () => { - console.log(selectedXkkcIds.value); +const submit = async () => { + // 判断是否已选课 + if (selectedXkkcIds.value.length === 0) { + uni.showToast({ + title: "请选择课程!", + icon: "none", + }); + return; + } + uni.showLoading({ + title: "抢课中...", + }); + const params = { + xsId: curXs.value.id, + xm: curXs.value.xm, + xkId: curXk.value.id, + xkkcIds: selectedXkkcIds.value, + jzId: getUser.jzId, + qmFile: sign_file ? sign_file.value : "", + }; + const res = await jzXkQkjApi(params); + uni.hideLoading(); + if (res.resultCode === 1) { + // 跳转到支付页面 + setData(res.result); + uni.reLaunch({ + url: "/pages/base/course-selection/payment", + }); + } else { + uni.showToast({ + title: res.message, + icon: "none", + }); + } } diff --git a/src/pages/base/course-selection/index.vue b/src/pages/base/course-selection/index.vue index 2fa3405..8251360 100644 --- a/src/pages/base/course-selection/index.vue +++ b/src/pages/base/course-selection/index.vue @@ -4,7 +4,7 @@ - + @@ -32,9 +32,14 @@ import XsPicker from "@/pages/base/components/XsPicker/index.vue" import XkPicker from "@/pages/base/components/XkPicker/index.vue" import XkCountdown from "@/pages/base/components/XkCountdown/index.vue" import XkkcList from "@/pages/base/components/XkkcList/index.vue" +import { jzXkQkjApi } from "@/api/base/server"; import { useUserStore } from "@/store/modules/user"; +import { useDataStore } from "@/store/modules/data"; -const { getCurXs } = useUserStore(); +const { getCurXs, getUser } = useUserStore(); +const { setData, getData } = useDataStore(); +const { sign_file } = getData; +const user = computed(() => getUser); const curXs = computed(() => getCurXs); const curXk = ref({}); @@ -51,13 +56,44 @@ const xkTimeOver = (val: any) => { // 选中课程 const changeXkkc = (ids: any) => { - console.log(ids); selectedXkkcIds.value = ids; } // 提交选课 -const submit = () => { - console.log(selectedXkkcIds.value); +const submit = async () => { + // 判断是否已选课 + if (selectedXkkcIds.value.length === 0) { + uni.showToast({ + title: "请选择课程!", + icon: "none", + }); + return; + } + uni.showLoading({ + title: "抢课中...", + }); + const params = { + xsId: curXs.value.id, + xm: curXs.value.xm, + xkId: curXk.value.id, + xkkcIds: selectedXkkcIds.value, + jzId: getUser.jzId, + qmFile: sign_file ? sign_file.value : "", + }; + const res = await jzXkQkjApi(params); + uni.hideLoading(); + if (res.resultCode === 1) { + // 跳转到支付页面 + setData(res.result); + uni.reLaunch({ + url: "/pages/base/course-selection/payment", + }); + } else { + uni.showToast({ + title: res.message, + icon: "none", + }); + } } diff --git a/src/pages/base/interest-class/index.vue b/src/pages/base/interest-class/index.vue index 72b2675..66112d1 100644 --- a/src/pages/base/interest-class/index.vue +++ b/src/pages/base/interest-class/index.vue @@ -4,7 +4,7 @@ - + @@ -12,7 +12,7 @@ - +