|
|
- <template>
- <view class="community-page">
- <!-- 顶部图片 -->
- <view class="banner-section">
- <!-- <image class="banner-image" :src="currentTab === 'current' ? '/static/社区_背景.png' : '/static/社区_背景2.png'" mode="aspectFit"></image> -->
- <uv-swiper :list="bannerList" indicator indicatorMode="line" height="375rpx" ></uv-swiper>
- </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 list"
- :key="index"
- >
- <!-- 用户信息 -->
- <view class="user-info">
- <image class="user-avatar" :src="item.member.headImage" mode="aspectFill"></image>
- <view class="user-details">
- <text class="username">{{ item.member.nickName }}</text>
- <text class="post-time">发布时间:{{ item.createTime }}</text>
- </view>
- </view>
-
- <!-- 动态内容 -->
- <view class="post-content">
- <text class="post-text">{{ item.content }}</text>
-
- <!-- 图片列表 -->
- <view class="image-grid" v-if="item.image && item.image.length > 0">
- <image
- class="post-image"
- v-for="(img, imgIndex) in item.image.split(',')"
- :key="imgIndex"
- :src="img"
- mode="aspectFill"
- ></image>
- </view>
- </view>
-
- <!-- 回复列表 -->
- <view class="comment-list" v-if="item.communityCommentList && item.communityCommentList.length > 0">
- <view class="comment-header">
- <text class="comment-title">回复 ({{ item.communityCommentList.length }})</text>
- </view>
- <view
- class="comment-item"
- v-for="(comment, commentIndex) in item.communityCommentList"
- :key="commentIndex"
- >
- <view class="comment-user-info">
- <text class="comment-username">{{ comment.createBy }}</text>
- <text class="comment-time">{{ comment.createTime }}</text>
- </view>
- <text class="comment-content">{{ comment.content }}</text>
- </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>
- import ListMixin from '@/mixins/list.js'
- export default {
- mixins: [ListMixin],
- name: 'CommunityPage',
- data() {
- return {
- currentTab: 'current', // current: 木邻说, past: 木邻见
- mixinListApi: 'community.queryPostList',
- bannerList: []
- }
- },
- computed: {
- actionButtonText() {
- return this.currentTab === 'current' ? '我要留言' : '随手拍'
- }
- },
- methods: {
- mixinSetParams(){
- return {
- type: this.currentTab === 'current' ? 0 : 1
- }
- },
- switchTab(tab) {
- this.currentTab = tab
- this.initPage()
- this.getList(true)
- this.getBannerList()
- },
-
- openAction() {
- if (this.currentTab === 'current') {
- // 我要留言功能
- this.goToComment()
- } else {
- this.takePhoto()
- }
- },
- takePhoto() {
-
-
- uni.navigateTo({
- url: '/subPages/community/publishPost?page=photo'
- })
- },
- goToComment() {
- uni.navigateTo({
- url: '/subPages/community/publishPost'
- })
- },
-
- // 获取帖子数据
- async getPostList() {
- const res = await this.$api.community.queryPostList({
- pageNo: this.pageNo,
- pageSize: this.pageSize,
- type: this.currentTab === 'current' ? 0 : 1
- })
- if (res.result.records.length) {
- this.postList.push(...res.result.records)
- this.pageNo++
- }else {
- uni.showToast({
- title: '暂无数据',
- icon: 'none'
- })
- }
- },
- // 获取顶部轮播图
- async getBannerList() {
- const res = await this.$api.home.queryBannerList({
- type: this.currentTab === 'current' ? 1 : 2
- })
- console.log('返回的结果', res);
-
- if (res.result.records.length) {
- this.bannerList = res.result.records.map(item => item.image)
- }
- }
- },
- onShow() {
- this.getBannerList()
- }
- }
- </script>
-
- <style lang="scss" scoped>
- .community-page {
- min-height: 100vh;
- background-color: #f8f9fa;
- position: relative;
- padding-bottom: 120rpx;
- }
-
- // 横幅样式
- .banner-section {
- height: 375rpx;
- 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;
- }
-
- // 回复列表样式
- .comment-list {
- margin-top: 24rpx;
- padding-top: 24rpx;
- border-top: 1rpx solid #f0f0f0;
- }
-
- .comment-header {
- margin-bottom: 20rpx;
- }
-
- .comment-title {
- font-size: 28rpx;
- color: #666;
- font-weight: 500;
- }
-
- .comment-item {
- background-color: #f8f9fa;
- border-radius: 12rpx;
- padding: 20rpx;
- margin-bottom: 16rpx;
-
- &:last-child {
- margin-bottom: 0;
- }
- }
-
- .comment-user-info {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 12rpx;
- }
-
- .comment-username {
- font-size: 26rpx;
- color: #007AFF;
- font-weight: 500;
- }
-
- .comment-time {
- font-size: 22rpx;
- color: #999;
- }
-
- .comment-content {
- font-size: 28rpx;
- color: #333;
- line-height: 1.5;
- display: block;
- }
-
- // 随手拍/我要留言按钮样式
- .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>
|