import Vue from 'vue';
import App from './App';
import store from './store';
import axios from './common/axios';
import utils from './common/util';
import ui from 'uview-ui'

const loading = title => {
  uni.showLoading({
    title: title ? title : '加载中',
    mask: true
  })
}

const hideLoading = () => {
  uni.hideLoading()
}

Vue.prototype.$loading = loading
Vue.prototype.$hideLoading = hideLoading

Vue.use(ui)
Vue.config.productionTip = false;
Vue.prototype.$store = store;
//初始化接口工具类
Vue.prototype.$http = axios;
Vue.prototype.$cdn = 'https://cdn.cunwuyun.cn/dvcp/h5/';
Object.keys(utils).map((e) => (Vue.prototype['$' + e] = utils[e]));
App.mpType = 'app';
// process.env.NODE_ENV == 'development' && new VConsole();
const app = new Vue({
  store,
  ...App
});
store.dispatch("agentSign").then(config => {
  const init = (c = 0) => {
    if (config) {
      store.commit("getConfig", {...config, latlng: [config.lat, config.lng]})
      app.$mount();
    } else {
      if (c < 5) {
        setTimeout(() => {
          init(++c)
        }, 300)
      }
    }
  }
  init()
})

