From 61397b1711755e6866bc2d24f69778eeb5dae689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Wed, 4 Mar 2026 11:17:06 +0800 Subject: [PATCH] =?UTF-8?q?feat(home):=20=E6=B7=BB=E5=8A=A0=E5=B8=B8?= =?UTF-8?q?=E8=A7=81=E9=97=AE=E9=A2=98=E5=8A=A8=E6=80=81=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=B9=B6=E4=BC=98=E5=8C=96=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 集成 CMS API 动态加载常见问题列表数据 - 实现常见问题列表点击跳转详情页功能 - 调整查找页面侧边栏宽度从 160rpx 到 120rpx - 优化导航箭头图标尺寸和边框样式 - 修改距离显示格式从"距离xxx"到直接显示距离值 - 更新滚动容器高度计算并移除固定总数显示 - 将距离单位从 --- src/pages/find/find.scss | 12 ++++---- src/pages/find/find.tsx | 11 ++----- src/pages/index/index.tsx | 63 +++++++++++++++++++++++++++++---------- 3 files changed, 57 insertions(+), 29 deletions(-) diff --git a/src/pages/find/find.scss b/src/pages/find/find.scss index f9171b6..aed8e22 100644 --- a/src/pages/find/find.scss +++ b/src/pages/find/find.scss @@ -102,7 +102,7 @@ page { } .siteSide { - width: 160rpx; + width: 120rpx; flex: 0 0 160rpx; display: flex; flex-direction: column; @@ -112,13 +112,13 @@ page { } .navArrow { - width: 34rpx; - height: 34rpx; - border-top: 8rpx solid #e60012; - border-right: 8rpx solid #e60012; + width: 14rpx; + height: 14rpx; + border-top: 5rpx solid #e60012; + border-right: 5rpx solid #e60012; border-radius: 4rpx; transform: rotate(45deg); - margin-right: 8rpx; + margin-right: 6rpx; } .distanceText { diff --git a/src/pages/find/find.tsx b/src/pages/find/find.tsx index e3548ad..69ee6cc 100644 --- a/src/pages/find/find.tsx +++ b/src/pages/find/find.tsx @@ -48,7 +48,7 @@ const formatDistance = (meter: number | undefined) => { const m = Math.max(0, Math.round(meter as number)) if (m < 1000) return `${m}米` const km = m / 1000 - return `${km.toFixed(km >= 10 ? 0 : 1)}公里` + return `${km.toFixed(km >= 10 ? 0 : 1)}km` } const Find = () => { @@ -181,7 +181,7 @@ const Find = () => { loadStores(true)} headHeight={60}> - + {viewList.length === 0 && !loading ? ( @@ -240,7 +240,7 @@ const Find = () => { onNavigate(item)}> - {distanceText ? `距离${distanceText}` : '查看导航'} + {distanceText ? `${distanceText}` : '查看导航'} @@ -249,11 +249,6 @@ const Find = () => { })} - {total > 0 && ( - - 共 {total} 个网点 - - )} )} diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index f8fa72d..ec8062b 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -1,10 +1,13 @@ import Taro, {useShareAppMessage, useShareTimeline} from '@tarojs/taro' import {Image, Swiper, SwiperItem, Text, View} from '@tarojs/components' +import {useEffect, useState} from 'react' import iconShop from '@/assets/tabbar/shop.png' import iconFind from '@/assets/tabbar/find.png' import iconKefu from '@/assets/tabbar/kefu.png' import './index.scss' import navTo from "@/utils/common"; +import {pageCmsArticle} from '@/api/cms/cmsArticle' +import type {CmsArticle} from '@/api/cms/cmsArticle/model' function Home() { useShareTimeline(() => { @@ -41,6 +44,29 @@ function Home() { Taro.showToast({title: '发需求(示例)', icon: 'none'}) } + const FAQ_CATEGORY_ID = 4558 + const [faqList, setFaqList] = useState([]) + + const loadFaq = async () => { + try { + const res = await pageCmsArticle({ + categoryId: FAQ_CATEGORY_ID, + page: 1, + limit: 5, + status: 0 + }) + setFaqList(res?.list || []) + } catch (e) { + console.error('loadFaq error:', e) + setFaqList([]) + Taro.showToast({title: '常见问题加载失败', icon: 'none'}) + } + } + + useEffect(() => { + loadFaq().then() + }, []) + return ( @@ -123,25 +149,32 @@ function Home() { 常见问题解答 - 更多>> + navTo(`/cms/category/index?id=${FAQ_CATEGORY_ID}`)} + > + 更多>> + - {[ - {title: '常见问题一', date: '2025-11-12'}, - {title: '常见问题二', date: '2025-11-12'}, - {title: '常见问题三', date: '2025-11-12'}, - {title: '常见问题四', date: '2025-11-12'}, - {title: '常见问题五', date: '2025-11-12'} - ].map((item, idx, arr) => ( - - {item.title} - {item.date} + {faqList.length > 0 ? ( + faqList.map((item, idx, arr) => ( + item.articleId && navTo(`/cms/detail/index?id=${item.articleId}`)} + > + {item.title} + {(item.createTime || '').slice(0, 10)} + + )) + ) : ( + + 暂无常见问题 + - ))} + )}