index.js 23.9 KB
Newer Older
zhanghaozhe committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
import React, { Component } from "react"
import QRCode from "qrcode"
import { http, SendMessageToApp, wxShare, browser, getParam } from "src/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 "src/common"
xuzhenghua committed
19
import { Toast } from "antd-mobile"
zhanghaozhe committed
20 21
import Live from "./live"
import Banner from "./banner"
xuzhenghua committed
22
import cookie from "js-cookie"
zhanghaozhe committed
23
import { setCurrentUser, startFetchUser } from "src/store/userAction"
xuzhenghua committed
24 25 26
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

class BlessingPreheat extends Component {
xuzhenghua committed
30 31
  recordInstance = null

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

  componentDidMount() {
    this.fetchUserBlessing()
zhanghaozhe committed
144
    if (browser.isWeixin) {
xuzhenghua committed
145
      wxShare({
zhanghaozhe committed
146 147 148
        title: "AI充电节,积福气享1折秒课,超10万元奖品来就送!!",
        desc:
          "把这门超5万人报名的【Python基础入门 升级版】课程送给你,附200元红包,请笑纳!--七月在线",
xuzhenghua committed
149
        link: window.location.href,
150
        imgUrl: "https://cdn.julyedu.com/active19_1111/m/index-share-img.png",
xuzhenghua committed
151 152 153 154
      })
    }

    // 获取App登录信息
zhanghaozhe committed
155
    window["loginInfo"] = (result) => {
xuzhenghua committed
156 157 158
      this.loginInfo(result)
    }

zhanghaozhe committed
159
    window["getNewData"] = () => {
xuzhenghua committed
160 161
      this.fetchUserBlessing()
    }
zhanghaozhe committed
162 163 164 165 166 167 168 169 170 171 172 173 174
    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
175 176 177
    }
  }

xuzhenghua committed
178
  componentWillUpdate() {
zhanghaozhe committed
179 180
    const { isFormal, onlyShow } = this.state
    if (isFormal === 1) {
xuzhenghua committed
181
      document.title = `11.11-11.13 AI充电节,为AI出击!重磅好课1折秒,海量奖品来就送-七月在线`
zhanghaozhe committed
182
      if (onlyShow) {
xuzhenghua committed
183 184
        document.title = `11.14 AI充电节 返场钜惠!200本纸质书送完即止!`
      }
zhanghaozhe committed
185
    } else {
xuzhenghua committed
186 187 188
      document.title = `11.11-11.13 AI充电节,预热来袭!积福气享1折秒课,海量奖品来就送-七月在线`
    }
  }
xuzhenghua committed
189

zhanghaozhe committed
190
  // 获取app登录数据
xuzhenghua committed
191
  loginInfo = (result) => {
zhanghaozhe committed
192 193 194 195 196 197 198 199 200
    this.setState(
      {
        userInfoList: result,
      },
      () => {
        if (this.state.userInfoList.length) {
          this.props.startFetchUser()
          this.appLogin()
        }
xuzhenghua committed
201
      }
zhanghaozhe committed
202
    )
xuzhenghua committed
203
  }
zhanghaozhe committed
204
  // 保存cookie
xuzhenghua committed
205 206
  appLogin = () => {
    let expires = addDays(new Date(), 90)
zhanghaozhe committed
207
    this.state.userInfoList.forEach((item) => {
zhanghaozhe committed
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
      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",
      })
xuzhenghua committed
233 234 235 236 237
    })

    if (cookie.get("token") && cookie.get("uid")) {
      this.fetchUserBlessing()
      this.setState({
zhanghaozhe committed
238
        isApp: true,
xuzhenghua committed
239 240 241 242 243
      })
    }

    this.props.setCurrentUser(this.transformUser(this.state.userInfoList))
  }
zhanghaozhe committed
244
  transformUser = (res) => {
xuzhenghua committed
245 246
    let payload

zhanghaozhe committed
247
    res.forEach((item) => {
xuzhenghua committed
248 249 250 251 252 253
      payload = {
        hasError: false,
        data: {
          username: item.uname,
          avatar: item.avatar_file,
          token: item.token,
zhanghaozhe committed
254
          uid: item.uid,
xuzhenghua committed
255
        },
zhanghaozhe committed
256
        isFetching: false,
xuzhenghua committed
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
      }
    })

    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) => {
zhanghaozhe committed
280 281
    const { navs } = this.state
    return findIndex(navs, (item) => item.id === str)
xuzhenghua committed
282 283
  }

zhanghaozhe committed
284 285
  componentWillUnmount() {
    window.removeEventListener("scroll", this.calcNavActive)
xuzhenghua committed
286
  }
xuzhenghua committed
287 288

  setInitialNavActiveStatus = () => {
zhanghaozhe committed
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307
    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,
    })
xuzhenghua committed
308 309 310
  }

  initNav = (isFormal) => {
zhanghaozhe committed
311
    const { formalNavs, onlyShow, encoreNavs } = this.state
xuzhenghua committed
312
    if (isFormal) {
zhanghaozhe committed
313 314 315 316 317 318 319 320 321 322
      if (onlyShow) {
        this.setState(
          {
            navs: encoreNavs,
          },
          () => {
            this.setInitialNavActiveStatus()
            window.addEventListener("scroll", throttle(this.calcNavActive, 100))
          }
        )
xuzhenghua committed
323
      } else {
zhanghaozhe committed
324 325 326 327 328 329 330 331 332
        this.setState(
          {
            navs: formalNavs,
          },
          () => {
            this.setInitialNavActiveStatus()
            window.addEventListener("scroll", throttle(this.calcNavActive, 100))
          }
        )
xuzhenghua committed
333
      }
xuzhenghua committed
334 335 336 337
    }
  }

  fetchMoudleId = (str) => {
zhanghaozhe committed
338 339
    const { navs } = this.state
    return findIndex(navs, (item) => item.id === str)
xuzhenghua committed
340 341 342
  }

  fetchUserBlessing = () => {
zhanghaozhe committed
343 344 345 346
    const { userInfo } = this.state
    const { history } = this.props
    http.get(`${API.home}/sys/user/blessing`).then((res) => {
      const { code, data } = res.data
xuzhenghua committed
347
      if (code === 200) {
zhanghaozhe committed
348 349 350
        if (data.is_over) {
          if (!getParam("version")) {
            history.push("/")
xuzhenghua committed
351
          } else {
zhanghaozhe committed
352
            SendMessageToApp("toQualityCourse")
xuzhenghua committed
353 354
          }
        }
zhanghaozhe committed
355
        this.setState(() => ({
xuzhenghua committed
356 357
          isSign: !!data.today_signed,
          isFormal: data.is_activity,
xuzhenghua committed
358
          onlyShow: data.onlyShow,
xuzhenghua committed
359 360 361 362
          testSum: parseInt(data.user_test_total, 10) || 0,
          userInfo: Object.assign({}, userInfo, {
            isFollow: data.subscribed,
            blessingVal: data.user_blessing_value,
zhanghaozhe committed
363 364 365 366 367 368 369 370 371 372 373 374
            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
375 376 377 378 379 380 381 382
        if (data.is_login === 1) {
          this.handleToSign()
        }
        this.initNav(data.is_activity)
      }
    })
  }
  handleToSign = () => {
zhanghaozhe committed
383 384 385 386 387 388 389 390 391 392 393 394 395
    const { userInfo } = this.state
    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
396 397
          })

zhanghaozhe committed
398 399 400
          Toast.info("+5点福气值~", 2, null, false)
        }
      })
xuzhenghua committed
401 402 403 404 405 406
  }

  handleToHide = (key) => {
    let obj = {}
    obj[key] = false
    this.setState({
zhanghaozhe committed
407
      ...obj,
xuzhenghua committed
408 409 410 411 412 413 414 415 416 417
    })
  }

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

    if (isLogin && !isLoginnew) {
      this.toLogin()
    } else {
zhanghaozhe committed
418
      if (key === "shareMark") {
xuzhenghua committed
419
        this.setState({
zhanghaozhe committed
420
          isClose: false,
xuzhenghua committed
421
        })
xuzhenghua committed
422 423
        setTimeout(() => {
          this.setState({
zhanghaozhe committed
424
            isClose: true,
xuzhenghua committed
425 426
          })
        }, 5000)
xuzhenghua committed
427 428 429 430
      }
      let obj = {}
      obj[key] = true
      this.setState({
zhanghaozhe committed
431
        ...obj,
xuzhenghua committed
432 433 434 435 436
      })
    }
  }

  handleToShowNotice = () => {
zhanghaozhe committed
437 438 439 440 441 442 443 444 445
    http
      .get(`${API["base-api"]}/sys/activity/create_blessing_qrcode`)
      .then((res) => {
        const { errno, data, msg } = res.data
        if (errno === 200) {
          QRCode.toDataURL(data.url, {
            width: 120,
            height: 120,
            margin: 1,
xuzhenghua committed
446
          })
zhanghaozhe committed
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462
            .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()
        } else {
          Toast.info(msg, 2, null, false)
        }
      })
xuzhenghua committed
463 464 465
  }

  toLogin = () => {
zhanghaozhe committed
466 467 468
    const { history } = this.props
    if (!getParam("version")) {
      history.push("/passport")
xuzhenghua committed
469 470 471 472 473
    } else {
      SendMessageToApp("toLogin")
    }
  }
  toSection = (i, e) => {
zhanghaozhe committed
474
    const { navs } = this.state
xuzhenghua committed
475 476 477
    e.preventDefault()
    let top = document.querySelector(`#${navs[i].id}`).offsetTop
    this.setState({
zhanghaozhe committed
478
      index: i,
xuzhenghua committed
479 480 481
    })
    window.scrollTo({
      top: top - 60,
zhanghaozhe committed
482
      left: 0,
xuzhenghua committed
483 484 485 486
    })
  }

  calcNavActive = () => {
zhanghaozhe committed
487 488
    const { navs, index } = this.state

xuzhenghua committed
489
    const y = window.scrollY
zhanghaozhe committed
490
    let swipeDirection = y > this.prevY ? "up" : "down"
xuzhenghua committed
491
    let _index
zhanghaozhe committed
492 493 494 495
    if (swipeDirection === "up") {
      if (Number.isInteger(index)) {
        _index = index + 1 >= navs.length ? index : index + 1
      } else {
xuzhenghua committed
496 497
        _index = 0
      }
xuzhenghua committed
498
    } else {
zhanghaozhe committed
499 500 501
      if (Number.isInteger(index)) {
        _index = index - 1 <= 0 ? 0 : index - 1
      } else {
xuzhenghua committed
502 503
        _index = 0
      }
xuzhenghua committed
504 505
    }
    let el = document.querySelector(`#${navs[_index].id}`)
zhanghaozhe committed
506
    let nav = document.querySelector("#main-nav")
xuzhenghua committed
507 508 509 510
    if (el) {
      let top = el.offsetTop

      if (y <= this.navTop) {
zhanghaozhe committed
511
        nav.classList.remove("fixed")
xuzhenghua committed
512
      } else {
zhanghaozhe committed
513
        !nav.classList.contains("fixed") && nav.classList.add("fixed")
xuzhenghua committed
514 515
      }

zhanghaozhe committed
516
      if (swipeDirection === "up") {
xuzhenghua committed
517 518
        if (y + 30 + 30 >= top) {
          this.setState({
zhanghaozhe committed
519
            index: _index,
xuzhenghua committed
520 521 522 523 524
          })
        }
      } else {
        if (y + 30 + 20 <= top) {
          this.setState({
zhanghaozhe committed
525
            index: _index,
xuzhenghua committed
526 527 528 529 530 531 532
          })
        }
      }
      this.prevY = y
    }
  }

xuzhenghua committed
533 534
  getMyPrizeRecord = () => {
    const isLoginnew = !this.props.user.hasError
zhanghaozhe committed
535
    const { history } = this.props
xuzhenghua committed
536
    if (!isLoginnew) {
zhanghaozhe committed
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
      history.push("/passport")
    } else {
      http.get(`${API.home}/sys/activity/my_lotteries`).then((res) => {
        const { code, data, msg } = res.data
        // eslint-disable-next-line eqeqeq
        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>
            ),
xuzhenghua committed
577
          })
zhanghaozhe committed
578 579 580 581
        } else {
          Toast.info(msg, 2, null, false)
        }
      })
xuzhenghua committed
582 583 584 585
    }
  }

  submitAddress = debounce(() => {
zhanghaozhe committed
586 587 588 589 590 591
    http
      .post(`${API.home}/sys/collect_info`, {
        ...this.state.address,
      })
      .then((res) => {
        const { code, msg } = res.data
zhanghaozhe committed
592
        // eslint-disable-next-line eqeqeq
xuzhenghua committed
593 594
        if (code == 200) {
          this.setState({
zhanghaozhe committed
595
            addressPopupVisible: false,
xuzhenghua committed
596 597 598 599 600 601 602
          })
        } else {
          Toast.info(msg, 2, null, false)
        }
      })
  }, 500)

zhanghaozhe committed
603
  setAddressState = (e) => {
xuzhenghua committed
604 605 606 607
    const value = e.target.value
    const name = e.target.name
    this.setState({
      address: {
zhanghaozhe committed
608 609 610 611 612
        ...this.state.address,
        ...{
          [name]: value,
        },
      },
xuzhenghua committed
613 614 615 616 617 618 619 620
    })
  }

  showAddressPopup = (isVirtual, prize) => {
    if (isVirtual) {
      Toast.info(`恭喜你抽中${prize},奖品已存放到你的账户`, 2, null, false)
      return
    }
zhanghaozhe committed
621 622 623 624 625 626 627 628 629 630 631 632
    http.get(`${API.home}/sys/user_address_info`).then((res) => {
      const { data, code, msg } = res.data
      // eslint-disable-next-line eqeqeq
      if (code == 200) {
        this.recordInstance && this.recordInstance.close()
        this.setState({
          address: {
            ...this.state.address,
            ...{
              name: data.name,
              phone: Number(data.phone),
              address: data.address,
xuzhenghua committed
633
            },
zhanghaozhe committed
634 635 636 637 638 639 640
          },
          addressPopupVisible: true,
        })
      } else {
        Toast.info(msg, 2, null, false)
      }
    })
xuzhenghua committed
641 642
  }

xuzhenghua committed
643 644 645 646 647 648 649 650 651 652 653 654 655
  render() {
    const {
      navs,
      userInfo,
      isRule,
      isCourse,
      isFormal,
      isSign,
      showRecordList,
      shareMark,
      index,
      isApp,
      isClose,
xuzhenghua committed
656 657 658
      testSum,
      address,
      addressPopupVisible,
xuzhenghua committed
659
      onlyShow,
xuzhenghua committed
660
    } = this.state
zhanghaozhe committed
661
    const { history } = this.props
xuzhenghua committed
662 663
    const isLogin = !this.props.user.hasError
    return (
zhanghaozhe committed
664
      <div id={"blessing-preheat"}>
xuzhenghua committed
665 666 667 668 669
        <Banner
          isFormal={isFormal}
          navs={navs}
          toSection={this.toSection}
          index={index}
xuzhenghua committed
670
          onlyShow={onlyShow}
xuzhenghua committed
671
        />
xuzhenghua committed
672

xuzhenghua committed
673
        {/* 精品课程特惠专区--返场 */}
zhanghaozhe committed
674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689
        {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}
            />
          </>
        )}
xuzhenghua committed
690 691

        {/* 大咖直播--返场 */}
zhanghaozhe committed
692
        {onlyShow && <Live isFormal={isFormal} isLogin={isLogin} />}
xuzhenghua committed
693

xuzhenghua committed
694
        {/* 抽奖--正式 */}
zhanghaozhe committed
695
        {isFormal === 1 && (
xuzhenghua committed
696
          <>
zhanghaozhe committed
697 698 699 700 701 702
            <ListHeader
              id={"lucky-draw"}
              text="幸运大抽奖"
              styles={{ margin: onlyShow ? "30px 0 10px" : "60px 0 10px" }}
            />
            {onlyShow ? <p className="active_over">活动已结束</p> : null}
xuzhenghua committed
703
            <div className="formal-draw-btns">
zhanghaozhe committed
704 705 706 707 708 709 710 711 712
              <button
                className="luck-draw__button"
                onClick={() => this.handleToShow("isRule")}
              >
                活动规则&gt;
              </button>
              <button className="prize-record" onClick={this.getMyPrizeRecord}>
                中奖记录&gt;
              </button>
xuzhenghua committed
713
            </div>
zhanghaozhe committed
714
            <FormalDraw toLogin={this.toLogin} isApp={isApp} />
xuzhenghua committed
715
          </>
zhanghaozhe committed
716
        )}
xuzhenghua committed
717

xuzhenghua committed
718
        {/* 积福气 */}
zhanghaozhe committed
719 720 721 722 723 724
        <ListHeader
          id={"lucky-value"}
          text="积福气,享受更多福利"
          styles={{ margin: "30px 0 15px" }}
        />
        {onlyShow ? <p className="active_over">活动已结束</p> : null}
xuzhenghua committed
725
        <Link className="blessing__sort" to="/blessingRank"></Link>
xuzhenghua committed
726 727 728 729 730 731

        <CollectBlessing
          isSign={isSign}
          userInfo={userInfo}
          isLogin={isLogin}
          history={this.props.history}
zhanghaozhe committed
732 733 734 735
          toSection={(e) =>
            this.toSection(this.fetchMoudleId("best-courses"), e)
          }
          handleToShowList={() => this.handleToShow("isCourse")}
xuzhenghua committed
736 737
          handleToShowNotice={this.handleToShowNotice}
          toLogin={this.toLogin}
zhanghaozhe committed
738
          handleToShowShare={() => this.handleToShow("shareMark")}
xuzhenghua committed
739 740 741
        />

        {/* 幸运大抽奖--预热 */}
zhanghaozhe committed
742
        {isFormal === 0 && (
xuzhenghua committed
743
          <>
zhanghaozhe committed
744 745 746 747 748
            <ListHeader
              id={"lucky-draw"}
              text="幸运大抽奖"
              styles={{ margin: "30px 0 10px" }}
            />
xuzhenghua committed
749
            <p className="luck-draw__tip">- 将于111110点开启 -</p>
zhanghaozhe committed
750 751 752 753 754 755 756
            <button
              className="luck-draw__button"
              onClick={() => this.handleToShow("isRule")}
            >
              活动规则&gt;
            </button>
            <LuckDraw />
xuzhenghua committed
757
          </>
zhanghaozhe committed
758
        )}
xuzhenghua committed
759 760

        {/*定金--只在预热期间显示*/}
zhanghaozhe committed
761
        {isFormal === 0 && (
xuzhenghua committed
762
          <>
zhanghaozhe committed
763 764 765 766 767 768
            <ListHeader
              id={"deposit"}
              text="预付1元定金,最高可省100元"
              styles={{ margin: "30px 0 15px" }}
            />
            <ReserveCourse isApp={isApp} />
xuzhenghua committed
769
          </>
zhanghaozhe committed
770
        )}
xuzhenghua committed
771 772

        {/* 精品课程特惠专区 */}
zhanghaozhe committed
773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801
        {!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}
            />
          </>
        )}

        {isRule && (
          <RulePopup handleToHide={() => this.handleToHide("isRule")} />
        )}
        {isCourse && (
          <CoursePopup
            toLogin={this.toLogin}
            history={history}
            isLogin={isLogin}
            handleToHide={() => this.handleToHide("isCourse")}
          />
        )}
        {showRecordList && (
xuzhenghua committed
802
          <RecordPopup
xuzhenghua committed
803
            history={this.props.history}
zhanghaozhe committed
804
            handleToHide={() => this.handleToHide("showRecordList")}
xuzhenghua committed
805
          />
zhanghaozhe committed
806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822
        )}
        {shareMark && (
          <SharePopup
            isClose={isClose}
            toClose={() => this.handleToHide("shareMark")}
          />
        )}
        <ListHeader
          id={"ai-test"}
          text="全国AI工程师水平测试"
          styles={{ margin: "30px 0 15px" }}
        />
        {onlyShow ? <p className="active_over">活动已结束</p> : null}
        <div
          className="test__record"
          onClick={() => this.handleToShow("showRecordList", true)}
        >
zhanghaozhe committed
823
          测试记录&gt;
xuzhenghua committed
824 825 826 827 828 829 830 831 832 833
        </div>
        <LevelTest
          history={history}
          testSum={testSum}
          isLogin={isLogin}
          toLogin={this.toLogin}
        />

        <RankList></RankList>

xuzhenghua committed
834
        {/* 大咖直播 -- 正式活动 */}
zhanghaozhe committed
835
        {!onlyShow && <Live isFormal={isFormal} isLogin={isLogin} />}
xuzhenghua committed
836

zhanghaozhe committed
837
        {addressPopupVisible && (
xuzhenghua committed
838 839 840 841
          <div className="address-mask">
            <div className="address-popup">
              <div className="title">收货信息</div>
              <div className="address-info-container">
zhanghaozhe committed
842 843 844 845 846 847 848 849 850 851 852
                <div className="tip">
                  请及时填写收货信息,获得实物奖品后将第一时间为您邮寄
                </div>
                <input
                  type="text"
                  placeholder={"收件人"}
                  name={"name"}
                  onChange={(e) => {
                    this.setAddressState(e)
                  }}
                  value={address.name}
xuzhenghua committed
853
                />
zhanghaozhe committed
854 855 856 857 858 859 860 861
                <input
                  type="tel"
                  placeholder={"联系方式"}
                  name={"phone"}
                  onChange={(e) => {
                    this.setAddressState(e)
                  }}
                  value={address.phone}
xuzhenghua committed
862
                />
zhanghaozhe committed
863 864 865 866 867 868 869 870
                <input
                  type="text"
                  placeholder={"收货地址"}
                  name={"address"}
                  onChange={(e) => {
                    this.setAddressState(e)
                  }}
                  value={address.address}
xuzhenghua committed
871
                />
zhanghaozhe committed
872
                {/* eslint-disable-next-line eqeqeq */}
zhanghaozhe committed
873 874 875
                <button
                  type="button"
                  className={
zhanghaozhe committed
876 877 878
                    address.name !== "" &&
                    String(address.phone) !== "" &&
                    address.address !== ""
zhanghaozhe committed
879 880 881 882 883 884
                      ? "active"
                      : ""
                  }
                  onClick={this.submitAddress}
                >
                  提交
xuzhenghua committed
885
                </button>
zhanghaozhe committed
886 887 888 889 890 891 892 893
                <i
                  className={"iconfont iconiconfront-2"}
                  onClick={() => {
                    this.setState({
                      addressPopupVisible: false,
                    })
                  }}
                />
xuzhenghua committed
894 895 896
              </div>
            </div>
          </div>
zhanghaozhe committed
897
        )}
xuzhenghua committed
898 899 900 901 902 903
      </div>
    )
  }
}

export default compose(
zhanghaozhe committed
904
  connect((state) => ({ user: state.user }), { setCurrentUser, startFetchUser })
xuzhenghua committed
905
)(BlessingPreheat)