This commit is contained in:
ywyonui 2025-08-04 16:31:35 +08:00
commit 88e398655d
21 changed files with 1356 additions and 134 deletions

17
src/api/base/notice.ts Normal file
View File

@ -0,0 +1,17 @@
import { get } from "@/utils/request";
// 通知公告分页查询参数接口
export interface NoticePageParams {
page: number;
rows: number;
appCode: string;
fbfw?: string;
xqId?: string;
fbNjmcId?: string;
releaseFlag?: string;
}
// 获取通知公告列表
export function getNoticeListApi(params: NoticePageParams) {
return get("/api/cms/article/list", params);
}

View File

@ -63,6 +63,14 @@ export const checkOpenId = async (param: {
export const updateUserApi = async (param: any) => {
return await post("/open/login/js/updateUser", param);
};
export const updateSignFileApi = async (param: { userId: number; signFile: string }) => {
return await post("/api/user/updateSignFile", {
id: param.userId,
signFile: param.signFile
});
};
export const findJsByPhoneApi = async (param: any) => {
return await get("/api/js/findJsByPhone", param);
};

View File

@ -57,6 +57,15 @@
}
}
},
{
"path": "pages/system/subscribe/index",
"style": {
"navigationStyle": "custom",
"navigationBarTitleText": "关注服务号",
"enablePullDownRefresh": false,
"backgroundColor": "#f4f5f7"
}
},
{
"path": "pages/system/webView/webView",
"style": {
@ -242,6 +251,13 @@
"enablePullDownRefresh": false
}
},
{
"path": "pages/base/course-selection/noticeclub",
"style": {
"navigationBarTitleText": "告知书",
"enablePullDownRefresh": false
}
},
{
"path": "pages/base/course-selection/enrolled",
"style": {
@ -254,6 +270,14 @@
"navigationBarTitleText": "未开放",
"enablePullDownRefresh": false
}
},
{
"path": "pages/base/course-selection/enrollment-ended",
"style": {
"navigationBarTitleText": "选课已结束",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
}
],
"globalStyle": {

View File

@ -1,7 +1,6 @@
<template>
<view class="countdown-section">
<template v-if="!isEnrollmentEnded">
<view class="countdown-title">{{ countdownTitle }}</view>
<view class="countdown-timer">
<view class="time-block">
<text class="time-value">{{ countdownTime.hours }}</text>
@ -20,10 +19,21 @@
</view>
</template>
<template v-else>
<view class="enrollment-ended">
<view class="enrollment-ended" v-if="isEnrollmentEnded && isCourseEnded">
<u-icon name="info-circle" color="#FF9900" size="20"></u-icon>
<text>选课已经结束</text>
</view>
<view class="enrollment-started" v-else-if="isEnrollmentEnded && !isCourseEnded">
<view class="enrollment-content">
<view class="enrollment-title">
<u-icon name="clock" color="#4CAF50" size="16"></u-icon>
<text>报名结束时间</text>
</view>
<view class="enrollment-date">
<text>{{ formatEndTime }}</text>
</view>
</view>
</view>
</template>
</view>
</template>
@ -48,17 +58,20 @@ const countdownTime = reactive({
const kcStatus = ref(false);
//
const countdownTitle = computed(() => {
return kcStatus.value ? "距离选课结束还剩" : "距离选课开始还剩";
});
//
let countdownTimer: number | null = null;
const remainTime = ref("00:00:00");
//
const isEnrollmentEnded = ref(false);
//
const isCourseEnded = ref(false);
//
const formatEndTime = computed(() => {
if (!props.xk || !props.xk.xkjstime) return '';
return dayjs(props.xk.xkjstime).format('YYYY-MM-DD');
});
//
const startCountdown = (endTimeStamp: number) => {
@ -82,26 +95,10 @@ const startCountdown = (endTimeStamp: number) => {
countdownTimer = null;
}
//
if (!kcStatus.value) {
//
kcStatus.value = true; //
uni.showToast({
title: "选课已开始",
icon: "none",
});
//
const xkjstime = dayjs(props.xk.xkjstime).valueOf();
startCountdown(xkjstime);
} else {
//
isEnrollmentEnded.value = true; //
emit("over");
uni.showToast({
title: "选课已结束",
icon: "none",
});
}
//
isEnrollmentEnded.value = true; //
isCourseEnded.value = false; //
emit("over");
return;
}
@ -134,22 +131,29 @@ const changeXk = (xk: any) => {
//
const xkjstime = dayjs(xk.xkjstime).valueOf();
//
if (now > xkjstime) {
kcStatus.value = true;
// >=
if (now >= xkjstime) {
isEnrollmentEnded.value = true;
isCourseEnded.value = true;
countdownTime.hours = "00";
countdownTime.minutes = "00";
countdownTime.seconds = "00";
return;
}
//
else if (now < xkkstime) {
kcStatus.value = false;
startCountdown(xkkstime);
} else {
kcStatus.value = true;
startCountdown(xkjstime);
// >= <
if (now >= xkkstime && now < xkjstime) {
isEnrollmentEnded.value = true;
isCourseEnded.value = false;
countdownTime.hours = "00";
countdownTime.minutes = "00";
countdownTime.seconds = "00";
return;
}
// <
kcStatus.value = false;
startCountdown(xkkstime);
}
//
@ -174,38 +178,37 @@ if (props.xk && props.xk.id) {
<style lang="scss" scoped>
.countdown-section {
.countdown-title {
font-size: 14px;
margin-bottom: 8px;
}
.countdown-timer {
display: flex;
align-items: center;
gap: 4px;
.time-block {
background-color: rgba(255, 255, 255, 0.2);
border-radius: 6px;
min-width: 40px;
padding: 5px 8px;
border-radius: 4px;
min-width: 30px;
padding: 3px 5px;
text-align: center;
.time-value {
font-size: 20px;
font-weight: bold;
display: block;
}
.time-value {
font-size: 14px;
font-weight: bold;
display: block;
line-height: 1;
color: #fff;
}
.time-unit {
font-size: 12px;
font-size: 9px;
opacity: 0.9;
line-height: 1;
}
}
.time-separator {
font-size: 20px;
font-size: 14px;
font-weight: bold;
margin: 0 5px;
margin: 0 1px;
}
}
@ -216,12 +219,49 @@ if (props.xk && props.xk.id) {
justify-content: center;
background-color: rgba(255, 255, 255, 0.2);
border-radius: 8px;
padding: 12px 15px;
font-size: 16px;
padding: 8px 12px;
font-size: 14px;
font-weight: 500;
color: #fff;
gap: 8px;
gap: 6px;
}
/* 选课已开始样式 */
.enrollment-started {
display: flex;
align-items: center;
justify-content: center;
background-color: rgba(76, 175, 80, 0.2);
border-radius: 8px;
padding: 8px 12px;
font-size: 12px;
font-weight: 500;
color: #fff;
text-align: center;
line-height: 1.3;
.enrollment-content {
display: flex;
flex-direction: column;
align-items: center;
gap: 4px;
.enrollment-title {
display: flex;
align-items: center;
gap: 4px;
font-size: 11px;
opacity: 0.9;
}
.enrollment-date {
font-size: 14px;
font-weight: bold;
color: #fff;
}
}
}
}
</style>

View File

@ -117,13 +117,6 @@ const loadXkList = async () => {
const switchXk = (xk: any) => {
curXk.value = xk;
showFlag.value = false;
if (xk && xk.id) {
//
uni.showToast({
title: `已切换到${xk.xkmc}`,
icon: "none",
});
}
emit("change", xk);
}

View File

@ -9,15 +9,17 @@
:class="{ selected: xkkc.isSelected }"
@click="toggleSelection(xkkc)"
>
<view class="course-name">{{ xkkc.kcmc }}</view>
<view class="course-header">
<view class="course-name">{{ xkkc.kcmc }}</view>
<view class="detail-btn" @click.stop="goToDetail(xkkc)">
<image src="/static/base/home/details.svg" class="detail-icon" />
</view>
</view>
<view class="register-info">
<text>报名情况</text>
<text class="register-count">{{ xkkc.hasNum || 0 }}</text>
<text> | {{ xkkc.maxNum || 0 }}</text>
</view>
<view class="detail-btn" @click.stop="goToDetail(xkkc)"
>详情</view
>
<view v-if="xkkc.isSelected" class="selected-mark">
<uni-icons
type="checkbox-filled"
@ -179,29 +181,40 @@ if (props.xk && props.xk.xkkcs) {
box-shadow: 0 2px 8px rgba(63, 191, 114, 0.15);
}
.course-name {
font-size: 16px;
font-weight: 500;
color: #333;
.course-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 10px;
.course-name {
font-size: 16px;
font-weight: 500;
color: #333;
flex: 1;
margin-right: 10px;
}
.detail-btn {
flex-shrink: 0;
padding: 4px;
.detail-icon {
width: 20px;
height: 20px;
}
}
}
.register-info {
font-size: 14px;
color: #666;
margin-bottom: 12px;
.register-count {
color: #2879ff;
}
}
.detail-btn {
display: inline-block;
color: #2879ff;
font-size: 14px;
}
.selected-mark {
position: absolute;
top: -6px;

View File

@ -86,21 +86,21 @@ const switchXs = (xs: any) => {
setCurXs(xs);
showFlag.value = false;
emit('change', xs);
//
uni.showToast({
title: `已切换到${xs.xm}`,
icon: "none",
});
}
//
const setCurrentStudent = (xs: any) => {
setCurXs(xs);
emit('change', xs);
}
// bar
if (props.isBar
//&& (getCurXs === null || !getCurXs.id)
) {
if (props.isBar) {
if (getUser.xsList.length > 1 ) {
showPicker();
} else {
switchXs(getUser.xsList[0]);
//
setCurrentStudent(getUser.xsList[0]);
}
}
</script>

View File

@ -3,12 +3,15 @@
<!-- 选课信息头部 - 固定部分 -->
<view class="selection-header">
<view class="header-content">
<!-- 选课类型选择部分 -->
<XkPicker title="俱乐部信息" :is-qk="true" xklx-id="816059832" :xs-id="curXs.id" @change="switchXk" v-if="!xsFlag" />
<!-- 学生选择部分 -->
<XsPicker :is-bar="true" @change="switchXs" />
<!-- 倒计时-->
<XkCountdown :xk="curXk" @over="xkTimeOver" v-if="curXk && curXk.id" />
<!-- 第一行选课类型选择 -->
<view class="top-row" v-if="!xsFlag">
<XkPicker title="俱乐部信息" :is-qk="true" xklx-id="816059832" :xs-id="curXs.id" @change="switchXk" />
</view>
<!-- 第二行学生选择和倒计时 -->
<view class="bottom-row">
<XsPicker :is-bar="true" @change="switchXs" />
<XkCountdown :xk="curXk" @over="xkTimeOver" v-if="curXk && curXk.id" />
</view>
</view>
</view>
@ -35,6 +38,7 @@ 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";
import dayjs from "dayjs";
const { getCurXs, getUser } = useUserStore();
const { setData, getData } = useDataStore();
@ -46,9 +50,31 @@ const selectedXkkcIds = ref<any>([]);
const xsFlag = ref(true);
//
const checkEnrollmentStatus = (xk: any) => {
if (!xk || !xk.xkjstime) return;
const now = new Date().getTime();
const endTime = new Date(xk.xkjstime).getTime();
if (now > endTime) {
//
const courseInfo = encodeURIComponent(JSON.stringify(xk));
uni.navigateTo({
url: `/pages/base/course-selection/enrollment-ended?courseInfo=${courseInfo}`
});
return true;
}
return false;
};
//
const switchXk = (xk: any) => {
curXk.value = xk;
//
if (checkEnrollmentStatus(xk)) {
return;
}
}
const switchXs = (xs: any) => {
@ -57,7 +83,9 @@ const switchXs = (xs: any) => {
//
const xkTimeOver = (val: any) => {
console.log(val);
console.log('选课时间结束:', val);
//
//
}
//
@ -75,6 +103,21 @@ const submit = async () => {
});
return;
}
//
if (curXk.value && curXk.value.xkkstime) {
const now = dayjs().valueOf();
const startTime = dayjs(curXk.value.xkkstime).valueOf();
if (now < startTime) {
uni.showToast({
title: "选课还未开始,请耐心等待!",
icon: "none",
});
return;
}
}
uni.showLoading({
title: "抢课中...",
});
@ -173,6 +216,36 @@ const submit = async () => {
flex-direction: column;
gap: 15px;
.top-row {
display: flex;
align-items: center;
:deep(.title-section) {
width: 100%;
}
}
.bottom-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 15px;
//
:deep(.xs-bar) {
flex: 1;
min-width: 0;
}
//
:deep(.countdown-section) {
flex-shrink: 0;
background: rgba(255, 255, 255, 0.1);
border-radius: 6px;
padding: 6px 10px;
backdrop-filter: blur(10px);
}
}
}
}

View File

@ -161,7 +161,7 @@ const courseDetail = computed(() => {
location: data.kcdd || "暂无地点信息",
price: data.kcje || 0,
studyTime: data.studyTime || "暂无上课时间",
xkkcImg: data.xkkcImg || "/static/images/robot-course.jpg", //
xkkcImg: imagUrl(data.xkkcImg), // 使imagUrl
};
});

View File

@ -0,0 +1,291 @@
<template>
<view class="enrollment-ended-page">
<view class="ended-container">
<!-- 页面头部 -->
<view class="page-header">
<text class="page-title">选课已结束</text>
<text class="page-subtitle">本次选课活动已经结束感谢您的参与</text>
</view>
<!-- 主要信息显示区域 -->
<view class="main-content">
<view class="content-card">
<view class="icon-section">
<u-icon name="clock" size="80" color="#FF6B6B" />
</view>
<view class="info-section">
<view class="info-item">
<text class="info-label">选课名称</text>
<text class="info-value">{{ courseInfo?.xkmc || '兴趣课选课' }}</text>
</view>
<view class="info-item">
<text class="info-label">选课时间</text>
<text class="info-value">{{ formatTime(courseInfo?.xkkstime) }} - {{ formatTime(courseInfo?.xkjstime) }}</text>
</view>
<view class="info-item">
<text class="info-label">结束时间</text>
<text class="info-value">{{ formatTime(courseInfo?.xkjstime) }}</text>
</view>
<view class="info-item" v-if="courseInfo?.qdmc">
<text class="info-label">选课地点</text>
<text class="info-value">{{ courseInfo.qdmc }}</text>
</view>
</view>
<view class="status-section">
<view class="status-badge">
<u-icon name="close-circle" size="16" color="#FF6B6B" />
<text class="status-text">选课已结束</text>
</view>
</view>
</view>
</view>
<!-- 提示信息 -->
<view class="tips-section">
<view class="tips-header">
<u-icon name="info-circle" size="16" color="#409EFF" />
<text class="tips-title">温馨提示</text>
</view>
<view class="tips-content">
<text class="tip-item"> 本次选课活动已经结束无法继续选课</text>
<text class="tip-item"> 如需了解选课结果请联系相关老师</text>
<text class="tip-item"> 下次选课时间请关注学校通知</text>
<text class="tip-item"> 如有疑问请联系学校教务处</text>
</view>
</view>
<!-- 操作按钮 -->
<view class="action-buttons">
<button @click="goBack" class="back-btn">
<u-icon name="arrow-left" size="16" color="#666" />
<text class="btn-text">返回首页</text>
</button>
<button @click="refreshPage" class="refresh-btn">
<u-icon name="reload" size="16" color="#409EFF" />
<text class="btn-text">刷新页面</text>
</button>
</view>
</view>
</view>
</template>
<script lang="ts" setup>
import { ref, onMounted } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
//
const courseInfo = ref<any>(null);
onLoad((options) => {
//
if (options?.courseInfo) {
try {
courseInfo.value = JSON.parse(decodeURIComponent(options.courseInfo));
} catch (error) {
console.error('解析选课信息失败:', error);
}
}
});
//
const formatTime = (time: string) => {
if (!time) return '未设置';
const date = new Date(time);
return date.toLocaleString('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit'
});
};
//
const goBack = () => {
uni.reLaunch({
url: '/pages/base/home/index'
});
};
//
const refreshPage = () => {
uni.reLaunch({
url: '/pages/base/course-selection/index'
});
};
</script>
<style lang="scss" scoped>
.enrollment-ended-page {
min-height: 100vh;
background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
padding: 20px;
box-sizing: border-box;
}
.ended-container {
max-width: 400px;
margin: 0 auto;
}
//
.page-header {
text-align: center;
margin-bottom: 30px;
.page-title {
display: block;
font-size: 28px;
font-weight: 600;
color: white;
margin-bottom: 8px;
}
.page-subtitle {
font-size: 16px;
color: rgba(255, 255, 255, 0.8);
}
}
//
.main-content {
margin-bottom: 30px;
}
.content-card {
background: white;
border-radius: 16px;
padding: 24px;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}
.icon-section {
display: flex;
justify-content: center;
margin-bottom: 20px;
}
.info-section {
margin-bottom: 20px;
.info-item {
display: flex;
margin-bottom: 12px;
.info-label {
font-size: 14px;
color: #666;
min-width: 80px;
font-weight: 500;
}
.info-value {
font-size: 14px;
color: #333;
flex: 1;
}
}
}
.status-section {
display: flex;
justify-content: center;
.status-badge {
display: flex;
align-items: center;
gap: 8px;
background: #fff5f5;
border: 1px solid #ff6b6b;
border-radius: 20px;
padding: 8px 16px;
.status-text {
font-size: 14px;
font-weight: 600;
color: #ff6b6b;
}
}
}
//
.tips-section {
background: rgba(255, 255, 255, 0.1);
border-radius: 12px;
padding: 20px;
backdrop-filter: blur(10px);
margin-bottom: 30px;
.tips-header {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 12px;
.tips-title {
font-size: 16px;
font-weight: 600;
color: white;
}
}
.tips-content {
.tip-item {
display: block;
font-size: 14px;
color: rgba(255, 255, 255, 0.9);
margin-bottom: 8px;
line-height: 1.4;
}
}
}
//
.action-buttons {
display: flex;
gap: 12px;
.back-btn, .refresh-btn {
flex: 1;
height: 44px;
border: none;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
font-size: 16px;
}
.back-btn {
background: #f5f5f5;
color: #666;
}
.refresh-btn {
background: #409EFF;
color: white;
}
.btn-text {
font-size: 14px;
}
}
//
@media (max-width: 375px) {
.enrollment-ended-page {
padding: 15px;
}
.content-card {
padding: 20px;
}
.page-header .page-title {
font-size: 24px;
}
}
</style>

View File

@ -5,10 +5,11 @@
<view class="header-content">
<!-- 选课类型选择部分 -->
<XkPicker title="俱乐部信息" :is-qk="true" xklx-id="962488654" :xs-id="curXs.id" @change="switchXk" v-if="!xsFlag" />
<!-- 学生选择部分 -->
<XsPicker :is-bar="true" @change="switchXs" />
<!-- 倒计时-->
<XkCountdown :xk="curXk" @over="xkTimeOver" v-if="curXk && curXk.id" />
<!-- 学生选择和倒计时 -->
<view class="bottom-row">
<XsPicker :is-bar="true" @change="switchXs" />
<XkCountdown :xk="curXk" @over="xkTimeOver" v-if="curXk && curXk.id" />
</view>
</view>
</view>
@ -35,6 +36,7 @@ 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";
import dayjs from "dayjs";
const { getCurXs, getUser } = useUserStore();
const { setData, getData } = useDataStore();
@ -47,9 +49,31 @@ const selectedXkkcIds = ref<any>([]);
const xsFlag = ref(true);
//
const checkEnrollmentStatus = (xk: any) => {
if (!xk || !xk.xkjstime) return;
const now = new Date().getTime();
const endTime = new Date(xk.xkjstime).getTime();
if (now > endTime) {
//
const courseInfo = encodeURIComponent(JSON.stringify(xk));
uni.navigateTo({
url: `/pages/base/course-selection/enrollment-ended?courseInfo=${courseInfo}`
});
return true;
}
return false;
};
//
const switchXk = (xk: any) => {
curXk.value = xk;
//
if (checkEnrollmentStatus(xk)) {
return;
}
}
//
@ -59,7 +83,12 @@ const switchXs = (xs: any) => {
//
const xkTimeOver = (val: any) => {
console.log(val);
console.log('选课时间结束:', val);
//
const courseInfo = encodeURIComponent(JSON.stringify(curXk.value));
uni.navigateTo({
url: `/pages/base/course-selection/enrollment-ended?courseInfo=${courseInfo}`
});
}
//
@ -77,6 +106,21 @@ const submit = async () => {
});
return;
}
//
if (curXk.value && curXk.value.xkkstime) {
const now = dayjs().valueOf();
const startTime = dayjs(curXk.value.xkkstime).valueOf();
if (now < startTime) {
uni.showToast({
title: "选课还未开始,请耐心等待!",
icon: "none",
});
return;
}
}
uni.showLoading({
title: "抢课中...",
});
@ -174,6 +218,27 @@ const submit = async () => {
flex-direction: column;
gap: 15px;
.bottom-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 15px;
//
:deep(.xs-bar) {
flex: 1;
min-width: 0;
}
//
:deep(.countdown-section) {
flex-shrink: 0;
background: rgba(255, 255, 255, 0.1);
border-radius: 6px;
padding: 6px 10px;
backdrop-filter: blur(10px);
}
}
}
}

View File

@ -25,14 +25,19 @@
</template>
<script lang="ts" setup>
import { ref } from "vue";
import { xkgzsApi } from "@/api/base/server";
import { updateSignFileApi } from "@/api/system/login";
import { useDataStore } from "@/store/modules/data";
import { useUserStore } from "@/store/modules/user";
import { showLoading } from "@/utils/uniapp";
import { onLoad } from "@dcloudio/uni-app";
import BasicSign from "@/components/BasicSign/Sign.vue";
const signCompRef = ref<any>(null);
const sign_file = ref<any>(null);
const { setData, getGlobal } = useDataStore();
const userStore = useUserStore();
const notice = ref("");
onLoad(async () => {
@ -43,20 +48,46 @@ onLoad(async () => {
});
async function submit() {
//
try {
//
const data = await signCompRef.value.getSyncSignature();
sign_file.value = data.base64;
//
const userInfo = userStore.getUser;
// localStorage userdatasignFile
const hasExistingSignFile = userInfo && userInfo.signFile;
// localStorage userdatasignFile
setData({
sign_file: sign_file.value,
});
if (getGlobal.type == 1) {
// localStorage userdatasignFileAPIu_user
if (!hasExistingSignFile && userInfo && userInfo.userId) {
try {
await updateSignFileApi({
userId: userInfo.userId,
signFile: sign_file.value
});
console.log('签名数据已更新到后端数据库');
} catch (error) {
console.error('更新后端签名数据失败:', error);
// 使
}
}
//
uni.reLaunch({
url: "/pages/base/course-selection/index",
});
}
if (getGlobal.type == 2) {
uni.reLaunch({
url: "/pages/base/course-selection/club-selection",
} catch (error) {
console.error('提交签名失败:', error);
uni.showToast({
title: '签名提交失败',
icon: 'none'
});
}
}

View File

@ -0,0 +1,73 @@
<template>
<BasicLayout>
<view class="p-15">
<view class="white-bg-color p-15 r-md" v-if="notice">
<view> 各位家长</view>
<view class="notice-text">
{{ notice }}
</view>
</view>
<BasicSign ref="signCompRef" title="签名"></BasicSign>
</view>
<template #bottom>
<view class="white-bg-color py-5">
<view class="flex-row items-center pb-10 pt-5">
<u-button
text="下一步"
class="mx-15"
type="primary"
@click="submit"
/>
</view>
</view>
</template>
</BasicLayout>
</template>
<script lang="ts" setup>
import { xkgzsApi } from "@/api/base/server";
import { useDataStore } from "@/store/modules/data";
import { showLoading } from "@/utils/uniapp";
import { onLoad } from "@dcloudio/uni-app";
const signCompRef = ref<any>(null);
const sign_file = ref<any>(null);
const { setData, getGlobal } = useDataStore();
const notice = ref("");
onLoad(async () => {
showLoading({ title: "加载中..." });
const res = await xkgzsApi({ kcLx: "俱乐部" });
notice.value = res.rows?.[0]?.content || "";
uni.hideLoading();
});
async function submit() {
//
const data = await signCompRef.value.getSyncSignature();
sign_file.value = data.base64;
setData({
sign_file: sign_file.value,
});
uni.reLaunch({
url: "/pages/base/course-selection/club-selection",
});
/*if (getGlobal.type == 1) {
uni.reLaunch({
url: "/pages/base/course-selection/index",
});
}
if (getGlobal.type == 2) {
uni.reLaunch({
url: "/pages/base/course-selection/club-selection",
});
}*/
}
</script>
<style lang="scss" scoped>
.notice-text {
margin-top: 10px;
text-indent: 2em; /* 添加两个中文字符的缩进 */
}
</style>

View File

@ -27,6 +27,7 @@
<view
v-for="(item, index) in menuItems"
:key="index"
v-show="hasPermissionDirect(item.permissionKey)"
class="grid-item"
@click="handleMenuClick(item)"
>
@ -79,14 +80,48 @@ import { ref, computed, onMounted, watch } from "vue";
import { onShow } from "@dcloudio/uni-app";
import XsPicker from "@/pages/base/components/XsPicker/index.vue"
import { cmsArticlePageApi, getUserLatestInfoApi } from "@/api/base/server";
import { getNoticeListApi } from "@/api/base/notice";
import { useUserStore } from "@/store/modules/user";
import { useDataStore } from "@/store/modules/data";
import { hasPermission } from "@/utils/permission";
const { getCurXs } = useUserStore();
const { setData, getAppCode } = useDataStore();
//
const { getLastRefreshTime, getRefreshInterval, setLastRefreshTime, updateStudentInfo, updateStudentList } = useUserStore();
const REFRESH_INTERVAL = 10 * 60 * 1000; // 10
const REFRESH_INTERVAL = 7 * 24 * 60 * 60 * 1000; // 17
// changeTime
const getCurrentChangeTime = () => {
try {
const userDataStr = uni.getStorageSync('app-user');
if (!userDataStr) return null;
const userData = typeof userDataStr === 'string' ? JSON.parse(userDataStr) : userDataStr;
return userData?.changeTime || null;
} catch (error) {
console.error('获取changeTime失败:', error);
return null;
}
};
// changeTime
const checkPermission = (permissionKey: string) => {
const changeTime = getCurrentChangeTime();
return hasPermission(permissionKey, changeTime);
};
//
const hasPermissionDirect = (permissionKey: string) => {
if (!permissionKey) return true;
const userStore = useUserStore();
const permissions = userStore.getAuth;
if (!permissions || permissions.length === 0) return false;
const uniquePermissions = [...new Set(permissions)];
return uniquePermissions.includes(permissionKey);
};
//
const checkAndRefreshStudentInfo = async () => {
@ -135,37 +170,56 @@ const menuItems = ref([
title: "班级课表",
icon: "/static/base/home/book-read-line.png",
path: "/pages/base/class-schedule/index",
permissionKey: "school-bjkb", //
},
{
title: "成绩查询",
icon: "/static/base/home/file-search-line.png",
path: "/pages/base/grades/list",
permissionKey: "school-cjcx", //
},
{
title: "在线请假",
icon: "/static/base/home/draft-line.png",
path: "/pages/base/leave-request/index",
permissionKey: "school-zxqj", // 线
},
// TODO:
// {
// title: "",
// icon: "/static/base/home/file-transfer-line.png",
// path: "/pages/base/campus-access/index",
// permissionKey: "school-jcxy", //
// },
{
title: "家校沟通",
icon: "/static/base/home/file-transfer-line.png",
path: "/pages/base/jl/index",
permissionKey: "school-jxgt", //
},
{
title: "兴趣课",
icon: "/static/base/home/file-text-line.png",
path: "/pages/base/interest-class/index",
permissionKey: "school-xqk", //
},
{
title: "俱乐部",
icon: "/static/base/home/contacts-book-3-line.png",
path: "/pages/base/club/index",
permissionKey: "school-jlb", //
},
{
title: "兴趣课选课",
icon: "/static/base/home/file-text-line.png",
path: "/pages/base/course-selection/notice",
permissionKey: "school-xqkxk", //
},
{
title: "俱乐部选课",
icon: "/static/base/home/contacts-book-3-line.png",
path: "/pages/base/course-selection/noticeclub",
permissionKey: "school-jlbxk", //
},
]);
@ -229,13 +283,21 @@ function goToDetail(notice: any) {
const getArticleList = async () => {
if (curXs.value && curXs.value.njmcId) {
const params = Object.assign({}, pageParams.value, { njmcId: curXs.value.njmcId });
const params = {
page: pageParams.value.page,
rows: pageParams.value.rows,
appCode: getAppCode,
fbfw: 'JZ', //
xqId: curXs.value.xqId || curXs.value.xq_id, //
fbNjmcId: curXs.value.njmcId, //
releaseFlag: 'A' //
};
cmsArticlePageApi(params).then(res => {
announcements.value = res.rows;
})
.catch((error) => {
//
getNoticeListApi(params).then(res => {
announcements.value = res.rows;
})
.catch((error) => {
//
});
}
};
@ -255,8 +317,66 @@ onMounted(async () => {
//
await checkAndRefreshStudentInfo();
//
const userStore = useUserStore();
const changeTime = userStore.getChangeTime;
if (changeTime) {
// changeTime
const { PermissionCacheManager } = await import('@/utils/permission');
const cacheInfo = PermissionCacheManager.getCacheInfo();
if (cacheInfo.hasCache && cacheInfo.changeTime) {
const serverTime = new Date(changeTime).getTime();
const cacheTime = new Date(cacheInfo.changeTime).getTime();
if (serverTime > cacheTime) {
//
const { refreshPermissionCache } = await import('@/utils/permission');
const currentPermissions = userStore.getAuth;
if (currentPermissions && currentPermissions.length > 0) {
refreshPermissionCache(currentPermissions, changeTime);
}
}
}
}
//
await checkSubscribeStatus();
});
//
const checkSubscribeStatus = async () => {
const userStore = useUserStore();
const userInfo = userStore.getUser;
if (userInfo && !userInfo.subscribed) {
//
setTimeout(() => {
showSubscribeReminder();
}, 2000);
}
};
//
const showSubscribeReminder = () => {
uni.showModal({
title: '关注服务号',
content: '请先关注我们的服务号,以便接收重要通知',
showCancel: true,
cancelText: '稍后关注',
confirmText: '立即关注',
success: (res) => {
if (res.confirm) {
//
uni.navigateTo({
url: '/pages/system/subscribe/index'
});
}
}
});
};
//
onShow(async () => {
await checkAndRefreshStudentInfo();

View File

@ -16,6 +16,7 @@ import {onLoad} from "@dcloudio/uni-app";
import {useDataStore} from "@/store/modules/data";
import {useUserStore} from "@/store/modules/user";
import {checkOpenId} from "@/api/system/login";
import {refreshPermissionCache} from "@/utils/permission";
const { setGlobal } = useDataStore();
const { afterLoginAction } = useUserStore();
@ -36,24 +37,35 @@ function toHome(data: any) {
onLoad(async (data: any) => {
setGlobal(data);
if (data && data.openId) {
checkOpenId({ openId: data.openId, appCode: "JZ" })
.then(async (res) => {
if (res.resultCode == 1) {
if (res.result) {
afterLoginAction(res.result);
toHome(data);
return;
try {
const res = await checkOpenId({ openId: data.openId, appCode: "JZ" });
if (res.resultCode == 1 && res.result) {
//
afterLoginAction(res.result);
// changeTime
if (data.changeTime) {
const userStore = useUserStore();
const currentPermissions = userStore.getAuth;
if (currentPermissions && currentPermissions.length > 0) {
refreshPermissionCache(currentPermissions, data.changeTime);
}
}
uni.reLaunch({
url: "/pages/system/login/login",
});
})
.catch((err) => {
uni.reLaunch({
url: "/pages/system/login/login",
});
});
//
toHome(data);
} else {
uni.reLaunch({
url: "/pages/system/login/login",
});
}
} catch (err) {
uni.reLaunch({
url: "/pages/system/login/login",
});
}
} else {
uni.reLaunch({
url: "/pages/system/login/login",

View File

@ -124,6 +124,7 @@ import { loginRegisterJzApi } from "@/api/base/server";
import { useUserStore } from "@/store/modules/user";
import { useDataStore } from "@/store/modules/data";
import {imagUrl} from "@/utils";
import {refreshPermissionCache} from "@/utils/permission";
const dicOptions = ref<any>([[[]]]);
const dicPickerRef = ref();
@ -264,7 +265,7 @@ function toHome() {
});
} else if (getGlobal.type == 2) {
uni.reLaunch({
url: "/pages/base/course-selection/club-selection",
url: "/pages/base/course-selection/noticeclub",
});
} else {
uni.reLaunch({
@ -305,6 +306,17 @@ async function submit() {
hideLoading();
if (res.resultCode == 1) {
afterLoginAction(res.result);
// changeTime
if (res.result && res.result.changeTime) {
const userStore = useUserStore();
const currentPermissions = userStore.getAuth;
if (currentPermissions && currentPermissions.length > 0) {
refreshPermissionCache(currentPermissions, res.result.changeTime);
}
}
toHome();
} else {
showToast({ title: res.message || "提交失败", icon: "none" });

View File

@ -0,0 +1,194 @@
<template>
<view class="subscribe-page">
<!-- 内容区域 -->
<view class="content-container">
<!-- 二维码区域 -->
<view class="qr-section">
<view class="qr-container">
<image src="/static/base/home/rdcode.jpg" class="qr-code" mode="aspectFit"></image>
</view>
<text class="qr-tip">请长按二维码识别并关注我们的服务号</text>
</view>
<!-- 关注好处 -->
<view class="benefits-section">
<view class="section-title">
<text class="title-text">关注后可享受</text>
</view>
<view class="benefits-list">
<view class="benefit-item">
<view class="benefit-icon">
<uni-icons type="notification" size="20" color="#4A90E2"></uni-icons>
</view>
<view class="benefit-content">
<text class="benefit-title">重要通知</text>
<text class="benefit-desc">及时接收学校重要通知和公告</text>
</view>
</view>
<view class="benefit-item">
<view class="benefit-icon">
<uni-icons type="calendar" size="20" color="#4A90E2"></uni-icons>
</view>
<view class="benefit-content">
<text class="benefit-title">课程安排</text>
<text class="benefit-desc">课程变更和安排调整实时推送</text>
</view>
</view>
<view class="benefit-item">
<view class="benefit-icon">
<uni-icons type="star" size="20" color="#4A90E2"></uni-icons>
</view>
<view class="benefit-content">
<text class="benefit-title">成绩查询</text>
<text class="benefit-desc">考试成绩发布第一时间通知</text>
</view>
</view>
<view class="benefit-item">
<view class="benefit-icon">
<uni-icons type="checkmarkempty" size="20" color="#4A90E2"></uni-icons>
</view>
<view class="benefit-content">
<text class="benefit-title">请假审批</text>
<text class="benefit-desc">请假申请审批结果及时反馈</text>
</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { useDataStore } from '@/store/modules/data';
const { getGlobal } = useDataStore();
//
</script>
<style lang="scss" scoped>
.subscribe-page {
min-height: 100vh;
background: linear-gradient(135deg, #f4f5f7 0%, #e8f0ff 100%);
display: flex;
flex-direction: column;
padding: 40rpx 30rpx;
}
.content-container {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 40rpx;
}
.qr-section {
background: white;
border-radius: 24rpx;
padding: 60rpx 40rpx;
text-align: center;
box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 600rpx;
}
.qr-container {
margin-bottom: 30rpx;
}
.qr-code {
width: 400rpx;
height: 400rpx;
border-radius: 16rpx;
box-shadow: 0 12rpx 36rpx rgba(0, 0, 0, 0.15);
}
.qr-tip {
font-size: 32rpx;
color: #333;
line-height: 1.5;
font-weight: 500;
}
.benefits-section {
background: white;
border-radius: 24rpx;
padding: 40rpx 30rpx;
box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 600rpx;
}
.section-title {
margin-bottom: 40rpx;
text-align: center;
}
.title-text {
font-size: 36rpx;
font-weight: 600;
color: #333;
position: relative;
padding-left: 24rpx;
&::before {
content: '';
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
width: 8rpx;
height: 32rpx;
background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
border-radius: 4rpx;
}
}
.benefits-list {
display: flex;
flex-direction: column;
gap: 30rpx;
}
.benefit-item {
display: flex;
align-items: flex-start;
gap: 24rpx;
}
.benefit-icon {
width: 80rpx;
height: 80rpx;
background: linear-gradient(135deg, #f0f4ff 0%, #e6f0ff 100%);
border-radius: 16rpx;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
box-shadow: 0 6rpx 16rpx rgba(74, 144, 226, 0.15);
}
.benefit-content {
flex: 1;
display: flex;
flex-direction: column;
gap: 12rpx;
}
.benefit-title {
font-size: 32rpx;
font-weight: 500;
color: #333;
}
.benefit-desc {
font-size: 28rpx;
color: #666;
line-height: 1.5;
}
</style>

View File

@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1754283033015" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="10483" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M511.812 929.397c-230.391 0-417.826-187.434-417.826-417.821 0-230.391 187.434-417.826 417.826-417.826 230.386 0 417.821 187.434 417.821 417.826 0 230.386-187.436 417.821-417.821 417.821zM511.812 137.482c-206.277 0-374.092 167.815-374.092 374.093 0 206.273 167.815 374.089 374.092 374.089 206.273 0 374.089-167.815 374.089-374.089 0-206.277-167.815-374.093-374.089-374.093z" p-id="10484" fill="#1296db"></path><path d="M589.938 510.195l-164.817 164.817 30.521 30.521 195.339-195.339-195.339-195.339-30.521 30.521z" p-id="10485" fill="#1296db"></path></svg>

After

Width:  |  Height:  |  Size: 889 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@ -15,6 +15,7 @@ interface UserState {
auth: string[];
lastRefreshTime: number; // 上次刷新时间
refreshInterval: number; // 刷新间隔(毫秒)
changeTime: string; // 权限变更时间
ws: any;
wsCallback: any;
}
@ -32,6 +33,7 @@ export const useUserStore = defineStore({
auth: [],
lastRefreshTime: 0, // 上次刷新时间
refreshInterval: 7 * 24 * 60 * 60 * 1000, // 刷新间隔(毫秒)
changeTime: '', // 权限变更时间
ws: null,
wsCallback: defWsCallback
}),
@ -53,6 +55,9 @@ export const useUserStore = defineStore({
},
getRefreshInterval(): number {
return this.refreshInterval;
},
getChangeTime(): string {
return this.changeTime;
}
},
actions: {
@ -74,6 +79,9 @@ export const useUserStore = defineStore({
setRefreshInterval(interval: number) {
this.refreshInterval = interval;
},
setChangeTime(changeTime: string) {
this.changeTime = changeTime;
},
// 更新学生信息
updateStudentInfo(studentInfo: any) {
this.setCurXs(studentInfo);

View File

@ -2,11 +2,258 @@ import {ISROUTERINTERCEPT} from "@/config";
import {getRouter} from "@/utils/uniapp";
import {useUserStore} from "@/store/modules/user";
export function _auth(autd: string) {
const {getAuth} = useUserStore()
return getAuth.includes(autd);
// 权限缓存接口
interface PermissionCache {
permissions: string[];
timestamp: number;
userId: string;
changeTime: string;
}
// 存储键名
const PERMISSION_CACHE_KEY = 'permission_cache';
const CHANGE_TIME_KEY = 'change_time';
// 存储操作
function setStorage(key: string, value: any): void {
try {
const jsonValue = JSON.stringify(value);
uni.setStorageSync(key, jsonValue);
} catch (error) {
console.error('存储权限缓存失败:', error);
}
}
function getStorage(key: string): any {
try {
const value = uni.getStorageSync(key);
if (value) {
const parsedValue = JSON.parse(value);
return parsedValue;
} else {
return null;
}
} catch (error) {
console.error('获取权限缓存失败:', error);
return null;
}
}
// 从app-user获取changeTime
export function getChangeTimeFromAppUser(): string | null {
try {
const userDataStr = uni.getStorageSync('app-user');
if (!userDataStr) return null;
const userData = typeof userDataStr === 'string' ? JSON.parse(userDataStr) : userDataStr;
return userData?.changeTime || null;
} catch (error) {
console.error('获取changeTime失败:', error);
return null;
}
}
// 设置changeTime到app-user
function setChangeTimeToAppUser(changeTime: string): void {
try {
const userDataStr = uni.getStorageSync('app-user');
if (!userDataStr) return;
const userData = typeof userDataStr === 'string' ? JSON.parse(userDataStr) : userDataStr;
userData.changeTime = changeTime;
uni.setStorageSync('app-user', JSON.stringify(userData));
} catch (error) {
console.error('设置changeTime失败:', error);
}
}
// 获取权限缓存
function getPermissionCache(): PermissionCache | null {
return getStorage(PERMISSION_CACHE_KEY);
}
// 设置权限缓存
function setPermissionCache(permissions: string[], userId: string, changeTime?: string): void {
const cache: PermissionCache = {
permissions,
timestamp: Date.now(),
userId,
changeTime: changeTime || ''
};
setStorage(PERMISSION_CACHE_KEY, cache);
if (changeTime) {
setChangeTimeToAppUser(changeTime);
}
}
// 清除权限缓存
function clearPermissionCache(): void {
try {
uni.removeStorageSync(PERMISSION_CACHE_KEY);
} catch (error) {
console.error('清除权限缓存失败:', error);
}
}
// 检查缓存是否有效
function isCacheValid(cache: PermissionCache, currentUserId: string): boolean {
if (!cache || !cache.permissions || cache.userId !== currentUserId) {
return false;
}
// 检查缓存是否过期7天
const now = Date.now();
const cacheAge = now - cache.timestamp;
const maxAge = 7 * 24 * 60 * 60 * 1000; // 7天
return cacheAge < maxAge;
}
// 获取用户权限(带缓存)
function getUserPermissionsWithCache(currentChangeTime?: string): string[] {
const userStore = useUserStore();
const currentUser = userStore.getUser;
const currentUserId = currentUser?.userId || currentUser?.id;
if (!currentUserId) {
return userStore.getAuth;
}
const cache = getPermissionCache();
if (cache && isCacheValid(cache, currentUserId)) {
if (currentChangeTime) {
const serverTime = new Date(currentChangeTime).getTime();
const cacheTime = new Date(cache.changeTime).getTime();
if (serverTime > cacheTime) {
const permissions = userStore.getAuth;
if (permissions && permissions.length > 0) {
setPermissionCache(permissions, currentUserId, currentChangeTime);
}
return permissions;
} else {
return cache.permissions;
}
} else {
return cache.permissions;
}
}
const permissions = userStore.getAuth;
if (permissions && permissions.length > 0) {
setPermissionCache(permissions, currentUserId, currentChangeTime);
}
return permissions;
}
// 刷新权限缓存
export function refreshPermissionCache(permissions?: string[], changeTime?: string): void {
const userStore = useUserStore();
const currentUser = userStore.getUser;
const currentUserId = currentUser?.userId || currentUser?.id;
if (!currentUserId) {
return;
}
const permissionList = permissions || userStore.getAuth;
const currentCache = getPermissionCache();
if (currentCache && currentCache.permissions && permissionList) {
const isSame = JSON.stringify(currentCache.permissions.sort()) === JSON.stringify(permissionList.sort());
if (isSame && currentCache.changeTime === changeTime) {
return;
}
}
setPermissionCache(permissionList, currentUserId, changeTime);
if (changeTime) {
userStore.setChangeTime(changeTime);
}
}
// 清除权限缓存(供外部调用)
export function clearPermissionCachePublic(): void {
clearPermissionCache();
}
// 权限检查函数
export function _auth(autd: string, changeTime?: string) {
const permissions = getUserPermissionsWithCache(changeTime);
return permissions.includes(autd);
}
export function hasPermission(permissionKey: string, changeTime?: string): boolean {
if (!permissionKey) return true;
const permissions = getUserPermissionsWithCache(changeTime);
// 去重处理,避免重复权限影响判断
const uniquePermissions = [...new Set(permissions)];
return uniquePermissions.includes(permissionKey);
}
export function hasAnyPermission(permissionKeys: string[], changeTime?: string): boolean {
if (!permissionKeys || permissionKeys.length === 0) return true;
const permissions = getUserPermissionsWithCache(changeTime);
// 去重处理,避免重复权限影响判断
const uniquePermissions = [...new Set(permissions)];
return permissionKeys.some(key => uniquePermissions.includes(key));
}
export function hasAllPermissions(permissionKeys: string[], changeTime?: string): boolean {
if (!permissionKeys || permissionKeys.length === 0) return true;
const permissions = getUserPermissionsWithCache(changeTime);
// 去重处理,避免重复权限影响判断
const uniquePermissions = [...new Set(permissions)];
return permissionKeys.every(key => uniquePermissions.includes(key));
}
// 获取用户权限
export function getUserPermissions(changeTime?: string): string[] {
return getUserPermissionsWithCache(changeTime);
}
// 权限缓存管理器
export const PermissionCacheManager = {
getCacheInfo() {
const cache = getPermissionCache();
const changeTime = getChangeTimeFromAppUser();
return {
cache,
changeTime,
hasCache: !!cache,
cacheAge: cache ? Date.now() - cache.timestamp : 0
};
},
debugCache() {
const info = this.getCacheInfo();
console.log('权限缓存信息:', info);
},
forceRefresh() {
clearPermissionCache();
const userStore = useUserStore();
const permissions = userStore.getAuth;
if (permissions && permissions.length > 0) {
const currentUser = userStore.getUser;
const currentUserId = currentUser?.userId || currentUser?.id;
if (currentUserId) {
setPermissionCache(permissions, currentUserId);
}
}
},
clear() {
clearPermissionCache();
}
};
function loginPage(url: string) {
uni.redirectTo({
url: "/pages/system/login/login?redirect=" + url,