留言板/留言板详情/消息中心/设置页面样式优化

This commit is contained in:
2025-12-27 17:22:45 +08:00
parent fb8a6cc27e
commit 7cd3dc373f
10 changed files with 461 additions and 24 deletions

209
pages/message/guestbook.vue Normal file
View File

@@ -0,0 +1,209 @@
<template>
<view class="page-view">
<!-- 顶部导航栏 -->
<customNavbar title="留言板" :is-transparent="navbarStyle.isTransparent" :bg-color="navbarStyle.bgColor"
:text-color="navbarStyle.textColor" :opacity="navbarStyle.opacity" :extra-icons="navbarStyle.extraIcons"
:show-home="false" />
<!-- 留言列表 -->
<scroll-view scroll-y="true" class="scroll-view">
<view class="message-item" v-for="(item, index) in messageList" :key="index" @click="navigateToDetail(item)">
<view class="message-header">
<text :class="['status-tag', item.status]">{{ item.statusText }}</text>
<text class="message-title">留言内容</text>
</view>
<view class="message-content">
<text class="content-text">{{ item.content }}</text>
</view>
<view class="message-footer">
<text class="message-time">留言时间{{ item.time }}</text>
</view>
</view>
</scroll-view>
<!-- 底部新增留言按钮 -->
<view class="add-btn-container">
<button class="add-btn" @click="addMessage">新增留言</button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
messageList: [{
id: 1,
status: 'processed',
statusText: '已处理',
content: '留言内容摘要留言内容摘要留言内容摘要留言内容摘要留言内容摘要留言内容摘要',
time: '2024-02-02'
},
{
id: 2,
status: 'processing',
statusText: '处理中',
content: '留言内容摘要留言内容摘要留言内容摘要留言内容摘要留言内容摘要留言内容摘要',
time: '2024-02-02'
},
{
id: 3,
status: 'pending',
statusText: '待处理',
content: '留言内容摘要留言内容摘要留言内容摘要留言内容摘要留言内容摘要留言内容摘要',
time: '2024-02-02'
}
],
// 导航栏样式控制
navbarStyle: {
isTransparent: true,
bgColor: '#ffffff',
textColor: '#000000',
opacity: 0,
extraIcons: ['ellipsis', 'eye'] // 右侧额外图标
},
// 滚动距离
scrollTop: 0
}
},
onPageScroll(e) {
this.scrollTop = e.scrollTop;
// 计算导航栏透明度和样式
this.updateNavbarStyle(e.scrollTop);
},
methods: {
// 点击留言项跳转到详情页
navigateToDetail(item) {
uni.navigateTo({
url: `/pages/detail/guestbookDetail?id=${item.id}`,
});
},
addMessage() {
// 新增留言逻辑
uni.showToast({
title: '新增留言',
icon: 'none'
});
},
// 根据滚动距离更新导航栏样式
updateNavbarStyle(scrollTop) {
// 定义滚动阈值,超过此值导航栏变为不透明
const threshold = 200;
// 计算透明度
let opacity = scrollTop / threshold;
opacity = Math.min(opacity, 1);
opacity = Math.max(opacity, 0);
// 更新导航栏样式
this.navbarStyle.opacity = opacity;
if (opacity > 0.5) {
this.navbarStyle.isTransparent = false;
} else {
this.navbarStyle.isTransparent = true;
}
},
}
}
</script>
<style scoped>
.page-view {
/* 给导航栏留空间 */
padding-top: 120rpx;
min-height: 100vh;
position: relative;
background: linear-gradient(0deg, #F3F1ED 43%, #F5E9DB 100%);
}
.scroll-view {
height: calc(100vh - 120rpx - 120rpx);
padding: 20rpx 0;
}
.message-item {
background-color: #ffffff;
border-radius: 10rpx;
padding: 32rpx;
padding-left: 95rpx;
width: 92%;
margin: auto;
margin-bottom: 20rpx;
}
.message-header {
display: flex;
align-items: center;
margin-bottom: 20rpx;
}
.status-tag {
font-size: 24rpx;
padding: 6rpx 16rpx;
border-radius: 21rpx;
margin-right: 20rpx;
color: #ffffff;
position: absolute;
left: 10rpx;
}
.status-tag.processed {
background: linear-gradient(90deg, #F34038 0%, #FF7C76 100%);
box-shadow: 0rpx 0rpx 7rpx 0rpx #FB392A;
}
.status-tag.processing {
background: linear-gradient(90deg, #FEAF04 0%, #FFC145 100%);
box-shadow: 0rpx 0rpx 7rpx 0rpx #FFBF41;
}
.status-tag.pending {
background: linear-gradient(90deg, #6688FC 0%, #809BFB 100%);
box-shadow: 0rpx 0rpx 7rpx 0rpx #7E99FB;
}
.message-title {
font-size: 30rpx;
font-weight: 500;
color: #2D2B2C;
}
.message-content {
margin-bottom: 20rpx;
}
.content-text {
font-size: 24rpx;
color: #86868C;
line-height: 44rpx;
}
.message-time {
font-size: 24rpx;
color: #ADADB1;
}
.add-btn-container {
position: fixed;
bottom: 0;
left: 0;
right: 0;
padding: 30rpx 40rpx;
background-color: #f5f5f5;
box-shadow: 0 -2rpx 12rpx rgba(0, 0, 0, 0.05);
}
.add-btn {
width: 100%;
height: 80rpx;
background: linear-gradient(90deg, #FF6F63 0%, #FB392A 100%);
border-radius: 10rpx;
color: #ffffff;
font-size: 32rpx;
border: none;
display: flex;
align-items: center;
justify-content: center;
}
</style>