import Vue from 'vue'
import App from './App'
import store from '@/store'
import getConfig from '@/config'
Vue.config.productionTip = false

App.mpType = 'app'
import uView from "uview-ui"
Vue.use(uView)

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

// 系统配置
Vue.prototype.$config = function (key) {
	const envText = {pro:'生产环境',dev:'开发环境',uat:'预发布环境'}
	const theme = getApp().globalData.theme
	const config = getConfig(theme)
	if(key == 'init'){
		let buildType = getApp().globalData.buildType
		let baseUrl = config[buildType+'_URL']
		getApp().globalData.baseUrl = baseUrl
		getApp().globalData.envTips = envText[buildType]
	}
	return config[key]
}
/**
 * 权限检查
 */
Vue.prototype.$hasPermissions = function (value) {
 let isExist = false;
 let permissionsStr = store.state.vuex_userData.permCodes;
 if (permissionsStr == undefined || permissionsStr == null) {
  return false;
 }
 let has = permissionsStr.find(item => {
   return item == value
 })
 if (has) {
  isExist = true;
 }
 return isExist;
}
/*
* 提示信息
*/ 
Vue.prototype.toashMsg = function (title) {
	title = title == undefined ? "系统繁忙" : title;
	uni.showToast({
		title:title,
		icon:'none',
		duration: 4000
	})
}

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