接龙调整

This commit is contained in:
hb 2025-07-02 09:11:31 +08:00
parent 60cf660a05
commit 66bc9dc920
3 changed files with 113 additions and 117 deletions

View File

@ -359,21 +359,21 @@
{
"path": "pages/view/notice/index",
"style": {
"navigationBarTitleText": "通知公告",
"navigationBarTitleText": "发布接龙",
"enablePullDownRefresh": false
}
},
{
"path": "pages/view/notice/detail",
"style": {
"navigationBarTitleText": "通知详情",
"navigationBarTitleText": "接龙详情",
"enablePullDownRefresh": false
}
},
{
"path": "pages/view/notice/publish",
"style": {
"navigationBarTitleText": "发布通知",
"navigationBarTitleText": "接龙推送",
"enablePullDownRefresh": false
}
},

View File

@ -206,7 +206,7 @@ const sections = reactive<Section[]>([
{
id: "r7",
icon: "file-text-fill-2",
text: "选课详情",
text: "课程介绍",
show: true,
path: "/pages/base/groupTeaching/xkList",
},
@ -218,6 +218,13 @@ const sections = reactive<Section[]>([
show: true,
path: "/pages/base/groupTeaching/dmXkList",
},
{
id: "r8",
icon: "draftfill",
text: "发布接龙",
show: true,
path: "/pages/view/notice/index",
},
],
},
{

View File

@ -1,120 +1,93 @@
<!-- src/pages/view/notice/index.vue -->
<template>
<view class="notice-list-page">
<BasicListLayout @register="register">
<template #default="{ data }">
<view class="notice-card" @click="goToDetail(data.id)">
<view class="card-header">
<text class="notice-title">{{ data.title }}</text>
<text class="notice-status" :class="getStatusClass(data.status)">{{
data.statusText
}}</text>
</view>
<view class="card-body">
<!-- 可选显示封面缩略图 -->
<image
v-if="data.coverImage"
:src="data.coverImage"
mode="aspectFill"
class="cover-thumbnail"
></image>
<text class="notice-excerpt">{{ data.excerpt }}</text>
</view>
<view class="card-footer">
<text class="footer-item">发布者: {{ data.publisher }}</text>
<text class="footer-item">{{ data.publishTime }}</text>
<text class="footer-item" v-if="data.target"
>范围: {{ data.target }}</text
>
</view>
</view>
</template>
</BasicListLayout>
<!-- 新建通知按钮 -->
<view class="jl-list-page">
<!-- 新建接龙按钮 -->
<view class="fab-button" @click="goToPublish">
<uni-icons type="plusempty" size="24" color="#fff"></uni-icons>
</view>
<!-- 列表内容 -->
<view v-if="jlList.length > 0">
<view v-for="item in jlList" :key="item.id" class="jl-card" @click="goToDetail(item.id)">
<view class="card-header">
<text class="jl-title">{{ item.jlmc }}</text>
<text class="jl-status" :class="getStatusClass(item.jlStatus)">
{{ getStatusText(item.jlStatus) }}
</text>
</view>
<view class="card-body">
<image v-if="item.jlfm" :src="item.jlfm" mode="aspectFill" class="cover-thumbnail"></image>
<text class="jl-excerpt" v-html="item.jlms"></text>
</view>
<view class="card-footer">
<text class="footer-item">发布者: {{ item.jsxm }}</text>
<text class="footer-item">{{ formatTime(item.jlFbtime) }}</text>
<text class="footer-item" v-if="item.bjmc">范围: {{ item.njmc+item.bjmc }}</text>
</view>
</view>
</view>
<view v-else class="empty-list">暂无数据</view>
</view>
</template>
<script lang="ts" setup>
import { ref } from "vue";
import { useLayout } from "@/components/BasicListLayout/hooks/useLayout";
import {ref, onMounted} from "vue";
import {BASE_URL} from "@/config";
interface NoticeItem {
interface JlItem {
id: string;
title: string;
excerpt: string; //
status: "published" | "draft" | "ended"; //
statusText: string; //
publisher: string;
publishTime: string;
coverImage?: string; // URL ()
target?: string; // ()
jlmc: string; //
jlms: string; //
jlStatus: string; // AB
jlFbr: string; //
jlFbtime: string; //
jlfm: string; //
njmc: string;
bjmc: string; //
jlkstime: string; //
jljstime: string; //
jsxm?: string;
}
// API
const fetchNoticeList = async (params: any): Promise<any> => {
// Promise<any>
console.log("Fetching notice list with params:", params);
return new Promise((resolve) => {
setTimeout(() => {
// params.pageNo params.pageSize
const pageNo = params.pageNo || 1;
const pageSize = params.pageSize || 10;
const total = 35; //
const mockData: NoticeItem[] = [];
const startIndex = (pageNo - 1) * pageSize;
const jlList = ref<JlItem[]>([]);
const total = ref(0);
for (let i = 0; i < pageSize; i++) {
const currentIndex = startIndex + i;
if (currentIndex >= total) break; //
const status =
currentIndex % 3 === 0
? "draft"
: currentIndex % 3 === 1
? "published"
: "ended";
mockData.push({
id: `notice_${currentIndex + 1}`,
title: `重要通知标题 ${currentIndex + 1}`,
excerpt: `这是通知 ${currentIndex + 1} 的内容摘要,只显示一部分...`,
status: status,
statusText:
status === "draft"
? "草稿"
: status === "published"
? "已发布"
: "已结束",
publisher: "教务处",
publishTime: `2024-06-${String(
18 - Math.floor(currentIndex / 5)
).padStart(2, "0")}`,
target: currentIndex % 2 === 0 ? "一年级3班" : "全体教师",
// coverImage: i % 3 === 0 ? '/static/mock/cover.png' : undefined
});
const fetchJlList = async () => {
try {
const response = await uni.request({
url: `${BASE_URL}/mobile/jl/list`,
method: "GET",
data: {pageNo: 1, pageSize: 10},
header: {"Content-Type": "application/json"}
});
if (response.statusCode === 200 && response.data) {
const result = response.data;
const pageData = result.data || result;
if (pageData.result && Array.isArray(pageData.result.rows)) {
jlList.value = pageData.result.rows;
total.value = pageData.result.total || 0;
} else {
jlList.value = [];
total.value = 0;
}
resolve({
message: "获取成功",
resultCode: 1,
rows: mockData,
total: total,
});
}, 800); //
});
} else {
jlList.value = [];
total.value = 0;
}
} catch (e) {
jlList.value = [];
total.value = 0;
}
};
const [register, { reload }] = useLayout({
api: fetchNoticeList,
onMounted(() => {
fetchJlList();
});
//
const goToDetail = (noticeId: string) => {
const goToDetail = (jlId: string) => {
uni.navigateTo({
url: `/pages/view/notice/detail?id=${noticeId}`,
url: `/pages/view/notice/detail?id=${jlId}`,
});
};
@ -126,21 +99,34 @@ const goToPublish = () => {
};
// CSS
const getStatusClass = (status: "published" | "draft" | "ended") => {
if (status === "published") return "status-published";
if (status === "draft") return "status-draft";
if (status === "ended") return "status-ended";
return "";
const getStatusClass = (status: string) => {
if (status === "A") return "status-published";
if (status === "B") return "status-draft";
return "status-ended";
};
//
const getStatusText = (status: string) => {
if (status === "A") return "已发布";
if (status === "B") return "暂存";
return "已结束";
};
//
const formatTime = (timeStr: string) => {
if (!timeStr) return '';
const date = new Date(timeStr);
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
};
</script>
<style scoped lang="scss">
.notice-list-page {
.jl-list-page {
position: relative; // FAB
min-height: 100vh; // FAB
}
.notice-card {
.jl-card {
background-color: #ffffff;
border-radius: 8px;
padding: 15px;
@ -155,7 +141,7 @@ const getStatusClass = (status: "published" | "draft" | "ended") => {
align-items: flex-start;
margin-bottom: 8px;
.notice-title {
.jl-title {
font-size: 16px;
font-weight: bold;
color: #333;
@ -169,7 +155,7 @@ const getStatusClass = (status: "published" | "draft" | "ended") => {
-webkit-box-orient: vertical;
}
.notice-status {
.jl-status {
font-size: 12px;
padding: 2px 6px;
border-radius: 4px;
@ -180,9 +166,11 @@ const getStatusClass = (status: "published" | "draft" | "ended") => {
&.status-published {
background-color: #19be6b; // 绿-
}
&.status-draft {
background-color: #ff9f0a; // -稿
background-color: #ff9f0a; // -
}
&.status-ended {
background-color: #999999; // -
}
@ -198,7 +186,8 @@ const getStatusClass = (status: "published" | "draft" | "ended") => {
margin-right: 10px;
float: left; //
}
.notice-excerpt {
.jl-excerpt {
font-size: 14px;
color: #666;
line-height: 1.5;
@ -209,12 +198,6 @@ const getStatusClass = (status: "published" | "draft" | "ended") => {
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
}
// float
// &::after {
// content: "";
// display: table;
// clear: both;
// }
}
.card-footer {
@ -247,4 +230,10 @@ const getStatusClass = (status: "published" | "draft" | "ended") => {
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
z-index: 10;
}
.empty-list {
text-align: center;
color: #999;
margin-top: 40px;
}
</style>