396 lines
8.8 KiB
Vue
Raw Normal View History

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">
2025-07-09 22:22:34 +08:00
<u-icon
name="list"
size="22"
color="#409EFF"
2025-07-08 22:09:38 +08:00
@click="goToFeedback(data.id)"
2025-07-09 22:22:34 +08:00
class="footer-action-icon"
/>
<u-icon
2025-07-08 22:09:38 +08:00
v-if="data.jlStatus === 'A'"
2025-07-09 22:22:34 +08:00
name="arrow-right"
size="22"
color="#FFA726"
2025-07-08 22:09:38 +08:00
@click="goToPush(data.id)"
2025-07-09 22:22:34 +08:00
class="footer-action-icon"
/>
2025-07-08 22:09:38 +08:00
</view>
2025-07-09 22:22:34 +08:00
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="flex-row items-center pb-10 pt-5">
<u-button
text="新增接龙"
class="mx-15"
type="primary"
@click="goToPublish"
/>
</view>
</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-07-09 22:22:34 +08:00
position: relative;
min-height: 100vh;
background-color: #f5f7fa;
padding: 12px;
box-sizing: border-box;
2025-04-22 10:22:33 +08:00
}
2025-07-02 09:11:31 +08:00
.jl-card {
2025-04-22 10:22:33 +08:00
background-color: #ffffff;
2025-07-09 22:22:34 +08:00
border-radius: 12px;
padding: 16px;
2025-04-22 10:22:33 +08:00
margin-bottom: 12px;
2025-07-09 22:22:34 +08:00
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
border: 1px solid #f0f0f0;
transition: all 0.3s ease;
position: relative;
overflow: hidden;
&:active {
transform: translateY(1px);
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12);
}
&::before {
content: '';
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 4px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border-radius: 2px;
}
2025-04-22 10:22:33 +08:00
}
.card-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
2025-07-09 22:22:34 +08:00
margin-bottom: 12px;
gap: 12px;
2025-04-22 10:22:33 +08:00
2025-07-02 09:11:31 +08:00
.jl-title {
2025-04-22 10:22:33 +08:00
font-size: 16px;
2025-07-09 22:22:34 +08:00
font-weight: 600;
color: #2c3e50;
2025-04-22 10:22:33 +08:00
flex: 1;
2025-07-09 22:22:34 +08:00
line-height: 1.4;
2025-04-22 10:22:33 +08:00
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
2025-07-09 22:22:34 +08:00
word-break: break-word;
2025-04-22 10:22:33 +08:00
}
2025-07-02 09:11:31 +08:00
.jl-status {
2025-07-09 22:22:34 +08:00
font-size: 11px;
padding: 4px 8px;
border-radius: 12px;
2025-04-22 10:22:33 +08:00
color: #fff;
white-space: nowrap;
flex-shrink: 0;
2025-07-09 22:22:34 +08:00
font-weight: 500;
letter-spacing: 0.5px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
2025-04-22 10:22:33 +08:00
&.status-published {
2025-07-09 22:22:34 +08:00
background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
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-09 22:22:34 +08:00
background: linear-gradient(135deg, #ffa726 0%, #ff9800 100%);
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-09 22:22:34 +08:00
background: linear-gradient(135deg, #66bb6a 0%, #4caf50 100%);
2025-04-22 10:22:33 +08:00
}
}
}
.card-body {
2025-07-09 22:22:34 +08:00
margin-bottom: 12px;
2025-04-22 10:22:33 +08:00
.cover-thumbnail {
width: 80px;
height: 60px;
2025-07-09 22:22:34 +08:00
border-radius: 8px;
margin-right: 12px;
float: left;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
object-fit: cover;
2025-04-22 10:22:33 +08:00
}
2025-07-02 09:11:31 +08:00
.jl-excerpt {
2025-04-22 10:22:33 +08:00
font-size: 14px;
2025-07-09 22:22:34 +08:00
color: #5a6c7d;
line-height: 1.6;
2025-04-22 10:22:33 +08:00
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
2025-07-09 22:22:34 +08:00
word-break: break-word;
2025-04-22 10:22:33 +08:00
}
}
.card-footer {
display: flex;
2025-07-08 22:09:38 +08:00
flex-wrap: wrap;
2025-07-09 22:22:34 +08:00
gap: 8px 16px;
align-items: center;
padding-top: 12px;
border-top: 1px solid #f0f0f0;
2025-04-22 10:22:33 +08:00
.footer-item {
white-space: nowrap;
2025-07-09 22:22:34 +08:00
font-size: 13px;
color: #7f8c8d;
overflow: hidden;
text-overflow: ellipsis;
max-width: 180px;
display: flex;
align-items: center;
&::before {
content: '';
width: 4px;
height: 4px;
background-color: #bdc3c7;
border-radius: 50%;
margin-right: 6px;
flex-shrink: 0;
}
2025-07-08 22:09:38 +08:00
}
2025-07-09 22:22:34 +08:00
2025-07-08 22:09:38 +08:00
.footer-actions {
display: flex;
justify-content: flex-end;
align-items: center;
2025-07-09 22:22:34 +08:00
gap: 18px;
2025-07-08 22:09:38 +08:00
width: 100%;
2025-07-09 22:22:34 +08:00
flex-basis: 100%;
margin-top: 8px;
2025-07-08 22:09:38 +08:00
padding: 0;
2025-07-09 22:22:34 +08:00
background: none;
border: none;
}
.footer-action-icon {
cursor: pointer;
transition: transform 0.1s;
background: none !important;
border: none !important;
padding: 0 !important;
margin: 0 !important;
}
.footer-action-icon:active {
transform: scale(0.92);
2025-07-08 22:09:38 +08:00
}
2025-07-09 22:22:34 +08:00
}
// 底部按钮区域优化
.white-bg-color {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border-radius: 16px;
margin: 16px 12px;
padding: 16px;
box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
.flex-row {
justify-content: center;
}
.u-button {
background: rgba(255, 255, 255, 0.9);
color: #667eea;
border: none;
font-weight: 600;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease;
&:active {
background: rgba(255, 255, 255, 1);
transform: translateY(1px);
}
}
}
// 响应式优化
@media (max-width: 375px) {
.jl-list-page {
padding: 8px;
}
.jl-card {
padding: 12px;
margin-bottom: 8px;
}
.card-header .jl-title {
font-size: 15px;
}
.card-footer .footer-item {
max-width: 150px;
2025-07-08 22:09:38 +08:00
font-size: 12px;
2025-04-22 10:22:33 +08:00
}
}
2025-07-09 22:22:34 +08:00
// 加载动画
.jl-card {
animation: fadeInUp 0.3s ease-out;
2025-04-22 10:22:33 +08:00
}
2025-07-02 09:11:31 +08:00
2025-07-09 22:22:34 +08:00
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
2025-04-22 10:22:33 +08:00
</style>