import Vue from 'vue';
import App from './App.vue';
import router from './router';
import axios from 'axios';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import scroll from 'vue-seamless-scroll'
Vue.use(scroll)
Vue.use(ElementUI);
var echarts = require('echarts')
Vue.prototype.$echarts = echarts

import 'babel-polyfill';
import numeral from 'numeral';// 用于格式化和操作数字的js库
// 金额显示
Vue.prototype.dollarFormat = function (text) {
    return '¥ ' + numeral(text).format('0,0.00')
}
// 转为千分位整数
Vue.prototype.numFormat = function (text) {
    return numeral(text).format('0,0.00')
}
//千分位转成数字
Vue.prototype.tonum = function (text) {
    if (text) {
        return numeral(text.toString()).value()
    }
}

//使用钩子函数对路由进行权限跳转
router.beforeEach((to, from, next) => {
    next();
    return
});
// 请求文件内容
function getServerConfig() {
    axios.get('./public.json').then(result => {
        let config = result.data;
        Vue.prototype['$config'] = config
        window.Vue = new Vue({
            router
        })
        main()
    })
}
// 请求文件内容及创建实例
async function main() {
    new Vue({
        router,
        render: h => h(App)
    }).$mount('#app');
}
getServerConfig()
