import { use, isDef } from '../utils';
import { inherit } from '../utils/functional';
import Tag from '../tag';
const [sfc, bem] = use('card');
function Card(h, props, slots, ctx) {
const { thumb } = props;
const showThumb = slots.thumb || thumb;
const showTag = slots.tag || props.tag;
const showNum = slots.num || isDef(props.num);
const showPrice = slots.price || isDef(props.price);
const showOriginPrice = slots['origin-price'] || isDef(props.originPrice);
const Thumb = showThumb && (
{slots.thumb ? (
slots.thumb()
) : props.lazyLoad ? (
) : (
)}
{showTag && (
{slots.tag ? (
slots.tag()
) : (
{props.tag}
)}
)}
);
const Title = slots.title
? slots.title()
: props.title &&
{props.title}
;
const Desc = slots.desc
? slots.desc()
: props.desc && (
{props.desc}
);
const Price = showPrice && (
{slots.price ? slots.price() : `${props.currency} ${props.price}`}
);
const OriginPrice = showOriginPrice && (
{slots['origin-price']
? slots['origin-price']
: `${props.currency} ${props.originPrice}`}
);
const Num = showNum && (
{slots.num ? slots.num() : `x ${props.num}`}
);
const Footer = slots.footer && (
);
return (
{Footer}
);
}
Card.props = {
tag: String,
desc: String,
thumb: String,
title: String,
centered: Boolean,
lazyLoad: Boolean,
thumbLink: String,
num: [Number, String],
price: [Number, String],
originPrice: [Number, String],
currency: {
type: String,
default: '¥'
}
};
export default sfc(Card);