时空网前端
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.

45 lines
1.1 KiB

  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. options.is_tabbar = true; // 是否为tabbar,如果是需要多传入该参数
  19. this.joinPagePath(options);
  20. }
  21. },
  22. // 拼接地址,并相应跳转
  23. joinPagePath(par){
  24. let path = par.page_url;
  25. let flag = true; // 标志,用于判断拼接次数,?只能出现一次
  26. for(let i in par){
  27. if(i != 'route' && i != 'page_url' && i != 'is_tabbar'){ // 跳过route、page_url、is_tabbar
  28. if(flag){
  29. path += '?'+ i +'='+ par[i];
  30. flag = false;
  31. }else{
  32. path += '&'+ i +'='+ par[i];
  33. }
  34. }
  35. }
  36. if(par.is_tabbar){
  37. this.$url(path, {type: 'switch'});
  38. }else{
  39. this.$url(path, {type: 'redirect'});
  40. }
  41. }
  42. }
  43. }
  44. </script>