import Vue from 'vue'
import store from './store'
import App from './App'
import './services/index.js'
import * as Api from '@/common/config/caimeiApi.js'
import * as Regs from '@/common/config/common.js'
import { dateFormat } from './utils/util.js'
import global from '@/mixins/global.js'
import ResidenceTime from './plugins/simple-residence-time'
import residence from './utils/residence.js'

// 公共组件 全局组件
import { msg, modal, prePage, boundingClientRect } from './utils/util'
import cuCustom from './components/cm-custom/cu-custom.vue'
import auCustom from './components/cm-custom/au-custom.vue'
import cmCustom from './components/cm-custom/cm-custom.vue'
import scrollTop from '@/components/cm-module/scrollTop/scrollTop.vue'
import CityPicker from '@/components/mpvue-citypicker/mpvueCityPicker.vue' //全局注册地址组件


Vue.component('cu-custom', cuCustom)
Vue.component('au-custom', auCustom)
Vue.component('cm-custom', cmCustom)
Vue.component('scroll-top', scrollTop)
Vue.component('city-Picker', CityPicker)


// 格式化时间
Vue.filter('dateFormat', function(value) {
    if (!value) return '未知'
    if (value instanceof Date) {
        return dateFormat(value, 'yyyy-MM-dd')
    } else {
        value = new Date(value)
        return dateFormat(value, 'yyyy-MM-dd')
    }
})

// Vue实例化
Vue.config.productionTip = false
Vue.prototype.$fire = new Vue()
Vue.prototype.$store = store
Vue.prototype.$util = { msg, prePage, modal, boundingClientRect }
Vue.prototype.$api = Api
Vue.prototype.$reg = Regs
Vue.prototype.global = global

App.mpType = 'app'

// 使用插件
// Vue.use(ResidenceTime, residence)

// 全局混入
// Vue.mixin(globalMixin)

const app = new Vue({
    ...App
})
app.$mount()
