index.js 2.33 KB
Newer Older
zhanghaozhe committed
1 2
import React, { Component } from 'react'
import { NavLink, Route, Switch, Redirect } from "react-router-dom"
xuzhenghua committed
3 4
import myCoupons from "./myCoupons"
import myPatch from './myPatch'
zhanghaozhe committed
5
import { HeaderBar } from "src/common";
zhanghaozhe committed
6
import './coupons.scss'
zhanghaozhe committed
7

zhanghaozhe committed
8

xuzhenghua committed
9
class coupons extends Component {
zhanghaozhe committed
10
    render() {
zhanghaozhe committed
11
        const {match, location} = this.props;
zhanghaozhe committed
12
        return (
xuzhenghua committed
13
            <div className={'coupons-box'}>
zhanghaozhe committed
14
                <HeaderBar title='优惠券' arrow={true}/>
xuzhenghua committed
15 16 17
                <section id='coupons'>
                    <div className='tab'>
                        <div>
zhanghaozhe committed
18 19 20 21 22
                            <NavLink to={{
                                pathname: `${match.url}/my-coupon`,
                                search: location.search,
                                state: {...this.props.location.state}
                            }}
xuzhenghua committed
23 24 25 26 27
                                     replace
                                     activeClassName='tab-active'
                            >我的优惠券</NavLink>
                        </div>
                        <div>
zhanghaozhe committed
28 29 30 31 32
                            <NavLink to={{
                                pathname: `${match.url}/my-patch`,
                                search: location.search,
                                state: {...this.props.location.state}
                            }}
xuzhenghua committed
33 34 35 36 37 38 39 40 41 42
                                     replace
                                     activeClassName='tab-active'
                            >碎片合成</NavLink>
                        </div>
                    </div>
                    <div className="btm-border"></div>

                    <div className="coupons-container">
                        <Switch>
                            <Redirect exact from='/coupons' to={{
zhanghaozhe committed
43
                                pathname: 'coupons/my-coupon', search: location.search, state: {
xuzhenghua committed
44 45 46
                                    from: this.props.location.state && this.props.location.state.from
                                }
                            }}/>
zhanghaozhe committed
47
                            <Route path={`${this.props.match.path}/my-coupon`} component={myCoupons}/>
xuzhenghua committed
48 49 50 51
                            <Route path={`${this.props.match.path}/my-patch`} component={myPatch}/>
                        </Switch>
                    </div>
                </section>
zhanghaozhe committed
52 53 54
            </div>
        )
    }
xuzhenghua committed
55

zhanghaozhe committed
56 57
}

xuzhenghua committed
58
export default coupons;