From 144cc8d94a255188c009545e814c5e91f3d88333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=93=E5=B9=B3=E8=89=BA?= <52643018@qq.com> Date: Fri, 9 Jul 2021 11:55:32 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BC=98=E5=8C=96]=20=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=E5=88=86=E5=8F=91=E9=A1=B5=EF=BC=8C=E5=85=BC=E5=AE=B9=E6=89=AB?= =?UTF-8?q?=E6=8F=8F=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=A0=81=E8=BF=9B=E5=85=A5?= =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/route/index.vue | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) 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; } } }