Browse Source

[优化] 路由分发页,兼容扫描小程序码进入小程序的情况

dev
邓平艺 5 years ago
parent
commit
144cc8d94a
  1. 22
      pages/route/index.vue

22
pages/route/index.vue

@ -6,12 +6,18 @@
/* 路由分发页面仅供跳转页面 */
export default {
onLoad(options){
this.routeToPage(options);
if(this.$shared.isValueType(options.scene) != 'undefined'){
const scene = decodeURIComponent(options.scene); //
const par = this.strToObj(scene);
this.routeToPage(par);
}else{
this.routeToPage(options); //
}
},
methods: {
//
routeToPage(options){
if(options.route == 'goods_detail'){
if(options.route == 'goods_detail' || options.route == 'goods'){
options.page_url = '/pages/goodsDetail/index';
this.joinPagePath(options);
}else if(options.route == 'home'){
@ -45,6 +51,18 @@
}else{
this.$url(path, {type: 'redirect'});
}
},
// key=value&key=value
strToObj(str){
let obj = {};
if(!str) return obj;
let arr = str.split('&');
arr.map(item => {
let a = item.split('=');
obj[a[0]] = a[1];
});
return obj;
}
}
}

Loading…
Cancel
Save