index.js 2.64 KB
import React, { Component } from 'react'
import { connect } from 'dva'

import styles from './InsuranceList.css'
import SwipeActionExample from "../../components/SwipeAction"


 class InsuranceList extends Component{

  constructor(props){
    super(props);
    this.state={
      planList:[],
    }

  }
  componentDidMount(){
    console.log(this.props.planList);
    this.setState({
      planList:this.props.planList
    })
  }
  go1=(item)=>{
    this.props.go1(item)
  }

 go=(item)=>{
   console.log(5555);

   let that = this;
   this.props.dispatch({
    type: 'planEditor/deletePlan',
    payload: {
    "seriNo": item.seriNo,
    "deleteType": 0,
    "riskCode": item.riskCode
    },
    callback(data){
    console.log(data);
      // that.props.go()
    that.props.getMyPlan()
    }
    })


 }


  render(){

    return (
      <div>

        {
          this.props.planList.map((item,index)=>{
            return(
              <div key={index}>
                {
                  this.props.my?
                    <div>
                      <SwipeActionExample  item={item}  go={this.go}  go1={this.go1} goPlanResult={()=>{
                        this.props.goPlanResult(item)
                      }
                      }/>


                    </div>

                    :
                    <div className={styles.item} style={{paddingTop:'.2rem'}} onClick={()=>{
                      this.props.goAddInsurance(item)
                    }} >
                      <div className={styles.left} >
                        <img src={item.thumbnail} alt=""/>
                      </div>
                    <div className={styles.right}>
                      <div className={styles.top}>
                        <div className={styles.title}>{item.riskName}</div>
                        {item.riskLabels && item.riskLabels.map((ite,ind)=>{
                          return(
                            <span key={ind} className={ite === '新品'?styles.orangeSpan:styles.redSpan}>
                                { ite =='热门' ?<img src={require("../../assets/image/label-hot.png")} alt=""/>:ite =='新品' ?<img src={require("../../assets/image/label-newProduct.png")} alt=""/> :null}
                              </span>
                          )
                        })}

                      </div>
                      <div className={styles.buttom}>
                        {item.riskIntroduce}
                      </div>
                    </div>

                    </div>
                }
              </div>
            )
          })
        }

      </div>



    )
  }
}
InsuranceList.propsTypes = {}
export default connect()(InsuranceList)