list.js 2.2 KB
Newer Older
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
1 2
import React from 'react';
import styles from './list.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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
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])
      menus.push(
        <div className={styles.row} key={i}>
          <div className={styles.col} key={images[i].key}>
            <img src={images[i].image} alt="" onClick={()=>goPage(images[i].key)} />
            <span>{images[i].title}</span>
          </div>
         {i+1< images.length &&  <div className={styles.col} key={images[i+ 1].key}>
            <img src={images[i + 1].image} alt="" onClick={()=>goPage(images[i + 1].key)} />
            <span>{images[i + 1].title}</span>
          </div>}
          {i+2< images.length && <div className={styles.col} key={images[i+ 2].key}>
            <img src={images[i + 2].image} alt="" onClick={()=>goPage(images[i + 2].key)} />
            <span>{images[i + 2].title}</span>
          </div>}
        </div>,
      );
    }
    i += 3;
  }
  return menus;
};
const Index = () => {
  return <div className={styles.root}>{renderMenu()}</div>;
duanledexianxianxian's avatar
sync  
duanledexianxianxian committed
92 93 94
};

export default Index;