
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store'
import './permission'
import './utils/validator'
import '../css/reset.css'
import echarts from 'echarts'

// import VConsole from 'vconsole'
// new VConsole()

import {
  Tabbar,Empty, TabbarItem,Grid, GridItem,Field,NavBar,Row, Col,Cell, CellGroup,Toast,Popup,Dialog,RadioGroup, Radio,Notify,
  Button,Icon
} from 'vant'
import Icon1 from 'vue2-svg-icon/Icon'

import VueScroller from '@/components/common/scroller/src'
import noData from '@/components/common/noData'
import {getTypes, getUserData, isPt_id, getCache, setCache } from '@/utils/auth'

Vue.prototype.$userInfo=getUserData;
Vue.prototype.$getTypes = getTypes()
Vue.prototype.$getCache = getCache
Vue.prototype.$setCache = setCache
Vue.prototype.$isPt_id = isPt_id
Vue.prototype.$echarts = echarts
Vue.prototype.$wx = (window).wx; // 全局使用

// wx通讯录
import wwOpenDAtas from '@/view/wxOpendata'
Vue.component('Wxopendata', wwOpenDAtas)

Vue.use(Button).use(Tabbar).use(TabbarItem).use(Grid).use(GridItem).use(Field).use(NavBar).use(Row).use(Col).use(Cell).use(CellGroup).use(Toast).use(Popup).use(Dialog).use(RadioGroup).use(Radio).use(Icon).use(Notify).use(Empty)
Vue.use(VueScroller)
Vue.component('icon', Icon1)
Vue.component('noData', noData)
Vue.config.productionTip = false
Vue.prototype.$route_back = function (setp) {
  if(typeof(setp) == 'undefined'){
    setp = -1
  }
  if (window.history.length <= 1 && window.plus) {
    localStorage.setItem('close_setp', setp)
    let all_view = plus.webview.all()
    for(let i = 0; i < all_view.length; i++){
      all_view[i].evalJS('if(window.$ajax_update){window.$ajax_update();}')
      all_view[i].evalJS('window.VueObj.$root.$children[0].parse_com(window.VueObj.$root.$children);window.VueObj.$root.$children[0].keep_alive_update_data = {}')
    }
  //先关掉键盘再
    document.activeElement.blur()
    setTimeout(() => {
      plus.webview.currentWebview().close()
    },100)
  }else{
    window.history.back(setp)
  }
}

Vue.config.ignoredElements = ['ww-open-data'];

window.VueObj = new Vue({
  el: '#app',
  router,
  store,
  components: {App},
  template: '<App/>'
})
