时空网前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
944 B

  1. <template>
  2. <view></view>
  3. </template>
  4. <script>
  5. /* 路由分发页面仅供跳转页面 */
  6. export default {
  7. onLoad(options){
  8. this.routeToPage(options);
  9. },
  10. methods: {
  11. // 路由分发
  12. routeToPage(options){
  13. if(options.route == 'goods_detail'){
  14. options.page_url = '/pages/goodsDetail/index';
  15. this.joinPagePath(options);
  16. }else if(options.route == 'home'){
  17. options.page_url = '/pages/index/index';
  18. this.joinPagePath(options);
  19. }
  20. },
  21. // 拼接地址,并相应跳转
  22. joinPagePath(par){
  23. let path = par.page_url;
  24. let flag = true; // 标志,用于判断拼接次数,?只能出现一次
  25. for(let i in par){
  26. if(i != 'route' && i != 'page_url'){ // 跳过route和page_url
  27. if(flag){
  28. path += '?'+ i +'='+ par[i];
  29. flag = false;
  30. }else{
  31. path += '&'+ i +'='+ par[i];
  32. }
  33. }
  34. }
  35. this.$url(path, {type: 'redirect'});
  36. }
  37. }
  38. }
  39. </script>