courselist.js 17.3 KB
Newer Older
xuzhenghua committed
1
import React, {Component} from 'react';
xuzhenghua committed
2
import {VList} from '../../common';
xuzhenghua committed
3
import {Tabs, WhiteSpace, SearchBar} from 'antd-mobile';
xuzhenghua committed
4
import './courselist.scss';
xuzhenghua committed
5 6

class Classify extends Component {
xuzhenghua committed
7 8 9 10 11 12 13 14 15
    constructor(props) {
        super(props)
        this.handleClick = this.handleClick.bind(this)
        this.ontabclick = this.ontabclick.bind(this)
    }

    handleClick() {
        console.log(1);
    }
xuzhenghua committed
16

xuzhenghua committed
17 18
    ontabclick(tab, index) {
        console.log(tab, index)
xuzhenghua committed
19 20 21
        this.setState(status => ({
            data: status.dataList,
        }));
xuzhenghua committed
22
    }
xuzhenghua committed
23 24 25 26

    pulldown() {
        this.setState(status => ({
            ispull: !status.ispull,
xuzhenghua committed
27 28 29 30 31 32 33 34 35
            display: status.ispull ? 'none' : 'block'
        }));
    }

    labelclick(name) {
        console.log(name)
        this.setState(status => ({
            ispull: !status.ispull,
            display: status.ispull ? 'none' : 'block'
xuzhenghua committed
36
        }));
xuzhenghua committed
37 38
    }

xuzhenghua committed
39
    toSearch() {
xuzhenghua committed
40
        window.location.href = '/search'
xuzhenghua committed
41
    }
xuzhenghua committed
42

xuzhenghua committed
43
    return() {
xuzhenghua committed
44
        window.location.href = '/classify'
xuzhenghua committed
45 46
    }

xuzhenghua committed
47
    state = {
xuzhenghua committed
48 49
        ispull: false,
        display: 'none',
xuzhenghua committed
50
        mockData: [
xuzhenghua committed
51
            {
xuzhenghua committed
52
                title: '三月面试求职三月面试求职三月面试求职',
xuzhenghua committed
53
                imgUrl: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
xuzhenghua committed
54
                contact: '学习到第2课2三月面试求职班三月面试求职班三月面试求职班分33秒6',
xuzhenghua committed
55
                time: '03月12日',
xuzhenghua committed
56 57
                record: '学习到第2课2三月面试求职班三月面试求职班三月面试求职班分33秒',
                isbuy: 1,
xuzhenghua committed
58 59
                price0: 100,
                price1: 100
xuzhenghua committed
60 61
            },
            {
xuzhenghua committed
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
                title: '三月面试求职三月面试求职三月面试求职',
                imgUrl: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
                contact: '学习到第2课2三月面试求职班三月面试求职班三月面试求职班分33秒6',
                time: '03月12日',
                record: '学习到第2课2三月面试求职班三月面试求职班三月面试求职班分33秒',
                isbuy: 1,
                price0: 100,
                price1: 100
            },
            {
                title: '三月面试求职班',
                imgUrl: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
                contact: 'QQ群:449141326',
                time: '03月12日',
                record: '学习到第2课2分33秒',
                isbuy: 0,
                price0: 100,
                price1: 100
            },
            {
                title: '三月面试求职班',
                imgUrl: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
                contact: 'QQ群:449141326',
                time: '03月12日',
                record: '学习到第2课2分33秒',
                isbuy: 0,
                price0: 100,
                price1: 100
            },
            {
                title: '三月面试求职班',
                imgUrl: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
                contact: 'QQ群:449141326',
                time: '03月12日',
                record: '学习到第2课2分33秒',
                isbuy: 0,
                price0: 100,
                price1: 100
            },
            {
                title: '三月面试求职班',
                imgUrl: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
                contact: 'QQ群:449141326',
                time: '03月12日',
                record: '学习到第2课2分33秒',
                isbuy: 0,
                price0: 100,
                price1: 100
            },
            {
                title: '三月面试求职班',
                imgUrl: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
                contact: 'QQ群:449141326',
                time: '03月12日',
                record: '学习到第2课2分33秒',
                isbuy: 0,
                price0: 100,
                price1: 100
            },
            {
                title: '三月面试求职班',
                imgUrl: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
                contact: 'QQ群:449141326',
                time: '03月12日',
                record: '学习到第2课2分33秒',
                isbuy: 0,
                price0: 100,
                price1: 100
            },
            {
                title: '三月面试求职班',
                imgUrl: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
                contact: 'QQ群:449141326',
                time: '03月12日',
                record: '学习到第2课2分33秒',
                isbuy: 0,
                price0: 100,
                price1: 100
            },
            {
                title: '三月面试求职班',
                imgUrl: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
                contact: 'QQ群:449141326',
                time: '03月12日',
                record: '学习到第2课2分33秒',
                isbuy: 0,
                price0: 100,
                price1: 100
            },
            {
                title: '三月面试求职班',
                imgUrl: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
                contact: 'QQ群:449141326',
                time: '03月12日',
                record: '学习到第2课2分33秒',
                isbuy: 0,
                price0: 100,
                price1: 100
            },
            {
                title: '三月面试求职班',
                imgUrl: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
                contact: 'QQ群:449141326',
                time: '03月12日',
                record: '学习到第2课2分33秒',
                isbuy: 0,
                price0: 100,
                price1: 100
            },
        ],
        data: [
            {
                title: '三月面试求职三月面试求职三月面试求职',
                imgUrl: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
                contact: '学习到第2课2三月面试求职班三月面试求职班三月面试求职班分33秒6',
                time: '03月12日',
                record: '学习到第2课2三月面试求职班三月面试求职班三月面试求职班分33秒',
                isbuy: 1,
                price0: 100,
                price1: 100
            },
            {
                title: '三月面试求职三月面试求职三月面试求职',
                imgUrl: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
                contact: '学习到第2课2三月面试求职班三月面试求职班三月面试求职班分33秒6',
                time: '03月12日',
                record: '学习到第2课2三月面试求职班三月面试求职班三月面试求职班分33秒',
                isbuy: 1,
                price0: 100,
                price1: 100
            },
            {
                title: '三月面试求职班',
                imgUrl: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
                contact: 'QQ群:449141326',
                time: '03月12日',
                record: '学习到第2课2分33秒',
                isbuy: 0,
                price0: 100,
                price1: 100
            },
            {
                title: '三月面试求职班',
                imgUrl: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
                contact: 'QQ群:449141326',
                time: '03月12日',
                record: '学习到第2课2分33秒',
                isbuy: 0,
                price0: 100,
                price1: 100
            },
            {
                title: '三月面试求职班',
                imgUrl: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
                contact: 'QQ群:449141326',
                time: '03月12日',
                record: '学习到第2课2分33秒',
                isbuy: 0,
                price0: 100,
                price1: 100
            },
            {
                title: '三月面试求职班',
                imgUrl: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
                contact: 'QQ群:449141326',
                time: '03月12日',
                record: '学习到第2课2分33秒',
                isbuy: 0,
                price0: 100,
                price1: 100
            },
            {
                title: '三月面试求职班',
                imgUrl: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
                contact: 'QQ群:449141326',
                time: '03月12日',
                record: '学习到第2课2分33秒',
                isbuy: 0,
                price0: 100,
                price1: 100
            },
            {
                title: '三月面试求职班',
                imgUrl: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
                contact: 'QQ群:449141326',
                time: '03月12日',
                record: '学习到第2课2分33秒',
                isbuy: 0,
                price0: 100,
                price1: 100
            },
            {
                title: '三月面试求职班',
                imgUrl: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
                contact: 'QQ群:449141326',
                time: '03月12日',
                record: '学习到第2课2分33秒',
                isbuy: 0,
                price0: 100,
                price1: 100
            },
            {
xuzhenghua committed
264 265 266 267 268 269 270 271
                title: '三月面试求职班',
                imgUrl: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
                contact: 'QQ群:449141326',
                time: '03月12日',
                record: '学习到第2课2分33秒',
                isbuy: 0,
                price0: 100,
                price1: 100
xuzhenghua committed
272 273
            },
            {
xuzhenghua committed
274 275 276 277 278 279 280 281
                title: '三月面试求职班',
                imgUrl: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
                contact: 'QQ群:449141326',
                time: '03月12日',
                record: '学习到第2课2分33秒',
                isbuy: 0,
                price0: 100,
                price1: 100
xuzhenghua committed
282 283
            },
            {
xuzhenghua committed
284 285 286 287 288 289 290 291 292
                title: '三月面试求职班',
                imgUrl: 'https://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/4c5ccac604.jpg',
                contact: 'QQ群:449141326',
                time: '03月12日',
                record: '学习到第2课2分33秒',
                isbuy: 0,
                price0: 100,
                price1: 100
            },
xuzhenghua committed
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
        ],
        dataList: [
            {
                'src': 'http://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/home/5afe433d01.png',
                'title': 'Spark大数据',
                'teacher': 'wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww',
                'time': '2343234',
                'isbuy': 0,
                'price0': 100,
                'price1': 1000
            },
            {
                'src': 'http://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/home/5afe433d01.png',
                'title': '机器学习',
                'teacher': 'wwwwww',
                'time': '2343234',
                'isbuy': 0,
                'price0': 100,
                'price1': 1000
            },
            {
                'src': 'http://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/home/5afe433d01.png',
                'title': 'Linux',
                'teacher': 'wwwwww',
                'time': '2343234',
                'isbuy': 0,
                'price0': 100,
                'price1': 1000
            },
            {
                'src': 'http://julyedu-img-public.oss-cn-beijing.aliyuncs.com/Public/Image/home/5afe433d01.png',
                'title': '数学',
                'teacher': 'wwwwww',
                'time': '2343234',
                'isbuy': 1,
                'price0': 200,
                'price1': 2000
            }
xuzhenghua committed
331 332
        ]
    }
xuzhenghua committed
333

xuzhenghua committed
334
    render() {
xuzhenghua committed
335 336 337 338 339 340 341 342 343 344 345

        const tabs = [
            {title: '机器学习'},
            {title: '数学'},
            {title: 'Linux'},
            {title: '深度学习'},
            {title: '数据结构'},
            {title: 'Linux'},
            {title: '数据结构'},
            {title: '数学'},
        ];
xuzhenghua committed
346 347 348 349 350 351
        const bottom = (
            <i className={'iconfont iconiconfront-69 pull-down'}></i>
        )
        const top = (
            <i className={'iconfont iconiconfront-71 pull-down'}></i>
        )
xuzhenghua committed
352

xuzhenghua committed
353
        return (
xuzhenghua committed
354
            <div className='class-child'>
xuzhenghua committed
355 356 357 358 359 360 361 362 363 364 365
                <div className="search-nav">
                    <i className={'iconfont iconiconfront-68 return'} onClick={this.return.bind(this)}></i>
                    <SearchBar
                        placeholder="搜索课程"
                        cancelText={" "}
                        onFocus={this.toSearch.bind(this)}
                        showCancelButton={false}
                    />
                    <i className={'iconfont icongouwuche shopping-cart'}></i>
                </div>
                <div className='class-content'>
xuzhenghua committed
366
                    <WhiteSpace/>
xuzhenghua committed
367 368 369 370 371
                    <div onClick={this.pulldown.bind(this)}>
                        {this.state.ispull ? top : bottom}
                    </div>

                    <Tabs
xuzhenghua committed
372 373
                        tabs={tabs}
                        animated={false}
xuzhenghua committed
374
                        onChange={(tab, index) => this.ontabclick(tab, index)}
xuzhenghua committed
375 376 377 378
                        onTabClick={(tab, index) => this.ontabclick(tab, index)}
                    >
                        <div className='tabs'>
                            <ul>
xuzhenghua committed
379
                                {this.state.data.map((item, index) => {
xuzhenghua committed
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395
                                    const Info = (
                                        <div className="info">
                                            <p className='title'>{item.title}</p>
                                            <p className='contact text-overflow-2'>{item.contact}</p>
                                            <div className='des'>
                                                {item.isbuy === 0 && <p className="course-price">
                                                    <span className="new">¥{item.price0}</span>
                                                    <span className="old">¥{item.price1}</span>
                                                </p>
                                                }
                                                {item.isbuy === 1 &&
                                                <a href="/#" className="isbuy">已购买</a>
                                                }
                                            </div>
                                        </div>
                                    )
xuzhenghua committed
396 397 398 399 400 401 402 403
                                    const status = (
                                        <div>
                                            {item.isbuy === 1 &&
                                            <p className='course-status'>拼团减100</p>
                                            }
                                        </div>

                                    )
xuzhenghua committed
404
                                    return (
xuzhenghua committed
405 406
                                        <VList handleClick={this.handleClick} key={index} status={status}
                                               info={Info}></VList>
xuzhenghua committed
407 408 409 410 411 412 413
                                    )
                                })}
                            </ul>
                        </div>
                    </Tabs>
                    <WhiteSpace/>
                </div>
xuzhenghua committed
414
                <div className='mbc-box' style={{display: this.state.display}}>
xuzhenghua committed
415
                    <div className="tabcontent">
xuzhenghua committed
416 417
                        <ClassCourse data={this.state.dataList} title={'基础入门'} onclick={this.labelclick.bind(this)}/>
                        <ClassCourse data={this.state.dataList} title={'进阶提高'} onclick={this.labelclick.bind(this)}/>
xuzhenghua committed
418 419
                    </div>
                </div>
xuzhenghua committed
420

xuzhenghua committed
421 422 423 424 425 426
            </div>
        )
    }

}

xuzhenghua committed
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444
function ClassCourse({data, title, onclick}) {
    return (
        <div className="class-course">
            <p className='course-items-title'>{title}</p>
            <div className='items-box'>
                {
                    data.map((item, index) => {
                        return (
                            <span key={index} onClick={onclick}
                                  className='item-label'>{item.title}</span>
                        )
                    })
                }
            </div>
        </div>
    )
}

xuzhenghua committed
445
export default Classify;