diff --git a/pages/route/index.vue b/pages/route/index.vue index e9c215e..8820ea6 100644 --- a/pages/route/index.vue +++ b/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; } } }