Files
hms/apps/miniprogram/src/components/ui/ShortcutButton/index.tsx
iven ded37830fe feat(mp): 新增 AvatarCircle/ShortcutButton/TodoAlert 组件 + 商品详情页
- AvatarCircle: 头像圆形组件
- ShortcutButton: 快捷操作按钮
- TodoAlert: 待办提醒组件
- pkg-mall/product: 积分商品详情页
2026-05-18 02:12:58 +08:00

40 lines
933 B
TypeScript

import React from 'react';
import { View, Text } from '@tarojs/components';
import './index.scss';
type ButtonColor = 'pri' | 'acc' | 'wrn' | 'dan';
interface ShortcutButtonProps {
icon: string;
label: string;
color?: ButtonColor;
onPress?: () => void;
badge?: number;
}
const ShortcutButton: React.FC<ShortcutButtonProps> = ({
icon,
label,
color = 'pri',
onPress,
badge,
}) => {
const cls = ['shortcut-btn', `shortcut-btn--${color}`].join(' ');
return (
<View className={cls} onClick={onPress}>
<View className="shortcut-btn__icon-wrap">
<Text className="shortcut-btn__icon">{icon}</Text>
{badge != null && badge > 0 && (
<Text className="shortcut-btn__badge">
{badge > 99 ? '99+' : badge}
</Text>
)}
</View>
<Text className="shortcut-btn__label">{label}</Text>
</View>
);
};
export default React.memo(ShortcutButton);