// 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 './store' //引入store
import "lib-flexible/flexible"
import qs from 'qs'
import preview  from 'vue-photo-preview'
import 'vue-photo-preview/dist/skin.css'
import BaiduMap from 'vue-baidu-map' //百度地图
import VueAMap from 'vue-amap' //高德地图
import clipper from '../static/clipper'
// import Back from './appback.js'
import MeScroll from 'mescroll.js'
import 'mescroll.js/mescroll.min.css'
import waterfall from 'vue-waterfall2'//瀑布流插件

//瀑布流加上拉加载

//瀑布流加上拉加载


import Vant from 'vant'
import 'vant/lib/index.css'


import VueAwesomeSwiper from 'vue-awesome-swiper'
import 'swiper/css/swiper.min.css'
Vue.use(VueAwesomeSwiper)
Vue.use(Vant)

// 点赞效果
import VueStar from 'vue-star'
Vue.component('VueStar', VueStar)

//切割图片
import VueCropper from 'vue-cropper'
Vue.use(VueCropper)

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



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

Vue.use(clipper)
Vue.use(BaiduMap, {
  ak: 'XCRCftAKzkKt44waETfPeVo5dBsfAR9u'
})

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:80' //配置全部接口的api前缀 
// axios.defaults.baseURL = 'http://127.0.0.1:8000' //配置全部接口的api前缀
// axios.defaults.baseURL = 'http://120.27.222.26:5555' //配置全部接口的api前缀
// axios.defaults.baseURL = 'http://39.104.94.153:9999' //配置全部接口的api前缀
// axios.defaults.baseURL = 'http://192.168.1.11:8000' //配置全部接口的api前缀


// axios.defaults.baseURL = 'http://47.99.110.100:8080' //配置全部接口的api前缀-中科院


// axios.defaults.baseURL = '/api' //配置全部接口的api前缀
// axios.defaults.headers.post['Content-Type'] = 'application/json';



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,
  components: { App },
  template: '<App/>'
})
