import * as React from "react";
import ShopListItem from '../commen/proItem';
import ProWrapper from '../commen/wrapper'
import MUtil from "../../../util/utils";
import DistriTimer from '../commen/timer/index'

const timerType = MUtil.timerType();

class NormalPro extends React.Component<any, any> {
    state: any;

    constructor(props) {
        super(props);
        this.state = {
            style: {
                key: 'shop-product-wrapper' + new Date().getTime(),
            }
        }
    }

    goBuy(data) {
        this.props.goBuy ? this.props.goBuy(data) : ''
    }

    render() {
        let source = this.props;
        let content = this.props.content;
        return (
            <div ref={this.state.key}>
                <ProWrapper className={'shop-product-wrapper-normal'} {...MUtil.initParams({}, source)}>
                    {
                        content && content.length > 0 ?
                            content.map((data, index) => (
                                <ShopListItem {...MUtil.initParams(data, source)}
                                              key={index}
                                              style={this.state.style}
                                              goBuy={this.goBuy.bind(this, data)}
                                              showGroupbuyNum={true}
                                              hideMarketNum={true}
                                >
                                    <DistriTimer {...MUtil.initParams(data, source)}
                                                 timerType={'big'}
                                                 className={'distri-timer-big'}></DistriTimer>
                                </ShopListItem>
                            )) : ''
                    }
                </ProWrapper>
            </div>

        );
    }
}

export default NormalPro;