import React from 'react'; import { connect } from 'dva'; import StepOne from './StepOne'; import StepTwo from './StepTwo'; import StepThree from './StepThree'; import StepFour from './StepFour'; import StepFive from './StepFive'; import '../financialWallet.less'; import { getComWalletServiceOpenInfo, getComWalletCurrentProcess }from '../../../services/api'; @connect(state => ({ global: state.global })) export default class BusinessWallet extends React.Component { constructor(props, context) { super(props, context); this.state = { initStatus: 0, //初始化没有页面 // initStatus: 1, isAuthorize: 0, //是否授权服务(1:是,0:否) isCompleteOpen: 0 //是否完成开户(1:是,0:否) }; } componentDidMount() { const companyInfo = this.props.global.companyInfo; console.log(companyInfo) //将数据存在storage中,防止刷新的时候数据丢失的现象 if(companyInfo.comName) { window.sessionStorage.setItem('companyInfo', JSON.stringify(this.props.global.companyInfo)); } // 获取企业钱包服务开通情况 this.__getComWalletServiceOpenInfo(); } // 获取企业钱包服务开通情况 __getComWalletServiceOpenInfo(){ getComWalletServiceOpenInfo().then(async res => { const { isAuthorize, isCompleteOpen } = res.data; // 已经授权,已经开户,直接跳到第五步,企业列表页面 if(isAuthorize == 1 && isCompleteOpen==1){ this.setState({ initStatus: 5 }); }else if(isAuthorize == 1) {// 如果已经授权 // 未完成开户的时候 获取步骤 let result=await getComWalletCurrentProcess({});//开户完,去查询步骤--getComWalletCurrentProcess API接口获取‘企业钱包服务当前开通步骤’ let process=result.data.step; if(isCompleteOpen == 0 && process == 1) {//process=1第一步填写开户资料 // this.__getComWalletCurrentProcess(); this.setState({ initStatus: 2 }); }else if(isCompleteOpen == 0 && process == 4) {//process=4第四步去认证 // this.__getComWalletCurrentProcess(); this.setState({ initStatus: 4 }); }else{// 完成开户 this.setState({ initStatus: 5 }); } }else {//否则,未授权,未开户,进入第一步,申请开通页面 this.setState({ initStatus: 1 }); } this.setState({ isAuthorize, isCompleteOpen }); }).catch(() => { this.setState({ initStatus: 1 }); }); } // __getComWalletCurrentProcess() { // getComWalletCurrentProcess().then(res => { // let step = res.data.step + 1; // // 完成了 // if(step >= 4) { // this.setState({ // initStatus: 5 // }); // // 还在第一步的时候 // }else if(step <=2) { // this.setState({ // initStatus: 1 // }); // // 未完成 // }else { // this.setState({ // initStatus: step // }); // } // }); // } setStatus(value) { this.setState({ initStatus: value }); } render() { const status = this.state.initStatus; // const status = 2; return (