import './index.less'
import React, { useEffect, useState } from "react";

import { Link, useHistory } from 'react-router-dom';
import kemu1 from './../../assets/images/kemu1.png'
import kemu2 from './../../assets/images/kemu2.png'
import kemu3 from './../../assets/images/kemu3.png'
import kemu4 from './../../assets/images/kemu4.png'
import api from '~/api'
export const VideoKindList: React.FC = (props: any) => {
    const [list, setList] = useState([{
        image: kemu1,
        title: "科目一"
    }, {
        image: kemu2,
        title: "科目二"
    }, {
        image: kemu3,
        title: "科目三"
    }, {
        image: kemu4,
        title: "科目四"
    }])
    useEffect(() => {

        let query = new URLSearchParams(window.location.search)
        api.studentUserInfo()
        if (query.get("state") == 'LOGIN') {
            api.loginGzhcode({
                authorizationCode: query.get("code") || ""
            }).then(res => {
                window.localStorage.setItem("token", res.data.data.token)
                window.location.replace('/')
                console.log(res.data.data.token)
            })
        }







    }, [])
    return (
        <div className="videokindList">
            <div className="list">
                {
                    list.map((item, index) => {
                        return (
                            <Link key={index} to={
                                './videoList?subject=' + (index + 1)
                            }>
                                <div className="list-item" key={index}>
                                    <img className="list-item-img" src={item.image} alt="图片" />
                                    <span className="list-item-text top54 ">{item.title}</span>
                                    <span className="list-item-text top128 left40">《视频讲解》</span>
                                </div>
                            </Link>


                        )
                    })

                }
            </div>
        </div>
    )

}