index.js 2.59 KB
Newer Older
zhanghaozhe committed
1 2
import React, { Component } from "react"
import "./index.scss"
wangshuo committed
3 4

export default class Test extends Component {
wangshuo committed
5
  Change = (data) => {
zhanghaozhe committed
6 7
    let cn = ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十"]
    let newStr = ""
wangshuo committed
8 9 10
    let str = data.toString()
    let ci = Number(str) % 10
    let cs = Math.floor(Number(str) / 10)
zhanghaozhe committed
11
    let cv = ""
wangshuo committed
12
    if (str.length > 1) {
zhanghaozhe committed
13
      if (cs === 1) {
zhanghaozhe committed
14 15 16 17
        cv = ci >= 1 ? cn[9] + cn[ci - 1] : cn[9]
      } else {
        cv = ci > 1 ? cn[cs - 1] + cn[9] + cn[ci - 1] : cn[cs - 1] + cn[9]
      }
wangshuo committed
18
    } else {
zhanghaozhe committed
19
      cv = cn[ci - 1]
wangshuo committed
20 21
    }
    newStr = str.replace(str, cv)
zhanghaozhe committed
22 23
    return newStr
  }
wangshuo committed
24

wangshuo committed
25 26
  render() {
    return (
zhanghaozhe committed
27 28 29 30 31 32 33
      <div className={"test_container"}>
        <p className={"title"}> /  /  / </p>
        <p className={"sub_title"}>
          涵盖完整知识体系,让你掌握实用高效的编程技巧
        </p>
        <div className={"table_container"}>
          <div className={"table_head"}>
wangshuo committed
34 35 36
            <span>序号</span>
            <span>实操项目</span>
          </div>
zhanghaozhe committed
37 38 39 40 41 42 43 44 45 46
          <div className={"table_body"}>
            {this.props.practice.map((item, index) => {
              return (
                <div className="stage-item" key={index}>
                  <div className="stage">{`第${this.Change(item.stage)}阶段 ${
                    item.name
                  }`}</div>
                  {item.questions.map((question, index) => {
                    return (
                      <div key={index} className={"line"}>
47
                        <span>{question.number}</span>
zhanghaozhe committed
48 49
                        <div className={"test_name"}>
                          <img src={question.icon} alt="" />
wangshuo committed
50 51 52
                          <p>{question.name}</p>
                        </div>
                      </div>
zhanghaozhe committed
53 54
                    )
                  })}
wangshuo committed
55 56
                </div>
              )
zhanghaozhe committed
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
            })}
          </div>
          <div className={"table_bottom"}>
            {this.props.allPracticeShow ? (
              <div onClick={() => this.props.hide(2)}>
                <p>收起</p>
                <img
                  src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/h5_python_class/shouqi.png"
                  alt=""
                />
              </div>
            ) : (
              <div onClick={() => this.props.show(2)}>
                <p>展开更多</p>
                <img
                  src="https://julyedu-cdn.oss-cn-beijing.aliyuncs.com/h5_python_class/zhankai.png"
                  alt=""
                />
              </div>
            )}
wangshuo committed
77 78 79 80 81 82
          </div>
        </div>
      </div>
    )
  }
}