import Vue from 'vue'
import axios from 'axios'
import Vuex from 'vuex'

Vue.use(Vuex)
// const homePath = window.sessionStorage.getItem('homePath') || '/index/home';
const activePath = window.sessionStorage.getItem('activePath') || '/index/home';


const state = {
    // homePath:homePath,
    activePath:activePath,   //激活的菜单项
    // baseLandList:[]
    // skin:'custom-ffffff'
}
const mutations = {
    changeHomePath(state,payload){
        var _state = state;
        var _payload = payload;
        _state.homePath = _payload.homePath;
        window.sessionStorage.setItem('activePath',_payload.homePath)
        // setTimeout(function(){
            console.log(_state)
            console.log(_payload)
            
            _state.activePath = _payload.homePath;
            window.sessionStorage.setItem('homePath',_payload.homePath)
        // },4000)
    },
    saveActiveState(state,payload){
        state.activePath = payload.activePath;  
        window.sessionStorage.setItem('activePath',payload.activePath)
    },
}
const actions = {
    getBaseLandList({state}){
        console.log(Vue);
        console.log(this);
        axios({
            method:"POST",
            url:"/api/api_gateway?method=ascend.ascend_manage.all_base",
        }).then((res)=>{
            if (res.data.message== "") {
                console.log(111);
                state.baseLandList=res.data.data.data;
            }
        })
    }
}

export default new Vuex.Store({
    state,
    mutations,
    actions,
})