import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import vueEsign from 'vue-esign'
import './assets/css/reset.css'
import './assets/css/common.css'
import './JS/plugin'
import './JS/FastClick'
import 'vant/lib/index.css'
import 'amfe-flexible'
import filters from './JS/filter'
import './JS/vconsole.js'
import utils from './JS/utils'
import WebUploader from 'webuploader'
import VueScroller from 'vue-scroller'
import './components/icon'
import { get, post, http } from './JS/ajax'
import FastClick from 'fastclick'
import './vant'
import './style/van-field.less'
import Header from '@/components/header'
import Radio from '@/components/module/radio'
import Checkbox from '@/components/module/checkbox'
import Input from '@/components/module/input.vue'
import Select from '@/components/module/select.vue'
import Date from '@/components/module/date.vue'
import Time from '@/components/module/time.vue'
import Uploader from '@/components/module/uploader.vue'
import FileUploader from '@/components/module/fileUploader.vue'
import ImageUpload from '@/components/module/imageUpload.vue'
import MultipleSelect from '@/components/module/multipleSelect.vue'
import { examine } from './utils/examine'
import { findItemById } from './utils/find'
import { Toast } from 'vant'
import vueMiniPlayer from 'vue-mini-player' // 视频播放器
import 'vue-mini-player/lib/vue-mini-player.css'// 视频播放器
Vue.use(Toast)
Vue.component(Uploader.name, Uploader)
Vue.component(FileUploader.name, FileUploader)
Vue.component(ImageUpload.name, ImageUpload)
Vue.component(Header.name, Header)
Vue.component(Time.name, Time)
Vue.component(Radio.name, Radio)
Vue.component(Checkbox.name, Checkbox)
Vue.component(Input.name, Input)
Vue.component(Select.name, Select)
Vue.component(Date.name, Date)
Vue.component(MultipleSelect.name, MultipleSelect)
Vue.use(WebUploader)
Vue.use(VueScroller)
Vue.use(utils)
Vue.use(vueEsign)
Vue.use(vueMiniPlayer)// 视频播放器
Vue.prototype.$http = { get, post, http }
Vue.prototype.$examine = examine
Vue.prototype.$findItemById = findItemById
// 注入全局过滤器
Object.keys(filters).forEach(item => {
  Vue.filter(item, filters[item])
})
FastClick.attach(document.body)

Vue.config.productionTip = false

router.beforeEach((to, from, next) => {
  // const token = window.localStorage.getItem('token') || ''
  // console.log(token, 'token')
  document.title = to.meta.title
  if (!to.meta.title) {
    next('/')
  } else {
    next()
  }
})

export default new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
