import React from 'react' import Util from '../../../util/utils' import ShopPrice from "../productPrice"; import ShopOriginalPrice from "../productOriginalPrice"; const marketType = Util.marketType(); class ShopTimer extends React.Component { constructor(props) { super(props); this.calcNum = this.calcNum.bind(this); this.calcTimer = this.calcTimer.bind(this); this.state = { vars: ['name', 'join', 'tip', 'time'], id: 'timer' + new Date().getTime() + Math.random() * 10000, remainTime: null } } componentDidMount(): void { let data = this.props.data; if (data.remainTime) { this.calcTimer(data.remainTime); this.setState({ remainTime: data.remainTime }) } } componentWillReceiveProps(nextProps: Readonly, nextContext: any): void { if (nextProps.data.remainTime != this.state.remainTime) { this.setState({ remainTime: nextProps.data.remainTime, // id: 'timer' + new Date().getTime() + Math.random() * 10000, }); this.calcTimer(nextProps.data.remainTime); } } lookMore() { this.props.lookMore(); } calcTimer(remainTime) { Util.calcTimerNew(remainTime, this.state.id) } calcNum(num) { let numNum = Util.calcNum(num); return numNum; } render() { let data = this.props.data; let vars = data.vars ? data.vars : this.state.vars; let className = 'shop-small-timer-wrapper'; let timerType = data.timerType; if (timerType == 'big') { className = 'shop-big-timer-wrapper'; } if (data.limitTime == 1) { return (
{ vars.indexOf('name') != -1 ? { data.cptCode == 9200 ? '拼团' : data.cptCode == 9100 ? { data.showPrice || data.markPrice == 1 ?
{/*价格*/} {/*划线价格*/} { data.cptType == 9101 || data.cptType == 9104 || data.cptType == 9301 || data.cptType == 9304 || data.cptType == 9201 || data.cptType == 9204 ? : '' }
: '' }
: data.cptCode == 9300 ? '砍价' : data.cptCode == 9400 ? '积分' : '' }
: '' } { timerType == 'big' && data.cptCode == 9200 ? ({data.groupBuyNum}人团) : '' } { data.showPartNum == 1 && vars.indexOf('join') != -1 &&data.cptCode!=9100 ? timerType == 'big' ? 已参与{this.calcNum(data.partNum)}人 : {this.calcNum(data.partNum)}人 : '' } { data.limitTime == 1 ? { vars.indexOf('tip') != -1 ? {data.tipText ? data.tipText : '距活动结束仅剩'} : '' } { vars.indexOf('time') != -1 ? 0天 00: 00: 00 : '' } : '' }
); } else { return null; } } } export default ShopTimer;