From a7e34bc4caff6e29f309585b9eaa4fda7664005a 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 17:57:51 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=AE=8C=E5=96=84]=20=E5=95=86=E5=93=81?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E8=B7=AF=E7=94=B1=E5=88=86=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/goodsDetail/index.vue | 6 ++++-- pages/route/index.vue | 22 ++++++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/pages/goodsDetail/index.vue b/pages/goodsDetail/index.vue index e652d3e..3a4192f 100644 --- a/pages/goodsDetail/index.vue +++ b/pages/goodsDetail/index.vue @@ -135,7 +135,8 @@ imagePath: '', userToken: '', wxCode: '', - onceCode: '' + onceCode: '', + pt: 1 } }, computed: { @@ -147,6 +148,7 @@ }, onLoad(options) { this.goods_id = options.id; + this.pt = options.pt || 1; this.getGoodsDetail(); this.getWxCode() }, @@ -305,7 +307,7 @@ toAddOrder() { let goods_id = this.goods_detail.id; let goods_specs_id = this.goods_detail.specs[0].id - this.$url('/pages/order/confirm-order?goods_id=' + goods_id + '&goods_specs_id=' + goods_specs_id); + this.$url('/pages/order/confirm-order?goods_id=' + goods_id + '&goods_specs_id=' + goods_specs_id +'&pt='+ this.pt); }, // 预览图片 lookImg(index) { 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; } } }