import Vue from 'vue'
import http from './http';
import App from '@/root/App.vue'
import axios from 'axios'
import router from './router'
import store from './store'
import '@/common/directives/test'
import baseCom from '@/common/components/global.js'
import ElementUI from 'element-ui'
import '../../assets/font/iconfont.css'
import 'element-ui/lib/theme-chalk/index.css'
import '../../assets/css/MapPoint.css'
import '../../assets/css/page.styl'
import './filters/filters';
import PageComponent from './components/Pagination/index';
import commonJS from './utils/common';
import echarts from 'echarts';
Vue.prototype.$echarts = echarts;

// import webSocket from './utils/webSocket.js';
Vue.prototype.axios = http;
Vue.prototype.$common = commonJS;
Vue.prototype.$echarts = echarts;
// Vue.prototype.$webSocket = webSocket;

// 引入高德使用高德
import VueAMap from 'vue-amap';
import { lazyAMapApiLoaderInstance } from 'vue-amap';

Vue.use(PageComponent)

Vue.use(VueAMap);
// VueAMap.initAMapApiLoader({
//   key: "937eb4405db2a8895695506871c3a1d5",
//   plugin: [
//     "AMap.Autocomplete",
//     "AMap.PlaceSearch",
//     "AMap.Scale",
//     "AMap.OverView",
//     "AMap.ToolBar",
//     "AMap.MapType",
//     "AMap.PolyEditor",
//     "AMap.CircleEditor"
//   ],
//   v: "1.4.4",
//   uiVersion: "1.0.11"
// });
// Vue.prototype.$host = 'http://192.168.1.66:8081'; 

Vue.use(ElementUI)
Vue.config.productionTip = false

import myToast from '@/common/plugins/Toast'
Vue.use(myToast())

import '@/assets/css/base.css'
import '@/assets/css/fun.styl'
import '@/assets/css/common.css'

baseCom().forEach((item)=>{
  Vue.component(item.comName,item.comDefault)
})

// title
Vue.use(require('vue-wechat-title'));

import EventProxy from 'vue-event-proxy';
Vue.use(EventProxy);

Vue.prototype.pathReg = /(http|https):\/\/([\w.]+\/?)\S*/

Vue.prototype.getButton =function (id,callback) {
  var url="https://app.edtyun.com:8443/system/menu/getButton"
  var param = {
      menuId:id
  }
  
  return axios.post(url, param,{ headers: {'Authorization': JSON.parse(sessionStorage.getItem('token')),'MobileType':0}})
  
}

Vue.prototype.$userId = global.$userId = function () {
  let userId = sessionStorage.getItem('user');
  if (userId) {
    return userId;
  }
  return null;
}

Vue.prototype.$userName = global.$userName = function () {
  let userName = sessionStorage.getItem('userName');
  if (userName) {
    return userName;
  }
  return null;
}

Vue.config.productionTip = false
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
