forked from gxwebsoft/mp-10550
refactor(components): 重构 CouponCard 组件样式
- 优化了 CouponCard 组件的视觉效果,增加了更多细节和动画 - 添加了响应式样式,提高了移动端体验 - 新增了 CouponList组件样式,用于展示优惠券列表
This commit is contained in:
@@ -1,46 +1,38 @@
|
||||
import Taro from '@tarojs/taro'
|
||||
import {useEffect, useState} from 'react'
|
||||
import {Image} from '@nutui/nutui-react-taro'
|
||||
import {Loading} from '@nutui/nutui-react-taro'
|
||||
import {listCmsNavigation} from "@/api/cms/cmsNavigation"
|
||||
import {CmsNavigation} from "@/api/cms/cmsNavigation/model"
|
||||
import {goTo} from "@/utils/navigation"
|
||||
import {useShopInfo} from "@/hooks/useShopInfo"
|
||||
|
||||
const Page = () => {
|
||||
// 使用 useShopInfo hooks 获取导航数据
|
||||
const {
|
||||
loading: shopLoading,
|
||||
error,
|
||||
getNavigation
|
||||
} = useShopInfo()
|
||||
|
||||
const [loading, setLoading] = useState<boolean>(true)
|
||||
const [navItems, setNavItems] = useState<CmsNavigation[]>([])
|
||||
// 获取顶部导航菜单
|
||||
const navigation = getNavigation()
|
||||
const home = navigation.topNavs.find(item => item.model == 'index')
|
||||
const navItems = navigation.topNavs.filter(item => item.parentId == home?.navigationId) || []
|
||||
|
||||
const reload = async () => {
|
||||
// 读取首页菜单
|
||||
const home = await listCmsNavigation({model: 'index'});
|
||||
if (home && home.length > 0) {
|
||||
// 读取首页导航条
|
||||
const menus = await listCmsNavigation({parentId: home[0].navigationId, hide: 0});
|
||||
setNavItems(menus || [])
|
||||
const onNav = (item: any) => {
|
||||
if (item.path) {
|
||||
return goTo(`${item.path}`)
|
||||
}
|
||||
};
|
||||
|
||||
const onNav = (row: CmsNavigation) => {
|
||||
console.log('nav = ', row)
|
||||
console.log('path = ', `/${row.model}${row.path}`)
|
||||
if (row.model == 'goods') {
|
||||
return Taro.navigateTo({url: `/shop/category/index?id=${row.navigationId}`})
|
||||
}
|
||||
if (row.model == 'article') {
|
||||
return Taro.navigateTo({url: `/cms/category/index?id=${row.navigationId}`})
|
||||
}
|
||||
return Taro.navigateTo({url: `${row.path}`})
|
||||
}
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
reload().then(() => {
|
||||
setLoading(false)
|
||||
});
|
||||
}, [])
|
||||
// 处理错误状态
|
||||
if (error) {
|
||||
return (
|
||||
<div className={'p-2 text-center text-red-500'}>
|
||||
加载导航菜单失败
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
loading ? (<Loading>加载中</Loading>) :
|
||||
shopLoading ? (<Loading>加载中</Loading>) :
|
||||
<div className={'p-2 z-50 mt-1'}>
|
||||
<div className={'flex justify-between pb-2 p-2 bg-white rounded-xl shadow-sm'}>
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@ import {Search} from '@nutui/icons-react-taro'
|
||||
import {Button, Input} from '@nutui/nutui-react-taro'
|
||||
import {useState} from "react";
|
||||
import Taro from '@tarojs/taro';
|
||||
import { goTo } from '@/utils/navigation';
|
||||
|
||||
function MySearch() {
|
||||
const [keywords, setKeywords] = useState<string>('')
|
||||
@@ -18,17 +19,13 @@ function MySearch() {
|
||||
});
|
||||
return false;
|
||||
}
|
||||
// 跳转到搜索页面
|
||||
Taro.navigateTo({
|
||||
url: `/shop/search/index?keywords=${encodeURIComponent(keywords.trim())}`
|
||||
});
|
||||
// 跳转到搜索页面 - 使用新的导航工具,自动处理路径和参数
|
||||
goTo('shop/search/index', { keywords: keywords.trim() });
|
||||
}
|
||||
|
||||
// 点击搜索框跳转到搜索页面
|
||||
const onInputFocus = () => {
|
||||
Taro.navigateTo({
|
||||
url: '/shop/search/index'
|
||||
});
|
||||
goTo('shop/search/index');
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user