Cards.jsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import React, { Component } from 'react';
  2. import { Link } from 'react-router-dom'
  3. import { Card, WingBlank, WhiteSpace } from 'antd-mobile';
  4. //import { Item } from 'antd-mobile/lib/tab-bar';
  5. import './Cards.css'
  6. class Cards extends Component{
  7. constructor(props){
  8. //console.log('111',props)
  9. super(props)
  10. this.stae={
  11. product_id:''
  12. }
  13. }
  14. //点击后跳转到商品详情页面
  15. onClickChange(id){
  16. console.log('product_id',id)
  17. this.props.changePage('detail',id)
  18. }
  19. render(){
  20. //console.log(this.props.products)
  21. const Cardss=this.props.products.map((item,index)=>{
  22. //console.log(item)
  23. return (
  24. <WingBlank size="lg" key={index} className="Card">
  25. <WhiteSpace size="lg" />
  26. {/*<Link to={"/detail?product_id="+item.id}>*/}
  27. <Card onClick={(e)=>{this.onClickChange(item.id)}}>
  28. <Card.Header
  29. title={<span className="title">{item.name}</span>}
  30. extra={<span className="hot">热门</span>}
  31. />
  32. <Card.Body>
  33. <div className="bodyWrap">
  34. <div className="imgWrap">
  35. <img src={item.img} alt="xxx" height="100px" width="100px"/>
  36. </div>
  37. <div className="sidebar">
  38. <p className="p1">{item.intro}</p>
  39. </div>
  40. <div className="rightsidebar">
  41. <p className="p2">{item.price}/斤</p>
  42. <p className="p3">库存:{item.stock}</p>
  43. </div>
  44. </div>
  45. </Card.Body>
  46. <Card.Footer content="" extra={<div></div>} />
  47. </Card>
  48. {/*</Link>*/}
  49. <WhiteSpace size="lg" />
  50. </WingBlank>
  51. )
  52. })
  53. return (
  54. <div>
  55. {Cardss}
  56. </div>
  57. )
  58. }
  59. }
  60. export default Cards