文件
fenleixinxi/uniapp/pages/post/mine.vue
linda 376a7ed793 feat(uniapp): 小程序端(用户端 uni-app)源码入库到 uniapp/ 目录
需求:小程序端代码要同时同步到服务器与 git 远程仓库,此前前端仅存在于本地目录(无 remote,从未推送),
服务器与 gitcode 上只有后端。现并入本仓库,复用现有「push 即部署」链路,一次推送双端落地。

- 新增 uniapp/:小程序端源码全量快照(150 文件 / 1.2M)
  pages(13 页面) · components(fc-navbar/fc-tabbar/fc-post-card/fc-empty) ·
  common(api·utils·mock·assets·store·config) · static(74 图标 + 3 轮播插画 + LOGO) ·
  docs(01-04 交付文档) · tests(零依赖全链路用例) · tools(图标/主题/轮播配图生成脚本)
- 明确排除:AGENTS.md(含后台密码、服务器 root 密码、小程序 AppSecret,切勿入库)、
  unpackage/(构建产物,由 uniapp/.gitignore 忽略)、node_modules、.DS_Store、*.log
- .gitignore 新增 /uniapp/AGENTS.md 兜底(与根 /AGENTS.md、/fluniapp/ 同一约定)
- README.md 增补「本项目结构 + 部署链路」章节,说明 uniapp/ 为源码快照、
  小程序真正上线仍需微信开发者工具 cli upload

说明:本次为源码快照,未携带前端本地仓库历史——其历史提交中含 AGENTS.md 凭据,
若做 subtree 合并会把密码永久写入本仓库历史,故采用快照方式。
2026-10-17 14:19:03 +08:00

331 行
8.2 KiB
Vue

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

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

<template>
<view class="mine-post fc-page">
<!-- 状态筛选 + 计数(后台审核/下架后状态一目了然) -->
<scroll-view class="mine-post__tabs" scroll-x :show-scrollbar="false">
<view class="mine-post__tabs-inner">
<view v-for="t in tabs" :key="t.value" class="mine-post__tab"
:class="{ 'mine-post__tab--active': status === t.value }" @click="changeStatus(t.value)">
<text>{{ t.label }}</text>
<text class="mine-post__tab-num">{{ counts[t.value] || 0 }}</text>
</view>
</view>
</scroll-view>
<view v-if="loading && !list.length" class="mine-post__loading">
<view v-for="i in 3" :key="i" class="fc-skeleton mine-post__skeleton"></view>
</view>
<fc-empty v-else-if="!list.length" text="还没有发布信息" btn-text="去发布" @action="goCreate" />
<view v-else class="mine-post__list">
<view v-for="p in list" :key="p.id" class="fc-card mine-post__item" @click="goDetail(p)">
<view class="mine-post__head">
<text class="mine-post__title fc-ellipsis-2">{{ p.title }}</text>
<text class="mine-post__status" :class="statusClass(p)">{{ statusText(p) }}</text>
</view>
<view class="mine-post__meta">
<text v-if="p.isTop" class="mine-post__badge">置顶</text>
<text class="mine-post__meta-text">{{ p.categoryName || '未分类' }}</text>
<text class="mine-post__dot">·</text>
<text class="mine-post__meta-text">{{ p.area || '未选区域' }}</text>
<text class="mine-post__dot">·</text>
<text class="mine-post__meta-text">{{ timeText(p.createdAt) }}</text>
</view>
<view v-if="p.status === 0" class="mine-post__reason">该信息已被后台下架</view>
<view v-else-if="p.auditStatus === 2" class="mine-post__reason">
驳回原因:{{ p.auditReason || '未填写' }}
</view>
<view class="mine-post__foot">
<view class="mine-post__stats">
<text>{{ p.views }} 浏览</text>
<text class="mine-post__dot">·</text>
<text>{{ p.commentCount || 0 }} 评价</text>
<text v-if="p.isPaid" class="mine-post__dot">·</text>
<text v-if="p.isPaid" class="mine-post__paid">已付费 ¥{{ p.amount }}</text>
</view>
<view class="mine-post__ops">
<text class="mine-post__op" @click.stop="goDetail(p)">查看</text>
<text class="mine-post__op mine-post__op--danger" @click.stop="remove(p)">删除</text>
</view>
</view>
</view>
<view class="mine-post__more">
<text v-if="loading">加载中…</text>
<text v-else-if="!hasMore">— 没有更多了 —</text>
<text v-else @click="loadMore">加载更多</text>
</view>
</view>
<view class="mine-post__fab" @click="goCreate">
<text>+ 发布</text>
</view>
</view>
</template>
<script>
import FcEmpty from '@/components/fc-empty/fc-empty.vue'
import postApi from '@/common/api/post.js'
import { fromNow } from '@/common/utils/format.js'
export default {
components: { FcEmpty },
data() {
return {
tabs: [
{ label: '全部', value: 'all' },
{ label: '待审核', value: 'pending' },
{ label: '已通过', value: 'passed' },
{ label: '已驳回', value: 'rejected' },
{ label: '已下架', value: 'offline' },
],
status: 'all',
list: [],
counts: {},
page: 1,
size: 10,
hasMore: true,
loading: false,
}
},
onLoad() {
this.fetch(true)
},
onShow() {
// 发布/编辑/后台审核后回到本页,需要看到最新状态与计数
this.page = 1
this.fetch(true)
},
onReachBottom() {
this.loadMore()
},
methods: {
timeText(t) {
return fromNow(t)
},
async fetch(reset = false) {
this.loading = true
try {
const res = await postApi.mine({ status: this.status, page: this.page, size: this.size })
this.list = reset ? res.list : this.list.concat(res.list)
this.hasMore = !!res.hasMore
this.counts = res.counts || {}
} catch (e) {
uni.showToast({ title: e.message || '加载失败', icon: 'none' })
} finally {
this.loading = false
}
},
loadMore() {
if (!this.hasMore || this.loading) return
this.page += 1
this.fetch()
},
changeStatus(v) {
if (this.status === v) return
this.status = v
this.page = 1
this.fetch(true)
},
statusText(p) {
if (Number(p.status) === 0) return '已下架'
const m = { 0: '待审核', 1: '已通过', 2: '已驳回' }
return m[Number(p.auditStatus)] || '待审核'
},
statusClass(p) {
if (Number(p.status) === 0) return 'mine-post__status--offline'
const m = { 0: 'mine-post__status--pending', 1: 'mine-post__status--passed', 2: 'mine-post__status--rejected' }
return m[Number(p.auditStatus)] || 'mine-post__status--pending'
},
goDetail(p) {
uni.navigateTo({ url: `/pages/detail/detail?id=${p.id}` })
},
goCreate() {
uni.navigateTo({ url: '/pages/post/create' })
},
remove(p) {
uni.showModal({
title: '删除信息',
content: `确认删除「${p.title}」?删除后不可恢复`,
success: async (r) => {
if (!r.confirm) return
try {
await postApi.remove(p.id)
uni.showToast({ title: '已删除', icon: 'none' })
this.page = 1
this.fetch(true)
} catch (e) {
uni.showToast({ title: e.message || '删除失败', icon: 'none' })
}
},
})
},
},
}
</script>
<style lang="scss" scoped>
.mine-post {
padding-bottom: 180rpx;
}
.mine-post__tabs {
background: $fc-bg-card;
white-space: nowrap;
padding: 16rpx 0;
border-bottom: 2rpx solid $fc-border;
}
.mine-post__tabs-inner {
display: inline-flex;
padding: 0 16rpx;
}
.mine-post__tab {
margin: 0 8rpx;
padding: 10rpx 24rpx;
border-radius: $fc-radius-pill;
background: $fc-bg;
font-size: $fc-font-sm;
color: $fc-text-regular;
display: inline-flex;
align-items: center;
flex: 0 0 auto;
&--active {
background: $fc-gradient-primary;
color: $fc-primary-ink;
font-weight: 700;
box-shadow: 0 6rpx 16rpx rgba(4, 48, 30, 0.28);
}
}
.mine-post__tab-num {
margin-left: 8rpx;
font-size: 22rpx;
opacity: 0.75;
}
.mine-post__loading {
padding: 24rpx;
}
.mine-post__skeleton {
height: 180rpx;
margin-bottom: 20rpx;
}
.mine-post__list {
padding: 24rpx;
}
.mine-post__item {
margin-bottom: 20rpx;
}
.mine-post__head {
display: flex;
align-items: flex-start;
justify-content: space-between;
}
.mine-post__title {
flex: 1;
font-size: $fc-font-lg;
font-weight: 700;
color: $fc-text;
line-height: 1.4;
}
.mine-post__status {
margin-left: 16rpx;
flex: 0 0 auto;
padding: 4rpx 14rpx;
border-radius: $fc-radius-sm;
font-size: 22rpx;
font-weight: 600;
&--pending {
background: $fc-accent-lighter;
color: $fc-accent-dark;
}
&--passed {
background: $fc-primary-lighter;
color: $fc-primary-text;
}
&--rejected {
background: #fdeaea;
color: $fc-danger;
}
&--offline {
background: $fc-bg;
color: $fc-text-secondary;
}
}
.mine-post__meta {
margin-top: 14rpx;
display: flex;
align-items: center;
flex-wrap: wrap;
font-size: $fc-font-sm;
color: $fc-text-secondary;
}
.mine-post__badge {
margin-right: 12rpx;
padding: 2rpx 12rpx;
border-radius: $fc-radius-sm;
background: $fc-gradient-primary;
color: $fc-primary-ink;
font-size: 20rpx;
font-weight: 700;
}
.mine-post__dot {
margin: 0 8rpx;
color: $fc-text-placeholder;
}
.mine-post__reason {
margin-top: 12rpx;
padding: 12rpx 16rpx;
border-radius: $fc-radius-sm;
background: #fdf4f4;
color: $fc-danger;
font-size: $fc-font-sm;
line-height: 1.5;
}
.mine-post__foot {
margin-top: 16rpx;
padding-top: 16rpx;
border-top: 2rpx solid $fc-border;
display: flex;
align-items: center;
justify-content: space-between;
}
.mine-post__stats {
display: flex;
align-items: center;
font-size: 24rpx;
color: $fc-text-secondary;
}
.mine-post__paid {
color: $fc-price;
}
.mine-post__ops {
display: flex;
align-items: center;
}
.mine-post__op {
margin-left: 28rpx;
font-size: $fc-font-sm;
color: $fc-primary-text;
font-weight: 600;
&--danger {
color: $fc-danger;
}
}
.mine-post__more {
text-align: center;
padding: 24rpx 0 40rpx;
font-size: $fc-font-sm;
color: $fc-text-placeholder;
}
.mine-post__fab {
position: fixed;
right: 32rpx;
bottom: 60rpx;
padding: 20rpx 36rpx;
border-radius: $fc-radius-pill;
background: $fc-gradient-primary;
color: $fc-primary-ink;
font-size: $fc-font;
font-weight: 700;
box-shadow: 0 10rpx 28rpx rgba(4, 48, 30, 0.4);
}
</style>