diff --git a/config/env.ts b/config/env.ts
index 16c21e5..eb27c6c 100644
--- a/config/env.ts
+++ b/config/env.ts
@@ -2,8 +2,8 @@
export const ENV_CONFIG = {
// 开发环境
development: {
- // API_BASE_URL: 'http://127.0.0.1:9200/api',
- API_BASE_URL: 'https://cms-api.websoft.top/api',
+ API_BASE_URL: 'http://127.0.0.1:9200/api',
+ // API_BASE_URL: 'https://cms-api.websoft.top/api',
APP_NAME: '开发环境',
DEBUG: 'true',
},
diff --git a/src/dealer/apply/add.tsx b/src/dealer/apply/add.tsx
index f862bf3..f49ff09 100644
--- a/src/dealer/apply/add.tsx
+++ b/src/dealer/apply/add.tsx
@@ -383,7 +383,7 @@ const AddUserAddress = () => {
-
+
diff --git a/src/pages/index/Banner.tsx b/src/pages/index/Banner.tsx
index 32400d4..48aa7c9 100644
--- a/src/pages/index/Banner.tsx
+++ b/src/pages/index/Banner.tsx
@@ -6,13 +6,38 @@ import {Image} from '@nutui/nutui-react-taro'
import {getCmsAdByCode} from "@/api/cms/cmsAd";
import navTo from "@/utils/common";
import {pageCmsArticle} from "@/api/cms/cmsArticle";
-import {CmsArticle} from "@/api/cms/cmsArticle/model";
+type AdImage = {
+ url?: string
+ path?: string
+ title?: string
+ // Compatible keys (some backends use different fields)
+ src?: string
+ imageUrl?: string
+}
+
+function normalizeAdImages(ad?: CmsAd): AdImage[] {
+ const list = ad?.imageList
+ if (Array.isArray(list) && list.length) return list as AdImage[]
+
+ // Some APIs only return `images` as a JSON string.
+ const raw = ad?.images
+ if (!raw) return []
+ try {
+ const parsed = JSON.parse(raw)
+ return Array.isArray(parsed) ? (parsed as AdImage[]) : []
+ } catch {
+ return []
+ }
+}
+
+function toNumberPx(input: unknown, fallback: number) {
+ const n = typeof input === 'number' ? input : Number.parseInt(String(input ?? ''), 10)
+ return Number.isFinite(n) ? n : fallback
+}
const MyPage = () => {
const [carouselData, setCarouselData] = useState()
- const [hotToday, setHotToday] = useState()
- const [item, setItem] = useState()
const [loading, setLoading] = useState(true)
// const [disableSwiper, setDisableSwiper] = useState(false)
@@ -21,24 +46,21 @@ const MyPage = () => {
// 加载数据
const loadData = async () => {
+ setLoading(true)
try {
- setLoading(true)
- // 轮播图
- const flash = await getCmsAdByCode('flash')
- // 今日热卖
- const hotToday = await getCmsAdByCode('hot_today')
- // 时里动态
- const news = await pageCmsArticle({limit:1,recommend:1})
- // 赋值
- if(flash){
- setCarouselData(flash)
- }
- if(hotToday){
- setHotToday(hotToday)
- }
- if(news && news.list.length > 0){
- setItem(news.list[0])
+ const [flashRes] = await Promise.allSettled([
+ getCmsAdByCode('flash'),
+ getCmsAdByCode('hot_today'),
+ pageCmsArticle({ limit: 1, recommend: 1 }),
+ ])
+
+ if (flashRes.status === 'fulfilled') {
+ console.log('flashflashflash', flashRes.value)
+ setCarouselData(flashRes.value)
+ } else {
+ console.error('Failed to fetch flash:', flashRes.reason)
}
+
} catch (error) {
console.error('Banner数据加载失败:', error)
} finally {
@@ -47,11 +69,13 @@ const MyPage = () => {
}
useEffect(() => {
- loadData()
+ loadData().then()
}, [])
// 轮播图高度,默认300px
- const carouselHeight = carouselData?.height || 300;
+ const carouselHeight = toNumberPx(carouselData?.height, 300)
+ const carouselImages = normalizeAdImages(carouselData)
+ console.log(carouselImages,'carouselImages')
// 骨架屏组件
const BannerSkeleton = () => (
@@ -100,94 +124,42 @@ const MyPage = () => {
}
return (
-
- {/* 左侧轮播图区域 */}
-
-
- {carouselData && carouselData?.imageList?.map((img, index) => (
-
- navTo(`${img.path}`)}
- lazyLoad={false}
- style={{
- height: `${carouselHeight}px`,
- borderRadius: '4px',
- touchAction: 'manipulation' // 关键修改:优化触摸操作
- }}
- />
-
- ))}
-
-
-
- {/* 右侧上下图片区域 - 从API获取数据 */}
-
- {/* 上层图片 - 使用今日热卖素材 */}
-
- 今日热卖
-
- {
- hotToday?.imageList?.map(item => (
-
- navTo('/shop/category/index?id=4424')}
- />
- {item.title || '到手价¥9.9'}
-
- ))
- }
-
-
-
- {/* 下层图片 - 使用社区拼团素材 */}
-
- 走进社区
-
+
+ {carouselImages.map((img, index) => {
+ const src = img.url || img.src || img.imageUrl
+ if (!src) return null
+ return (
+
(img.path ? navTo(`${img.path}`) : undefined)}
lazyLoad={false}
style={{
- borderRadius: '4px'
+ height: `${carouselHeight}px`,
+ borderRadius: '4px',
+ touchAction: 'manipulation' // 关键修改:优化触摸操作
}}
- onClick={() => navTo('cms/detail/index?id=' + item?.articleId)}
/>
-
-
-
-
+
+ )
+ })}
+
)
}
diff --git a/src/pages/index/MySearch.tsx b/src/pages/index/MySearch.tsx
index 3c6d9a5..2015ee6 100644
--- a/src/pages/index/MySearch.tsx
+++ b/src/pages/index/MySearch.tsx
@@ -30,7 +30,7 @@ function MySearch(props: any) {
return (
-
+
- {/* 顶部活动主视觉 */}
-
-
-
-
-
-
- 桂乐淘
-
-
- 新人有礼
-
-
- 202X年X月X日 - X月X日
-
-
-
-
- 大容量家庭装
- 净含量15L
-
-
-
-
-
-
-
- 山泉水
-
-
-
-
-
+ {/* 顶部活动主视觉:使用 Banner 组件 */}
+
{/* 电子水票 */}
@@ -283,7 +253,7 @@ function Home() {
diff --git a/src/pages/user/components/IsDealer.tsx b/src/pages/user/components/IsDealer.tsx
index a5fd05e..6c001f0 100644
--- a/src/pages/user/components/IsDealer.tsx
+++ b/src/pages/user/components/IsDealer.tsx
@@ -51,7 +51,7 @@ const IsDealer = () => {
{config?.vipText || '入驻申请'}
+ className={'pl-3 text-orange-100 font-medium'}>{config?.vipText || '门店入驻'}
{/*门店核销*/}
}
@@ -75,8 +75,8 @@ const IsDealer = () => {
title={
- {config?.vipText || '开通VIP'}
- {config?.vipComments || '享优惠'}
+ {config?.vipText || '门店入驻'}
+ {config?.vipComments || ''}
}
extra={}