index.js 5 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"
10
import {getCourses} from './../detail/actions';
.  
baiguangyao committed
11 12 13

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

15 16 17
@connect(state => ({
    user: state.user
}))
18
class My extends PureComponent {
xuzhenghua committed
19 20 21 22 23 24
    constructor(props) {
        super(props)
        this.state = {
            data: []
        }
    }
xuzhenghua committed
25 26 27 28 29 30

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

31 32
    toCourseDetail = (id) => {
        const { dispatch, history } = this.props;
33
        // dispatch(getCourses(id, () => {
34 35
            history.push(`/detail?id=${id}`);
            return false;
36
        // }));
37 38
    }

baiguangyao committed
39
    render() {
xuzhenghua committed
40 41 42 43 44
        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
xuzhenghua committed
45

xuzhenghua committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59
        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
60 61 62 63 64 65 66 67 68 69 70 71 72
                <Link to='/myedit'>
                    <Item
                        className="avatar-wrap"
                        arrow="horizontal"
                        multipleLine
                        thumb={avatar}
                    >
                        <Brief>
                            {username}
                            {
                                isVIP === 1 &&
                                <img src={Vip} className='vip' alt=""/>
                            }
xuzhenghua committed
73

xuzhenghua committed
74 75 76 77
                        </Brief>
                        <Brief style={{fontSize: "12px"}}>学号: {uid}</Brief>
                    </Item>
                </Link>
xuzhenghua committed
78
                {
xuzhenghua committed
79
                    !isVIP &&
xuzhenghua committed
80
                    <a href="javascript:;" className="my-isvip" onClick={() => this.toCourseDetail(139)}></a>
xuzhenghua committed
81 82 83
                }
            </List>
        }
baiguangyao committed
84
        return (
baiguangyao committed
85 86 87
            <div className="flex-container">
                <Flex>
                    <Flex.Item>
xuzhenghua committed
88 89
                        <HeaderBar title='我的' arrow={false} cart={false}></HeaderBar>

xuzhenghua committed
90 91
                        {list}

xuzhenghua committed
92 93 94 95 96
                        {
                            !uid &&
                            <div className="am-list-header"></div>

                        }
xuzhenghua committed
97 98 99 100 101 102 103 104

                        <List className="my-list-content">
                            <Link to='/purchased'>
                                <Item arrow="horizontal">
                                    <i className="iconfont iconiconfront-27"></i>
                                    已购课程
                                </Item>
                            </Link>
xuzhenghua committed
105
                            <Link to='/shopcart'>
xuzhenghua committed
106 107
                                <Item arrow="horizontal">
                                    <i className="iconfont icongouwuche-xianxing"></i>
xuzhenghua committed
108 109 110 111
                                    购物车
                                </Item>
                            </Link>
                            <Link to='/myorders'>
xuzhenghua committed
112
                                <Item arrow="horizontal">
xuzhenghua committed
113 114 115 116
                                    <i className="iconfont iconiconfront-24"></i>
                                    课程订单
                                </Item>
                            </Link>
zhanghaozhe committed
117 118 119 120 121 122
                            <Link to={{
                                pathname: '/coupons',
                                state: {
                                    from: this.props.location.pathname
                                }
                            }}>
xuzhenghua committed
123
                                <Item arrow="horizontal" className="no-border">
124 125
                                    <i className="iconfont iconiconfront-52"></i>
                                    优惠券
zhanghaozhe committed
126 127
                                </Item>
                            </Link>
xuzhenghua committed
128
                            <div className="am-list-header"></div>
129

xuzhenghua committed
130 131
                            <Link to='/scholarship'>
                                <Item arrow="horizontal" className='btm-scholarship'>
xuzhenghua committed
132 133 134
                                    <i className="iconfont iconiconfront-51"></i>
                                    赚奖学金
                                </Item>
xuzhenghua committed
135 136
                            </Link>
                        </List>
xuzhenghua committed
137

baiguangyao committed
138 139
                    </Flex.Item>
                </Flex>
140
                <WhiteSpace size="lg"/>
baiguangyao committed
141 142 143 144 145 146
            </div>
        )
    }

}

147
export default WithTab(My);