index.js 4.64 KB
Newer Older
xuzhenghua committed
1 2 3 4 5
import React, {PureComponent} from 'react'
import {Flex, WhiteSpace, List} from 'antd-mobile'
import './index.scss'
import Avatar from './image/avatar.png'
import Vip from './image/vip.png'
xuzhenghua committed
6
import {WithTab} from '@/HOCs'
xuzhenghua committed
7 8 9
import {Link} from "react-router-dom"
import {connect} from "react-redux"
import {HeaderBar} from "@/common"
.  
baiguangyao committed
10 11 12

const Item = List.Item;
const Brief = Item.Brief;
baiguangyao committed
13

14
class My extends PureComponent {
xuzhenghua committed
15 16 17 18 19 20
    constructor(props) {
        super(props)
        this.state = {
            data: []
        }
    }
xuzhenghua committed
21 22 23 24 25 26

    // 去登录
    toLogin = () => {
        this.props.history.push('/passport')
    }

baiguangyao committed
27
    render() {
xuzhenghua committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
        const {user} = this.props
        const uid = user && user.data && user.data.uid
        const username = user && user.data && user.data.username
        const avatar = user && user.data && user.data.avatar
        const isVIP = user && user.data && user.data.isVIP
        let list
        if (!uid) {
            list = <List className="my-list">
                <Item
                    className="avatar-wrap"
                    arrow="horizontal"
                    multipleLine
                    thumb={Avatar}
                    onClick={this.toLogin}>
                    <Brief>点击登录</Brief>
                </Item>
            </List>
        } else {
            list = <List className="my-list">
xuzhenghua committed
47 48 49 50 51 52 53 54 55 56 57 58 59
                <Link to='/myedit'>
                    <Item
                        className="avatar-wrap"
                        arrow="horizontal"
                        multipleLine
                        thumb={avatar}
                    >
                        <Brief>
                            {username}
                            {
                                isVIP === 1 &&
                                <img src={Vip} className='vip' alt=""/>
                            }
xuzhenghua committed
60

xuzhenghua committed
61 62 63 64
                        </Brief>
                        <Brief style={{fontSize: "12px"}}>学号: {uid}</Brief>
                    </Item>
                </Link>
xuzhenghua committed
65
                {
xuzhenghua committed
66
                    (isVIP === 0 || !isVIP) &&
xuzhenghua committed
67
                    <Link className="my-isvip" to={`/detail?id=139`}></Link>
xuzhenghua committed
68 69 70
                }
            </List>
        }
baiguangyao committed
71
        return (
baiguangyao committed
72 73 74
            <div className="flex-container">
                <Flex>
                    <Flex.Item>
xuzhenghua committed
75 76
                        <HeaderBar title='我的' arrow={false} cart={false}></HeaderBar>

xuzhenghua committed
77 78 79 80 81 82 83 84 85 86 87
                        {list}

                        <div className="am-list-header"></div>

                        <List className="my-list-content">
                            <Link to='/purchased'>
                                <Item arrow="horizontal">
                                    <i className="iconfont iconiconfront-27"></i>
                                    已购课程
                                </Item>
                            </Link>
xuzhenghua committed
88
                            <Link to='/shopcart'>
xuzhenghua committed
89 90
                                <Item arrow="horizontal">
                                    <i className="iconfont icongouwuche-xianxing"></i>
xuzhenghua committed
91 92 93 94
                                    购物车
                                </Item>
                            </Link>
                            <Link to='/myorders'>
xuzhenghua committed
95
                                <Item arrow="horizontal">
xuzhenghua committed
96 97 98 99
                                    <i className="iconfont iconiconfront-24"></i>
                                    课程订单
                                </Item>
                            </Link>
zhanghaozhe committed
100 101 102 103 104 105
                            <Link to={{
                                pathname: '/coupons',
                                state: {
                                    from: this.props.location.pathname
                                }
                            }}>
xuzhenghua committed
106
                                <Item arrow="horizontal" className="no-border">
107 108
                                    <i className="iconfont iconiconfront-52"></i>
                                    优惠券
zhanghaozhe committed
109 110
                                </Item>
                            </Link>
xuzhenghua committed
111
                            <div className="am-list-header"></div>
112

xuzhenghua committed
113 114
                            <Link to='/scholarship'>
                                <Item arrow="horizontal" className='btm-scholarship'>
xuzhenghua committed
115 116 117
                                    <i className="iconfont iconiconfront-51"></i>
                                    赚奖学金
                                </Item>
xuzhenghua committed
118 119
                            </Link>
                        </List>
xuzhenghua committed
120

baiguangyao committed
121 122
                    </Flex.Item>
                </Flex>
123
                <WhiteSpace size="lg"/>
baiguangyao committed
124 125 126 127 128 129
            </div>
        )
    }

}

xuzhenghua committed
130 131 132 133
export default connect(
    state => ({user: state.user}),
    null
)(WithTab(My))