Browse Source

[新增] 路由分发页面,并将首页开放转发分享

test
邓平艺 5 years ago
parent
commit
a3b9420836
  1. 6
      pages.json
  2. 7
      pages/index/index.vue
  3. 51
      pages/route/index.vue

6
pages.json

@ -136,6 +136,12 @@
"style": { "style": {
"navigationBarTitleText": "商品列表" "navigationBarTitleText": "商品列表"
} }
},
{
"path": "pages/route/index",
"style": {
"navigationBarTitleText": "海南旅游"
}
} }
], ],
"globalStyle": { "globalStyle": {

7
pages/index/index.vue

@ -201,6 +201,13 @@
}, },
onPullDownRefresh(){ onPullDownRefresh(){
uni.stopPullDownRefresh(); uni.stopPullDownRefresh();
},
onShareAppMessage(){
let shareInfo = {
title: '欢迎使用海南旅游小程序',
path: '/pages/route/index?route=home'
}
return shareInfo;
} }
} }
</script> </script>

51
pages/route/index.vue

@ -0,0 +1,51 @@
<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';
options.is_tabbar = true; // tabbar
this.joinPagePath(options);
}else{
let obj = {
page_url: '/pages/index/index', //
is_tabbar: true
};
this.joinPagePath(obj);
}
},
//
joinPagePath(par){
let path = par.page_url;
let flag = true; //
for(let i in par){
if(i != 'route' && i != 'page_url' && i != 'is_tabbar'){ // routepage_urlis_tabbar
if(flag){
path += '?'+ i +'='+ par[i];
flag = false;
}else{
path += '&'+ i +'='+ par[i];
}
}
}
if(par.is_tabbar){
this.$url(path, {type: 'switch'});
}else{
this.$url(path, {type: 'redirect'});
}
}
}
}
</script>
Loading…
Cancel
Save