import Vue from 'vue'
import App from './App'

import uView from '@/uni_modules/uview-ui'
Vue.use(uView)

import store from './store'
Vue.prototype.$store = store

import custom from '@/components/custom.vue';
import loadingText from '@/components/loadingText.vue';
import noData from '@/components/noData.vue';
Vue.component('custom', custom);
Vue.component('loading-text', loadingText);
Vue.component('no-data', noData);

import {axios} from '@/api/axios.js';
Vue.prototype.$axios = axios;

import * as filters from './filters/index.js' // global filters
// register global utility filters
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

import {toast, successToast, modal, navPage, redPage, backPage} from '@/utils/common.js'
Vue.prototype.$toast = toast;
Vue.prototype.$successToast = successToast;
Vue.prototype.$modal = modal;
Vue.prototype.$navPage = navPage;
Vue.prototype.$redPage = redPage;
Vue.prototype.$backPage = backPage;

import {compareTime} from '@/utils/utils.js'
Vue.prototype.$compareTime = compareTime;

import { getUserInfo } from '@/api/index.js';
Vue.prototype.$getUserInfo = getUserInfo;

// 渲染图片文件
import { base_url } from '@/utils/config.js';
Vue.prototype.$imageUrl = base_url + '/common/img/get?key=';

Vue.prototype.$onLaunched = new Promise(resolve => {
    Vue.prototype.$isResolve = resolve
})

Vue.prototype.$auth = (url)=>{
	if(store.state.isLogin){
		uni.navigateTo({
			url,
			fail:err=>{
				console.log('auth跳转失败',url,err)
			}
		})
	}else{
		uni.navigateTo({
			url:'/pages/login/index'
		})
	}
}

Vue.config.productionTip = false

App.mpType = 'app'

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