This commit is contained in:
zhangds 2022-10-18 16:07:11 +08:00
commit 85a0309e1c
1 changed files with 7 additions and 9 deletions

View File

@ -49,27 +49,25 @@ export default class bottomBar extends React.Component {
this.setState({active:index}); this.setState({active:index});
} }
componentDidMount(){ componentDidMount(){
let config = JSON.parse(sessionStorage.getItem('editorConfig')); let config = JSON.parse(sessionStorage.getItem('editorConfig'));
if (config && config.coupon && config.coupon.product_list) { let { navlist, defaultText, selectText, background, iswitch } = this.props.bottomBarConfig?this.props.bottomBarConfig:config.coupon.product_list.bottomBar;
let { navlist, defaultText, selectText, background, iswitch } = config.coupon.product_list.bottomBar; this.setState({ defaultText, selectText, background, iswitch });
this.setState({ defaultText, selectText, background, iswitch }); let naVisual=navlist.filter(item=>item.iswitch);
let naVisual=navlist.filter(item=>item.iswitch); this.setState({navList:naVisual});
this.setState({navList:naVisual});
}
} }
render() { render() {
let active=this.state.active; let active=this.state.active;
return ( return (
<ul className='bottomBar-view' style={{ background:this.props.bottomBarConfig.background? `url('${this.props.bottomBarConfig.background}') center center /cover`:'#f9f9f9'}}> <ul className='bottomBar-view' style={{ background:this.props.bottomBarConfig.background? `url('${this.props.bottomBarConfig.background}') center center /cover`:'#f9f9f9'}}>
{ {
this.state.navList.length>1?this.state.navList.map((item,index)=>{ this.state.navList.map((item,index)=>{
return( return(
<li onClick={e=>this.clickIcon(e,index)} key={item.id}> <li onClick={e=>this.clickIcon(e,index)} key={item.id}>
<img src={active==index?item.pic.selectShow:item.pic.show} alt=""/> <img src={active==index?item.pic.selectShow:item.pic.show} alt=""/>
<span style={{color:active==index?this.props.bottomBarConfig.selectText:this.props.bottomBarConfig.defaultText}}>{item.text}</span> <span style={{color:active==index?this.props.bottomBarConfig.selectText:this.props.bottomBarConfig.defaultText}}>{item.text}</span>
</li> </li>
) )
}):null })
} }
</ul> </ul>
) )