文件
fenleixinxi/uniapp/pages/post/list.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

282 行
6.4 KiB
Vue

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

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

<template>
<view class="list fc-page">
<!-- 分类横滑 -->
<scroll-view class="list__cats" scroll-x :show-scrollbar="false">
<view class="list__cats-inner">
<view v-for="c in categories" :key="c.id" class="list__cat"
:class="{ 'list__cat--active': categoryId === c.id }" @click="changeCategory(c)">
<image class="list__cat-icon" :src="catIcon(c)" mode="aspectFit" />
<text>{{ c.name }}</text>
</view>
</view>
</scroll-view>
<!-- 多维筛选 -->
<view class="list__filters">
<view v-for="s in sorts" :key="s.value" class="list__filter"
:class="{ 'list__filter--active': sort === s.value }" @click="changeSort(s.value)">
<text>{{ s.label }}</text>
</view>
<view class="list__filter list__filter--right" @click="showArea = true">
<text>{{ area || '区域 ▾' }}</text>
</view>
</view>
<view v-if="loading && !list.length" class="list__loading">
<view v-for="i in 3" :key="i" class="fc-skeleton list__skeleton"></view>
</view>
<fc-empty v-else-if="!list.length" text="该分类下暂无信息" btn-text="发布一条" @action="goCreate" />
<view v-else>
<fc-post-card v-for="p in list" :key="p.id" :post="p" @click="goDetail" />
<view class="list__more">
<text v-if="loading">加载中…</text>
<text v-else-if="!hasMore">— 没有更多了 —</text>
<text v-else @click="loadMore">加载更多</text>
</view>
</view>
<view class="list__fab" @click="goCreate">
<text>+ 发布</text>
</view>
<view v-if="showArea" class="list__mask" @click="showArea = false">
<view class="list__sheet" @click.stop>
<text class="list__sheet-title">选择区域</text>
<view class="list__sheet-list">
<view v-for="a in areaOptions" :key="a" class="list__sheet-item"
:class="{ 'list__sheet-item--active': area === a }" @click="pickArea(a)">
<text>{{ a }}</text>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import FcPostCard from '@/components/fc-post-card/fc-post-card.vue'
import FcEmpty from '@/components/fc-empty/fc-empty.vue'
import homeApi from '@/common/api/home.js'
import { iconUrl, categoryIconUrl, loadUiConfig } from '@/common/store/ui.js'
export default {
components: { FcPostCard, FcEmpty },
data() {
return {
categories: [],
categoryId: 0,
list: [],
page: 1,
size: 10,
hasMore: true,
loading: false,
sort: 'new',
area: '',
showArea: false,
areaOptions: ['云岩区', '南明区', '观山湖区', '花溪区'],
sorts: [
{ label: '最新', value: 'new' },
{ label: '最热', value: 'hot' },
{ label: '价格', value: 'price' },
],
}
},
onLoad(query) {
this.categoryId = Number(query.categoryId || 0)
if (query.name) {
uni.setNavigationBarTitle({ title: decodeURIComponent(query.name) })
}
loadUiConfig()
this.init()
},
onReachBottom() {
this.loadMore()
},
methods: {
iconUrl,
catIcon(c) {
return (c.iconKey && iconUrl(c.iconKey)) || categoryIconUrl(c.id)
},
async init() {
try {
this.categories = await homeApi.categories()
} catch (e) {}
this.fetch(true)
},
async fetch(reset = false) {
this.loading = true
try {
const res = await homeApi.feed({
page: this.page,
size: this.size,
categoryId: this.categoryId || undefined,
sort: this.sort,
area: this.area || undefined,
})
this.list = reset ? res.list : this.list.concat(res.list)
this.hasMore = res.hasMore
} catch (e) {
uni.showToast({ title: '加载失败', icon: 'none' })
} finally {
this.loading = false
}
},
loadMore() {
if (!this.hasMore || this.loading) return
this.page += 1
this.fetch()
},
changeCategory(c) {
this.categoryId = this.categoryId === c.id ? 0 : c.id
this.page = 1
this.fetch(true)
},
changeSort(v) {
if (this.sort === v) return
this.sort = v
this.page = 1
this.fetch(true)
},
pickArea(a) {
this.area = this.area === a ? '' : a
this.showArea = false
this.page = 1
this.fetch(true)
},
goDetail(p) {
uni.navigateTo({ url: `/pages/detail/detail?id=${p.id}` })
},
goCreate() {
uni.navigateTo({ url: '/pages/post/create' })
},
},
}
</script>
<style lang="scss" scoped>
.list__cats {
background: #ffffff;
white-space: nowrap;
padding: 16rpx 0;
border-bottom: 2rpx solid $fc-border;
}
.list__cats-inner {
display: inline-flex;
padding: 0 16rpx;
}
.list__cat {
margin: 0 10rpx;
padding: 10rpx 24rpx;
border-radius: $fc-radius-pill;
background: $fc-bg;
font-size: $fc-font-sm;
color: $fc-text-regular;
flex: 0 0 auto;
display: inline-flex;
align-items: center;
&--active {
background: $fc-gradient-primary;
color: $fc-primary-ink;
font-weight: 600;
box-shadow: 0 6rpx 16rpx rgba(4, 48, 30, 0.3);
}
}
.list__cat-icon {
width: 34rpx;
height: 34rpx;
margin-right: 8rpx;
}
.list__filters {
display: flex;
align-items: center;
padding: 20rpx 24rpx 12rpx;
}
.list__filter {
margin-right: 28rpx;
font-size: $fc-font;
color: $fc-text-secondary;
&--active {
color: $fc-primary-text;
font-weight: 700;
}
&--right {
margin-left: auto;
margin-right: 0;
}
}
.list__loading {
padding: 24rpx;
}
.list__skeleton {
height: 220rpx;
margin-bottom: 20rpx;
}
.list__more {
text-align: center;
padding: 24rpx 0 40rpx;
font-size: $fc-font-sm;
color: $fc-text-placeholder;
}
.list__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);
}
.list__mask {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
z-index: 200;
background: rgba(4, 48, 42, 0.5);
display: flex;
align-items: flex-end;
}
.list__sheet {
width: 100%;
background: #ffffff;
border-radius: 32rpx 32rpx 0 0;
padding: 36rpx 32rpx 60rpx;
}
.list__sheet-title {
display: block;
text-align: center;
font-size: $fc-font-lg;
font-weight: 700;
margin-bottom: 28rpx;
}
.list__sheet-list {
display: flex;
flex-wrap: wrap;
}
.list__sheet-item {
width: 30%;
margin: 0 1.5% 20rpx;
height: 76rpx;
border-radius: $fc-radius;
background: $fc-bg;
display: flex;
align-items: center;
justify-content: center;
font-size: $fc-font;
color: $fc-text-regular;
&--active {
background: $fc-primary-lighter;
color: $fc-primary-text;
font-weight: 700;
border: 2rpx solid $fc-primary-text;
}
}
</style>