From dbd366302031ed7999f0443d15c9589be9ab169c Mon Sep 17 00:00:00 2001 From: lf <1534621107@qq.com> Date: Wed, 12 Jun 2024 19:00:17 +0800 Subject: [PATCH] =?UTF-8?q?webview=20=E4=BC=A0=E5=80=BC=E7=BC=96=E8=A7=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/coupon/index.vue | 11 ++++------- src/pages/coupon/product.vue | 13 +++++++++++-- src/pages/index/index.vue | 6 +++--- src/typings.ts | 1 + 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/pages/coupon/index.vue b/src/pages/coupon/index.vue index c3359f6..5c2b900 100644 --- a/src/pages/coupon/index.vue +++ b/src/pages/coupon/index.vue @@ -159,14 +159,11 @@ function getlist() { } function qudui(val) { if (val.status === 1) { + const url = + 'product_id=' + val.product_id + '&id=' + val.id + '&activity_code=' + query.activity_code + const newUrl = encodeURIComponent(url) uni.navigateTo({ - url: - '/pages/coupon/product?p_id=' + - val.product_id + - '&id=' + - val.id + - '&code=' + - query.activity_code, + url: '/pages/coupon/product?url=' + newUrl, }) } } diff --git a/src/pages/coupon/product.vue b/src/pages/coupon/product.vue index 4b563d7..ef56fd3 100644 --- a/src/pages/coupon/product.vue +++ b/src/pages/coupon/product.vue @@ -58,7 +58,7 @@ const exchange = () => { }) } function getlist() { - const params = { product_id: route.p_id, activity_code: route.code } + const params = { product_id: route.product_id, activity_code: route.activity_code } Api.getProductDetail(params).then((res: any) => { if (res.code === 200) { uni.hideLoading() @@ -79,8 +79,17 @@ function getlist() { } }) } +const getUrlParm = (url) => { + const theRequest = {} + const strs = url.split('&') + for (let i = 0; i < strs.length; i++) { + theRequest[strs[i].split('=')[0]] = strs[i].split('=')[1] + } + return theRequest +} onLoad((options) => { - Object.assign(route, options) + const url = decodeURIComponent(options.url) + Object.assign(route, getUrlParm(url)) getlist() }) diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 33911b1..a915364 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -94,10 +94,10 @@ window.parent.addEventListener('message', function (event) { title: contentData.user_content_templates.moduledesc, } } else if (event.data.data.type === 'product') { + const url = `product_id=${event.data.data.product_id}&id=${event.data.data.id}&activity_code=${query.value}` + const newUrl = encodeURIComponent(url) srcData = { - url: - contentData.user_content_templates.source + - `#/pages/coupon/product?product_id=${event.data.data.product_id}&id=${event.data.data.id}&activity_code=${query.value}`, + url: contentData.user_content_templates.source + `#/pages/coupon/product?url=${newUrl}`, title: contentData.user_content_templates.moduledesc, } } else if (event.data.data.type === 'couponBack') { diff --git a/src/typings.ts b/src/typings.ts index 848963f..4ef185d 100644 --- a/src/typings.ts +++ b/src/typings.ts @@ -28,6 +28,7 @@ type IUserInfo = { token?: string srcList?: SrcListType contentData?: object + query?: string } enum TestEnum {