index.js 2.22 KB
Newer Older
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
1
import React from 'react';
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
2
import styles from './index.less';
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
3
import router from 'umi/router';
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
4 5 6

const images = [
  {
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
7 8 9
    key: 'single',
    image: '/images/danxuanti.png',
    title: '单选题',
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
10 11
  },
  {
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
12 13 14
    key: 'multiple',
    image: '/images/duoxuanti.png',
    title: '多选题',
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
15 16
  },
  {
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
17 18 19
    key: 'judgment',
    image: '/images/panduanti.png',
    title: '判断题',
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
20 21
  },
  {
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
22 23 24
    key: 'completion',
    image: '/images/tiankongti.png',
    title: '填空题',
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
25 26
  },
  {
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
27 28 29
    key: 'short',
    image: '/images/jiandati.png',
    title: '简答题',
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
30 31
  },
  {
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
32 33 34
    key: 'caseChoice ',
    image: '/images/anlixuanzeti.png',
    title: '案例选择题',
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
35 36
  },
  {
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
37 38 39
    key: 'caseMultiple',
    image: '/images/mingcijieshi.png',
    title: '名词解释',
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
40 41
  },
  {
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
42 43 44
    key: 'b1',
    image: '/images/b1tixing.png',
    title: 'B1题型',
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
45 46
  },
  {
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
47 48 49 50 51 52 53 54
    key: 'argumentation',
    image: '/images/lunshuti.png',
    title: '论述题',
  },
  {
    key: 'analytical ',
    image: '/images/fenxiti.png',
    title: '分析题',
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
55 56
  },
];
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
57 58 59
const goPage = key => {
  router.push(`/exam/question/${key}`);
};
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
60

duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
61 62 63 64 65 66 67 68
const renderMenu = () => {
  const menus = [];
  for (let i = 0; i < images.length; ) {
    if (i % 3 === 0) {
      console.log(i)
      console.log(images[i])
      console.log(images[i + 1])
      console.log(images[i + 2])
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
69 70 71
     const v1= images[i]
     const v2=images[i + 1]
     const v3=  images[i + 2]
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
72 73
      menus.push(
        <div className={styles.row} key={i}>
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
74 75 76
          <div className={styles.col} key={v1.key} data-id={v1.key}>
            <img src={v1.image} alt="" onClick={()=>goPage(v1.key)} />
            <span>{v1.title}</span>
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
77
          </div>
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
78 79 80
         {i+1< images.length &&  <div className={styles.col} key={v2.key} data-id={i+ 1}>
            <img src={v2.image} alt="" onClick={()=>goPage(v2.key)} />
            <span>{v2.title}</span>
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
81
          </div>}
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
82 83 84
          {i+2< images.length && <div className={styles.col} key={v3.key} data-id={i+ 2}>
            <img src={v3.image} alt="" onClick={()=>goPage(v3.key)} />
            <span>{v3.title}</span>
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
85
          </div>}
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
86
        </div>
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
87 88 89 90 91 92 93 94
      );
    }
    i += 3;
  }
  return menus;
};
const Index = () => {
  return <div className={styles.root}>{renderMenu()}</div>;
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
95 96 97
};

export default Index;