<template>
|
|
<view class="community-page">
|
|
<!-- 顶部图片 -->
|
|
<view class="banner-section">
|
|
<image class="banner-image" src="/static/bannerImage.png" mode="aspectFill"></image>
|
|
</view>
|
|
|
|
<!-- Tab切换区域 -->
|
|
<view class="tab-section">
|
|
<view class="tab-container">
|
|
<view
|
|
class="tab-item"
|
|
:class="{ active: currentTab === 'current' }"
|
|
@click="switchTab('current')"
|
|
>
|
|
<text class="tab-text">木邻说</text>
|
|
<view class="tab-line" v-if="currentTab === 'current'"></view>
|
|
</view>
|
|
<view
|
|
class="tab-item"
|
|
:class="{ active: currentTab === 'past' }"
|
|
@click="switchTab('past')"
|
|
>
|
|
<text class="tab-text">木邻见</text>
|
|
<view class="tab-line" v-if="currentTab === 'past'"></view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 动态列表 -->
|
|
<view class="post-list">
|
|
<view
|
|
class="post-item"
|
|
v-for="(item, index) in filteredPosts"
|
|
:key="index"
|
|
@click="goToPostDetail(item)"
|
|
>
|
|
<!-- 用户信息 -->
|
|
<view class="user-info">
|
|
<image class="user-avatar" :src="item.avatar" mode="aspectFill"></image>
|
|
<view class="user-details">
|
|
<text class="username">{{ item.username }}</text>
|
|
<text class="post-time">发布时间:{{ item.time }}</text>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 动态内容 -->
|
|
<view class="post-content">
|
|
<text class="post-text">{{ item.content }}</text>
|
|
|
|
<!-- 图片列表 -->
|
|
<view class="image-grid" v-if="item.images && item.images.length > 0">
|
|
<image
|
|
class="post-image"
|
|
v-for="(img, imgIndex) in item.images"
|
|
:key="imgIndex"
|
|
:src="img"
|
|
mode="aspectFill"
|
|
@click.stop="previewImage(img, item.images)"
|
|
></image>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 随手拍/我要留言按钮 -->
|
|
<view class="action-btn" :class="currentTab === 'current' ? 'current-btn' : 'photo'" @click="openAction">
|
|
<uv-icon name="edit-pen-fill" size="20" color="white"></uv-icon>
|
|
<text class="action-text">{{ actionButtonText }}</text>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name: 'CommunityPage',
|
|
data() {
|
|
return {
|
|
currentTab: 'current', // current: 木邻说, past: 木邻见
|
|
postList: [
|
|
{
|
|
id: 1,
|
|
username: '猫小姐',
|
|
avatar: '/static/默认头像.png',
|
|
time: '2023-12-10 14:15:26',
|
|
content: '建议社区草地修剪一下,杂草太多了!',
|
|
images: ['/static/bannerImage.png', '/static/bannerImage.png', '/static/bannerImage.png'],
|
|
type: 'current'
|
|
},
|
|
{
|
|
id: 2,
|
|
username: '猫小姐',
|
|
avatar: '/static/默认头像.png',
|
|
time: '2023-12-10 14:15:26',
|
|
content: '建议社区草地修剪一下,杂草太多了!',
|
|
images: ['/static/bannerImage.png', '/static/bannerImage.png', '/static/bannerImage.png'],
|
|
type: 'current'
|
|
},
|
|
{
|
|
id: 3,
|
|
username: '邻居小王',
|
|
avatar: '/static/默认头像.png',
|
|
time: '2023-12-09 16:30:15',
|
|
content: '今天在小区里捡到一只小猫,有人丢失了吗?',
|
|
images: ['/static/bannerImage.png'],
|
|
type: 'past'
|
|
},
|
|
{
|
|
id: 4,
|
|
username: '李阿姨',
|
|
avatar: '/static/默认头像.png',
|
|
time: '2023-12-08 09:20:30',
|
|
content: '分享一下我种的花,希望大家喜欢!',
|
|
images: ['/static/bannerImage.png', '/static/bannerImage.png'],
|
|
type: 'past'
|
|
}
|
|
]
|
|
}
|
|
},
|
|
computed: {
|
|
filteredPosts() {
|
|
return this.postList.filter(post => post.type === this.currentTab)
|
|
},
|
|
actionButtonText() {
|
|
return this.currentTab === 'current' ? '我要留言' : '随手拍'
|
|
}
|
|
},
|
|
methods: {
|
|
switchTab(tab) {
|
|
this.currentTab = tab
|
|
},
|
|
goToPostDetail(post) {
|
|
// 跳转到动态详情页面
|
|
uni.navigateTo({
|
|
url: `/subPages/community/postDetail?id=${post.id}`
|
|
})
|
|
},
|
|
previewImage(current, urls) {
|
|
uni.previewImage({
|
|
current: current,
|
|
urls: urls
|
|
})
|
|
},
|
|
openAction() {
|
|
if (this.currentTab === 'current') {
|
|
// 我要留言功能
|
|
this.goToComment()
|
|
} else {
|
|
// 随手拍功能
|
|
// this.goToComment()
|
|
this.takePhoto()
|
|
}
|
|
},
|
|
takePhoto() {
|
|
// uni.chooseMedia({
|
|
// count: 9,
|
|
// mediaType: ['image'],
|
|
// sourceType: ['album', 'camera'],
|
|
// success: (res) => {
|
|
// // 处理拍照结果
|
|
// uni.navigateTo({
|
|
// url: '/subPages/community/publishPost'
|
|
// })
|
|
// }
|
|
// })
|
|
|
|
uni.navigateTo({
|
|
url: '/subPages/community/publishPost?page=photo'
|
|
})
|
|
},
|
|
goToComment() {
|
|
uni.navigateTo({
|
|
url: '/subPages/community/publishPost'
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.community-page {
|
|
min-height: 100vh;
|
|
background-color: #f8f9fa;
|
|
position: relative;
|
|
padding-bottom: 120rpx;
|
|
}
|
|
|
|
// 横幅样式
|
|
.banner-section {
|
|
height: 400rpx;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.banner-image {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
|
|
// Tab切换区域
|
|
.tab-section {
|
|
background: white;
|
|
padding: 0 40rpx;
|
|
border-bottom: 1rpx solid #f0f0f0;
|
|
box-shadow: 0px 1.5px 3px 0px rgba(0,0,0,0.16);
|
|
}
|
|
|
|
.tab-container {
|
|
display: flex;
|
|
// gap: 60rpx;
|
|
justify-content: space-evenly;
|
|
|
|
}
|
|
|
|
.tab-item {
|
|
position: relative;
|
|
padding: 30rpx 0;
|
|
|
|
.tab-text {
|
|
font-size: 32rpx;
|
|
color: #666;
|
|
font-weight: 500;
|
|
transition: color 0.3s ease;
|
|
}
|
|
|
|
&.active {
|
|
.tab-text {
|
|
color: #007AFF;
|
|
font-weight: bold;
|
|
}
|
|
}
|
|
}
|
|
|
|
.tab-line {
|
|
position: absolute;
|
|
bottom: 0;
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
width: 40rpx;
|
|
height: 6rpx;
|
|
background: #007AFF;
|
|
border-radius: 3rpx;
|
|
animation: slideIn 0.3s ease;
|
|
}
|
|
|
|
@keyframes slideIn {
|
|
from {
|
|
width: 0;
|
|
}
|
|
to {
|
|
width: 40rpx;
|
|
}
|
|
}
|
|
|
|
// 动态列表样式
|
|
.post-list {
|
|
// padding: 20rpx;
|
|
}
|
|
|
|
.post-item {
|
|
background-color: white;
|
|
border-radius: 16rpx;
|
|
// margin-bottom: 24rpx;
|
|
padding: 32rpx;
|
|
box-shadow: 0 2rpx 16rpx rgba(0, 0, 0, 0.06);
|
|
border: 1rpx solid #f5f5f5;
|
|
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
|
|
|
&:active {
|
|
transform: scale(0.98);
|
|
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
|
|
}
|
|
}
|
|
|
|
.user-info {
|
|
display: flex;
|
|
align-items: center;
|
|
margin-bottom: 24rpx;
|
|
}
|
|
|
|
.user-avatar {
|
|
width: 88rpx;
|
|
height: 88rpx;
|
|
border-radius: 50%;
|
|
margin-right: 24rpx;
|
|
border: 2rpx solid #f0f0f0;
|
|
}
|
|
|
|
.user-details {
|
|
flex: 1;
|
|
}
|
|
|
|
.username {
|
|
font-size: 30rpx;
|
|
font-weight: bold;
|
|
color: #333;
|
|
display: block;
|
|
margin-bottom: 8rpx;
|
|
}
|
|
|
|
.post-time {
|
|
font-size: 24rpx;
|
|
color: #999;
|
|
}
|
|
|
|
.post-content {
|
|
.post-text {
|
|
font-size: 30rpx;
|
|
color: #333;
|
|
line-height: 1.6;
|
|
display: block;
|
|
margin-bottom: 24rpx;
|
|
}
|
|
}
|
|
|
|
.image-grid {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 12rpx;
|
|
}
|
|
|
|
.post-image {
|
|
width: 200rpx;
|
|
height: 200rpx;
|
|
border-radius: 12rpx;
|
|
border: 1rpx solid #f0f0f0;
|
|
}
|
|
|
|
// 随手拍/我要留言按钮样式
|
|
.action-btn {
|
|
position: fixed;
|
|
bottom: 120rpx;
|
|
right: 30rpx;
|
|
width: 120rpx;
|
|
height: 120rpx;
|
|
background: linear-gradient(135deg, #007AFF 0%, #0056CC 100%);
|
|
border-radius: 50%;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
box-shadow: 0 8rpx 24rpx rgba(0, 122, 255, 0.4);
|
|
z-index: 100;
|
|
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
|
|
|
&:active {
|
|
transform: scale(0.95);
|
|
box-shadow: 0 4rpx 16rpx rgba(0, 122, 255, 0.6);
|
|
}
|
|
|
|
&.photo {
|
|
background: linear-gradient(135deg, #FF6666 0%, #CC3333 100%);
|
|
}
|
|
}
|
|
|
|
.action-text {
|
|
font-size: 20rpx;
|
|
color: white;
|
|
margin-top: 8rpx;
|
|
font-weight: bold;
|
|
}
|
|
</style>
|