import App from './App'


//分享
let mpShare = require('uview-ui/libs/mixin/mpShare.js');
Vue.mixin(mpShare)

//store
import store from '@/store';
let vuexStore = require("@/store/$u.mixin.js");
Vue.mixin(vuexStore);

//登录组件
import login from "@/components/login.vue"
Vue.component('login',login)

//回到首页
import homeBtn from "@/components/home-btn.vue"
Vue.component('home-btn',homeBtn)

//uView
import uView from "uview-ui";
Vue.use(uView);


import toast from '@/components/toast/toast.vue'
Vue.component('toast',toast)



import loading from '@/components/loading/loading.vue'
Vue.component('loading',loading)

import pointAuth from '@/components/alert/pointAuth.vue'
Vue.component('pointAuth',pointAuth)

// util begin
//缓存
import simpleCache from "@/utils/cache.js"
Vue.prototype.$cache = simpleCache

//封装日期时间工具类
import dateTime from 'utils/dateTime.js'
Vue.prototype.$dateTime = dateTime

//封装提示工具
import dialog from 'utils/dialog.js'
Vue.prototype.$dialog = dialog

//数字处理
import digital from './utils/digital.js'
Vue.prototype.$digital = digital

// 全局注入
import Mixin from './utils/mixin'
Vue.mixin(Mixin)

// 微信函数封装
import Mpi from './utils/mpi'
Vue.prototype.$mpi = Mpi

//引入工具类
import util from 'utils/util.js'
Vue.prototype.$util = util

//校验文件
import verify from 'utils/verify.js'
Vue.prototype.$verify = verify

//全局变量
import global from 'utils/global.js'
Vue.prototype.$global = global
//util end

import config from 'assets/http/config.js'
Vue.prototype.$config = config

//封装api
import {
	api
} from 'assets/http/api.js'
Vue.prototype.$api = api

//跳转
Vue.prototype.$jump = function(url, events) {
	if(this.$isEmpty(url)){
		uni.showToast({
		    title: '暂未开放',
		    icon: 'none'
		});
	}
	uni.navigateTo({
		url,
		events,
		fail(err) {
			console.log(err);
		}
	})
}
Vue.prototype.$back = function() {
	uni.navigateBack({
		delta: 1
	})
}
//判空函数
Vue.prototype.$isEmpty = function(value) {
	switch (typeof value) {
		case 'undefined':
			return true;
		case 'string':
			if (value == 'undefined') return true
			if (value.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return true;
			break;
		case 'boolean':
			if (!value) return true;
			break;
		case 'number':
			if (0 === value || isNaN(value)) return true;
			break;
		case 'object':
			if (null === value || value.length === 0) return true;
			for (var i in value) {
				return false;
			}
			return true;
	}
	return false;
}
Vue.prototype.$isNotEmpty = function(value) {
	switch (typeof value) {
		case 'undefined':
			return false;
		case 'string':
			if (value == 'undefined') return false
			if (value.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return false;
			break;
		case 'boolean':
			if (!value) return false;
			break;
		case 'number':
			if (0 === value || isNaN(value)) return false;
			break;
		case 'object':
			if (null === value || value.length === 0) return false;
			for (var i in value) {
				return true;
			}
			return false;
	}
	return true;
}

// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
App.mpType = 'app'

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

// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
export function createApp() {
	const app = createSSRApp(App)
	return {
		app
	}
}
// #endif
