/*
 * Creator:     ML
 * CreatDate:   2020-03-12
 * descripts：  患者中心 提交申请 状态提示
 * */
import React from 'react';
import { Button, Icon, List, Result } from 'antd-mobile';
// import { $http } from "containers/config/https";
// import { Util } from 'tools';
import store from 'store'
import './style/index.less';
import PayTips from './componts/payTips'
// const ListItem = List.Item;
class ApplyTips extends React.Component {
    constructor({ history }) {
        super();
        let userData = localStorage.getItem("userData") ? JSON.parse(localStorage.getItem("userData")) : {};
        this.state = {
            userData,
            errorData: {}
        };
        this.history = history;
    }

    componentDidMount = () => {
        console.log(" (store.getState().homeRedux && store.getState().homeRedux.treatmentItemsData.cureAppID) || ", (store.getState().homeRedux && store.getState().homeRedux.treatmentItemsData))
    }

    componentWillUnmount() {
        // 组件销毁前将静止让setState修改state的状态
        this.setState = (state, callback) => { return; }
    }
    onRef = (ref) => {
        this.childPay = ref
    }
    // 搜索
    handleSearch = (val) => {
        // console.log(val)
    }
    //返回治疗订单列表
    handleOrderList = () => {
        this.history.push({
            pathname: "/0002/0013",
            state: ((store.getState().homeRedux && store.getState().homeRedux && store.getState().homeRedux.treatmentItemsData.cureAppID) || "")
        })
    }
    //进入预约治疗
    handleAppointment = () => {
        let item = store.getState().homeRedux.treatmentItemsData
        // console.log("store.getState().homeRedux.treatmentItemsData点击进入预约治疗",store.getState().homeRedux.treatmentItemsData)
        this.history.push({
            pathname: "/0002/0014",
            state: { ...item }
        })
        store.dispatch({
            type: "treatmentItems",
            value: { ...item }
        });
    }
    //点击付款
    handleToPay = (price,payNote) => {
        this.childPay.showModal(price,payNote)
    }
    //支付成功
    payToNext=()=>{
        this.handleOrderList()
    }
    render() {
        return (
            <div className="apply-tips apply-dom">
                <div className="tips">
                    <div>
                        <Result
                            img={<Icon type="check-circle-o" className="spe" style={{ fill: 'rgb(31, 177, 18)' }} />}
                            title="申请成功"
                        />
                    </div>
                </div>
                <span></span>
                <div>
                    <List>
                        <div className="title project-list">
                            <p>
                                <span>{(store.getState().homeRedux && store.getState().homeRedux && store.getState().homeRedux.treatmentItemsData.descripts) || "--"}</span>
                                <span>{(store.getState().homeRedux && store.getState().homeRedux && store.getState().homeRedux.treatmentItemsData.totalPrice) || "0"}元</span>
                            </p>
                            <p>
                                <span>{(store.getState().homeRedux && store.getState().homeRedux && store.getState().homeRedux.treatmentItemsData.locDesc) || "--"}</span>
                                <span>{(store.getState().homeRedux && store.getState().homeRedux && store.getState().homeRedux.treatmentItemsData.patPrice + "元") || "--"}</span>
                            </p>
                            <p className="time-dom">
                                <span>{(store.getState().homeRedux && store.getState().homeRedux && store.getState().homeRedux.treatmentItemsData.applyData) || "--"}</span>
                                <span>{("x" + (store.getState().homeRedux && store.getState().homeRedux && store.getState().homeRedux.treatmentItemsData.count) || "--")}</span>
                            </p>
                        </div>
                    </List>
                    <div className="btn-dom">
                        <p>
                            <Button onClick={this.handleAppointment}>预约</Button>
                        </p>
                        <p>
                            <Button onClick={()=>this.handleToPay((store.getState().homeRedux && store.getState().homeRedux && store.getState().homeRedux.treatmentItemsData.totalPrice),
                                (store.getState().homeRedux && store.getState().homeRedux && store.getState().homeRedux.treatmentItemsData.payNote) )}>付款</Button>
                        </p>
                        <p>
                            <span onClick={this.handleOrderList}>返回订单列表</span>
                        </p>
                    </div>
                    <PayTips onRef={this.onRef} payToNext={this.payToNext}></PayTips>
                </div>
            </div>
        )
    }
};
export default ApplyTips;