index.js 3.59 KB
import React,{Component} from 'react';
import { connect } from 'dva';
import { SwipeAction, List ,Modal} from 'antd-mobile';
import styles from "./swipeActive.css"
const alert = Modal.alert;
let alert2=null;
class SwipeActionExample extends Component{
    constructor(props){
      super(props);
      this.state={

      }
    }
  componentDidMount(){

  }
  componentWillUnmount(){
    //如果弹框没有关闭则关闭
    if(alert2){
      alert2.close();
    }
  }
  editor=(item)=>{


    if(item.seriNo){

      this.props.go1(item)

    }

    //通讯录修改
    if(this.props.client){
      this.props.dispatch(item)
    }
  }

  delete=(item)=>{
    alert2 = alert('', '确定删除吗?', [
          { text: '取消', onPress: () => {
            return;
          } },
          { text: '确定', onPress: () => {
            if(this.props.client) {
              console.log(this.props.item.id);
              this.props.delete(this.props.item.id)
            }else{
              this.props.go(item)
            }
          } },
        ])

  }
  history=(item)=>{

  }
    render(){
      return (
          <List style={{width:'4.14rem',}} >
            <SwipeAction
              style={{ backgroundColor: 'red',width:'4.14rem', }}
              autoClose
              disabled = {this.props.disabled}
              right={[
                {
                  text: '编辑',
                  onPress: ()=>{
                    this.editor(this.props.item)
                  },
                  style: { backgroundColor: '#ddd', color: 'white',width:'.8rem' },
                },
                {
                  text: '删除',
                  onPress: () => {
                    this.delete(this.props.item)
                  },
                  style: { backgroundColor: '#F4333C', color: 'white' ,width:'.8rem'},
                },
              ]}
              onOpen={() => console.log('global open')}
              onClose={() => console.log('global close')}
            >
              <List.Item

                // arrow="horizontal"
                onClick={e => console.log(e)}
                style={{width:'4.14rem'}}
              >
                {/* 我的客户----通讯录 */}
                {this.props.client ? <div >
                  {this.props.item.name}
                    {this.props.label && <span className={styles.label}>{this.props.item.label}</span>}
                  <span className={styles.time}>{this.props.item.time}</span>
                </div>
                  :
                  /*  计划书 --- 我的 */
                  <div className={styles.myItem} onClick={(e)=>{
                    // e.preventDefault();
                    this.props.goPlanResult(this.props.item)
                  }}  >
                  <div className={styles.myleft}>
                  <img src={this.props.item.thumbnail} alt=""/>
                  </div>
                  <div className={styles.myright}>
                  <div className={styles.top} style={{marginBottom:'.05rem'}}>
                  <div className={styles.mytitle}>{this.props.item.riskName}</div>
                  </div>
                  <div className={styles.detail}>{this.props.item.insSex == 'M'?'男':'女'} &nbsp;&nbsp;   {this.props.item.insAge} &nbsp;&nbsp;&nbsp;   期缴保费:{this.props.item.prem} </div>
                  <div className={styles.detail2}>制作时间:{this.props.item.createTime}</div>
                  </div>
                  </div>}
              </List.Item>
            </SwipeAction>

          </List>



            )
    }
}
export default connect(({home})=>({home}))(SwipeActionExample)