// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import {
	VueJsonp
} from 'vue-jsonp'
Vue.use(VueJsonp)
import App from './App'
import router from './router'
import store from './store/store' // 引入store
import resource from 'vue-resource' // 引入vue-resource
import tabbar from './components/tabbar.vue'
import banner from './components/banner.vue'
import back from './components/back.vue'
import backIndex from './components/backindex.vue'
import Vant from 'vant'
import 'vant/lib/index.css'
import request from "@/utils/request" 
Vue.prototype.$axios = request
// Vue.use(request)
Vue.component('tabbar', tabbar)
Vue.component('banner', banner)
Vue.component('back', back)
Vue.component('backindex', backIndex)
Vue.config.productionTip = false
Vue.use(Vant)
Vue.use(resource)
import common from './script/common.js'
Vue.use(common)
import * as echarts from 'echarts'
Vue.prototype.$echarts = echarts
import Swiper from "swiper"
import 'swiper/swiper.min.css' //样式文件
//import wx from "weixin-jsapi"; 
// 在man.js中注册 weixin-jsapi
//Vue.prototype.wx = wx
import wx from 'weixin-js-sdk'
Vue.prototype.$wx= wx

//Vue.prototype.common=common
// Vue.http.options.emulateJSON = true;
// Vue.http.options.headers = {'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'};

// Vue.http.interceptors.push((request, next) => {
// next((response) => {}

// })
/* eslint-disable no-new */
router.beforeEach((to, from, next) => {
	if (to.matched.some(record => record.meta.needLogin)) { // 判断该路由是否需要登录权限
		if (localStorage.getItem('userId')) { // 判断当前用户的登录信息loginInfo是否存在
			next();
		} else {
			next({
				path: '/Login'
			})
		}
	} else {
		next();
	}
})
new Vue({
	el: '#app',
	router,
	store: store,
	components: {
		App
	},
	template: '<App/>'
})
/* router.beforeEach(function(to, from, next) {
  if (to.meta.needLogin) {
    //页面是否登录
    if (sessionStorage.getItem("userId")) {
      //存储中是否有token(uid)数据
      next(); //表示已经登录
    } else {
      //next可以传递一个路由对象作为参数 表示需要跳转到的页面
      next({
        path: "Login"
      });
    }
  } else {
    //表示不需要登录
    next(); //继续往后走
  }
}); */


