import * as React from 'react'; import { Props, State } from './type'; import * as Styled from './index.style' import { formatImage } from '../utils/imgResize'; import {getCouponData4Show} from '../utils/lofterMarket' export class Container extends React.Component { public static defaultProps = new Props(); public state = new State(); private gotoProduct(id:any) { location.href = `//www.lofter.com/benefit/main/product?productId=${id}`; } public render() { let {backgroundImage, containerType, style, list, numbers=1, overflow }= this.props; if(backgroundImage && this.props.style.width){ const {url, width, height} = backgroundImage; style = { backgroundImage: `url(${formatImage(url)})` } if(this.props.isAutoHeight){ style.height = 'auto' style.backgroundSize = '100% auto' }else{ style.height = `${parseFloat(this.props.style.width) * (height/width)}rem` style.backgroundSize = '100% 100%' } }else{ style = null; } // 兼容以前overflow为true的情况 // @ts-ignore if (overflow === true) { overflow = 'auto' } return (
{ containerType === 'list' && numbers === 1 &&
    { list && list.map((pro:any) => { const product = pro.product const imgSrc = JSON.parse(product.productImages) return (
  • {this.gotoProduct(product.id)}}> {product.status != 1 && }
    {product.productName}
    {/*
    */} {pro.coupons && pro.coupons.length > 0 &&
    {getCouponData4Show(pro.coupons[0]).corecnt}
    }
    ¥{pro.minStorePrice} {pro.maxStorePrice < pro.marketPrice && ¥{pro.marketPrice} }
  • ) }) }
} { containerType === 'list' && numbers === 2 && { list && list.map((pro:any) => { const product = pro.product const imgSrc = JSON.parse(product.productImages) return (
{this.gotoProduct(product.id)}}> {product.status != 1 && }
{product.productName}
{/*
*/} {pro.coupons && pro.coupons.length > 0 &&
{getCouponData4Show(pro.coupons[0]).corecnt}
}
¥{pro.minStorePrice} {pro.maxStorePrice < pro.marketPrice && ¥{pro.marketPrice} }
) }) }
} {this.props.children}
) } }