import Vue from 'vue'
import 'element-ui/lib/theme-chalk/index.css'
import App from './App.vue'
import store from './store/index'
import ElementUI from 'element-ui'
import router from './router'
import * as echarts from 'echarts'
import curd from '@/utils/curd'
// import '@/styles/index.scss' // global css
import VueParticles from 'vue-particles'
import jsonp from 'vue-jsonp'
import { Guid } from '@/utils/tool'
import service from '@/utils/request'
import scroll from 'vue-seamless-scroll'
import mqtt from 'mqtt'
import elDragDialog from '@/directive/el-dragDialog'
import dataV from '@jiaminghi/data-view'
import VideoPlayer from 'vue-video-player'

require('video.js/dist/video-js.css')
require('vue-video-player/src/custom-theme.css')
Vue.use(VideoPlayer)

Vue.use(elDragDialog)
// 关闭点弹窗周围关闭功能 -- 20200218
ElementUI.Dialog.props.closeOnClickModal.default = false
Vue.prototype.Guid = Guid
Vue.prototype.ExecDatabase = function(num) {
  return service({
    url: '',
    method: 'post',
    data: num
  })
}
Vue.use(scroll)
Vue.use(VueParticles)
Vue.use(curd)
Vue.use(jsonp)
Vue.use(ElementUI)
Vue.use(dataV)

Vue.prototype.echarts = echarts
Vue.prototype.mqtt = mqtt
Vue.config.productionTip = true
Vue.directive('loadmore', {
  bind(el, binding) {
    var p = 0
    var t = 0
    var down = true
    var selectWrap = el.querySelector('.el-table__body-wrapper')
    selectWrap.addEventListener('scroll', function() {
      // 判断是否向下滚动
      p = this.scrollTop
      // if ( t < p){down=true}else{down=false}
      if (t < p) {
        down = true
      } else {
        down = false
      }
      t = p
      // 判断是否到底
      const sign = 10
      const scrollDistance = this.scrollHeight - this.scrollTop - this.clientHeight
      if (scrollDistance <= sign && down) {
        binding.value()
      }
    })
  }
})
new Vue({
  store,
  router,
  render: h => h(App)
}).$mount('#app')
