diff --git a/src/card/index.js b/src/card/index.js
index 1b673fee5..3d1d6fb7f 100644
--- a/src/card/index.js
+++ b/src/card/index.js
@@ -28,154 +28,145 @@ export default createComponent({
emits: ['click-thumb'],
setup(props, { slots, emit }) {
- return () => {
- const { thumb } = props;
+ const renderTitle = () => {
+ if (slots.title) {
+ return slots.title();
+ }
+ if (props.title) {
+ return (
+
+ {props.title}
+
+ );
+ }
+ };
+
+ const renderThumbTag = () => {
+ if (slots.tag || props.tag) {
+ return (
+
+ {slots.tag ? (
+ slots.tag()
+ ) : (
+
+ {props.tag}
+
+ )}
+
+ );
+ }
+ };
+
+ const renderThumbImage = () => {
+ if (slots.thumb) {
+ return slots.thumb();
+ }
+
+ return (
+
+ );
+ };
+
+ const renderThumb = () => {
+ if (slots.thumb || props.thumb) {
+ return (
+ {
+ emit('click-thumb', event);
+ }}
+ >
+ {renderThumbImage()}
+ {renderThumbTag()}
+
+ );
+ }
+ };
+
+ const renderDesc = () => {
+ if (slots.desc) {
+ return slots.desc();
+ }
+
+ if (props.desc) {
+ return {props.desc}
;
+ }
+ };
+
+ const renderPriceText = () => {
+ const priceArr = props.price.toString().split('.');
+ return (
+
+ {props.currency}
+ {priceArr[0]}.
+ {priceArr[1]}
+
+ );
+ };
+
+ return () => {
const showNum = slots.num || isDef(props.num);
const showPrice = slots.price || isDef(props.price);
const showOriginPrice = slots['origin-price'] || isDef(props.originPrice);
const showBottom =
showNum || showPrice || showOriginPrice || slots.bottom;
- function onThumbClick(event) {
- emit('click-thumb', event);
- }
+ const Price = showPrice && (
+
+ {slots.price ? slots.price() : renderPriceText()}
+
+ );
- function ThumbTag() {
- if (slots.tag || props.tag) {
- return (
-
- {slots.tag ? (
- slots.tag()
- ) : (
-
- {props.tag}
-
- )}
-
- );
- }
- }
+ const OriginPrice = showOriginPrice && (
+
+ {slots['origin-price']
+ ? slots['origin-price']()
+ : `${props.currency} ${props.originPrice}`}
+
+ );
- function Thumb() {
- if (slots.thumb || thumb) {
- return (
-
- {slots.thumb ? (
- slots.thumb()
- ) : (
-
- )}
- {ThumbTag()}
-
- );
- }
- }
+ const Num = showNum && (
+
+ {slots.num ? slots.num() : `x${props.num}`}
+
+ );
- function Title() {
- if (slots.title) {
- return slots.title();
- }
+ const Footer = slots.footer && (
+
+ );
- if (props.title) {
- return (
-
- {props.title}
-
- );
- }
- }
-
- function Desc() {
- if (slots.desc) {
- return slots.desc();
- }
-
- if (props.desc) {
- return {props.desc}
;
- }
- }
-
- function PriceContent() {
- const priceArr = props.price.toString().split('.');
- return (
-
- {props.currency}
- {priceArr[0]}.
- {priceArr[1]}
-
- );
- }
-
- function Price() {
- if (showPrice) {
- return (
-
- {slots.price ? slots.price() : PriceContent()}
-
- );
- }
- }
-
- function OriginPrice() {
- if (showOriginPrice) {
- const slot = slots['origin-price'];
- return (
-
- {slot ? slot() : `${props.currency} ${props.originPrice}`}
-
- );
- }
- }
-
- function Num() {
- if (showNum) {
- return (
-
- {slots.num ? slots.num() : `x${props.num}`}
-
- );
- }
- }
-
- function Footer() {
- if (slots.footer) {
- return ;
- }
- }
+ const Bottom = showBottom && (
+
+ {slots['price-top']?.()}
+ {Price}
+ {OriginPrice}
+ {Num}
+ {slots.bottom?.()}
+
+ );
return (
- {Footer()}
+ {Footer}
);
};