import Vue from 'vue'
import Router from 'vue-router'

const routerPush = Router.prototype.push  

Router.prototype.push = function push(location) {
 
  // if(typeof(location)=="string"){
  //   var Separator = "&";
  //   if(location.indexOf('?')==-1) { Separator='?'; }
  //   location = location + Separator + "random=" + Math.random();
  // }

  return routerPush.call(this, location).catch(error => error)
}

Vue.use(Router)

export default new Router({
  // mode: 'history',
  base: process.env.BASE_URL,
  routes: [
    {
      path: '/',
      redirect: '/home'
    },
    {
      path: '/home',
      name: 'home',
      component: () => import('./views/Home.vue'),
      meta: {
        title: '荆州市红十字会'
      }
    },
	{
		path: '/donation',
		name: 'donation',
		component: () => import('./views/Donation.vue'),
		redirect: '/donation/contribution',
		meta: {
			title: '捐赠平台'
		},
		children: [
			{
				path: 'contribution',
				name: 'contribution',
				component: () => import('./views/donation/Contribution.vue'),
				meta: {
					title: '捐款'
				}
			},
			{
				path: 'organDonation',
				name: 'organDonation',
				component: () => import('./views/donation/OrganDonation.vue'),
				meta: {
					title: '器官捐献'
				}
			},
			{
				path: 'HPC',
				name: 'HPC',
				component: () => import('./views/donation/Hpc.vue'),
				meta: {
					title: '捐献造血干细胞'
				}
			},
		]
	},
	{
		path: '/loveList',
		name: 'loveList',
		component: () => import('./views/LoveList.vue'),
		meta: {
			title: '爱心榜'
		}
	},
	{
		path: '/join',
		name: 'join',
		component: () => import('./views/Join.vue'),
		redirect: '/join/volunteer',
		meta: {
			title: '我要参与'
		},
		children: [
			{
				path: 'volunteer',
				name: 'volunteer',
				component: () => import('./views/join/Volunteer.vue'),
				meta: {
					title: '登记志愿者'
				}
			},
			{
				path: 'member',
				name: 'member',
				component: () => import('./views/join/Member.vue'),
				meta: {
					title: '登记个人会员'
				}
			},
			{
				path: 'train',
				name: 'train',
				component: () => import('./views/join/Train.vue'),
				meta: {
					title: '参与普及培训'
				}
			},
			{
				path: 'rescue',
				name: 'rescue',
				component: () => import('./views/join/Rescue.vue'),
				meta: {
					title: '登记救护员'
				}
			}
		]
	},
	{
		path: '/about',
		name: 'about',
		component: () => import('./views/About.vue'),
		meta: {
			title: '关于我们'
		}
	},
	{
		path: '/concat',
		name: 'concat',
		component: () => import('./views/Concat.vue'),
		meta: {
			title: '联系我们'
		}
	},
	{
		path: '/popularScience',
		name: 'popularScience',
		component: () => import('./views/PopularScience.vue'),
		meta: {
			title: '红会科普'
		},
		redirect: '/popularScience/list',
		children: [
			{
				path: 'list',
				name: 'list',
				component: () => import('./views/popularScience/List.vue'),
				meta: {
					title: '红会科普'
				}
			},
			{
				path: 'detail',
				name: 'detail',
				component: () => import('./views/popularScience/Detail.vue'),
				meta: {
					title: '红会科普'
				}
			}
		]
	},
	{
		path: '/news',
		name: 'news',
		component: () => import('./views/News.vue'),
		meta: {
			title: '红会新闻'
		},
		redirect: '/news/list',
		children: [
			{
				path: 'list',
				name: 'newslist',
				component: () => import('./views/news/List.vue'),
				meta: {
					title: '红会新闻'
				}
			},
			{
				path: 'detail',
				name: 'newsdetail',
				component: () => import('./views/news/Detail.vue'),
				meta: {
					title: '红会新闻'
				}
			}
		]
	},
	{
		path: '/publicity',
		name: 'publicity',
		component: () => import('./views/Publicity.vue'),
		meta: {
			title: '信息公示'
		},
		redirect: '/publicity/list',
		children: [
			{
				path: 'list',
				name: 'publicitylist',
				component: () => import('./views/publicity/List.vue'),
				meta: {
					title: '信息公示'
				}
			},
			{
				path: 'detail',
				name: 'publicitydetail',
				component: () => import('./views/publicity/Detail.vue'),
				meta: {
					title: '信息公示'
				}
			}
		]
	},
	{
		path: '/regulations',
		name: 'regulations',
		component: () => import('./views/Regulations.vue'),
		meta: {
			title: '政策法规'
		},
		redirect: '/regulations/list',
		children: [
			{
				path: 'list',
				name: 'regulationsList',
				component: () => import('./views/regulations/List.vue'),
				meta: {
					title: '政策法规'
				}
			},
			{
				path: 'detail',
				name: 'regulationsdetail',
				component: () => import('./views/regulations/Detail.vue'),
				meta: {
					title: '政策法规'
				}
			}
		]
	},
	{
		path: '*',
		redirect: '/home'
	}
  ]
})
