// 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 FastClick from 'fastclick'
import App from './App'
import router from './router/index'
import flexible from './common/ydui.flexible'
import components from './components/component'

import {componentInstall, appStyle} from 'hls-easy-ui'

/**
 * 指令
 */
import directives from './scripts/directives'

import filter from './scripts/filter'

import {
  Picker,
} from 'vux'

import WorkflowPrj from './components/workflow-prj'
import WorkflowCon from './components/workflow-con'

import BasicInfo from './components/Contract/basic-info'
import QuoteInfo from './components/Contract/quote-info'
import QuoteDetail from './components/Contract/quote-detail'
import FileInfo from './components/Contract/file-info'
/**
 * 弹框组件
 */
import hlsPopup from './scripts/hlsPopup'

/**
 * http
 */
import {post, get} from './scripts/hlsHttp'

/** 全局函数hlsUtil**/

import hlsUtil from './scripts/hlsUtil'

if (process.env.CONFIG_ENV === 'uat') {
  const VConsole = require('vconsole')
  new VConsole() // eslint-disable-line
}

Vue.use(directives)

Vue.use(filter)

/**
 * 组件
 */

Vue.use(componentInstall)
Vue.use(components)
Vue.use(appStyle)
Vue.use(flexible)
Vue.component('picker', Picker)
Vue.component('workflow-prj', WorkflowPrj)
Vue.component('workflow-con', WorkflowCon)
Vue.component('basic-info', BasicInfo)
Vue.component('quote-info', QuoteInfo)
Vue.component('quote-detail', QuoteDetail)
Vue.component('file-info', FileInfo)

Vue.prototype.hlsPopup = window.hlsPopup = hlsPopup
Vue.prototype.$devicePixelRatio = 2

Vue.prototype.$post = post
Vue.prototype.$get = get
let hlsHttp = {
  get: get,
  post: post,
}
Vue.prototype.hlsHttp = window.hlsHttp = hlsHttp

Vue.prototype.hlsUtil = window.hlsUtil = hlsUtil

/** end**/

/**
 * 全局返回上一页面
 * @param index
 */
let routeGo = function (index) {
  if (!index) {
    index = -1
  }
  this.$router.go(index)
}
Vue.prototype.$routeGo = routeGo

FastClick.attach(document.body)

Vue.config.productionTip = true


/* eslint-disable no-new */
new Vue({
  data () {
    return {
      pathList: [],
      transitionName: null,
    }
  },
  router,
  watch: { // 监听路由变化
    $route (to, from) {
      document.body.scrollTop = 0
      document.documentElement.scrollTop = 0
    },
  },
  render: h => h(App),
}).$mount('#app-box')
