index.js 23.4 KB
Newer Older
xuzhenghua committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
import React, { Component } from 'react'
import QRCode from 'qrcode'
import { http, SendMessageToApp, wxShare, is_weixin, getParam } from '@/utils'
import { Link } from 'react-router-dom'
import { throttle, findIndex, debounce } from 'lodash'
import RulePopup from './rulePopup/index'
import CoursePopup from './coursePopup/index'
import RecordPopup from './recordPopup/index'
import CourseList from './courseList/index'
import SharePopup from './sharePopup/index'
import LuckDraw from './luckDraw/index'
import CollectBlessing from './collectBlessing/index'
import ReserveCourse from './ReserveCourse/index'
import ListHeader from './listHeader/index'
import LevelTest from './levelTest/index'
import RankList from './rankList/index'
import './index.scss'
import { Popup } from '@/common'
import { Toast } from "antd-mobile"
import Live from './live'
import Banner from './banner'
import cookie from "js-cookie"
import { setCurrentUser, startFetchUser } from "@/store/userAction"
import { addDays } from "date-fns"
import { compose } from "redux"
import { connect } from "react-redux"
xuzhenghua committed
27
import FormalDraw from "./formal-draw"
xuzhenghua committed
28 29 30 31


class BlessingPreheat extends Component {

xuzhenghua committed
32 33
  recordInstance = null

xuzhenghua committed
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
  constructor(props) {
    super(props)
    this.navTop = 183
    this.prevY = 0
    this.state = {
      userInfoList: [],
      // userInfoList: [{
      //     token:'fcfef221e60ab7a2-92a80d5d30196999',
      //     uid:'545292',
      //     uname:'xzhtest2',
      //     avatar_file:''
      // }],
      isRule: false,
      isCourse: false,
      inviteUrl: '',
      inviteVisible: false,
      joinLotteryVisible: false,
      timelineShareVisible: false,
      showRecordList: false,
      isFormal: false, // 1正式 0 预热
xuzhenghua committed
54
      onlyShow: false, // 14号返场
xuzhenghua committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
      isServer: false,
      serverUrl: '',
      shareMark: false,
      userInfo: {},
      isSign: false,
      navs: [
        {
          text: '积福气',
          id: 'lucky-value'
        },
        {
          text: '幸运大抽奖',
          id: 'lucky-draw'
        },
        {
          text: '预付定金',
          id: 'deposit'
        },
        {
          text: '精品特惠',
          id: 'best-courses'
        },
        {
          text: 'AI测试',
          id: 'ai-test'
        },
        {
          text: '大咖直播',
          id: 'live'
        },
      ],
xuzhenghua committed
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
      formalNavs: [
        {
          text: '幸运大抽奖',
          id: 'lucky-draw'
        },
        {
          text: '积福气',
          id: 'lucky-value'
        },
        {
          text: '精品特惠',
          id: 'best-courses'
        },
        {
          text: 'AI测试',
          id: 'ai-test'
        },
        {
          text: '大咖直播',
          id: 'live'
        },
      ],
xuzhenghua committed
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
      encoreNavs: [
        {
          text: '精品特惠',
          id: 'best-courses'
        },
        {
          text: '大咖直播',
          id: 'live'
        },
        {
          text: '幸运大抽奖',
          id: 'lucky-draw'
        },
        {
          text: '积福气',
          id: 'lucky-value'
        },
        {
          text: 'AI测试',
          id: 'ai-test'
        },
      ],
xuzhenghua committed
130 131 132 133 134
      index: 0,
      userHasError: props.user.hasError,
      isApp: false,
      isClose: false,
      testSum: 0,
xuzhenghua committed
135 136 137 138 139 140
      address: {
        name: '',
        phone: '',
        address: ''
      },
      addressPopupVisible: false
xuzhenghua committed
141 142 143 144
    }
  }

  componentDidMount() {
xuzhenghua committed
145
    const _this = this;
xuzhenghua committed
146
    this.fetchUserBlessing()
xuzhenghua committed
147 148 149 150 151
    // setTimeout(function(){
    //   // 这里有获取ID的步骤,由于运营过多的调整,导致顺序不定,所以包含ID的title必须要放到判断中(防止出现多个title),设置定时器是因为如果返回较慢 获取不到ID导致报错
    //   _this.setInitialNavActiveStatus()
    // }, 50);
    // window.addEventListener('scroll', throttle(this.calcNavActive, 100))
xuzhenghua committed
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
    if (is_weixin()) {
      wxShare({
        title: 'AI充电节,积福气享1折秒课,超10万元奖品来就送!!',
        desc: '把这门超5万人报名的【Python基础入门 升级版】课程送给你,附200元红包,请笑纳!--七月在线',
        link: window.location.href,
        imgUrl: 'https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_1111/m/index-share-img.png',
      })
    }

    // 获取App登录信息
    window['loginInfo'] = result => {
      this.loginInfo(result)
    }

    window['getNewData'] = result => {
      this.fetchUserBlessing()
    }
    window['QQWXWBshare'] = result => {
      http.post(`${API.home}/sys/add/blessing`, {
        share_platform: result, // 1 朋友圈 2 微博 3 qq
        type: 3 // 1:签到;3:分享;4:浏览课程;
      }).then(res => {
        const {code} = res.data
        if (code === 200) {
          Toast.info('+2点福气值~', 2, null, false)
          this.fetchUserBlessing()
        }
      })
    }

  }

xuzhenghua committed
184
  componentWillUpdate() {
xuzhenghua committed
185
    const {isFormal,onlyShow} = this.state;
xuzhenghua committed
186 187
    if(isFormal === 1) {
      document.title = `11.11-11.13 AI充电节,为AI出击!重磅好课1折秒,海量奖品来就送-七月在线`
xuzhenghua committed
188 189 190
      if(onlyShow) {
        document.title = `11.14 AI充电节 返场钜惠!200本纸质书送完即止!`
      }
xuzhenghua committed
191 192 193 194
    }else{
      document.title = `11.11-11.13 AI充电节,预热来袭!积福气享1折秒课,海量奖品来就送-七月在线`
    }
  }
xuzhenghua committed
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 264 265 266 267 268 269

// 获取app登录数据
  loginInfo = (result) => {
    this.setState({
      userInfoList: result
    }, () => {
      if (this.state.userInfoList.length) {
        this.props.startFetchUser()
        this.appLogin()
      }
    })

  }
// 保存cookie
  appLogin = () => {
    let expires = addDays(new Date(), 90)
    this.state.userInfoList.map((item, index) => {
      cookie.set("token", item.token, {expires, path: '/', domain: '.julyedu.com'})
      cookie.set("plat", item.plat, {expires, path: '/', domain: '.julyedu.com'})
      cookie.set("uid", item.uid, {expires, path: '/', domain: '.julyedu.com'})
      cookie.set("uname", item.uname, {expires, path: '/', domain: '.julyedu.com'})
      cookie.set("avatar_file", item.avatar_file, {expires, path: '/', domain: '.julyedu.com'})
    })

    if (cookie.get("token") && cookie.get("uid")) {
      this.fetchUserBlessing()
      this.setState({
        isApp: true
      })
    }

    this.props.setCurrentUser(this.transformUser(this.state.userInfoList))
  }
  transformUser = res => {
    let payload

    res.map((item, index) => {
      payload = {
        hasError: false,
        data: {
          username: item.uname,
          avatar: item.avatar_file,
          token: item.token,
          uid: item.uid
        },
        isFetching: false
      }
    })

    return payload
  }


  getActiveIndex = (arr, n) => {
    for (let i = 0, len = arr.length; i < len; i++) {
      if (arr[i] > n) {
        if (!i) {
          return i
        } else {
          if (Math.abs(n - arr[i]) < Math.abs(n - arr[i - 1])) {
            return i
          } else {
            return i - 1
          }
        }
      }
    }

  }

  fetchMoudleId = (str) => {
    const {navs} = this.state
    return findIndex(navs, item => item.id === str)
  }

xuzhenghua committed
270 271 272
  componentWillUnmount () {
    window.removeEventListener('scroll', this.calcNavActive);
  }
xuzhenghua committed
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289

  setInitialNavActiveStatus = () => {
    const observer = new MutationObserver(debounce((list, observer) => {
      const navs = this.state.navs.map(item => document.querySelector(`#${item.id}`))
      if (navs.every(item => item)) {
        const navsTop = navs.map(item => item.offsetTop)
        const index = this.getActiveIndex(navsTop, window.pageYOffset)
        this.setState({index, navsTop}, () => {
          this.calcNavActive()
          observer.disconnect()
        })
      }
    }, 30))
    observer.observe(document.querySelector('#blessing-preheat'), {childList: true, subtree: true})
  }

  initNav = (isFormal) => {
xuzhenghua committed
290
    const {formalNavs, onlyShow, encoreNavs} = this.state
xuzhenghua committed
291
    if (isFormal) {
xuzhenghua committed
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
      if(onlyShow) {
        this.setState({
            navs: encoreNavs
        }, () => {
          this.setInitialNavActiveStatus()
          window.addEventListener('scroll', throttle(this.calcNavActive, 100))
        })
        
      } else {
        this.setState({
          navs: formalNavs
        }, () => {
          this.setInitialNavActiveStatus()
          window.addEventListener('scroll', throttle(this.calcNavActive, 100))
        })
        
      }

xuzhenghua committed
310 311 312 313 314 315 316 317 318 319
    }
  }

  fetchMoudleId = (str) => {
    const {navs} = this.state
    return findIndex(navs, item => item.id === str)
  }

  fetchUserBlessing = () => {
    const {userInfo} = this.state
xuzhenghua committed
320
    const {history} = this.props;
xuzhenghua committed
321 322 323
    http.get(`${API.home}/sys/user/blessing`).then(res => {
      const {code, data} = res.data
      if (code === 200) {
xuzhenghua committed
324 325 326 327 328 329 330 331
        if(data.is_over) {
          if(!getParam('version')) {
            history.push('/');
          } else {
            SendMessageToApp("toQualityCourse");
          }
        }
        this.setState(()=>({
xuzhenghua committed
332 333
          isSign: !!data.today_signed,
          isFormal: data.is_activity,
xuzhenghua committed
334
          onlyShow: data.onlyShow,
xuzhenghua committed
335 336 337 338 339 340 341
          testSum: parseInt(data.user_test_total, 10) || 0,
          userInfo: Object.assign({}, userInfo, {
            isFollow: data.subscribed,
            blessingVal: data.user_blessing_value,
            buyBlessing: (data.types_total_blessing_value && data.types_total_blessing_value.buy_course) ? data.types_total_blessing_value.buy_course : 0,
            inviteBlessing: (data.types_total_blessing_value && data.types_total_blessing_value.invite) ? data.types_total_blessing_value.invite : 0,
          })
xuzhenghua committed
342
        }));
xuzhenghua committed
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365
        if (data.is_login === 1) {
          this.handleToSign()
        }
        this.initNav(data.is_activity)
      }
    })
  }


  handleToAddBlessing = (key) => {
    http.post(`${API.home}/sys/add/blessing`, {
      share_platform: key, // 1 朋友圈 2 微博 3 qq
      type: 3 // 1:签到;3:分享;4:浏览课程;
    }).then(res => {
      const {code} = res.data
      if (code === 200) {
        Toast.info('+2点福气值~', 2, null, false)
      }
    })
  }


  handleToSign = () => {
xuzhenghua committed
366
    const {userInfo} = this.state
xuzhenghua committed
367 368 369 370 371 372 373 374 375 376
    http.post(`${API.home}/sys/add/blessing`, {
      type: 1 // 1:签到;3:分享;4:浏览课程;
    }).then(res => {
      const {code} = res.data
      if (code === 200) {
        this.setState({
          isSign: true,
          userInfo: Object.assign({}, userInfo, {
            blessingVal: userInfo.blessingVal + 5
          })
xuzhenghua committed
377
        })
xuzhenghua committed
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398

        Toast.info('+5点福气值~', 2, null, false)
      }
    })
  }

  handleToHide = (key) => {
    let obj = {}
    obj[key] = false
    this.setState({
      ...obj
    })
  }

  handleToShow = (key, isLogin = false) => {
    // 需要用户登录 并且用户未登录
    const isLoginnew = !this.props.user.hasError

    if (isLogin && !isLoginnew) {
      this.toLogin()
    } else {
xuzhenghua committed
399
      if (key === 'shareMark') {
xuzhenghua committed
400 401
        this.setState({
          isClose: false
xuzhenghua committed
402
        })
xuzhenghua committed
403 404 405
        setTimeout(() => {
          this.setState({
            isClose: true
xuzhenghua committed
406 407
          })
        }, 5000)
xuzhenghua committed
408 409 410 411 412 413 414 415 416 417 418
      }
      let obj = {}
      obj[key] = true
      this.setState({
        ...obj
      })
    }
  }

  handleToShowNotice = () => {
    http.get(`${API['base-api']}/sys/activity/create_blessing_qrcode`).then(res => {
xuzhenghua committed
419
      const {errno, data, msg} = res.data
xuzhenghua committed
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436
      if (errno === 200) {
        QRCode.toDataURL(data.url, {
          width: 120,
          height: 120,
          margin: 1
        }).then(url => {
          Popup({
            title: '扫码关注“七月在线”服务号',
            content: <img src={url} alt="barcode" className="qr-code"/>,
            className: 'invite-popup'
          })
        })
          .catch(err => {
            console.error(err)
          })
      } else if (errno === 4030 || errno === 4040) {
        this.toLogin()
xuzhenghua committed
437 438
      } else {
        Toast.info(msg, 2, null, false)
xuzhenghua committed
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470
      }
    })
  }

  toLogin = () => {
    const {history} = this.props
    if (!getParam('version')) {
      history.push('/passport')
    } else {
      SendMessageToApp("toLogin")
    }
  }

  onCopy = () => {
    Toast.info('复制成功', 2, null, false)
  }

  toSection = (i, e) => {
    const {navs} = this.state
    e.preventDefault()
    let top = document.querySelector(`#${navs[i].id}`).offsetTop
    this.setState({
      index: i
    })
    window.scrollTo({
      top: top - 60,
      left: 0
    })
  }

  calcNavActive = () => {
    const {navs, index} = this.state
xuzhenghua committed
471
    
xuzhenghua committed
472 473 474 475
    const y = window.scrollY
    let swipeDirection = y > this.prevY ? 'up' : 'down'
    let _index
    if (swipeDirection === 'up') {
xuzhenghua committed
476 477
      if(Number.isInteger(index)){
        _index = (index + 1) >= navs.length ? index : index + 1
xuzhenghua committed
478

xuzhenghua committed
479 480 481
      }else {
        _index = 0
      }
xuzhenghua committed
482
    } else {
xuzhenghua committed
483 484 485 486 487
      if(Number.isInteger(index)){
        _index = (index - 1) <= 0 ? 0 : index - 1
      }else {
        _index = 0
      }
xuzhenghua committed
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517
    }
    let el = document.querySelector(`#${navs[_index].id}`)
    let nav = document.querySelector('#main-nav')
    if (el) {

      let top = el.offsetTop

      if (y <= this.navTop) {
        nav.classList.remove('fixed')
      } else {
        !nav.classList.contains('fixed') && nav.classList.add('fixed')
      }

      if (swipeDirection === 'up') {
        if (y + 30 + 30 >= top) {
          this.setState({
            index: _index
          })
        }
      } else {
        if (y + 30 + 20 <= top) {
          this.setState({
            index: _index
          })
        }
      }
      this.prevY = y
    }
  }

xuzhenghua committed
518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617
  getMyPrizeRecord = () => {
    const isLoginnew = !this.props.user.hasError
    const {history} = this.props
    if (!isLoginnew) {
      history.push('/passport')
    }else{
      http.get(`${API.home}/sys/activity/my_lotteries`)
          .then(res => {
            const {code, data, msg} = res.data
            if (code == 200) {
              this.recordInstance = Popup({
                title: '我的中奖纪录',
                className: 'prize-record-popup',
                content: (
                    <div className={'record-container'}>
                      <div className="list-title">
                        <div>时间</div>
                        <div>奖品名称</div>
                      </div>
                      <ul>
                        {
                          Array.isArray(data)
                              ? data.map((item, index) => {
                                return (
                                    <li key={index}>
                                      <div className="time">{item.time}</div>
                                      <div className="name"
                                           onClick={this.showAddressPopup.bind(this, item['is_virtual'], item.prize)}>{item.prize}</div>
                                    </li>
                                )
                              })
                              : <li style={{justifyContent: 'center'}}>暂无中奖纪录</li>
                        }
                      </ul>
                    </div>
                )
              })
            } else {
              Toast.info(msg, 2, null, false)
            }
          })
    }
  }

  submitAddress = debounce(() => {
    http.post(`${API.home}/sys/collect_info`, {
      ...this.state.address
    })
      .then(res => {
        const {data, code, msg} = res.data
        if (code == 200) {

          this.setState({
            addressPopupVisible: false
          })

        } else {
          Toast.info(msg, 2, null, false)
        }
      })
  }, 500)

  setAddressState = e => {
    const value = e.target.value
    const name = e.target.name
    this.setState({
      address: {
        ...this.state.address, ...{
          [name]: value
        }
      }
    })
  }

  showAddressPopup = (isVirtual, prize) => {
    if (isVirtual) {
      Toast.info(`恭喜你抽中${prize},奖品已存放到你的账户`, 2, null, false)
      return
    }
    http.get(`${API.home}/sys/user_address_info`)
      .then(res => {
        const {data, code, msg} = res.data
        if (code == 200) {
          this.recordInstance && this.recordInstance.close()
          this.setState({
            address: {
              ...this.state.address, ...{
                name: data.name,
                phone: Number(data.phone),
                address: data.address
              }
            },
            addressPopupVisible: true
          })
        } else {
          Toast.info(msg, 2, null, false)
        }
      })
  }

xuzhenghua committed
618 619 620 621 622 623 624 625 626 627 628 629 630
  render() {
    const {
      navs,
      userInfo,
      isRule,
      isCourse,
      isFormal,
      isSign,
      showRecordList,
      shareMark,
      index,
      isApp,
      isClose,
xuzhenghua committed
631 632 633
      testSum,
      address,
      addressPopupVisible,
xuzhenghua committed
634
      onlyShow,
xuzhenghua committed
635
    } = this.state
xuzhenghua committed
636 637 638 639 640 641 642 643 644
    const {history} = this.props
    const isLogin = !this.props.user.hasError
    return (
      <div id={'blessing-preheat'}>
        <Banner
          isFormal={isFormal}
          navs={navs}
          toSection={this.toSection}
          index={index}
xuzhenghua committed
645
          onlyShow={onlyShow}
xuzhenghua committed
646
        />
xuzhenghua committed
647

xuzhenghua committed
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668
        {/* 精品课程特惠专区--返场 */}
        {
          onlyShow && (
            <>
              <ListHeader id={'best-courses'} text="精品课程特惠专区" styles={{margin: '60px 0 15px'}}/>
              <CourseList
                isApp={isApp}
                isFormal={isFormal}
                isLogin={isLogin}
                history={this.props.history}
                toLogin={this.toLogin}
              />
            </>
          )
        }

        {/* 大咖直播--返场 */}
        {
          onlyShow && <Live isFormal={isFormal} isLogin={isLogin}/>
        }

xuzhenghua committed
669 670 671 672
        {/* 抽奖--正式 */}
        {
          isFormal === 1 &&
          <>
xuzhenghua committed
673 674 675 676 677 678
            <ListHeader id={'lucky-draw'} text="幸运大抽奖" styles={{margin: onlyShow ? '30px 0 10px' : '60px 0 10px'}}/>
            {
              onlyShow ? (
                <p className='active_over'>活动已结束</p>
              ) : null
            }
xuzhenghua committed
679 680 681 682
            <div className="formal-draw-btns">
              <button className="luck-draw__button" onClick={() => this.handleToShow('isRule')}>活动规则></button>
              <button className='prize-record' onClick={this.getMyPrizeRecord}>中奖记录></button>
            </div>
xuzhenghua committed
683
            <FormalDraw toLogin={this.toLogin} isApp={isApp}/>
xuzhenghua committed
684 685 686 687
          </>

        }

xuzhenghua committed
688
        {/* 积福气 */}
xuzhenghua committed
689
        <ListHeader id={'lucky-value'} text="积福气,享受更多福利" styles={{margin: '30px 0 15px'}}/>
xuzhenghua committed
690 691 692 693 694 695
        {
          onlyShow ? (
            <p className='active_over'>活动已结束</p>
          ) : null
        }
        <Link className="blessing__sort" to="/blessingRank"></Link>
xuzhenghua committed
696 697 698 699 700 701 702 703 704 705 706 707 708 709 710


        <CollectBlessing
          isSign={isSign}
          userInfo={userInfo}
          isLogin={isLogin}
          history={this.props.history}
          toSection={(e) => this.toSection(this.fetchMoudleId('best-courses'), e)}
          handleToShowList={() => this.handleToShow('isCourse')}
          handleToShowNotice={this.handleToShowNotice}
          toLogin={this.toLogin}
          handleToShowShare={() => this.handleToShow('shareMark')}
        />

        {/* 幸运大抽奖--预热 */}
xuzhenghua committed
711 712 713 714 715 716 717 718 719 720
        {
          isFormal === 0 &&
          <>
            <ListHeader id={'lucky-draw'} text="幸运大抽奖" styles={{margin: '30px 0 10px'}}/>
            <p className="luck-draw__tip">- 将于111110点开启 -</p>
            <button className="luck-draw__button" onClick={() => this.handleToShow('isRule')}>活动规则></button>
            <LuckDraw/>
          </>

        }
xuzhenghua committed
721 722 723 724 725 726 727 728 729 730 731

        {/*定金--只在预热期间显示*/}
        {
          isFormal === 0 &&
          <>
            <ListHeader id={'deposit'} text="预付1元定金,最高可省100元" styles={{margin: '30px 0 15px'}}/>
            <ReserveCourse isApp={isApp}/>
          </>
        }

        {/* 精品课程特惠专区 */}
xuzhenghua committed
732 733 734 735 736 737 738 739 740 741 742 743 744 745
        {
          !onlyShow && (
            <>
              <ListHeader id={'best-courses'} text="精品课程特惠专区" styles={{margin: '30px 0 15px'}}/>
              <CourseList
                isApp={isApp}
                isFormal={isFormal}
                isLogin={isLogin}
                history={this.props.history}
                toLogin={this.toLogin}
              />
            </>
          )
        }
xuzhenghua committed
746 747 748 749 750 751 752 753 754 755 756 757

        {
          isRule &&
          <RulePopup handleToHide={() => this.handleToHide('isRule')}/>
        }
        {
          isCourse &&
          <CoursePopup toLogin={this.toLogin} history={history} isLogin={isLogin}
                       handleToHide={() => this.handleToHide('isCourse')}/>
        }
        {
          showRecordList &&
xuzhenghua committed
758
          <RecordPopup
xuzhenghua committed
759 760 761
            history={this.props.history}
            handleToHide={() => this.handleToHide('showRecordList')}
          />
xuzhenghua committed
762 763 764 765 766 767
        }
        {
          shareMark &&
          <SharePopup isClose={isClose} toClose={() => this.handleToHide('shareMark')}/>
        }
        <ListHeader id={'ai-test'} text="全国AI工程师水平测试" styles={{margin: '30px 0 15px'}}/>
xuzhenghua committed
768 769 770 771 772
        {
              onlyShow ? (
                <p className='active_over'>活动已结束</p>
              ) : null
            }
xuzhenghua committed
773 774 775 776 777 778 779 780 781 782 783 784 785
        <div className="test__record" onClick={() => this.handleToShow('showRecordList', true)}>
          测试记录>
        </div>
        <LevelTest
          history={history}
          testSum={testSum}
          isLogin={isLogin}
          toLogin={this.toLogin}
        />


        <RankList></RankList>

xuzhenghua committed
786 787 788 789 790
        {/* 大咖直播 -- 正式活动 */}
        {
          !onlyShow && <Live isFormal={isFormal} isLogin={isLogin}/>
        }

xuzhenghua committed
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807
        {
          addressPopupVisible &&
          <div className="address-mask">
            <div className="address-popup">
              <div className="title">收货信息</div>
              <div className="address-info-container">
                <div className="tip">请及时填写收货信息,获得实物奖品后将第一时间为您邮寄</div>
                <input type="text"
                       placeholder={'收件人'}
                       name={'name'}
                       onChange={e => {
                         this.setAddressState(e)
                       }}
                       value={address.name}
                />
                <input type="tel"
                       placeholder={'联系方式'}
xuzhenghua committed
808
                       name={'phone'}
xuzhenghua committed
809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835
                       onChange={e => {
                         this.setAddressState(e)
                       }}
                       value={address.phone}
                />
                <input type="text"
                       placeholder={'收货地址'}
                       name={'address'}
                       onChange={e => {
                         this.setAddressState(e)
                       }}
                       value={address.address}
                />
                <button type='button'
                        className={(address.name != '' && address.phone != '' && address.address != '') ? 'active' : ''}
                        onClick={this.submitAddress}
                >提交
                </button>
                <i className={'iconfont iconiconfront-2'} onClick={() => {
                  this.setState({
                    addressPopupVisible: false
                  })
                }}/>
              </div>
            </div>
          </div>
        }
xuzhenghua committed
836 837 838 839 840 841 842 843 844 845 846
      </div>
    )
  }
}

export default compose(
  connect(
    state => ({user: state.user}),
    {setCurrentUser, startFetchUser}
  )
)(BlessingPreheat)