// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui' //element-ui的全部组件
import 'element-ui/lib/theme-chalk/index.css' //element-ui的css
import 'element-ui/lib/index.js' //element-ui的js
import axios from 'axios' //引入axios组件
import store from './vuex' //引入store
import "lib-flexible/flexible"
import qs from 'qs'
import Back from './appback.js'
import Imei from './imei.js'
import preview  from 'vue-photo-preview'
import 'vue-photo-preview/dist/skin.css'
import VueAMap from 'vue-amap' //高德地图
import Toast from './components/Toast'
import VueInputCode from 'vue-input-code' //验证码页面组件
Vue.component('VueInputCode', VueInputCode)
import MeScroll from 'mescroll.js'
import 'mescroll.js/mescroll.min.css'
import echarts from 'echarts' //百度图表插件
import VueCropper from 'vue-cropper' //图片上传剪切插件
Vue.use(VueCropper)


//图片懒加载
import VueLazyLoad from 'vue-lazyload'
Vue.use(VueLazyLoad, {
  preLoad: 1,
  error: require('./assets/assets/noimage.png'),
  loading: require('./assets/assets/shot.gif'),
  attempt: 2,
})


Vue.prototype.$echarts = echarts;  //百度图表插件
Vue.use(Toast)
Vue.use(VueAMap);
VueAMap.initAMapApiLoader({
  key: "fdc489725992ba738397be65dc657d9e",
  // key: "9684a36adacb0ae49e22c8aed1388dd6",
  // key: "fbf78ae9f8ced913ecf1887a97028a19",
  plugin: [
    'AMap.Autocomplete',
    'AMap.PlaceSearch', // POI搜索插件
    'AMap.Scale', // 右下角缩略图插件 比例尺
    'AMap.ToolBar', // 地图工具条
    'AMap.CircleEditor', // 圆形编辑器插件
    'AMap.Geolocation', // 定位控件，用来获取和展示用户主机所在的经纬度位置
    'AMap.Geocoder'
  ],
  uiVersion: '1.0'
})

Vue.use(preview)
Vue.prototype.$rem = rem
Vue.prototype.$qs =qs;
Vue.use(ElementUI) //使用elementUI
Vue.prototype.$axios = axios //使用aixos
// axios.defaults.baseURL = 'http://47.104.218.216:8000' //配置全部接口的api前缀-大服务器
// axios.defaults.baseURL = 'http://120.27.222.26:80' //配置全部接口的api前缀-大服务器
// axios.defaults.baseURL = 'http://192.168.1.11:9000' //测试
// axios.defaults.baseURL = 'http://39.104.94.153:80' //配置全部接口的api前缀-小服务器
// axios.defaults.baseURL = 'http://192.168.2.24:8000' //配置全部接口的api前缀-本地



// axios.defaults.baseURL = 'bigservers/' //配置全部接口的api前缀-
Vue.config.productionTip = false

router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title
  }
  const type = to.meta.type;
  // 判断该路由是否需要登录权限
  if (type === 'login') {
    if (window.sessionStorage.getItem('login')) {
      next()
    } else {
      next('/')
    }
  } else {
    next()  // 确保一定要有next()被调用
  }
})



/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store, //使用store
  Back,
  Imei,
  components: { App },
  render: h => h(App),
  template: '<App/>'
})
