feat: 新增分类页面与规范化顶部导航栏组件

新增分类页面及图标资源,完善底部导航分类 tab,新增 navbar 度量工具适配不同设备,优化请求参数处理,修复通知相关显示问题,统一顶部导航栏样式以适配系统状态栏与胶囊避让。
这个提交包含在:
2026-10-20 11:02:42 +08:00
父节点 81a48feaad
当前提交 c2e0f72b30
共有 21 个文件被更改,包括 913 次插入 和 64 次删除

查看文件

@@ -118,6 +118,16 @@ class Home extends V1
$keyword = trim((string)$this->input('keyword', ''));
$area = trim((string)$this->input('area', ''));
$sort = (string)$this->input('sort', '');
// 容错处理:过滤前端小程序可能序列化出的 undefined 与 null 字符串
if ($area === 'undefined' || $area === 'null') {
$area = '';
}
if ($keyword === 'undefined' || $keyword === 'null') {
$keyword = '';
}
if ($sort === 'undefined' || $sort === 'null') {
$sort = '';
}
$query = Db::name('fc_post')
->where('audit_status', 1)

查看文件

@@ -15,10 +15,12 @@ export const ICON_GROUPS = [
items: [
{ key: 'tab-home', name: '首页(常态)', file: 'tab-home.png' },
{ key: 'tab-home-on', name: '首页(选中)', file: 'tab-home-on.png' },
{ key: 'tab-category', name: '分类(常态)', file: 'tab-category.png' },
{ key: 'tab-category-on', name: '分类(选中)', file: 'tab-category-on.png' },
{ key: 'tab-post', name: '发布(常态)', file: 'tab-post.png' },
{ key: 'tab-post-on', name: '发布(选中)', file: 'tab-post-on.png' },
{ key: 'tab-message', name: '消息(常态)', file: 'tab-message.png' },
{ key: 'tab-message-on', name: '消息(选中)', file: 'tab-message-on.png' },
{ key: 'tab-message', name: '通知(常态)', file: 'tab-message.png' },
{ key: 'tab-message-on', name: '通知(选中)', file: 'tab-message-on.png' },
{ key: 'tab-mine', name: '我的(常态)', file: 'tab-mine.png' },
{ key: 'tab-mine-on', name: '我的(选中)', file: 'tab-mine-on.png' },
],

查看文件

@@ -14,7 +14,7 @@ const IS_DEV = ENV !== 'production'
// 各环境后端域名(dev=运行 / prod=发行)
const HOSTS = {
dev: 'http://127.0.0.1:9980', // 本地后端
dev: 'http://192.168.2.61:9980', // 本地后端(phpstudy 虚拟域名与端口 9980)
prod: 'https://fenleixinxi.gzyakj.com.cn', // 远程正式后端
}
// 接口统一前缀

查看文件

@@ -0,0 +1,64 @@
/**
* 顶部导航栏与胶囊避让度量工具
* 规范化统一各页面的 Topbar 状态栏高度、导航栏高度及微信小程序右上角胶囊避让
*/
/**
* 获取当前设备与平台环境下的导航栏尺寸度量
* @returns {Object} 包含 statusBarHeight, navBarHeight, capsulePadding, capsuleWidth, capsuleHeight, capsuleTop, totalHeight
*/
export function getNavMetrics() {
let statusBarHeight = 20
let navBarHeight = 44
let capsulePadding = 0
let capsuleWidth = 0
let capsuleHeight = 32
let capsuleTop = 24
let capsuleRight = 0
try {
const sys = uni.getSystemInfoSync ? uni.getSystemInfoSync() : null
if (sys && sys.statusBarHeight) {
statusBarHeight = sys.statusBarHeight
}
// #ifdef MP-WEIXIN || MP
if (typeof uni.getMenuButtonBoundingClientRect === 'function') {
const menu = uni.getMenuButtonBoundingClientRect()
if (menu && menu.width && menu.top) {
capsuleWidth = menu.width
capsuleHeight = menu.height
capsuleTop = menu.top
const winWidth = (sys && sys.windowWidth) ? sys.windowWidth : 375
capsuleRight = winWidth - menu.right
// 右侧避让距离 = 胶囊宽度 + 胶囊右边距 + 左右视觉留白间隙(8px)
capsulePadding = (winWidth - menu.left) + 8
// 胶囊垂直居中时的标准导航条高度:上下边距对称 (menu.top - statusBarHeight) * 2 + menu.height
const barH = (menu.top - statusBarHeight) * 2 + menu.height
if (barH >= 38 && barH <= 64) {
navBarHeight = barH
}
} else {
capsulePadding = 96
}
}
// #endif
} catch (e) {
capsulePadding = 96
}
return {
statusBarHeight,
navBarHeight,
capsulePadding,
capsuleWidth,
capsuleHeight,
capsuleTop,
totalHeight: statusBarHeight + navBarHeight,
}
}
export default {
getNavMetrics,
}

查看文件

@@ -46,6 +46,24 @@ export function buildHeaders(extra = {}) {
* 底层请求(返回 Promise<data>)
* @param {Object} options { url, method, data, header, silent, mock }
*/
/**
* 清理请求参数中 undefined / null / 空串 的无效字段
* 防止在微信小程序等环境下 GET 请求被底层错误序列化为 "key=undefined"
* @param {Object} data 原始请求参数
* @returns {Object} 清理后的参数
*/
export function cleanParams(data) {
if (!data || typeof data !== 'object' || Array.isArray(data)) return data
const cleaned = {}
for (const key of Object.keys(data)) {
const val = data[key]
if (val !== undefined && val !== null && val !== '') {
cleaned[key] = val
}
}
return cleaned
}
export function request(options = {}) {
const {
url,
@@ -56,6 +74,7 @@ export function request(options = {}) {
mock = config.forceMock, // 强制走 mock
} = options
const requestData = String(method).toUpperCase() === 'GET' ? cleanParams(data) : data
const runtime = getRuntime()
const finalUrl = buildUrl(url)
const headers = buildHeaders(header)
@@ -72,7 +91,7 @@ export function request(options = {}) {
runtime.request({
url: finalUrl,
method: method.toUpperCase(),
data,
data: requestData,
header: headers,
timeout: config.timeout,
success(res) {

查看文件

@@ -1,15 +1,26 @@
<template>
<view class="fc-navbar" :class="[`fc-navbar--${theme}`]">
<!-- 系统状态栏占位 -->
<view class="fc-navbar__status" :style="{ height: statusBarHeight + 'px' }"></view>
<view class="fc-navbar__bar" :style="{ height: barHeight + 'px' }">
<!-- 导航内容条:精确对齐胶囊高度并避让右侧胶囊 -->
<view
class="fc-navbar__bar"
:style="{
height: barHeight + 'px',
paddingRight: capsulePadding ? (capsulePadding + 'px') : '24rpx',
}"
>
<!-- 返回按钮 -->
<view v-if="showBack" class="fc-navbar__back" @click="onBack">
<text class="fc-navbar__back-icon">‹</text>
</view>
<!-- 标题区域 -->
<view class="fc-navbar__title" :class="{ 'fc-navbar__title--center': center }">
<slot>
<text class="fc-navbar__title-text">{{ title }}</text>
<text class="fc-navbar__title-text fc-ellipsis">{{ title }}</text>
</slot>
</view>
<!-- 右侧功能区(位于胶囊左侧) -->
<view class="fc-navbar__right">
<slot name="right"></slot>
</view>
@@ -18,30 +29,50 @@
</template>
<script>
import { getNavMetrics } from '@/common/utils/navbar.js'
export default {
name: 'FcNavbar',
props: {
/** 导航标题文字 */
title: { type: String, default: '' },
theme: { type: String, default: 'gradient' }, // gradient | white
/** 风格主题:gradient(主色渐变白字) | white(白底黑字) */
theme: { type: String, default: 'gradient' },
/** 是否展示左侧返回按钮 */
showBack: { type: Boolean, default: false },
/** 标题文字是否居中 */
center: { type: Boolean, default: true },
},
data() {
return { statusBarHeight: 20, barHeight: 44 }
},
created() {
try {
const info = uni.getSystemInfoSync()
this.statusBarHeight = info.statusBarHeight || 20
} catch (e) {
/* 忽略(非 uni 环境) */
return {
statusBarHeight: 20,
barHeight: 44,
capsulePadding: 0,
}
},
created() {
this.initMetrics()
},
methods: {
/**
* 初始化获取设备状态栏和胶囊参数
*/
initMetrics() {
const m = getNavMetrics()
this.statusBarHeight = m.statusBarHeight
this.barHeight = m.navBarHeight
this.capsulePadding = m.capsulePadding
},
/**
* 点击返回上一页,若无历史页面则返回首页
*/
onBack() {
const pages = getCurrentPages()
if (pages && pages.length > 1) uni.navigateBack()
else uni.reLaunch({ url: '/pages/index/index' })
if (pages && pages.length > 1) {
uni.navigateBack()
} else {
uni.reLaunch({ url: '/pages/index/index' })
}
},
},
}
@@ -75,7 +106,8 @@ export default {
.fc-navbar__bar {
display: flex;
align-items: center;
padding: 0 24rpx;
padding-left: 24rpx;
box-sizing: border-box;
position: relative;
}
.fc-navbar__back {
@@ -84,6 +116,7 @@ export default {
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.fc-navbar__back-icon {
font-size: 52rpx;
@@ -92,12 +125,12 @@ export default {
}
.fc-navbar__title {
flex: 1;
min-width: 0;
display: flex;
align-items: center;
&--center {
position: absolute;
left: 0;
right: 0;
justify-content: center;
text-align: center;
pointer-events: none;
}
}
.fc-navbar__title-text {
@@ -109,5 +142,6 @@ export default {
z-index: 1;
display: flex;
align-items: center;
flex-shrink: 0;
}
</style>

查看文件

@@ -1,17 +1,19 @@
<template>
<view class="fc-tabbar">
<view
v-for="(item, idx) in tabs"
:key="item.path"
class="fc-tabbar__item"
:class="{ 'fc-tabbar__item--active': current === idx, 'fc-tabbar__item--primary': item.primary }"
@click="switchTo(item, idx)"
>
<view class="fc-tabbar__icon" :class="{ 'fc-tabbar__icon--circle': item.primary }">
<image v-if="item.primary" class="fc-tabbar__plus" :src="iconUrl('plus-ink')" mode="aspectFit" />
<image v-else class="fc-tabbar__img" :src="iconUrl(current === idx ? item.active : item.icon)" mode="aspectFit" />
<view class="fc-tabbar__nav">
<view
v-for="(item, idx) in tabs"
:key="item.path"
class="fc-tabbar__item"
:class="{ 'fc-tabbar__item--active': current === idx, 'fc-tabbar__item--primary': item.primary }"
@click="switchTo(item, idx)"
>
<view class="fc-tabbar__icon" :class="{ 'fc-tabbar__icon--circle': item.primary }">
<image v-if="item.primary" class="fc-tabbar__plus" :src="iconUrl('plus-ink')" mode="aspectFit" />
<image v-else class="fc-tabbar__img" :src="iconUrl(current === idx ? item.active : item.icon)" mode="aspectFit" />
</view>
<text class="fc-tabbar__text">{{ item.text }}</text>
</view>
<text class="fc-tabbar__text">{{ item.text }}</text>
</view>
<view class="fc-safe-bottom"></view>
</view>
@@ -22,24 +24,43 @@ import { iconUrl } from '@/common/store/ui.js'
export default {
name: 'FcTabbar',
options: {
/** 开启虚拟化宿主节点,避免小程序自定义组件样式隔离产生非预期布局 */
virtualHost: true,
},
props: {
/** 当前激活的 Tab 索引(0:首页 1:分类 2:发布 3:通知 4:我的) */
current: { type: Number, default: 0 },
},
data() {
return {
tabs: [
{ text: '首页', icon: 'tab-home', active: 'tab-home-on', path: '/pages/index/index' },
{ text: '分类', icon: 'tab-category', active: 'tab-category-on', path: '/pages/category/index' },
{ text: '发布', icon: 'tab-post', active: 'tab-post-on', path: '/pages/post/create', primary: true },
{ text: '消息', icon: 'tab-message', active: 'tab-message-on', path: '/pages/message/index' },
{ text: '通知', icon: 'tab-message', active: 'tab-message-on', path: '/pages/message/index' },
{ text: '我的', icon: 'tab-mine', active: 'tab-mine-on', path: '/pages/mine/index' },
],
}
},
methods: {
// 暴露给模板:图标地址由后台配置决定(未配置则用内置图标)
/** 暴露给模板:图标地址由后台配置决定(未配置则用内置图标) */
iconUrl,
/**
* 切换底部导航目标页面
* @param {Object} item 目标 Tab 配置对象
* @param {number} idx 目标 Tab 索引
*/
switchTo(item, idx) {
if (idx === this.current) return
// 🌟 中间突出加号(发布):作为独立模态表单页推入,保留前序页面栈,支持原路返回
if (item.primary) {
uni.navigateTo({ url: item.path })
return
}
// 其余常驻 Tab 页面平滑切换
uni.reLaunch({ url: item.path })
},
},
@@ -52,14 +73,19 @@ export default {
left: 0;
right: 0;
bottom: 0;
z-index: 100;
display: flex;
align-items: center;
justify-content: space-around;
padding-top: 10rpx;
z-index: 999;
background: #ffffff;
border-top: 2rpx solid $fc-border;
box-shadow: 0 -6rpx 24rpx rgba(4, 48, 30, 0.08);
box-sizing: border-box;
}
.fc-tabbar__nav {
display: flex;
align-items: center;
justify-content: space-around;
height: 104rpx;
padding-top: 8rpx;
box-sizing: border-box;
}
.fc-tabbar__item {
flex: 1;
@@ -88,7 +114,7 @@ export default {
&--circle {
width: 76rpx;
height: 76rpx;
margin-top: -34rpx;
margin-top: -38rpx;
border-radius: 50%;
background: $fc-gradient-primary;
box-shadow: 0 8rpx 20rpx rgba(4, 48, 30, 0.4);

查看文件

@@ -9,6 +9,14 @@
"backgroundColor": "#f2fef7"
}
},
{
"path": "pages/category/index",
"style": {
"navigationBarTitleText": "全部分类",
"navigationStyle": "custom",
"backgroundColor": "#f8fafc"
}
},
{
"path": "pages/post/create",
"style": {
@@ -28,7 +36,7 @@
{
"path": "pages/message/index",
"style": {
"navigationBarTitleText": "消息中心",
"navigationBarTitleText": "通知中心",
"navigationBarBackgroundColor": "#04874a",
"navigationBarTextStyle": "white"
}
@@ -130,9 +138,18 @@
"condition": {
"current": 0,
"list": [
{ "name": "首页", "path": "pages/index/index" },
{ "name": "发布", "path": "pages/post/create" },
{ "name": "会员中心", "path": "pages/member/index" }
{
"name": "首页",
"path": "pages/index/index"
},
{
"name": "发布",
"path": "pages/post/create"
},
{
"name": "会员中心",
"path": "pages/member/index"
}
]
},
"uniIdRouter": {}

查看文件

@@ -1,7 +1,8 @@
<template>
<view class="login">
<view class="login__bg"></view>
<view class="login__status" :style="{ height: statusBarHeight + 'px' }"></view>
<!-- 规范化顶部 Topbar:自适应系统状态栏与微信胶囊避让,提供返回键 -->
<fc-navbar title="" theme="gradient" :show-back="true" />
<view class="login__brand">
<image class="fc-logo fc-logo--lg" :src="logoUrl()" mode="aspectFit" />
@@ -65,8 +66,10 @@ import authApi from '@/common/api/auth.js'
import postApi from '@/common/api/post.js'
import config from '@/common/config/index.js'
import { iconUrl, logoUrl, loadUiConfig, uiState } from '@/common/store/ui.js'
import FcNavbar from '@/components/fc-navbar/fc-navbar.vue'
export default {
components: { FcNavbar },
data() {
return {
statusBarHeight: 20,
@@ -256,7 +259,7 @@ export default {
}
.login__brand {
position: relative;
padding: 120rpx 60rpx 60rpx;
padding: 40rpx 60rpx 50rpx;
display: flex;
flex-direction: column;
align-items: center;

查看文件

@@ -0,0 +1,430 @@
<template>
<view class="cat-page fc-page">
<!-- 规范化顶部 Topbar:自适应系统状态栏与微信胶囊避让 -->
<view class="cat-header">
<!-- 状态栏占位 -->
<view class="cat-header__status" :style="{ height: statusBarHeight + 'px' }"></view>
<!-- 标题与搜索条(右侧自动避开微信右上角胶囊) -->
<view
class="cat-header__bar"
:style="{
height: navBarHeight + 'px',
paddingRight: (capsulePadding || 12) + 'px',
}"
>
<text class="cat-header__title">全部分类</text>
<view class="cat-header__search" @click="goSearch">
<image class="fc-icon fc-icon--sm" :src="iconUrl('search')" mode="aspectFit" />
<text class="cat-header__placeholder">搜索本地信息...</text>
</view>
</view>
</view>
<!-- 经典双联主体区域 -->
<view class="cat-main">
<!-- 左侧一级分类垂直菜单 -->
<scroll-view class="cat-sidebar" scroll-y :show-scrollbar="false">
<view
v-for="c in categories"
:key="c.id"
class="cat-sidebar__item"
:class="{ 'cat-sidebar__item--active': currentCategory && currentCategory.id === c.id }"
@click="selectCategory(c)"
>
<view v-if="currentCategory && currentCategory.id === c.id" class="cat-sidebar__bar"></view>
<image class="cat-sidebar__icon" :src="categoryIconUrl(c.id)" mode="aspectFit" />
<text class="cat-sidebar__name">{{ c.name }}</text>
</view>
</scroll-view>
<!-- 右侧内容区域(排序 + 信息流) -->
<scroll-view
class="cat-content"
scroll-y
:show-scrollbar="false"
@scrolltolower="loadMore"
>
<!-- 快捷排序选项 -->
<view class="cat-sort">
<view
v-for="s in sortOptions"
:key="s.value"
class="cat-sort__item"
:class="{ 'cat-sort__item--active': sort === s.value }"
@click="changeSort(s.value)"
>
{{ s.label }}
</view>
</view>
<!-- 信息流列表 -->
<view v-if="list.length" class="cat-list">
<fc-post-card
v-for="item in list"
:key="item.id"
:post="item"
@click="goDetail"
/>
<view v-if="loading" class="cat-loading">正在加载中...</view>
<view v-else-if="!hasMore" class="cat-nomore">没有更多信息了</view>
</view>
<!-- 空状态 -->
<view v-else-if="!loading" class="cat-empty-wrap">
<fc-empty icon="inbox" text="该分类下暂无信息,快来抢先发布吧!" />
<button class="cat-empty-btn" @click="goPublish">立即发布此分类</button>
</view>
<!-- 底部留白防止遮挡 -->
<view class="cat-content__space"></view>
</scroll-view>
</view>
<!-- 底部 Tabbar(当前选中索引为 1) -->
<fc-tabbar :current="1" />
</view>
</template>
<script>
import FcTabbar from '@/components/fc-tabbar/fc-tabbar.vue'
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 } from '@/common/store/ui.js'
import { getNavMetrics } from '@/common/utils/navbar.js'
export default {
components: { FcTabbar, FcPostCard, FcEmpty },
data() {
return {
statusBarHeight: 20,
navBarHeight: 44,
capsulePadding: 0,
categories: [],
currentCategory: null,
sort: 'new',
sortOptions: [
{ label: '最新', value: 'new' },
{ label: '最热', value: 'hot' },
{ label: '附近', value: 'nearby' },
{ label: '价格', value: 'price' },
],
list: [],
page: 1,
size: 10,
total: 0,
hasMore: true,
loading: false,
lat: null,
lng: null,
}
},
onLoad(options) {
this.initMetrics()
this.initLocation()
this.fetchCategories(options && options.categoryId)
},
methods: {
/** 暴露给模板:图标地址解析 */
iconUrl,
/** 暴露给模板:分类图标解析 */
categoryIconUrl,
/**
* 初始化设备导航栏与胶囊避让度量
*/
initMetrics() {
const m = getNavMetrics()
this.statusBarHeight = m.statusBarHeight
this.navBarHeight = m.navBarHeight
this.capsulePadding = m.capsulePadding
},
/**
* 初始化获取当前用户定位坐标(用于“附近”距离计算与排序)
*/
initLocation() {
uni.getLocation({
type: 'gcj02',
success: (res) => {
this.lat = res.latitude
this.lng = res.longitude
},
fail: () => {},
})
},
/**
* 拉取全部分类数据
* @param {string|number} defaultCatId 默认选中的分类 ID
*/
async fetchCategories(defaultCatId) {
try {
const cats = await homeApi.categories()
this.categories = Array.isArray(cats) ? cats : []
if (this.categories.length) {
const target = defaultCatId
? this.categories.find((c) => String(c.id) === String(defaultCatId))
: null
this.selectCategory(target || this.categories[0])
}
} catch (e) {
uni.showToast({ title: '分类加载失败', icon: 'none' })
}
},
/**
* 切换当前选中的左侧分类
* @param {Object} cat 选中的分类对象
*/
selectCategory(cat) {
if (!cat || (this.currentCategory && this.currentCategory.id === cat.id)) return
this.currentCategory = cat
this.page = 1
this.list = []
this.hasMore = true
this.fetchPosts()
},
/**
* 切换排序规则
* @param {string} s 排序值 new|hot|nearby|price
*/
changeSort(s) {
if (this.sort === s) return
this.sort = s
this.page = 1
this.list = []
this.hasMore = true
this.fetchPosts()
},
/**
* 获取当前分类下的信息列表
*/
async fetchPosts() {
if (this.loading || !this.currentCategory) return
this.loading = true
try {
const params = {
categoryId: this.currentCategory.id,
sort: this.sort,
page: this.page,
size: this.size,
}
if (this.lat && this.lng) {
params.lat = this.lat
params.lng = this.lng
}
const res = await homeApi.feed(params)
const rows = (res && res.list) || []
this.list = this.page === 1 ? rows : this.list.concat(rows)
this.total = (res && res.total) || 0
this.hasMore = res ? !!res.hasMore : false
} catch (e) {
uni.showToast({ title: '加载信息失败', icon: 'none' })
} finally {
this.loading = false
}
},
/**
* 触底加载下一页数据
*/
loadMore() {
if (this.hasMore && !this.loading) {
this.page += 1
this.fetchPosts()
}
},
/**
* 跳转到搜索页
*/
goSearch() {
uni.navigateTo({ url: '/pages/search/index' })
},
/**
* 跳转到当前分类的发布页
*/
goPublish() {
const catId = this.currentCategory ? this.currentCategory.id : ''
uni.navigateTo({ url: `/pages/post/create?categoryId=${catId}` })
},
/**
* 查看信息详情
* @param {Object} post 点击的信息项
*/
goDetail(post) {
if (post && post.id) {
uni.navigateTo({ url: `/pages/detail/detail?id=${post.id}` })
}
},
},
}
</script>
<style lang="scss" scoped>
.cat-page {
height: 100vh;
display: flex;
flex-direction: column;
background: #f8fafc;
overflow: hidden;
}
/* 规范化顶部 Topbar */
.cat-header {
background: #ffffff;
border-bottom: 2rpx solid $fc-border;
z-index: 10;
flex-shrink: 0;
}
.cat-header__status {
width: 100%;
}
.cat-header__bar {
display: flex;
align-items: center;
padding-left: 28rpx;
box-sizing: border-box;
gap: 20rpx;
}
.cat-header__title {
font-size: 34rpx;
font-weight: 700;
color: $fc-primary-ink;
flex-shrink: 0;
}
.cat-header__search {
flex: 1;
min-width: 0;
height: 64rpx;
background: #f1f5f9;
border-radius: 32rpx;
display: flex;
align-items: center;
padding: 0 20rpx;
gap: 12rpx;
}
.cat-header__placeholder {
font-size: 24rpx;
color: $fc-text-placeholder;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
/* 双联主体容器 */
.cat-main {
flex: 1;
display: flex;
min-height: 0; /* 必须,确保内部滚动条生效 */
}
/* 左侧垂直分类栏 */
.cat-sidebar {
width: 184rpx;
height: 100%;
background: #f1f5f9;
flex-shrink: 0;
}
.cat-sidebar__item {
position: relative;
height: 110rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 6rpx;
color: $fc-text-secondary;
font-size: 24rpx;
transition: all 0.2s ease;
border-bottom: 1rpx solid rgba(0, 0, 0, 0.03);
&--active {
background: #ffffff;
color: $fc-primary-text;
font-weight: 700;
}
}
.cat-sidebar__bar {
position: absolute;
left: 0;
top: 28rpx;
bottom: 28rpx;
width: 8rpx;
border-radius: 0 4rpx 4rpx 0;
background: $fc-primary;
}
.cat-sidebar__icon {
width: 44rpx;
height: 44rpx;
}
.cat-sidebar__name {
line-height: 1.2;
}
/* 右侧内容展示区 */
.cat-content {
flex: 1;
height: 100%;
padding: 20rpx 20rpx 0;
box-sizing: border-box;
}
/* 排序切换 */
.cat-sort {
display: flex;
align-items: center;
background: #ffffff;
border-radius: $fc-radius;
padding: 12rpx 16rpx;
margin-bottom: 16rpx;
box-shadow: $fc-shadow-sm;
}
.cat-sort__item {
flex: 1;
text-align: center;
font-size: 26rpx;
color: $fc-text-secondary;
padding: 8rpx 0;
border-radius: $fc-radius-sm;
&--active {
color: $fc-primary-text;
font-weight: 700;
background: $fc-primary-lighter;
}
}
/* 信息流列表 */
.cat-list {
display: flex;
flex-direction: column;
gap: 16rpx;
}
.cat-loading,
.cat-nomore {
text-align: center;
padding: 24rpx 0;
font-size: 22rpx;
color: $fc-text-placeholder;
}
/* 空状态卡片 */
.cat-empty-wrap {
padding: 60rpx 0;
display: flex;
flex-direction: column;
align-items: center;
}
.cat-empty-btn {
margin-top: 30rpx;
height: 68rpx;
line-height: 68rpx;
padding: 0 44rpx;
background: $fc-gradient-primary;
color: $fc-primary-ink;
font-size: 26rpx;
font-weight: 700;
border-radius: 34rpx;
box-shadow: 0 6rpx 18rpx rgba(0, 224, 112, 0.4);
}
.cat-content__space {
height: 140rpx;
}
</style>

查看文件

@@ -1,8 +1,10 @@
<template>
<view class="dist fc-page">
<!-- 规范化顶部 Topbar:自适应系统状态栏与微信胶囊避让 -->
<fc-navbar title="分销中心" theme="gradient" :show-back="true" />
<!-- 佣金概览 -->
<view class="dist__header">
<view class="dist__status" :style="{ height: statusBarHeight + 'px' }"></view>
<view class="dist__overview">
<text class="dist__overview-label">可提现佣金(元)</text>
<text class="dist__overview-num">{{ overview.withdrawable || 0 }}</text>
@@ -120,9 +122,10 @@ import distributionApi from '@/common/api/distribution.js'
import { WITHDRAW_TEXT } from '@/common/constants/ui.js'
import { fromNow } from '@/common/utils/format.js'
import { iconUrl, loadUiConfig } from '@/common/store/ui.js'
import FcNavbar from '@/components/fc-navbar/fc-navbar.vue'
export default {
components: { FcEmpty },
components: { FcEmpty, FcNavbar },
data() {
return {
statusBarHeight: 20,

查看文件

@@ -3,7 +3,13 @@
<!-- 顶部:LOGO + 定位 + 消息 + 搜索 -->
<view class="home__header">
<view class="home__header-status" :style="{ height: statusBarHeight + 'px' }"></view>
<view class="home__header-bar">
<view
class="home__header-bar"
:style="{
paddingRight: (capsulePadding || 12) + 'px',
minHeight: (navBarHeight || 44) + 'px',
}"
>
<image class="fc-logo fc-logo--sm" :src="logoUrl()" mode="aspectFit" />
<view class="home__location" @click="onLocation">
<image class="fc-icon fc-icon--sm" :src="iconUrl('home-location')" mode="aspectFit" />
@@ -147,12 +153,15 @@ import messageApi from '@/common/api/message.js'
import { useUserStore } from '@/common/store/index.js'
import { iconUrl, logoUrl, categoryIconUrl, loadUiConfig } from '@/common/store/ui.js'
import { bannerArtUrl, bannerHasValue, bannerBg } from '@/common/assets/banners.js'
import { getNavMetrics } from '@/common/utils/navbar.js'
export default {
components: { FcPostCard, FcTabbar, FcEmpty },
data() {
return {
statusBarHeight: 20,
navBarHeight: 44,
capsulePadding: 0,
// 顶栏定位文案:由真实定位/区域选择驱动,不再写死具体区(原为「贵阳 · 观山湖区」)
location: '',
unread: 0,
@@ -210,7 +219,10 @@ export default {
},
onLoad() {
try {
this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight || 20
const m = getNavMetrics()
this.statusBarHeight = m.statusBarHeight
this.navBarHeight = m.navBarHeight
this.capsulePadding = m.capsulePadding
} catch (e) {}
// 拉取后台自定义的 LOGO 与图标配置(失败自动用内置默认图)
loadUiConfig()

查看文件

@@ -1,8 +1,10 @@
<template>
<view class="vip fc-page">
<!-- 规范化顶部 Topbar:自适应系统状态栏与微信胶囊避让 -->
<fc-navbar title="会员中心" theme="gradient" :show-back="true" />
<!-- 头部会员卡 -->
<view class="vip__header">
<view class="vip__status" :style="{ height: statusBarHeight + 'px' }"></view>
<view class="vip__card">
<view class="vip__card-top">
<view>
@@ -124,8 +126,10 @@ import { iconUrl, loadUiConfig } from '@/common/store/ui.js'
import { formatTime } from '@/common/utils/format.js'
import { pay } from '@/common/utils/pay.js'
import config from '@/common/config/index.js'
import FcNavbar from '@/components/fc-navbar/fc-navbar.vue'
export default {
components: { FcNavbar },
data() {
return {
statusBarHeight: 20,

查看文件

@@ -9,7 +9,7 @@
</view>
</view>
<fc-empty v-if="!loading && !list.length" icon="inbox" text="暂无消息" />
<fc-empty v-if="!loading && !list.length" icon="inbox" text="暂无通知" />
<view v-else class="msg__list">
<view v-for="m in list" :key="m.id" class="msg__item" :class="{ 'msg__item--unread': !m.read }"
@@ -27,18 +27,23 @@
<view v-if="!m.read" class="msg__dot"></view>
</view>
</view>
<!-- 底部 Tabbar 占位 -->
<view class="msg__tabbar-space"></view>
<fc-tabbar :current="3" />
</view>
</template>
<script>
import FcEmpty from '@/components/fc-empty/fc-empty.vue'
import FcTabbar from '@/components/fc-tabbar/fc-tabbar.vue'
import messageApi from '@/common/api/message.js'
import { MESSAGE_TYPE } from '@/common/constants/ui.js'
import { fromNow } from '@/common/utils/format.js'
import { iconUrl } from '@/common/store/ui.js'
export default {
components: { FcEmpty },
components: { FcEmpty, FcTabbar },
data() {
return {
type: 'system',
@@ -46,7 +51,7 @@ export default {
loading: false,
tabs: [
{ label: '系统通知', value: 'system' },
{ label: '互动消息', value: 'interact' },
{ label: '互动提醒', value: 'interact' },
],
}
},
@@ -54,35 +59,65 @@ export default {
this.fetch()
},
methods: {
/** 暴露给模板:获取图标完整地址 */
iconUrl,
/**
* 获取指定通知类型的元信息
* @param {string} t 通知类型 system|interact
* @returns {Object} 包含 iconKey 与标题配置的对象
*/
meta(t) {
return MESSAGE_TYPE[t] || MESSAGE_TYPE.system
},
/**
* 格式化相对时间文本
* @param {string|number} t 时间戳或日期字符串
* @returns {string} 相对时间文本,如“刚刚”、“5分钟前”
*/
timeText(t) {
return fromNow(t)
},
/**
* 拉取当前类型的通知列表
*/
async fetch() {
this.loading = true
try {
const res = await messageApi.list({ type: this.type, page: 1, size: 20 })
this.list = res.list
} catch (e) {
uni.showToast({ title: '消息加载失败', icon: 'none' })
uni.showToast({ title: '通知加载失败', icon: 'none' })
} finally {
this.loading = false
}
},
/**
* 切换通知频道
* @param {string} v 频道类型值 system|interact
*/
changeType(v) {
if (this.type === v) return
this.type = v
this.fetch()
},
/**
* 点击查看通知详情并标记已读
* @param {Object} m 通知项对象
*/
async openMsg(m) {
if (m.read) return
m.read = true
try {
await messageApi.read(m.id)
} catch (e) {}
if (!m.read) {
m.read = true
try {
await messageApi.read(m.id)
} catch (e) {}
}
uni.showModal({
title: m.title || '通知详情',
content: m.content || '',
showCancel: false,
confirmText: '我知道了',
confirmColor: '#04874a',
})
},
},
}
@@ -174,4 +209,7 @@ export default {
border-radius: 50%;
background: $fc-primary;
}
.msg__tabbar-space {
height: 130rpx;
}
</style>

查看文件

@@ -3,6 +3,9 @@
<!-- 用户信息头 -->
<view class="mine__header">
<view class="mine__status" :style="{ height: statusBarHeight + 'px' }"></view>
<view class="mine__nav" :style="{ height: navBarHeight + 'px', paddingRight: (capsulePadding || 12) + 'px' }">
<text class="mine__nav-title">个人中心</text>
</view>
<view class="mine__user" @click="goLogin">
<view class="mine__avatar">
<text>{{ nick.slice(0, 1) }}</text>
@@ -69,7 +72,7 @@
<view class="mine__version">同城分类信息 v1.1.0</view>
<view class="mine__tabbar-space"></view>
<fc-tabbar :current="3" />
<fc-tabbar :current="4" />
</view>
</template>
@@ -79,12 +82,15 @@ import memberApi from '@/common/api/member.js'
import { useUserStore } from '@/common/store/index.js'
import { iconUrl, loadUiConfig } from '@/common/store/ui.js'
import { formatTime } from '@/common/utils/format.js'
import { getNavMetrics } from '@/common/utils/navbar.js'
export default {
components: { FcTabbar },
data() {
return {
statusBarHeight: 20,
navBarHeight: 44,
capsulePadding: 0,
assets: {},
entries: [
{ iconKey: 'mine-post', text: '我的发布', url: '/pages/post/mine' },
@@ -138,7 +144,10 @@ export default {
},
onLoad() {
try {
this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight || 20
const m = getNavMetrics()
this.statusBarHeight = m.statusBarHeight
this.navBarHeight = m.navBarHeight
this.capsulePadding = m.capsulePadding
} catch (e) {}
loadUiConfig()
this.fetchAssets()
@@ -176,6 +185,18 @@ export default {
padding-bottom: 120rpx;
border-radius: 0 0 40rpx 40rpx;
}
.mine__nav {
display: flex;
align-items: center;
padding-left: 32rpx;
box-sizing: border-box;
}
.mine__nav-title {
color: #ffffff;
font-size: 36rpx;
font-weight: 700;
letter-spacing: 1rpx;
}
.mine__user {
display: flex;
align-items: center;

二进制文件未显示。

之后

宽度:  |  高度:  |  大小: 1.3 KiB

二进制
uniapp/static/icons/tab-category.png 普通文件

二进制文件未显示。

之后

宽度:  |  高度:  |  大小: 1.3 KiB

查看文件

@@ -0,0 +1,44 @@
/**
* 顶部导航栏与胶囊避让度量工具单测
*/
import { describe, it, expect } from './harness.mjs'
import { getNavMetrics } from '../common/utils/navbar.js'
describe('顶部导航栏 · 规范度量与胶囊避让', () => {
it('无 uni 环境或默认兜底时返回安全度量', () => {
const m = getNavMetrics()
expect(typeof m.statusBarHeight).toBe('number')
expect(typeof m.navBarHeight).toBe('number')
expect(typeof m.capsulePadding).toBe('number')
expect(typeof m.totalHeight).toBe('number')
expect(m.statusBarHeight >= 0).toBe(true)
expect(m.navBarHeight >= 38).toBe(true)
expect(m.totalHeight).toBe(m.statusBarHeight + m.navBarHeight)
})
it('模拟微信小程序环境精确计算胶囊避让与导航栏高度', () => {
const originalUni = globalThis.uni
try {
globalThis.uni = {
getSystemInfoSync: () => ({ statusBarHeight: 44, windowWidth: 390 }),
getMenuButtonBoundingClientRect: () => ({
left: 280,
right: 380,
top: 48,
bottom: 80,
width: 100,
height: 32,
}),
}
const m = getNavMetrics()
expect(m.statusBarHeight).toBe(44)
// capsulePadding = (390 - 280) + 8 = 118
expect(m.capsulePadding).toBe(118)
// navBarHeight = (48 - 44) * 2 + 32 = 40
expect(m.navBarHeight).toBe(40)
expect(m.totalHeight).toBe(84)
} finally {
globalThis.uni = originalUni
}
})
})

查看文件

@@ -16,5 +16,6 @@ await import('./publish.test.mjs')
await import('./e2e.flow.test.mjs')
await import('./v110.test.mjs')
await import('./integration.test.mjs')
await import('./navbar.test.mjs')
await run()

查看文件

@@ -0,0 +1,119 @@
/**
* 生成底部导航「分类」Tab 图标(常态与选中态)
* 采用 192x192 真实透明通道 PNG,带平滑抗锯齿
*/
import fs from 'node:fs'
import path from 'node:path'
import url from 'node:url'
import { encodePng } from './png-util.mjs'
const __dirname = path.dirname(url.fileURLToPath(import.meta.url))
const OUT_DIR = path.resolve(__dirname, '..', 'static', 'icons')
/**
* 16进制颜色解析为 RGBA 数组
* @param {string} hex 16进制颜色,如 #04874A
* @param {number} a 透明度 0~1
* @returns {number[]} [r, g, b, a255]
*/
function parseHex(hex, a = 1) {
const clean = hex.replace('#', '')
const r = parseInt(clean.substring(0, 2), 16)
const g = parseInt(clean.substring(2, 4), 16)
const b = parseInt(clean.substring(4, 6), 16)
return [r, g, b, Math.round(a * 255)]
}
/**
* 圆角矩形的带符号距离场(SDF)
* @param {number} px 当前像素 x
* @param {number} py 当前像素 y
* @param {number} cx 矩形中心 x
* @param {number} cy 矩形中心 y
* @param {number} hw 半宽
* @param {number} hh 半高
* @param {number} r 圆角半径
* @returns {number} 距离(负数在内部,正数在外部)
*/
function sdRoundRect(px, py, cx, cy, hw, hh, r) {
const dx = Math.abs(px - cx) - (hw - r)
const dy = Math.abs(py - cy) - (hh - r)
const ax = Math.max(dx, 0)
const ay = Math.max(dy, 0)
const outsideDist = Math.hypot(ax, ay)
const insideDist = Math.min(Math.max(dx, dy), 0)
return outsideDist + insideDist - r
}
/**
* 绘制分类 4 宫格方块图标
* @param {string} c1 主色(左上、右上、左下)
* @param {string} c2 强调色(右下)
* @returns {Buffer} PNG 二进制 Buffer
*/
function renderCategoryIcon(c1, c2) {
const W = 192
const H = 192
const rgba = Buffer.alloc(W * H * 4, 0)
const col1 = parseHex(c1)
const col2 = parseHex(c2)
// 4 个方块的中心与规格
const boxes = [
{ cx: 56, cy: 56, hw: 30, hh: 30, r: 10, col: col1 }, // 左上
{ cx: 136, cy: 56, hw: 30, hh: 30, r: 10, col: col1 }, // 右上
{ cx: 56, cy: 136, hw: 30, hh: 30, r: 10, col: col1 }, // 左下
{ cx: 136, cy: 136, hw: 30, hh: 30, r: 10, col: col2 }, // 右下
]
for (let y = 0; y < H; y++) {
for (let x = 0; x < W; x++) {
let finalA = 0
let finalR = 0
let finalG = 0
let finalB = 0
for (const box of boxes) {
const d = sdRoundRect(x + 0.5, y + 0.5, box.cx, box.cy, box.hw, box.hh, box.r)
// 抗锯齿平滑过渡 [-0.75, 0.75]
let cov = 0
if (d < -0.75) cov = 1
else if (d > 0.75) cov = 0
else cov = (0.75 - d) / 1.5
if (cov > 0) {
finalR = box.col[0]
finalG = box.col[1]
finalB = box.col[2]
finalA = Math.max(finalA, Math.round(cov * 255))
}
}
const idx = (y * W + x) * 4
rgba[idx] = finalR
rgba[idx + 1] = finalG
rgba[idx + 2] = finalB
rgba[idx + 3] = finalA
}
}
return encodePng({ width: W, height: H, rgba })
}
/**
* 主执行函数:输出常态与选中态图标
*/
function main() {
// 常态:灰绿 #7C9A8B / #B4CDC0
const offBuf = renderCategoryIcon('#7C9A8B', '#B4CDC0')
fs.writeFileSync(path.join(OUT_DIR, 'tab-category.png'), offBuf)
console.log('✅ 生成 tab-category.png 完成')
// 选中态:品牌春绿 #04874A / #A9F2CE
const onBuf = renderCategoryIcon('#04874A', '#A9F2CE')
fs.writeFileSync(path.join(OUT_DIR, 'tab-category-on.png'), onBuf)
console.log('✅ 生成 tab-category-on.png 完成')
}
main()

查看文件

@@ -123,6 +123,7 @@ $fc-bg: #f2fef7;
$fc-bg-card: #ffffff;
$fc-bg-hover: #e4fdf0;
$fc-border: #d6f3e3;
$fc-shadow-sm: 0 4rpx 14rpx rgba(4, 48, 30, 0.06);
$fc-shadow: 0 6rpx 24rpx rgba(4, 48, 30, 0.12);
$fc-shadow-lg: 0 12rpx 40rpx rgba(4, 48, 30, 0.18);
$fc-shadow-gold: 0 10rpx 28rpx rgba(245, 166, 35, 0.28);
@@ -136,7 +137,8 @@ $fc-price: #e0891b;
/* 圆角 / 间距 */
$fc-radius-sm: 8rpx;
$fc-radius: 16rpx;
$fc-radius: 16rpx;
$fc-radius-md: 16rpx;
$fc-radius-lg: 24rpx;
$fc-radius-pill: 999rpx;
$fc-gap-xs: 8rpx;