import * as React from 'react'; import BaseButton from '@beisen/base-button' import { taker, getApiUrl2, getApiUrl, getUserInfo } from '&/helper' interface Props{ closePop:Function, wxUser:any, init:any, unDrawCashFee:number } export default class Password extends React.Component { state:{ value?:string, infoPopShow:boolean, cashNum:string, cashMore:boolean, message?:string, cashError:boolean, cashOk:boolean, text:string, status?:boolean, } constructor(p:Props) { super(p); this.submitCashInfo = this.submitCashInfo.bind(this); this.submitPWD = this.submitPWD.bind(this); this.state = { value: '', //密码值 status:undefined,//密码状态 infoPopShow: false, //提现信息 cashNum: '', //提现金额 cashMore: false, //提现金额大于可提现金额 message: undefined, //接口出错信息 cashError: false, //提现接口信息出错? cashOk: false, //提现成功? text:'' } } async submitPWD(val:string) { //验证密码再操作。--提现密码验证 const url = getApiUrl2('user/login/validate'); const response = await taker(url, 'POST', { password: val }); const status = response.Data; this.setState({ infoPopShow: status, status:status }); } cashNumChange = (e:any) => { const val = e.target.value; if(val == ''){ this.setState({ cashNum: '' }); }else{ if (!isNaN(parseFloat(val))) { if (val.split('.').length > 1 && val.split('.')[1].length > 2) {} else { this.setState({ cashNum: val }) } } } } handleChangePWD = (e:any) => { let a = '' for(let i=0;i { this.setState({ infoPopShow: false }); this.props.closePop(); } async submitCashInfo(cashNum:string) { if(!cashNum) return; const url = getApiUrl(`wx/pay/cash/add?totalFee=${cashNum}`); const response = await taker(url, 'POST', { totalFee: cashNum }); const data = response; if (data.Code == 0) { this.setState({ cashError: true, message: data.Message }); } else { this.setState({ cashOk: true, message: data.Message }) setTimeout(() => { this.setState({ cashOk: false }); this.props.closePop(); }, 3000) } } clearCashMore = () => { this.setState({ cashError: false, cashMore: false, message: undefined }) } submitCash = (cashNum:string) => { const cashWill = parseFloat(cashNum); const cashRest = parseFloat(this.props.init.get('unDrawCashFee')); if (cashWill > cashRest) { this.setState({ cashError: true, cashMore: true }) } else { this.setState({ infoPopShow: true }) } } render() { //infoPopShow && const { closePop, wxUser, unDrawCashFee } = this.props; const { value, status, text, infoPopShow, cashNum, cashMore, message, cashError, cashOk } = this.state; return
提现 {closePop()} }>×
{!status && 密码 }
{ cashOk &&
提现申请提交成功!
} { infoPopShow &&
微信昵称:{ wxUser && wxUser.get('wxName') || '暂无' } 可提现金额:{ unDrawCashFee ||'0' } 姓名:{ getUserInfo().Name|| '暂无' } 申请提现金额 手机:{ wxUser && wxUser.get('mobile') ||'暂无' } { message && { message } }
{ this.submitCashInfo( cashNum ) } } />
} { !status && } { cashMore && 超过账户最多可提现金额! } { status === false && 密码不正确,请重新输入 }
{ !status &&
{ if(status){ this.submitCash( cashNum ) } else { value && this.submitPWD( value ) } } } />
}
} }