2025-04-22 10:22:33 +08:00
|
|
|
|
<!-- src/pages/view/notice/index.vue -->
|
|
|
|
|
|
<template>
|
2025-07-02 09:11:31 +08:00
|
|
|
|
<view class="jl-list-page">
|
|
|
|
|
|
<!-- 列表内容 -->
|
2025-07-08 22:09:38 +08:00
|
|
|
|
<BasicListLayout @register="register" v-model="dataList">
|
2025-07-02 22:43:30 +08:00
|
|
|
|
<template v-slot="{ data }">
|
2025-07-08 22:09:38 +08:00
|
|
|
|
<view class="jl-card">
|
2025-07-02 22:43:30 +08:00
|
|
|
|
<view class="card-header">
|
|
|
|
|
|
<text class="jl-title">{{ data.jlmc }}</text>
|
|
|
|
|
|
<text class="jl-status" :class="getStatusClass(data.jlStatus)">
|
|
|
|
|
|
{{ getStatusText(data.jlStatus) }}
|
|
|
|
|
|
</text>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="card-body">
|
|
|
|
|
|
<image
|
|
|
|
|
|
v-if="data.jlfm"
|
|
|
|
|
|
:src="imagUrl(data.jlfm)"
|
|
|
|
|
|
mode="aspectFill"
|
|
|
|
|
|
class="cover-thumbnail"
|
|
|
|
|
|
></image>
|
|
|
|
|
|
<rich-text class="jl-excerpt" :nodes="data.jlms"></rich-text>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="card-footer">
|
2025-07-08 22:09:38 +08:00
|
|
|
|
<text class="footer-item">发布者: {{ data.jsxm || '未知' }}</text>
|
2025-07-02 22:43:30 +08:00
|
|
|
|
<text class="footer-item">{{ formatTime(data.jlFbtime) }}</text>
|
|
|
|
|
|
<text class="footer-item" v-if="data.bjmc"
|
|
|
|
|
|
>范围: {{ data.njmc + data.bjmc }}</text
|
|
|
|
|
|
>
|
2025-07-08 22:09:38 +08:00
|
|
|
|
<view class="footer-actions">
|
|
|
|
|
|
<u-button
|
|
|
|
|
|
class="footer-btn"
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
size="mini"
|
|
|
|
|
|
@click="goToFeedback(data.id)"
|
|
|
|
|
|
>接龙情况</u-button>
|
|
|
|
|
|
<u-button
|
|
|
|
|
|
v-if="data.jlStatus === 'A'"
|
|
|
|
|
|
class="footer-btn"
|
|
|
|
|
|
type="warning"
|
|
|
|
|
|
size="mini"
|
|
|
|
|
|
@click="goToPush(data.id)"
|
|
|
|
|
|
>消息推送</u-button>
|
|
|
|
|
|
</view>
|
2025-07-02 22:43:30 +08:00
|
|
|
|
</view>
|
2025-07-02 09:11:31 +08:00
|
|
|
|
</view>
|
2025-07-02 22:43:30 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
<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="goToPublish"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</view>
|
2025-07-02 09:11:31 +08:00
|
|
|
|
</view>
|
2025-07-02 22:43:30 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</BasicListLayout>
|
2025-07-08 22:09:38 +08:00
|
|
|
|
<!-- 用uniqueList渲染 -->
|
|
|
|
|
|
<template v-for="item in uniqueList" :key="item.id">
|
|
|
|
|
|
<!-- 这里可以加自定义渲染内容做二次验证 -->
|
|
|
|
|
|
</template>
|
2025-04-22 10:22:33 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2025-07-02 22:43:30 +08:00
|
|
|
|
import { useLayout } from "@/components/BasicListLayout/hooks/useLayout";
|
|
|
|
|
|
import { mobilejllistApi } from "@/api/base/server";
|
|
|
|
|
|
import { imagUrl } from "@/utils";
|
2025-07-08 22:09:38 +08:00
|
|
|
|
import { computed, watch } from "vue";
|
|
|
|
|
|
import { onShow } from "@dcloudio/uni-app";
|
2025-04-22 10:22:33 +08:00
|
|
|
|
|
2025-07-02 09:11:31 +08:00
|
|
|
|
interface JlItem {
|
2025-04-22 10:22:33 +08:00
|
|
|
|
id: string;
|
2025-07-02 09:11:31 +08:00
|
|
|
|
jlmc: string; // 接龙名称
|
|
|
|
|
|
jlms: string; // 接龙描述
|
2025-07-08 22:09:38 +08:00
|
|
|
|
jlStatus: string; // 发布状态:A待推送,B暂存,C已推送
|
2025-07-02 09:11:31 +08:00
|
|
|
|
jlFbr: string; // 发布人
|
|
|
|
|
|
jlFbtime: string; // 发布时间
|
|
|
|
|
|
jlfm: string; // 接龙封面
|
|
|
|
|
|
njmc: string;
|
|
|
|
|
|
bjmc: string; // 班级名称
|
|
|
|
|
|
jlkstime: string; // 接龙开始时间
|
|
|
|
|
|
jljstime: string; // 接龙结束时间
|
|
|
|
|
|
jsxm?: string;
|
2025-04-22 10:22:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-02 22:43:30 +08:00
|
|
|
|
// 使用 BasicListLayout
|
|
|
|
|
|
const [register, { reload }] = useLayout({
|
|
|
|
|
|
api: mobilejllistApi, // 必须提供 api,即使使用了 query
|
|
|
|
|
|
componentProps: {},
|
2025-04-22 10:22:33 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2025-07-08 22:09:38 +08:00
|
|
|
|
// 兜底去重逻辑
|
|
|
|
|
|
const dataList = ref<JlItem[]>([]);
|
|
|
|
|
|
const uniqueList = computed(() => {
|
|
|
|
|
|
const map = new Map();
|
|
|
|
|
|
(dataList.value || []).forEach(item => {
|
|
|
|
|
|
if (item && item.id != null) map.set(String(item.id), item);
|
|
|
|
|
|
});
|
|
|
|
|
|
return Array.from(map.values());
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 日志:每次dataList变化时打印
|
|
|
|
|
|
watch(dataList, (val) => {
|
|
|
|
|
|
// 监听数据变化
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2025-04-22 10:22:33 +08:00
|
|
|
|
// 跳转到详情页
|
2025-07-02 09:11:31 +08:00
|
|
|
|
const goToDetail = (jlId: string) => {
|
2025-04-22 10:22:33 +08:00
|
|
|
|
uni.navigateTo({
|
2025-07-02 09:11:31 +08:00
|
|
|
|
url: `/pages/view/notice/detail?id=${jlId}`,
|
2025-04-22 10:22:33 +08:00
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 跳转到发布页
|
|
|
|
|
|
const goToPublish = () => {
|
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
|
url: "/pages/view/notice/publish",
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-07-08 22:09:38 +08:00
|
|
|
|
// 跳转到接龙反馈(detail)页
|
|
|
|
|
|
const goToFeedback = (jlId: string) => {
|
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
|
url: `/pages/view/notice/detail?id=${jlId}`,
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 跳转到消息推送页
|
|
|
|
|
|
const goToPush = (jlId: string) => {
|
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
|
url: `/pages/view/notice/push-list?jlId=${jlId}`,
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-04-22 10:22:33 +08:00
|
|
|
|
// 根据状态获取对应的 CSS 类
|
2025-07-02 09:11:31 +08:00
|
|
|
|
const getStatusClass = (status: string) => {
|
|
|
|
|
|
if (status === "A") return "status-published";
|
|
|
|
|
|
if (status === "B") return "status-draft";
|
|
|
|
|
|
return "status-ended";
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 根据状态获取状态文字
|
|
|
|
|
|
const getStatusText = (status: string) => {
|
2025-07-08 22:09:38 +08:00
|
|
|
|
if (status === "A") return "待推送";
|
2025-07-02 09:11:31 +08:00
|
|
|
|
if (status === "B") return "暂存";
|
2025-07-08 22:09:38 +08:00
|
|
|
|
return "已推送";
|
2025-07-02 09:11:31 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 格式化时间
|
|
|
|
|
|
const formatTime = (timeStr: string) => {
|
2025-07-02 22:43:30 +08:00
|
|
|
|
if (!timeStr) return "";
|
2025-07-02 09:11:31 +08:00
|
|
|
|
const date = new Date(timeStr);
|
2025-07-02 22:43:30 +08:00
|
|
|
|
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(
|
|
|
|
|
|
2,
|
|
|
|
|
|
"0"
|
|
|
|
|
|
)}-${String(date.getDate()).padStart(2, "0")}`;
|
2025-04-22 10:22:33 +08:00
|
|
|
|
};
|
2025-07-08 22:09:38 +08:00
|
|
|
|
|
|
|
|
|
|
onShow(() => {
|
|
|
|
|
|
reload();
|
|
|
|
|
|
});
|
2025-04-22 10:22:33 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
2025-07-02 09:11:31 +08:00
|
|
|
|
.jl-list-page {
|
2025-04-22 10:22:33 +08:00
|
|
|
|
position: relative; // 为了 FAB 定位
|
|
|
|
|
|
min-height: 100vh; // 确保 FAB 总在视图内
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-02 09:11:31 +08:00
|
|
|
|
.jl-card {
|
2025-04-22 10:22:33 +08:00
|
|
|
|
background-color: #ffffff;
|
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
|
padding: 15px;
|
|
|
|
|
|
margin-bottom: 12px;
|
|
|
|
|
|
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
|
|
|
|
|
|
border-left: 4px solid #447ade; // 左侧加个强调色条
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.card-header {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
align-items: flex-start;
|
|
|
|
|
|
margin-bottom: 8px;
|
|
|
|
|
|
|
2025-07-02 09:11:31 +08:00
|
|
|
|
.jl-title {
|
2025-04-22 10:22:33 +08:00
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
color: #333;
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
margin-right: 10px;
|
|
|
|
|
|
// 最多显示两行
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
display: -webkit-box;
|
|
|
|
|
|
-webkit-line-clamp: 2;
|
|
|
|
|
|
-webkit-box-orient: vertical;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-02 09:11:31 +08:00
|
|
|
|
.jl-status {
|
2025-04-22 10:22:33 +08:00
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
padding: 2px 6px;
|
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
color: #fff;
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
|
|
|
|
|
|
&.status-published {
|
2025-07-08 22:09:38 +08:00
|
|
|
|
background-color: #BE193FFF; // 红色-待推送
|
2025-04-22 10:22:33 +08:00
|
|
|
|
}
|
2025-07-02 09:11:31 +08:00
|
|
|
|
|
2025-04-22 10:22:33 +08:00
|
|
|
|
&.status-draft {
|
2025-07-02 09:11:31 +08:00
|
|
|
|
background-color: #ff9f0a; // 橙色-暂存
|
2025-04-22 10:22:33 +08:00
|
|
|
|
}
|
2025-07-02 09:11:31 +08:00
|
|
|
|
|
2025-04-22 10:22:33 +08:00
|
|
|
|
&.status-ended {
|
2025-07-08 22:09:38 +08:00
|
|
|
|
background-color: #19be4d; // 绿色-已推送
|
2025-04-22 10:22:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.card-body {
|
|
|
|
|
|
// 封面图样式 (如果启用)
|
|
|
|
|
|
.cover-thumbnail {
|
|
|
|
|
|
width: 80px;
|
|
|
|
|
|
height: 60px;
|
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
margin-right: 10px;
|
|
|
|
|
|
float: left; // 文字环绕图片
|
|
|
|
|
|
}
|
2025-07-02 09:11:31 +08:00
|
|
|
|
|
|
|
|
|
|
.jl-excerpt {
|
2025-04-22 10:22:33 +08:00
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
color: #666;
|
|
|
|
|
|
line-height: 1.5;
|
|
|
|
|
|
// 最多显示 3 行
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
display: -webkit-box;
|
|
|
|
|
|
-webkit-line-clamp: 3;
|
|
|
|
|
|
-webkit-box-orient: vertical;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.card-footer {
|
|
|
|
|
|
display: flex;
|
2025-07-08 22:09:38 +08:00
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
|
gap: 5px 15px;
|
2025-04-22 10:22:33 +08:00
|
|
|
|
.footer-item {
|
|
|
|
|
|
white-space: nowrap;
|
2025-07-08 22:09:38 +08:00
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
color: #666;
|
|
|
|
|
|
}
|
|
|
|
|
|
.footer-actions {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 4px;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
flex-basis: 100%; /* 独占一行 */
|
|
|
|
|
|
margin-top: 6px;
|
|
|
|
|
|
padding: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
.footer-btn {
|
|
|
|
|
|
min-width: 60px;
|
|
|
|
|
|
width: auto;
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
padding: 0 12px;
|
|
|
|
|
|
flex: none;
|
|
|
|
|
|
margin: 0;
|
2025-04-22 10:22:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-02 22:43:30 +08:00
|
|
|
|
// FAB 按钮样式 - 由 DragButton 组件处理定位
|
2025-04-22 10:22:33 +08:00
|
|
|
|
.fab-button {
|
|
|
|
|
|
width: 50px;
|
|
|
|
|
|
height: 50px;
|
|
|
|
|
|
background-color: #4477ee;
|
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
|
|
|
|
|
|
}
|
2025-07-02 09:11:31 +08:00
|
|
|
|
|
2025-07-02 22:43:30 +08:00
|
|
|
|
/* 空列表样式已由 BasicListLayout 组件处理,移除此样式 */
|
2025-04-22 10:22:33 +08:00
|
|
|
|
</style>
|