import promise from 'es6-promise';
promise.polyfill();
// import Vue from 'vue';
import App from './App';
import router from './router';
import { Message } from 'element-ui';
import VueAxios from 'vue-axios';
import axios from 'axios';
import store from './store/store';
/* eslint-disable */
import * as types from './store/types';
import '../theme/index.css';
import '../static/css/index.less';
import '../static/font/iconfont.css';
import vueGicDatepicker from '@gic-test/vue-gic-datepicker';
import buttonCode from '@/config/button-code.js';
window.ELEMENT.Dialog.props.closeOnClickModal.default = false; // 全局设置点击蒙层不关闭
Vue.use(vueGicDatepicker);
Vue.config.devtools = true;
Vue.use(VueAxios, axios);
Vue.axios.defaults.withCredentials = true; // 跨域cookie访问
console.log(window.ELEMENT.Dialog)
Vue.axios.interceptors.request.use(
  config => {
    return config;
  },
  err => {
    return Promise.reject(err);
  }
);
Vue.axios.interceptors.response.use(
  response => {
    if (response.status == 200 && response.data.errorCode == 1) {
    }
    return response;
  },
  error => {
    if (error.response) {
      switch (error.response.status) {
        case 401:
          // 401 清除token信息并跳转到登录页面
          // store.commit(types.LOGOUT);
          // router.replace({
          //   path: 'login',
          //   query: {redirect: router.currentRoute.fullPath}
          // });
          window.location.href = window.location.origin + '/gic-web/#/';
        case 500:
          Message.error('服务器500');
      }
    }
    return Promise.reject(error.response.data);
  }
);

window.getLimit(router, 'member-tag').then(() => {
  /* eslint-disable no-new */
  new Vue({
    el: '#app',
    router,
    store,
    components: { App },
    template: '<App/>'
  });
})
