diff --git a/application/api/controller/Home.php b/application/api/controller/Home.php index c2d83b3..37e29fe 100644 --- a/application/api/controller/Home.php +++ b/application/api/controller/Home.php @@ -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) diff --git a/uniapp/common/assets/icons.js b/uniapp/common/assets/icons.js index d1a300a..3ee2de3 100644 --- a/uniapp/common/assets/icons.js +++ b/uniapp/common/assets/icons.js @@ -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' }, ], diff --git a/uniapp/common/config/index.js b/uniapp/common/config/index.js index 8f360f4..adbf6c4 100644 --- a/uniapp/common/config/index.js +++ b/uniapp/common/config/index.js @@ -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', // 远程正式后端 } // 接口统一前缀 diff --git a/uniapp/common/utils/navbar.js b/uniapp/common/utils/navbar.js new file mode 100644 index 0000000..0db7644 --- /dev/null +++ b/uniapp/common/utils/navbar.js @@ -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, +} diff --git a/uniapp/common/utils/request.js b/uniapp/common/utils/request.js index 307ccf7..0867ba4 100644 --- a/uniapp/common/utils/request.js +++ b/uniapp/common/utils/request.js @@ -46,6 +46,24 @@ export function buildHeaders(extra = {}) { * 底层请求(返回 Promise) * @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) { diff --git a/uniapp/components/fc-navbar/fc-navbar.vue b/uniapp/components/fc-navbar/fc-navbar.vue index 47abbb5..0062197 100644 --- a/uniapp/components/fc-navbar/fc-navbar.vue +++ b/uniapp/components/fc-navbar/fc-navbar.vue @@ -1,15 +1,26 @@ + + diff --git a/uniapp/pages/distribution/index.vue b/uniapp/pages/distribution/index.vue index 3ce0e4a..24a087f 100644 --- a/uniapp/pages/distribution/index.vue +++ b/uniapp/pages/distribution/index.vue @@ -1,8 +1,10 @@