import './sass/custom.scss';
import React,{Component} from 'react';
import {Layout} from 'antd';

const {Footer} = Layout;

export function CopyRight() {
    return (
        <div className="copyright">
            <span>💐 Zip Alvelous</span>
            <span>🍒 blog.ourfor.top</span>
        </div>
    );
}

export function MyFooter(props){
    return (
        <Footer style={{ textAlign: 'center' }}>
            <CopyRight />
        </Footer>
    );
}

export function Ipc(props){
    return (
        <div className="ipc">
            <a href="https://blog.ourfor.top">
                <span>💐 鱼香肉丝的部落阁</span>
            </a>
            <a href="http://www.beian.miit.gov.cn">
                <span>🍒 湘ICP备19022818号-1</span>
            </a>
        </div>
    );
}

const weather = [
    '⛅️','🌦','🌧','⛈','🌩','🔥','💥',
    '🌨','⛄️','🌬','💨','🌪','🌫','☔️',
    '💧','💦','☂','🌥','🌤'
]
const map = {
    xue: 8, lei: 4, shachen: 11, wu: 12, bingbao: 3, yun: 18, yu: 3, yin: 17, qing: 18
}

class Weather extends Component {
    
    
    constructor(props){
        super(props);
        this.state = {
            isLoaded: false
        };
    }

    componentDidMount(){
        $.get('https://www.tianqiapi.com/api/?appid=78525678&appsecret=R72kuNVv',data => {
            this.setState({
                isLoaded: true,
                data
            });
        },'json')
    }

    render(){
        if(this.state.isLoaded){
            let data = this.state.data;
            let now = data.data[0];
            return (
                <div className="weather">
                    <span>🏠 {data.city}</span>
                    <span>{weather[map[now.wea_img]]} {now.wea}</span>
                    <span>🌡 {`${now.tem2}~${now.tem1}`}</span>
                    <span>📚 &copy; 2016 ~ 2019</span>
                </div>
            );
        } else {
            return <></>
        }
    }
}

export { Weather };