登录处理

This commit is contained in:
hb 2025-07-21 20:21:57 +08:00
parent 0892a4771e
commit 4c541c9861
5 changed files with 180 additions and 96 deletions

View File

@ -180,3 +180,10 @@ export const jzXsQjListApi = async (params: any) => {
export const jzXsQjActivitiHistoryApi = async (params: any) => { export const jzXsQjActivitiHistoryApi = async (params: any) => {
return await get("/activiti/history/historicFlow", params); return await get("/activiti/history/historicFlow", params);
}; };
/**
*
*/
export const getUserLatestInfoApi = async () => {
return await get("/open/login/getLatestInfo");
};

View File

@ -75,14 +75,60 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref } from "vue"; import { ref, computed, onMounted, watch } from "vue";
import { onShow } from "@dcloudio/uni-app";
import XsPicker from "@/pages/base/components/XsPicker/index.vue" import XsPicker from "@/pages/base/components/XsPicker/index.vue"
import { cmsArticlePageApi } from "@/api/base/server"; import { cmsArticlePageApi, getUserLatestInfoApi } from "@/api/base/server";
import { useUserStore } from "@/store/modules/user"; import { useUserStore } from "@/store/modules/user";
import { useDataStore } from "@/store/modules/data"; import { useDataStore } from "@/store/modules/data";
const { getCurXs } = useUserStore(); const { getCurXs } = useUserStore();
const { setData, getAppCode } = useDataStore(); const { setData, getAppCode } = useDataStore();
//
const { getLastRefreshTime, getRefreshInterval, setLastRefreshTime, updateStudentInfo, updateStudentList } = useUserStore();
const REFRESH_INTERVAL = 10 * 60 * 1000; // 10
//
const checkAndRefreshStudentInfo = async () => {
const lastRefreshTime = getLastRefreshTime;
const currentTime = Date.now();
if (!lastRefreshTime || (currentTime - lastRefreshTime) > REFRESH_INTERVAL) {
await refreshStudentInfo();
setLastRefreshTime(currentTime);
}
};
//
const refreshStudentInfo = async () => {
try {
const response = await getUserLatestInfoApi();
if (response && response.result) {
//
if (response.result.xsList && response.result.xsList.length > 0) {
updateStudentList(response.result.xsList);
//
const currentXsId = curXs.value?.id;
if (currentXsId) {
const currentStudent = response.result.xsList.find((xs: any) => xs.id === currentXsId);
if (currentStudent) {
updateStudentInfo(currentStudent);
} else {
//
updateStudentInfo(response.result.xsList[0]);
}
} else {
//
updateStudentInfo(response.result.xsList[0]);
}
}
}
} catch (error) {
//
}
};
// //
const menuItems = ref([ const menuItems = ref([
{ {
@ -161,7 +207,6 @@ const goToGlxs = () => {
// //
function handleMenuClick(item: any) { function handleMenuClick(item: any) {
console.log("点击菜单:", item.title);
if (item.path) { if (item.path) {
uni.navigateTo({ uni.navigateTo({
url: item.path, url: item.path,
@ -183,19 +228,46 @@ function goToDetail(notice: any) {
} }
const getArticleList = async () => { const getArticleList = async () => {
if (curXs.value && curXs.value.njmcId) {
const params = Object.assign({}, pageParams.value, { njmcId: curXs.value.njmcId }); const params = Object.assign({}, pageParams.value, { njmcId: curXs.value.njmcId });
cmsArticlePageApi(params).then(res => { cmsArticlePageApi(params).then(res => {
announcements.value = res.rows; announcements.value = res.rows;
}) })
.catch((error) => { .catch((error) => {
// //
console.error("调用检查通知公告接口失败:", error);
}); });
}
}; };
onMounted(async () => { onMounted(async () => {
//
if (curXs.value && curXs.value.njmcId) {
getArticleList(); getArticleList();
} else {
// store
setTimeout(() => {
if (curXs.value && curXs.value.njmcId) {
getArticleList();
}
}, 100);
}
//
await checkAndRefreshStudentInfo();
}); });
//
onShow(async () => {
await checkAndRefreshStudentInfo();
});
//
watch(curXs, (newXs, oldXs) => {
if (newXs && newXs.njmcId) {
getArticleList();
}
}, { immediate: false });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -24,11 +24,11 @@
<view class="notice-content"> <view class="notice-content">
<view v-if="!descExpanded"> <view v-if="!descExpanded">
<text class="desc-preview">{{ descPreview }}</text> <text class="desc-preview">{{ descPreview }}</text>
<u-button type="text" size="mini" @click="descExpanded = true">更多</u-button> <u-button type="text" size="mini" class="more-btn" @click="descExpanded = true">更多</u-button>
</view> </view>
<view v-else> <view v-else>
<rich-text :nodes="noticeDetail.jlms" class="desc-rich-text"></rich-text> <rich-text :nodes="noticeDetail.jlms" class="desc-rich-text"></rich-text>
<u-button type="text" size="mini" @click="descExpanded = false">收起</u-button> <u-button type="text" size="mini" class="more-btn" @click="descExpanded = false">收起</u-button>
</view> </view>
</view> </view>
</view> </view>
@ -53,10 +53,7 @@
v-for="stu in studentList" v-for="stu in studentList"
:key="stu.id || stu.xsId" :key="stu.id || stu.xsId"
class="name-tag" class="name-tag"
:class="{ :class="{ received: stu.jlwc_status === 'A' }"
received: stu.jlwc_status === 'A',
currentStudent: isCurrentStudent(stu)
}"
> >
<text>{{ stu.xsxm || stu.name }}</text> <text>{{ stu.xsxm || stu.name }}</text>
<view v-if="stu.jlwc_status === 'A'" class="checkmark-icon"> <view v-if="stu.jlwc_status === 'A'" class="checkmark-icon">
@ -68,29 +65,24 @@
</view> </view>
<view v-else class="empty-state">通知详情未找到</view> <view v-else class="empty-state">通知详情未找到</view>
</view> </view>
<!-- 添加签名组件 --> <!-- 添加签名组件 - 只在需要时显示 -->
<BasicSign ref="signCompRef" :title="signTitle" @confirm="onSignConfirm"/> <BasicSign v-if="showSignature" ref="signCompRef" :title="signTitle"></BasicSign>
<template #bottom> <template #bottom>
<view class="flex-row items-center pb-10 pt-5"> <view class="bottom-actions">
<u-button <button class="action-btn publish-btn" @click="onRelayClick">接龙</button>
text="点击接龙"
class="mr-15 mr-7"
type="primary"
@click="onRelayClick"
/>
</view> </view>
</template> </template>
</BasicLayout> </BasicLayout>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import {ref, computed, watch} from "vue"; import { ref, computed, watch, nextTick } from "vue";
import { onLoad } from "@dcloudio/uni-app"; import { onLoad } from "@dcloudio/uni-app";
import { getByJlIdApi, jlzxFindByJlParamsApi, relayFinishApi } from "@/api/base/server"; import { getByJlIdApi, jlzxFindByJlParamsApi, relayFinishApi } from "@/api/base/server";
import { imagUrl } from "@/utils"; import { imagUrl } from "@/utils";
import { BASE_IMAGE_URL } from "@/config"; import { BASE_IMAGE_URL } from "@/config";
import { useUserStore } from "@/store/modules/user"; import { useUserStore } from "@/store/modules/user";
import {navigateBack, showLoading, hideLoading} from "@/utils/uniapp"; import { showLoading, hideLoading } from "@/utils/uniapp";
const noticeId = ref<string>(""); const noticeId = ref<string>("");
const noticeDetail = ref<any>(null); const noticeDetail = ref<any>(null);
@ -102,6 +94,7 @@ const descExpanded = ref(false);
const signCompRef = ref<any>(null); const signCompRef = ref<any>(null);
const signTitle = ref<string>("签名"); const signTitle = ref<string>("签名");
const sign_file = ref<string>(""); const sign_file = ref<string>("");
const showSignature = ref<boolean>(false);
// //
const userStore = useUserStore(); const userStore = useUserStore();
@ -123,16 +116,11 @@ const getFileName = (filePath: string) => {
// Computed properties for feedback status // Computed properties for feedback status
const receivedCount = computed(() => { const receivedCount = computed(() => {
return studentList.value.filter((s) => s.jlwc_status === '1').length; return studentList.value.filter((s) => s.jlwc_status === 'A').length;
}); });
const totalStudents = computed(() => studentList.value.length); const totalStudents = computed(() => studentList.value.length);
// //
const isCurrentStudent = (student: any) => {
return currentStudent.value && student.xsId === currentStudent.value.id;
};
//
async function onRelayClick() { async function onRelayClick() {
try { try {
const res = await getByJlIdApi({ jlId: noticeId.value }); const res = await getByJlIdApi({ jlId: noticeId.value });
@ -149,38 +137,24 @@ async function onRelayClick() {
} }
if (detail && detail.mdqz == 1) { if (detail && detail.mdqz == 1) {
// //
showSignature.value = true;
sign_file.value = ''; sign_file.value = '';
if (signCompRef.value) { //
onSignConfirm(); await nextTick();
} const data = await signCompRef.value.getSyncSignature();
sign_file.value = data.base64;
showSignature.value = false;
submitRelay();
} else { } else {
submitRelay(); submitRelay();
} }
} catch (e) { } catch (e) {
showSignature.value = false;
uni.showToast({title: '获取详情失败', icon: 'none'}); uni.showToast({title: '获取详情失败', icon: 'none'});
} }
} }
// //
async function onSignConfirm() {
try {
if (!sign_file.value) {
if (signCompRef.value && signCompRef.value.getSyncSignature) {
const data = await signCompRef.value.getSyncSignature();
sign_file.value = data.base64;
}
}
if (!sign_file.value) {
uni.showToast({title: '请完成签名', icon: 'none'});
return;
}
submitRelay();
} catch (e) {
uni.showToast({title: '签名流程异常', icon: 'none'});
}
}
//
async function submitRelay() { async function submitRelay() {
const params: any = { const params: any = {
jl_id: noticeId.value, jl_id: noticeId.value,
@ -196,7 +170,6 @@ async function submitRelay() {
if (res && res.resultCode === 1 ) { if (res && res.resultCode === 1 ) {
uni.showToast({title: '接龙成功', icon: 'success'}); uni.showToast({title: '接龙成功', icon: 'success'});
await refreshStudentList(); await refreshStudentList();
} else { } else {
uni.showToast({title: res?.msg || '接龙失败', icon: 'none'}); uni.showToast({title: res?.msg || '接龙失败', icon: 'none'});
} }
@ -206,7 +179,7 @@ async function submitRelay() {
} }
} }
// //
async function refreshStudentList() { async function refreshStudentList() {
try { try {
const stuRes = await jlzxFindByJlParamsApi({ jlId: noticeId.value }); const stuRes = await jlzxFindByJlParamsApi({ jlId: noticeId.value });
@ -235,7 +208,7 @@ onLoad(async (options) => {
uni.showToast({ title: "加载学生状态失败", icon: "none" }); uni.showToast({ title: "加载学生状态失败", icon: "none" });
} }
isLoading.value = false; isLoading.value = false;
uni.setNavigationBarTitle({title: "点击接龙"}); uni.setNavigationBarTitle({ title: "接龙情况" });
} else { } else {
uni.showToast({ title: "加载失败缺少通知ID", icon: "none" }); uni.showToast({ title: "加载失败缺少通知ID", icon: "none" });
} }
@ -300,13 +273,17 @@ watch(noticeDetail, (val) => {
// //
}, { immediate: true, deep: true }); }, { immediate: true, deep: true });
// studentListjlwc_status //
watch(studentList, (list) => { watch(studentList, (list) => {
list.forEach(stu => { list.forEach(stu => {
// //
if (stu.jlwcStatus && !stu.jlwc_status) { if (stu.jlwcStatus && !stu.jlwc_status) {
stu.jlwc_status = stu.jlwcStatus; stu.jlwc_status = stu.jlwcStatus;
} }
// '1''A'
if (stu.jlwc_status === '1') {
stu.jlwc_status = 'A';
}
}); });
}, { immediate: true, deep: true }); }, { immediate: true, deep: true });
</script> </script>
@ -578,14 +555,12 @@ watch(studentList, (list) => {
box-sizing: border-box; box-sizing: border-box;
// 44 // 44
flex-basis: calc((100% - 30px) / 4); // 43 flex-basis: calc((100% - 30px) / 4); // 43
min-width: 60px; // 4
height: 30px; // Slightly taller height height: 30px; // Slightly taller height
line-height: 20px; // Adjust line-height for vertical centering line-height: 20px; // Adjust line-height for vertical centering
border: 1px solid #f4f4f5; border: 1px solid #f4f4f5;
// //
white-space: normal; white-space: normal;
word-break: keep-all; // word-break: break-all; // Break long names if they don't fit
overflow: hidden;
} }
.name-tag { .name-tag {
@ -635,6 +610,13 @@ watch(studentList, (list) => {
} }
} }
/* 更多按钮样式 */
.more-btn {
font-size: 16px !important;
color: #409eff !important;
font-weight: 500;
}
/* 列表项样式的卡片 */ /* 列表项样式的卡片 */
.list-item-card { .list-item-card {
padding: 5px 15px; // padding padding: 5px 15px; // padding

View File

@ -206,7 +206,6 @@ const openDicPicker = (xs: any) => {
}; };
const dicChanged = (dicArr: any) => { const dicChanged = (dicArr: any) => {
console.log(dicArr);
const dic = dicOptions.value[0][dicArr[0]]; const dic = dicOptions.value[0][dicArr[0]];
curXs.value.jzxsgxId = dic.dictionaryValue; curXs.value.jzxsgxId = dic.dictionaryValue;
curXs.value.jzxsgxmc = dic.dictionaryCode; curXs.value.jzxsgxmc = dic.dictionaryCode;
@ -224,11 +223,9 @@ async function afterRead(event: any, index: number) {
const result = res.result; const result = res.result;
if (result && result.length > 0 && result[0].filePath) { if (result && result.length > 0 && result[0].filePath) {
students.value[index].xstx = result[0].filePath; students.value[index].xstx = result[0].filePath;
console.log(`Student ${index} avatar uploaded:`, result[0].filePath);
showToast({ title: "上传成功" }); showToast({ title: "上传成功" });
} else { } else {
showToast({ title: "上传失败,请重试", icon: "none" }); showToast({ title: "上传失败,请重试", icon: "none" });
console.error("Upload result format error:", result);
} }
} catch (error) { } catch (error) {
showToast({ title: "上传出错", icon: "none" }); showToast({ title: "上传出错", icon: "none" });
@ -313,7 +310,7 @@ async function submit() {
showToast({ title: res.message || "提交失败", icon: "none" }); showToast({ title: res.message || "提交失败", icon: "none" });
} }
} catch (error) { } catch (error) {
console.log(error); //
} }
} }

View File

@ -12,9 +12,11 @@ interface UserState {
userdata: any; userdata: any;
curXs: any; curXs: any;
token: string; token: string;
auth: string[], auth: string[];
ws: any, lastRefreshTime: number; // 上次刷新时间
wsCallback: any refreshInterval: number; // 刷新间隔(毫秒)
ws: any;
wsCallback: any;
} }
export const useUserStore = defineStore({ export const useUserStore = defineStore({
@ -28,6 +30,8 @@ export const useUserStore = defineStore({
token: '', token: '',
//用户注册信息 //用户注册信息
auth: [], auth: [],
lastRefreshTime: 0, // 上次刷新时间
refreshInterval: 7 * 24 * 60 * 60 * 1000, // 刷新间隔(毫秒)
ws: null, ws: null,
wsCallback: defWsCallback wsCallback: defWsCallback
}), }),
@ -43,6 +47,12 @@ export const useUserStore = defineStore({
}, },
getAuth(): string[] { getAuth(): string[] {
return this.auth; return this.auth;
},
getLastRefreshTime(): number {
return this.lastRefreshTime;
},
getRefreshInterval(): number {
return this.refreshInterval;
} }
}, },
actions: { actions: {
@ -58,6 +68,22 @@ export const useUserStore = defineStore({
setAuth(data: string[]) { setAuth(data: string[]) {
this.auth = data; this.auth = data;
}, },
setLastRefreshTime(time: number) {
this.lastRefreshTime = time;
},
setRefreshInterval(interval: number) {
this.refreshInterval = interval;
},
// 更新学生信息
updateStudentInfo(studentInfo: any) {
this.setCurXs(studentInfo);
},
// 更新学生列表
updateStudentList(studentList: any[]) {
if (this.userdata) {
this.userdata.xsList = studentList;
}
},
setWsCallback(callback: any) { setWsCallback(callback: any) {
this.wsCallback = callback; this.wsCallback = callback;
}, },