<template>
	<view></view>
</template>

<script>
	/* 路由分发页面仅供跳转页面 */
	export default {
		onLoad(options){
			this.routeToPage(options);
		},
		methods: {
			// 路由分发
			routeToPage(options){
				if(options.route == 'goods_detail'){
					options.page_url = '/pages/goodsDetail/index';
					this.joinPagePath(options);
				}else if(options.route == 'home'){
					options.page_url = '/pages/index/index';
					this.joinPagePath(options);
				}
			},
			// 拼接地址，并相应跳转
			joinPagePath(par){
				let path = par.page_url;
				let flag = true; // 标志，用于判断拼接次数，？只能出现一次
				for(let i in par){
					if(i != 'route' && i != 'page_url'){ // 跳过route和page_url
						if(flag){
							path += '?'+ i +'='+ par[i];
							flag = false;
						}else{
							path += '&'+ i +'='+ par[i];
						}
					}
				}
				this.$url(path, {type: 'redirect'});
			}
		}
	}
</script>
