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";

const timerType = MUtil.timerType();

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

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

    componentDidMount(): void {

    }

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

    render() {
        let source = this.props;
        let content = this.props.content;

        return (
            <div id={this.state.key}>
                <ProWrapper className={'shop-product-wrapper-detail'}  {...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}
                                              styleType={4}
                                >
                                    <DistriTimer {...MUtil.initParams(data, source)}
                                                 vars={['tip', 'time']}
                                                 tipText={'距结束'}
                                                 timerType={timerType.TIMER_SMALL}
                                    ></DistriTimer>
                                </ShopListItem>
                            )) : ''
                    }
                </ProWrapper>
            </div>
        )
    }
}

export default DetailList;