index.js 3.97 KB
Newer Older
xuzhenghua committed
1 2 3
import React, { Component } from 'react'
import './index.scss'
import listFrame from './../listFrame/index';
zhanghaozhe committed
4
import { http, SendMessageToApp, getParam} from "src/utils"
xuzhenghua committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

class LevelTest extends Component {
  constructor(props) {
    super(props);
    this.state = {
      testNumber: '',
      number: 1,
      prizeListUrl: [
        {
          url:
            "https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_1111/AIExam/top1.png"
        },
        {
          url:
            "https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_1111/AIExam/top2.png"
        },
        {
          url:
            "https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_1111/AIExam/top3-4.png"
        },
        {
          url:
            "https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_1111/AIExam/top5-7.png"
        },
        {
          url:
            "https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_1111/AIExam/top8-10.png"
wangshuo committed
32 33 34 35
        },
        {
          url:
            "https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_1111/AIExam/top11-20.png"
xuzhenghua committed
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
        }
      ],
    }
  }

  componentDidMount() {
    const {isLogin} = this.props;
    if(isLogin) {
      http.get(`${API.home}/sys/ai_test/get_user_testinfo`).then(res => {
        let {code, data: {user_test_total, user_residue_number}} = res.data;
        if(code === 200) {
          this.setState({
            testNumber: user_test_total,
            number: user_residue_number
          })
        }
      });
    }
  }

  startTest = () => {
FE committed
57
    const {isLogin, toLogin} = this.props;
xuzhenghua committed
58
    if(isLogin) {
xuzhenghua committed
59 60 61
      var _czc = _czc || [];
      _czc.push(["_trackEvent", 'AI水平测试', 'm端双十一AI水平测试-点击测试']);

FE committed
62 63 64
      if(getParam('version')) {
        window.location.href = `${API.m}/levelTest/test?version=${getParam('version')}`;
      }else{
xuzhenghua committed
65
        window.location.href = `${API.m}/levelTest/test`;
FE committed
66
      }
xuzhenghua committed
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
    }else{
      toLogin();
    }
  }

  render() {
    let {
      testNumber,
      number,
      prizeListUrl,
    } = this.state;
    const {isLogin, testSum} = this.props;
    return (
      <>
      <div className="level__test_module">
        <div className='start__test' onClick={this.startTest}>
          <img className='test-img' src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/active19_1111/m/test_icon.png" />
          <div className="button__text">
            <p>点击测试</p>
          </div>
        </div>
        <div className='test__number'>
          已有
          <span className='number'>
            {testNumber || testSum}
          </span>
          人参加测试
        </div>
        <div className='prize__rules'>
          <div className="prize__title"> 活动奖品 </div>
          <div className="prize__list">
            {
              prizeListUrl.map((item, index) => {
                return (
                  <div className='prize__container' key={index}>
                    <img src={item.url} />
                  </div>
                )
              })
            }
          </div>

          <div className="prize__title"> 活动规则 </div>
          <div className="rules__text">
            <p>1. 115日至1113日之间每人有一次测试机会,可通过“集福气”活动额外获得2次测试机会;</p>
            <p>2. 单次测试时间为一小时,超时自动提交试卷;</p>
            <p>3. 试卷内容为Python基础(8道题*3分)、机器学习(12道题*3分)、深度学习(10道题*4分),总分100分;</p>
            <p>4. 无固定试卷,参与测试时从试题库中随机抽题组卷;</p>
            <p>5. 排行榜实时更新,分数相同则用时短者排名更高,多次测试保留最高分;</p>
            <p>6. 如发现某账号有作弊嫌疑,七月在线有权清空账号测试成绩;</p>
            <p>7. 活动最终解释权归七月在线所有。</p>
          </div>
        </div>
      </div>
      </>
    )
  }
}

export default listFrame(LevelTest)