webview 传值编解码
This commit is contained in:
parent
705f765564
commit
dbd3663020
|
@ -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,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -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') {
|
||||
|
|
|
@ -28,6 +28,7 @@ type IUserInfo = {
|
|||
token?: string
|
||||
srcList?: SrcListType
|
||||
contentData?: object
|
||||
query?: string
|
||||
}
|
||||
|
||||
enum TestEnum {
|
||||
|
|
Loading…
Reference in New Issue