import { use, isDef } from '../utils'; import Tag from '../tag'; const [sfc, bem] = use('card'); export default sfc({ 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: '¥' } }, render(h) { const { thumb, $slots: slots } = this; const showThumb = slots.thumb || thumb; const showTag = slots.tag || this.tag; const showNum = slots.num || isDef(this.num); const showPrice = slots.price || isDef(this.price); const showOriginPrice = slots['origin-price'] || isDef(this.originPrice); const Thumb = showThumb && ( {slots.thumb || (this.lazyLoad ? ( ) : ( ))} {showTag && (
{slots.tag || ( {this.tag} )}
)}
); const Title = slots.title || (this.title &&
{this.title}
); const Desc = slots.desc || (this.desc &&
{this.desc}
); const Price = showPrice && (
{slots.price || `${this.currency} ${this.price}`}
); const OriginPrice = showOriginPrice && (
{slots['origin-price'] || `${this.currency} ${this.originPrice}`}
); const Num = showNum &&
{slots.num || `x ${this.num}`}
; const Footer = slots.footer &&
{slots.footer}
; return (
{Thumb}
{Title} {Desc} {slots.tags}
{Price} {OriginPrice} {Num}
{Footer}
); } });