import Vue from 'vue'
import Router from 'vue-router'
// import HelloWorld from '@/components/HelloWorld'

Vue.use(Router)
const route = new Router({
	routes: [{
		path: '/',
		name: 'Sthome',
		component: resolve => require(['@/pages/StHome/StHome'], resolve)
	},
		{
			path: '/AllMatch',
			name: 'AllMatch',
			component: resolve => require(['@/pages/AllMatch/index/AllMatch'], resolve)
		},
		{
			path: '/StRollBallpage',
			name: 'RollBallpage',
			component: resolve => require(['@/pages/StRollBallPage/index/StRollBallpage'], resolve)
			//()=>import('@/components/StRollBallpage'),
			// beforeEnter: function(to, from, next){
			//   to.query.isTrue =true;
			//   console.log(to);
			//   next();
			// }
		},
		{
			path: '/StRollBallBettingPage',
			name: 'RollBallBettingPage',
			component: resolve => require(['@/pages/StRollBallBettingPage/index/StRollBallBettingPage'], resolve)

		},
		{
			path: '/StBallBettingPage',
			name: 'BallBettingPage',
			component: resolve => require(['@/pages/StBallBettingPage/index/StBallBettingPage'], resolve)

		},
		{
			path: '/StLeagueList',
			name: 'StLeagueList',
			component: resolve => require(['@/pages/StLeagueBetting/index/StLeagueList'], resolve)
		},{
			path: '/StLeagueBetting',
			name: 'StLeagueBetting',
			component: resolve => require(['@/pages/StLeagueBetting/index/StLeagueBetting'], resolve)
		},
		{
			path: '/TennisBall',
			name: 'TennisBall',
			component: resolve => require(['@/pages/TennisBall/index/StTennisBall'], resolve)
		},
		{
			path: '/BaseBall',
			name: "BaseBall",
			component: resolve => require(['@/pages/BaseBall/index/BaseballMatch'], resolve)
		},
		{
			path:'/BasketBall',
			name:'BasketBall',
			component: resolve=>require(['@/pages/BasketBall/index/StBasketballMatch'],resolve)
		},{
			path:'/Login',
			name:'Login',
			component:resolve=>require(['@/pages/Login/index/StLogin'],resolve)
		},
		{
			path:'/Register',
			name:'./Register',
			component:resolve=>require(['@/pages/Login/index/register'],resolve)
		},
		// 个人中心路由
		{
			path:'/PersonalCenter',
			name:"PersonalCenter",
			component:resolve=>require(['@/pages/PersonalCenter/index/PersonalCenter'],resolve)
		},
		// 投注记录路由
		{
			path:'/BettingRecord',
			name:"BettingRecord",
			component:resolve=>require(['@/pages/PersonalCenter/BettingRecord/BettingRecord'],resolve)
		},
		// 盈亏记录路由
		{
			path:'/ProfitAndLossRecord',
			name:"ProfitAndLossRecord",
			component:resolve=>require(['@/pages/PersonalCenter/ProfitAndLossRecord/ProfitAndLossRecord'],resolve)
		},
		// 存取款记录路由
		{
			path:'/AccessRecords',
			name:"PrepaidPhoneRecords",
			component:resolve=>require(['@/pages/PersonalCenter/AccessRecords/AccessRecords'],resolve)
		},

		// 个人资料
		{
			path:'/PersonInfo',
			name:"PersonInfo",
			component:resolve=>require(['@/pages/PersonalCenter/PersonInfo/PersonInfo'],resolve)
		},
		// 我的消息
		{
			path:'/MessageCenter',
			name:"MessageCenter",
			component:resolve=>require(['@/pages/PersonalCenter/MessageCenter/MessageCenter'],resolve)
		},
		// 消息详情
		{
			path:'/MessageDetail/:id',
			name:"MessageDetail",
			component:resolve=>require(['@/pages/PersonalCenter/MessageDetail/MessageDetail'],resolve)
		}
	],
	scrollBehavior(to,from,savedPosition){
		if(savedPosition){
			return savedPosition;
		}else{
			return {x:0,y:0}
		}
	},
})

/**
 * 前置守卫
 */
route.beforeEach((to, from, next) => {
	//to.query.isTrue =true;
	//console.log(from);
	/**
	 * 拦截头部导航页面跳转
	 */
	if (to.path == '/StRollBallpage') {
		to.query.isTrue = true;
		//console.log(to);
	}
	next();

})

export default route
