feat(index): 添加首页快捷服务组件
- 在首页添加 QuickActions 组件展示常用功能 - 实现 2x2 网格布局的快捷操作卡片 - 集成分销商、客户管理、邀请好友、钱包等功能入口 - 添加登录验证机制确保功能访问安全 - 创建详细的项目长期记忆文档 MEMORU.md - 实现响应式设计和交互反馈效果
This commit is contained in:
116
src/pages/index/QuickActions.tsx
Normal file
116
src/pages/index/QuickActions.tsx
Normal file
@@ -0,0 +1,116 @@
|
||||
import React from 'react'
|
||||
import { View, Text } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import {
|
||||
Star,
|
||||
People,
|
||||
AddCircle,
|
||||
Wallet
|
||||
} from '@nutui/icons-react-taro'
|
||||
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[] = [
|
||||
{
|
||||
icon: <Star size={26} />,
|
||||
title: '我要推荐',
|
||||
subtitle: '推荐赚佣金',
|
||||
path: '/dealer/index',
|
||||
needLogin: true,
|
||||
bgColor: 'rgba(255, 147, 0, 0.08)',
|
||||
iconColor: '#FF9300',
|
||||
gradient: 'linear-gradient(135deg, #FF9300 0%, #FFB347 100%)'
|
||||
},
|
||||
{
|
||||
icon: <People size={26} />,
|
||||
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%)'
|
||||
},
|
||||
{
|
||||
icon: <AddCircle size={26} />,
|
||||
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%)'
|
||||
},
|
||||
{
|
||||
icon: <Wallet size={26} />,
|
||||
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%)'
|
||||
}
|
||||
]
|
||||
|
||||
const handleClick = (action: QuickActionItem) => {
|
||||
if (action.needLogin) {
|
||||
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'>
|
||||
<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>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default QuickActions
|
||||
Reference in New Issue
Block a user