YingXingAI/pages/notes/index.vue

243 lines
6.0 KiB
Vue
Raw Normal View History

2025-07-04 16:04:01 +08:00
<template>
<div class="notes-page">
2025-07-09 16:43:03 +08:00
<PageHeader
title="留言板"
:is-back="false"
:border-bottom="false"
/>
<view class="custom-tabs-box">
<u-tabs
:list="tabList"
:current="tabCurrent"
@change="onTabChange"
:is-scroll="false"
:height="80"
:font-size="28"
active-color="#4A6CF7"
inactive-color="#333333"
:bar-width="120"
:bar-height="4"
bg-color="#ffffff"
:item-width="200"
></u-tabs>
<div class="space"></div>
</view>
2025-07-04 16:04:01 +08:00
<div class="content-wrapper">
<scroll-view class="message-list" scroll-y>
2025-07-09 16:43:03 +08:00
<view v-for="(item, index) in currentMessages" :key="index" class="message-wrapper">
<MessageItem
:item="item"
:itemIndex="index"
:defaultAvatar="defaultAvatar"
@delete="handleDelete"
@open-swipe="handleOpenSwipe"
@reply="handleReply"
@toggle-expand="toggleExpand"
/>
2025-07-04 16:04:01 +08:00
</view>
<view class="empty-tip" v-if="currentMessages.length === 0">
暂无留言数据
</view>
</scroll-view>
</div>
2025-07-09 16:43:03 +08:00
2025-07-04 16:04:01 +08:00
<TabBar :currentPath="'/pages/notes/index'" @change="handleTabChange" />
2025-07-09 16:43:03 +08:00
2025-07-04 16:04:01 +08:00
<u-modal
v-model="showDevModal"
:show-cancel-button="false"
title="提示"
content="该功能正在开发中,敬请期待!"
@confirm="showDevModal = false"
></u-modal>
</div>
</template>
<script>
2025-07-09 16:43:03 +08:00
import TabBar from "@/components/TabBar.vue";
import PageHeader from "@/components/PageHeader.vue";
import MessageItem from "@/components/MessageItem.vue";
2025-07-04 16:04:01 +08:00
export default {
2025-07-09 16:43:03 +08:00
name: "NotesPage",
2025-07-04 16:04:01 +08:00
components: {
2025-07-09 16:43:03 +08:00
TabBar,
PageHeader,
MessageItem
2025-07-04 16:04:01 +08:00
},
data() {
return {
2025-07-09 16:43:03 +08:00
tabList: [{ name: "未回复" }, { name: "已回复" }],
tabCurrent: 0,
2025-07-09 16:43:03 +08:00
activeTab: "unread",
2025-07-04 16:04:01 +08:00
showDevModal: false,
2025-07-09 16:43:03 +08:00
defaultAvatar: "/static/avatar/default-avatar.png",
2025-07-04 16:04:01 +08:00
unreadMessages: [
{
id: 1,
2025-07-09 16:43:03 +08:00
avatar: "",
username: "浙江理工生13024",
time: "2023/6/26 15:45:12",
question: "学校在录取时有没有一些专业会有特殊要求?",
reply: "",
2025-07-04 16:04:01 +08:00
expanded: false,
2025-07-09 16:43:03 +08:00
show: false,
2025-07-04 16:04:01 +08:00
},
{
id: 2,
2025-07-09 16:43:03 +08:00
avatar: "",
username: "理工13024",
time: "2023/6/26 15:45:12",
question: "在录取时有没有一些专业会有特殊要求?",
reply: "",
2025-07-04 16:04:01 +08:00
expanded: false,
2025-07-09 16:43:03 +08:00
show: false,
},
2025-07-04 16:04:01 +08:00
],
repliedMessages: [
{
id: 3,
2025-07-09 16:43:03 +08:00
avatar: "",
username: "浙江理工生13024",
time: "2023/6/26 15:45:12",
question: "学校在录取时有没有一些专业会有特殊要求?",
reply:
"学生与体健康状况必须符合教育部、卫生部、中国残疾人联合会印发的《普通高等学校招生体检工作指导意见》和人力资源社会保障部、原卫生部、原教育部、原公安部、原国家人口计划生育委员会制定的有关规定。原卫生部、原教育部、原公安部、原国家人口计划生育委员会制定的有关规定。",
replyUser: "系统回复",
2025-07-04 16:04:01 +08:00
expanded: false,
2025-07-09 16:43:03 +08:00
show: false,
},
2025-07-04 16:04:01 +08:00
]
};
},
computed: {
currentMessages() {
2025-07-09 16:43:03 +08:00
return this.activeTab === "unread"
? this.unreadMessages
: this.repliedMessages;
},
2025-07-04 16:04:01 +08:00
},
methods: {
onTabChange(index) {
this.tabCurrent = index;
// 根据索引设置activeTab值
2025-07-09 16:43:03 +08:00
this.activeTab = index === 0 ? "unread" : "replied";
// 切换选项卡时关闭所有打开的滑动按钮
this.closeAllSwipe();
},
2025-07-04 16:04:01 +08:00
switchTab(tab) {
this.activeTab = tab;
// 更新tabCurrent以匹配activeTab
2025-07-09 16:43:03 +08:00
this.tabCurrent = tab === "unread" ? 0 : 1;
2025-07-04 16:04:01 +08:00
// 切换选项卡时关闭所有打开的滑动按钮
this.closeAllSwipe();
},
handleTabChange(path, index) {
2025-07-09 16:43:03 +08:00
console.log("切换到标签页:", path, index);
2025-07-04 16:04:01 +08:00
},
handleReply(item) {
this.showDevModal = true;
},
toggleExpand(item) {
item.expanded = !item.expanded;
},
2025-07-09 16:43:03 +08:00
handleDelete(index) {
// 删除当前消息
if (this.activeTab === "unread") {
this.unreadMessages.splice(index, 1);
} else {
this.repliedMessages.splice(index, 1);
2025-07-04 16:04:01 +08:00
}
},
2025-07-09 16:43:03 +08:00
handleOpenSwipe(index) {
2025-07-04 16:04:01 +08:00
// 打开滑动按钮时,关闭其他打开的滑动按钮
this.closeOther(index);
},
closeOther(index) {
// 关闭除当前外的所有滑动按钮
2025-07-09 16:43:03 +08:00
if (this.activeTab === "unread") {
2025-07-04 16:04:01 +08:00
this.unreadMessages.forEach((item, idx) => {
if (idx !== index) {
item.show = false;
}
});
} else {
this.repliedMessages.forEach((item, idx) => {
if (idx !== index) {
item.show = false;
}
});
}
},
closeAllSwipe() {
// 关闭所有滑动按钮
2025-07-09 16:43:03 +08:00
this.unreadMessages.forEach((item) => {
2025-07-04 16:04:01 +08:00
item.show = false;
});
2025-07-09 16:43:03 +08:00
this.repliedMessages.forEach((item) => {
2025-07-04 16:04:01 +08:00
item.show = false;
});
}
2025-07-09 16:43:03 +08:00
},
};
2025-07-04 16:04:01 +08:00
</script>
<style scoped>
.notes-page {
height: 100vh;
background-color: #f5f6fa;
display: flex;
flex-direction: column;
position: relative;
}
.header {
background-color: #fff;
padding-top: 10px;
}
.title {
font-size: 18px;
font-weight: 500;
text-align: center;
padding: 10px 0;
}
.custom-tabs-box {
2025-07-09 16:43:03 +08:00
display: flex;
2025-07-04 16:04:01 +08:00
}
2025-07-09 16:43:03 +08:00
.space {
width: 100%;
height: 100%;
background: #fff;
2025-07-04 16:04:01 +08:00
}
.content-wrapper {
flex: 1;
display: flex;
flex-direction: column;
padding-bottom: 60px; /* 为底部导航栏预留空间 */
overflow-y: auto; /* 允许内容滚动 */
}
/* 留言列表样式 */
.message-list {
2025-07-09 16:43:03 +08:00
box-sizing: border-box;
padding: 26rpx;
2025-07-04 16:04:01 +08:00
flex: 1;
}
2025-07-09 16:43:03 +08:00
.message-wrapper {
2025-07-04 16:04:01 +08:00
margin-bottom: 10px;
}
.empty-tip {
text-align: center;
padding: 20px;
color: #999;
font-size: 14px;
}
2025-07-09 16:43:03 +08:00
</style>