import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './router/router'
import store from './store/'
const mixins = require('@/utils/mixins');
import '@/utils/rem'					// 引入自适应
import '@/utils/yqyServerRegister'		// 移动端服务
import FastClick from 'fastclick'
import Logger from './plugins/logger' 	// 日志插件
import Swiper from './plugins/swiper.min.js' 	// 日志插件

// 引入Mint
import Mint from 'mint-ui'
import 'mint-ui/lib/style.css'

import VueLazyload from 'vue-lazyload'
Vue.use(VueLazyload, {
	preLoad: 3,
	// loading: 'http://pica-pro.oss-cn-shanghai.aliyuncs.com/h5/app_home/2018/12/5-121204193935-51.gif',
	// loading: 'images/change.png',
	// error: 'https://file.yunqueyi.com/File/course_doctor/2018-11/20/web_454.png',
	error: require('./images/evaluatBg.png'),
	attempt: 1
	// lazyComponent: true
})

// 可调试
Vue.config.devtools = true;
Vue.use(Mint)
Vue.use(Logger, { prefix: new Date(), isDev: process.env.NODE_ENV === 'development', cLevel: 'debug' })

if ('addEventListener' in document) {
    document.addEventListener('DOMContentLoaded', function() {
        FastClick.attach(document.body);
    }, false);
}

Vue.use(VueRouter)
const router = new VueRouter({
	routes,
	mode: 'hash',
	strict: process.env.NODE_ENV !== 'production',
	scrollBehavior (to, from, savedPosition) {
	    if (savedPosition) {
		    return savedPosition
		} else {
			if (from.meta.keepAlive) {
				from.meta.savedPosition = document.body.scrollTop;
			}
		    return { x: 0, y: to.meta.savedPosition || 0 }
		}
	}
})

// 加入混合
Vue.mixin({
	...mixins
})
new Vue({
	router,
	store,
}).$mount('#app')

