refactor(QuickActions): 重构快捷操作组件样式和结构
- 将网格布局改为行布局,优化响应式显示效果 - 简化登录验证逻辑,移除不必要的配置项 - 更新图标尺寸从26px到28px,提升视觉体验 - 移除子标题显示,简化界面元素 - 重构CSS类名,统一命名规范 - 优化渐变背景色实现,增强视觉层次感 - 调整内边距和间距,改善整体布局美观度
This commit is contained in:
@@ -10,104 +10,83 @@ import {
|
||||
import navTo from '@/utils/common'
|
||||
import './QuickActions.scss'
|
||||
|
||||
interface QuickActionItem {
|
||||
icon: React.ReactNode
|
||||
title: string
|
||||
subtitle?: string
|
||||
path: string
|
||||
needLogin: boolean
|
||||
bgColor: string
|
||||
iconColor: string
|
||||
gradient: string
|
||||
}
|
||||
|
||||
const QuickActions: React.FC = () => {
|
||||
|
||||
const actions: QuickActionItem[] = [
|
||||
const actions = [
|
||||
{
|
||||
icon: <Star size={26} />,
|
||||
icon: <Star size={28} />,
|
||||
title: '我要推荐',
|
||||
subtitle: '推荐赚佣金',
|
||||
path: '/dealer/index',
|
||||
needLogin: true,
|
||||
bgColor: 'rgba(255, 147, 0, 0.08)',
|
||||
iconColor: '#FF9300',
|
||||
gradient: 'linear-gradient(135deg, #FF9300 0%, #FFB347 100%)'
|
||||
path: '/dealer/index'
|
||||
},
|
||||
{
|
||||
icon: <People size={26} />,
|
||||
icon: <People size={28} />,
|
||||
title: '我的客户',
|
||||
subtitle: '查看客户列表',
|
||||
path: '/dealer/customer/index',
|
||||
needLogin: true,
|
||||
bgColor: 'rgba(59, 130, 246, 0.08)',
|
||||
iconColor: '#3B82F6',
|
||||
gradient: 'linear-gradient(135deg, #3B82F6 0%, #60A5FA 100%)'
|
||||
path: '/dealer/customer/index'
|
||||
},
|
||||
{
|
||||
icon: <AddCircle size={26} />,
|
||||
icon: <AddCircle size={28} />,
|
||||
title: '邀请好友',
|
||||
subtitle: '分享赚收益',
|
||||
path: '/dealer/qrcode/index',
|
||||
needLogin: true,
|
||||
bgColor: 'rgba(16, 185, 129, 0.08)',
|
||||
iconColor: '#10B981',
|
||||
gradient: 'linear-gradient(135deg, #10B981 0%, #34D399 100%)'
|
||||
path: '/dealer/qrcode/index'
|
||||
},
|
||||
{
|
||||
icon: <Wallet size={26} />,
|
||||
icon: <Wallet size={28} />,
|
||||
title: '我的钱包',
|
||||
subtitle: '收益与提现',
|
||||
path: '/user/wallet/wallet',
|
||||
needLogin: true,
|
||||
bgColor: 'rgba(139, 92, 246, 0.08)',
|
||||
iconColor: '#8B5CF6',
|
||||
gradient: 'linear-gradient(135deg, #8B5CF6 0%, #A78BFA 100%)'
|
||||
path: '/user/wallet/wallet'
|
||||
}
|
||||
]
|
||||
|
||||
const handleClick = (action: QuickActionItem) => {
|
||||
if (action.needLogin) {
|
||||
if (!Taro.getStorageSync('access_token') || !Taro.getStorageSync('UserId')) {
|
||||
Taro.showToast({
|
||||
title: '请先登录',
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
})
|
||||
return
|
||||
}
|
||||
const handleClick = (action: { path: string }) => {
|
||||
if (!Taro.getStorageSync('access_token') || !Taro.getStorageSync('UserId')) {
|
||||
Taro.showToast({
|
||||
title: '请先登录',
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
})
|
||||
return
|
||||
}
|
||||
navTo(action.path)
|
||||
}
|
||||
|
||||
return (
|
||||
<View className='quick-actions'>
|
||||
<View className='quick-actions__title-row'>
|
||||
<View className='quick-actions__header'>
|
||||
<Text className='quick-actions__title'>快捷服务</Text>
|
||||
<Text className='quick-actions__subtitle'>为您精选常用功能</Text>
|
||||
</View>
|
||||
<View className='quick-actions__grid'>
|
||||
{actions.map((action, index) => (
|
||||
<View
|
||||
key={index}
|
||||
className='quick-actions__item'
|
||||
onClick={() => handleClick(action)}
|
||||
>
|
||||
<View className='quick-actions__icon-wrap'>
|
||||
<View
|
||||
className='quick-actions__icon-bg'
|
||||
style={{ background: action.gradient }}
|
||||
/>
|
||||
<View className='quick-actions__icon-inner'>
|
||||
{React.cloneElement(action.icon as React.ReactElement, {
|
||||
color: '#ffffff'
|
||||
})}
|
||||
</View>
|
||||
</View>
|
||||
<Text className='quick-actions__item-title'>{action.title}</Text>
|
||||
<Text className='quick-actions__item-subtitle'>{action.subtitle}</Text>
|
||||
<View className='quick-actions__row'>
|
||||
<View className='quick-actions__item' onClick={() => handleClick(actions[0])}>
|
||||
<View className='quick-actions__icon-box'>
|
||||
{React.cloneElement(actions[0].icon as React.ReactElement, { color: '#ffffff' })}
|
||||
</View>
|
||||
))}
|
||||
<Text className='quick-actions__item-title'>{actions[0].title}</Text>
|
||||
<Text className='quick-actions__item-desc'>{actions[0].subtitle}</Text>
|
||||
</View>
|
||||
<View className='quick-actions__item' onClick={() => handleClick(actions[1])}>
|
||||
<View className='quick-actions__icon-box quick-actions__icon-box--light'>
|
||||
{React.cloneElement(actions[1].icon as React.ReactElement, { color: '#ffffff' })}
|
||||
</View>
|
||||
<Text className='quick-actions__item-title'>{actions[1].title}</Text>
|
||||
<Text className='quick-actions__item-desc'>{actions[1].subtitle}</Text>
|
||||
</View>
|
||||
</View>
|
||||
<View className='quick-actions__row'>
|
||||
<View className='quick-actions__item' onClick={() => handleClick(actions[2])}>
|
||||
<View className='quick-actions__icon-box quick-actions__icon-box--deep'>
|
||||
{React.cloneElement(actions[2].icon as React.ReactElement, { color: '#ffffff' })}
|
||||
</View>
|
||||
<Text className='quick-actions__item-title'>{actions[2].title}</Text>
|
||||
<Text className='quick-actions__item-desc'>{actions[2].subtitle}</Text>
|
||||
</View>
|
||||
<View className='quick-actions__item' onClick={() => handleClick(actions[3])}>
|
||||
<View className='quick-actions__icon-box quick-actions__icon-box--navy'>
|
||||
{React.cloneElement(actions[3].icon as React.ReactElement, { color: '#ffffff' })}
|
||||
</View>
|
||||
<Text className='quick-actions__item-title'>{actions[3].title}</Text>
|
||||
<Text className='quick-actions__item-desc'>{actions[3].subtitle}</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user