文件
fenleixinxi/uniapp/components/fc-post-card/fc-post-card.vue
MiAn d508949921 feat: 规范化页面导航与交互体验,优化多端适配
- 统一定制顶部导航组件,支持沉浸式渐变主题与返回逻辑
- 适配 H5 环境的页面跳转逻辑,避免 reLaunch 导致的闪屏问题
- 重构会员、充值、发布等页面布局,改用 Grid 提升移动端适配
- 优化搜索、收藏、消息等页面交互细节,增加点击反馈
- 统一配置页面导航样式,替换原生导航为自定义组件
2026-10-20 13:56:05 +08:00

214 行
5.4 KiB
Vue

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<template>
<view class="fc-post-card" @click="$emit('click', post)">
<view class="fc-post-card__thumb" :class="{ 'fc-post-card__thumb--icon': !thumbUrl }">
<image v-if="thumbUrl" class="fc-post-card__thumb-img" :src="thumbUrl" mode="aspectFill" />
<image v-else class="fc-post-card__thumb-icon" :src="categoryIconUrl(post.categoryId)" mode="aspectFit" />
</view>
<view class="fc-post-card__body">
<view class="fc-post-card__title fc-ellipsis-2">{{ post.title }}</view>
<view v-if="post.isTop || (post.tags && post.tags.length)" class="fc-post-card__tags">
<text v-if="post.isTop" class="fc-tag fc-post-card__tag fc-post-card__tag--top">置顶</text>
<text v-for="t in (post.tags || []).slice(0, 2)" :key="t" class="fc-tag fc-post-card__tag">{{ t }}</text>
</view>
<view class="fc-post-card__meta">
<text class="fc-post-card__area">{{ post.area || '同城' }}</text>
<text v-if="distanceText" class="fc-post-card__dot">·</text>
<text v-if="distanceText" class="fc-post-card__distance">{{ distanceText }}</text>
<text class="fc-post-card__dot">·</text>
<text class="fc-post-card__time">{{ timeText }}</text>
</view>
<view class="fc-post-card__bottom">
<view class="fc-price fc-price--card">
<template v-if="post.price > 0">
<text class="fc-price__symbol">¥</text>
<text class="fc-post-card__amount">{{ post.price }}</text>
<text class="fc-post-card__unit">{{ post.priceUnit || '元' }}</text>
</template>
<text v-else class="fc-post-card__neg">面议</text>
</view>
<view class="fc-post-card__stats">
<view class="fc-post-card__stat">
<image class="fc-icon fc-icon--xs" :src="iconUrl('eye')" mode="aspectFit" />
<text class="fc-post-card__stat-num">{{ post.views || 0 }}</text>
</view>
<view class="fc-post-card__stat">
<image class="fc-icon fc-icon--xs" :src="iconUrl('comment-gray')" mode="aspectFit" />
<text class="fc-post-card__stat-num">{{ post.commentCount || 0 }}</text>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import { iconUrl, categoryIconUrl } from '@/common/store/ui.js'
import { fromNow, formatKm, assetUrl } from '@/common/utils/format.js'
export default {
name: 'FcPostCard',
props: {
post: { type: Object, required: true },
},
computed: {
/** 相对发布时间描述 */
timeText() {
return fromNow(this.post.createdAt)
},
/** 距离文案(如「1.2km」);契约下发的 distance 为 km,信息无坐标时为 null 不展示 */
distanceText() {
return this.post.distance == null ? '' : formatKm(this.post.distance)
},
/**
* 帖子封面图:优先使用实际上传封面或第一张实拍图,无图时回退为空由图标兜底
*/
thumbUrl() {
if (this.post.cover) {
return assetUrl(this.post.cover)
}
if (this.post.media && Array.isArray(this.post.media) && this.post.media.length) {
const first = this.post.media[0]
if (typeof first === 'string' && !first.match(/\.(mp4|mov|avi)$/i)) {
return assetUrl(first)
}
}
return ''
},
},
methods: {
/** 暴露图标地址解析工具 */
iconUrl,
/** 暴露分类图标解析工具 */
categoryIconUrl,
},
}
</script>
<style lang="scss" scoped>
.fc-post-card {
display: flex;
padding: 24rpx;
margin: 0 24rpx 20rpx;
background: $fc-bg-card;
border-radius: $fc-radius-lg;
box-shadow: $fc-shadow-sm;
border: 1rpx solid rgba(4, 48, 30, 0.05);
cursor: pointer;
transition: all 0.2s ease;
&:hover {
box-shadow: $fc-shadow;
}
&:active {
transform: scale(0.985);
}
}
.fc-post-card__thumb {
width: 190rpx;
height: 190rpx;
flex: 0 0 190rpx;
margin-right: 22rpx;
border-radius: 16rpx;
overflow: hidden;
background: #f1f5f9;
display: flex;
align-items: center;
justify-content: center;
&--icon {
background: $fc-gradient-soft;
}
}
.fc-post-card__thumb-img {
width: 100%;
height: 100%;
}
.fc-post-card__thumb-icon {
width: 88rpx;
height: 88rpx;
opacity: 0.85;
}
.fc-post-card__body {
flex: 1;
display: flex;
flex-direction: column;
min-width: 0;
justify-content: space-between;
}
.fc-post-card__title {
font-size: 30rpx;
font-weight: 600;
color: $fc-text;
line-height: 1.4;
margin-bottom: 6rpx;
}
.fc-post-card__tags {
display: flex;
flex-wrap: wrap;
gap: 8rpx;
margin-bottom: 8rpx;
}
.fc-post-card__tag {
margin: 0;
font-size: 20rpx;
padding: 2rpx 10rpx;
}
.fc-post-card__tag--top {
background: $fc-gradient-primary;
color: $fc-primary-ink;
font-weight: 700;
}
.fc-post-card__meta {
display: flex;
align-items: center;
font-size: 22rpx;
color: $fc-text-placeholder;
margin-bottom: 8rpx;
}
.fc-post-card__dot {
margin: 0 8rpx;
}
.fc-post-card__distance {
color: $fc-primary-text;
font-weight: 600;
}
.fc-post-card__bottom {
display: flex;
align-items: flex-end;
justify-content: space-between;
padding-top: 4rpx;
}
.fc-price--card {
display: flex;
align-items: baseline;
}
.fc-post-card__amount {
font-size: 36rpx;
font-weight: 700;
line-height: 1;
}
.fc-post-card__neg {
font-size: 28rpx;
font-weight: 700;
color: $fc-price;
}
.fc-post-card__unit {
margin-left: 4rpx;
font-size: 22rpx;
color: $fc-text-secondary;
font-weight: 400;
}
.fc-post-card__stats {
display: flex;
align-items: center;
}
.fc-post-card__stat {
display: flex;
align-items: center;
margin-left: 16rpx;
}
.fc-post-card__stat-num {
margin-left: 6rpx;
font-size: 22rpx;
color: $fc-text-placeholder;
}
</style>