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

Vue.config.productionTip = false

App.mpType = 'app'

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



// 引入文件
import Dever from './lib/dever'

// 绑定全局的组件
import ourLoading from '@/lib/our-loading/our-loading.vue'
Vue.component('ourLoading', ourLoading)
Vue.prototype.pageLoading = true;
Vue.prototype.pageLoadingText = '加载中...';

// 绑定到 Vue 的实例上
Vue.prototype.Dever = Dever;

// 载入全局配置 默认配置,防止第一次载入报错的,系统会自动从后台更新最新的配置
var defaultConfig = {
	'system_name' : '云境',
	'system_info' : '云境',
	'system_logo' : '../../static/logo.png',
	//自动更新时间间隔
	'set_update' : 86400,
	//本次更新时间
	'update_time' : false,
};
Vue.prototype.Dever.init('main/?l=api.config', Vue, defaultConfig);

//自定义get的loading效果,设置全屏loading
Vue.prototype.Dever.setGetLoading(function(self) {
	self.vue.prototype.pageLoading = true;
}, function(self) {
	self.vue.prototype.pageLoading = false;
	self.btnFinish();
});
//自定义post的loading
Vue.prototype.Dever.setPostLoading(function(self) {
	self.btnLoad();
	uni.showLoading({title: '加载中', mask: true});
}, function(self) {
	self.btnFinish();
	uni.hideLoading();
});

//设置switchTab
Vue.prototype.Dever.switchTab = ['index/index'];

//自定义switchTab页面回调,因为switchTab执行后不会自动刷新页面,这里需要做个回调
Vue.prototype.Dever.switchTabCall = {
	'index/index' : function(self, e) {
		var page = self.getPage();
		if (!page) return;
		if ('getInfo' in page) {
			page.getInfo();
		}
	}
};

//载入一些通用的方法
Vue.prototype.Dever.common({
	
// 载入人工客服
'callPhone' : function() {
	uni.makePhoneCall({
		phoneNumber: Vue.prototype.$config.system_phone
	});
},
// 跳转到页面
'location' : function(e) {
	Vue.prototype.Dever.viewLocation(e);
},

// 提示
'alert' : function(e) {
	Vue.prototype.Dever.viewAlert(e);
},

})


app.$mount()