// 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 axios from 'axios'
import VueI18n from 'vue-i18n'
import App from './App'
import router from './router'
import ajaxPlug from './plug/index'
import cookie from './assets/utils/cookie'
import commonUtils from './assets/utils/commonUtils'
import tripUtils from './assets/utils/tripUtils'

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

import vueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import echarts from 'echarts'
Vue.prototype.$echarts = echarts
// import VueWebsocket from "vue-websocket"
// import global_ from './components/Global'
//import VueAMap from 'vue-amap'
import VueBarcode from '@xkeshi/vue-barcode'  //导入条形码插件
import chartsUtils from './assets/utils/chartsUtils' //图标工具类
import calendarUtils from './assets/utils/calendarUtils' //日历帮助类
import lunarCalendar from './assets/utils/lunarCalendar' //农历日历帮助类
import googleMap from './assets/utils/googleMap' //引入谷歌地图
import AuthCode from './assets/utils/AuthCode'   //权限编码JS
import store from './store'
import languageUtils from './assets/utils/languageUtils' //引入语言转换帮助类
// import htmlToPdf from './assets/utils/htmlToPdf'
import DMCUtils from './assets/utils/DMCUtils'

import pinyin from 'pinyin'

// import JsPDF from 'jspdf'
import lrz from 'lrz'
import 'vue-easytable/libs/themes-base/index.css'
import { VTable, VPagination } from 'vue-easytable'
import 'viewerjs/dist/viewer.css'
import Viewer from 'v-viewer'



Vue.component(VTable.name, VTable)
Vue.component(VPagination.name, VPagination)
Vue.config.productionTip = false
Vue.http = Vue.prototype.$http = axios
Vue.cookie = Vue.prototype.$cookie = cookie
Vue.commonUtils = Vue.prototype.$commonUtils = commonUtils
Vue.tripUtils = Vue.prototype.$tripUtils = tripUtils
Vue.DMCUtils = Vue.prototype.$DMCUtils = DMCUtils
Vue.languageUtils = Vue.prototype.$languageUtils = languageUtils

Vue.calendarUtils = Vue.prototype.$calendarUtils = calendarUtils
Vue.lunarCalendar = Vue.prototype.$lunarCalendar = lunarCalendar
Vue.googleMap = Vue.prototype.$googleMap = googleMap
Vue.AuthCode = Vue.prototype.$AuthCode = AuthCode
Vue.prototype.$echarts = echarts
Vue.chartsUtils = Vue.prototype.$chartsUtils = chartsUtils
Vue.prototype.$VueBarcode = VueBarcode
// Vue.prototype.GLOBAL = global_
// Vue.component('barcode', VueBarcode);
Vue.prototype.pinyin = pinyin

// Vue.prototype.h2c=h2c
Vue.prototype.lrz = lrz

/* eslint-disable no-new */
// Vue.use(htmlToPdf)
Vue.use(VueI18n) // 通过插件的形式挂载
Vue.use(ajaxPlug)
Vue.use(ElementUI)
Vue.use(vueQuillEditor)
//Vue.use(VueAMap);
Vue.use(VueBarcode);  //声明条形码组件
Vue.use(store);
Vue.use(Viewer, {
  defaultOptions: {
    zIndex: 9999
  }
})
//Vue.use(OSS);




// 时间扩展格式化
Date.prototype.Format = function (fmt) {
  var o = {
    "M+": this.getMonth() + 1, //月份
    "d+": this.getDate(), //日
    "h+": this.getHours(), //小时
    "m+": this.getMinutes(), //分
    "s+": this.getSeconds() //秒
  };
  if (/(y+)/.test(fmt)) { //根据y的长度来截取年
    fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  }
  for (var k in o) {
    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  }
  return fmt;
};
Vue.prototype.DateDiff = function (sDate1, sDate2) {
  var aDate, oDate1, oDate2, iDays
  aDate = sDate1.split("-")
  oDate1 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0])
  aDate = sDate2.split("-")
  oDate2 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0])
  iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 / 24)    //把相差的毫秒数转换为天数  
  return iDays
}

// 数组对比
Array.prototype.equals = function (array) {
  // if the other array is a falsy value, return
  if (!array)
    return false;

  // compare lengths - can save a lot of time
  if (this.length != array.length)
    return false;

  for (var i = 0, l = this.length; i < l; i++) {
    // Check if we have nested arrays
    if (this[i] instanceof Array && array[i] instanceof Array) {
      // recurse into the nested arrays
      if (!this[i].equals(array[i]))
        return false;
    }
    else if (this[i] != array[i]) {
      // Warning - two different object instances will never be equal: {x:20} != {x:20}
      return false;
    }
  }
  return true;
};

// VueAMap.initAMapApiLoader({
//   // 高德的key
//   key: 'b0fb63eaf3daca5e673d5a61573e2287',
//   // 插件集合
//   plugin: ['AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor'],
//   // 高德 sdk 版本,默认为 1.4.4
//   v: '1.4.4'
// });




const i18n = new VueI18n({
  locale: 'zh-CN',    // 语言标识
  //this.$i18n.locale // 通过切换locale的值来实现语言切换
  messages: {
    'zh-CN': require('./assets/common/lang/zh'),   // 中文语言包
    'en-US': require('./assets/common/lang/en'),    // 英文语言包
    'zh-TW': require('./assets/common/lang/zh-tw'),    // 台湾语言包
    'Japanese': require('./assets/common/lang/jp')    // 日本语言包
  }
})



new Vue({
  el: '#app',
  router,
  i18n,
  cookie,
  store,
  components: { App },
  template: '<App/>'
}).$mount('#app')