Compare commits
2 Commits
3908a1611c
...
efdfc91833
Author | SHA1 | Date |
---|---|---|
xiaogang | efdfc91833 | |
lf | 75a8a4d5fc |
|
@ -88,76 +88,30 @@ const getUrlPathName = () => {
|
|||
}
|
||||
|
||||
window.parent.addEventListener('message', function (event) {
|
||||
let srcData = {
|
||||
url: '',
|
||||
title: '',
|
||||
}
|
||||
switch (event.data.data.type) {
|
||||
case 'login':
|
||||
srcData = {
|
||||
url: contentData.content_templates.source + `?activity_code=${activityCode.value}`,
|
||||
title: contentData.content_templates.moduledesc,
|
||||
}
|
||||
case 'couponBack':
|
||||
srcList.url = contentData.content_templates.source + `?activity_code=${activityCode.value}`
|
||||
srcList.title = contentData.content_templates.moduledesc
|
||||
break
|
||||
case 'coupon':
|
||||
srcData = {
|
||||
url: contentData.user_content_templates.source + `?activity_code=${activityCode.value}`,
|
||||
title: contentData.user_content_templates.moduledesc,
|
||||
}
|
||||
srcList.url =
|
||||
contentData.user_content_templates.source + `?activity_code=${activityCode.value}`
|
||||
srcList.title = contentData.user_content_templates.moduledesc
|
||||
break
|
||||
case 'product':
|
||||
// eslint-disable-next-line no-case-declarations
|
||||
const url = `product_id=${event.data.data.product_id}&id=${event.data.data.id}&activity_code=${activityCode.value}`
|
||||
// eslint-disable-next-line no-case-declarations
|
||||
const newUrl = encodeURIComponent(url)
|
||||
srcData = {
|
||||
url: contentData.user_content_templates.source + `#/pages/coupon/product?url=${newUrl}`,
|
||||
title: contentData.user_content_templates.moduledesc,
|
||||
}
|
||||
break
|
||||
case 'couponBack':
|
||||
srcData = {
|
||||
url: contentData.content_templates.source + `?activity_code=${activityCode.value}`,
|
||||
title: contentData.content_templates.moduledesc,
|
||||
}
|
||||
srcList.url =
|
||||
contentData.user_content_templates.source +
|
||||
`#/pages/coupon/product?url=${encodeURIComponent(url)}`
|
||||
srcList.title = contentData.user_content_templates.moduledesc
|
||||
break
|
||||
case 'logout':
|
||||
return initContent()
|
||||
}
|
||||
// if (event.data.data.type === 'login') {
|
||||
// srcData = {
|
||||
// url: contentData.content_templates.source + `?activity_code=${activityCode.value}`,
|
||||
// title: contentData.content_templates.moduledesc,
|
||||
// }
|
||||
// } else if (event.data.data.type === 'coupon') {
|
||||
// srcData = {
|
||||
// url: contentData.user_content_templates.source + `?activity_code=${activityCode.value}`,
|
||||
// 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=${activityCode.value}`
|
||||
// const newUrl = encodeURIComponent(url)
|
||||
// srcData = {
|
||||
// url: contentData.user_content_templates.source + `#/pages/coupon/product?url=${newUrl}`,
|
||||
// title: contentData.user_content_templates.moduledesc,
|
||||
// }
|
||||
// } else if (event.data.data.type === 'couponBack') {
|
||||
// srcData = {
|
||||
// url: contentData.content_templates.source + `?activity_code=${activityCode.value}`,
|
||||
// title: contentData.content_templates.moduledesc,
|
||||
// }
|
||||
// } else if (event.data.data.type === 'logout') {
|
||||
// return initContent()
|
||||
// // srcData = {
|
||||
// // url: contentData.login_content_templates.source,
|
||||
// // title: contentData.login_content_templates.moduledesc,
|
||||
// // }
|
||||
// }
|
||||
nextTick(() => {
|
||||
Object.assign(srcList, {
|
||||
url: getTimesTamp(srcData.url),
|
||||
title: srcData.title,
|
||||
})
|
||||
srcList.url = getTimesTamp(srcList.url)
|
||||
uni.setNavigationBarTitle({
|
||||
title: srcList.title,
|
||||
})
|
||||
|
@ -191,16 +145,14 @@ function initData(res) {
|
|||
Object.assign(contentData, res.data)
|
||||
if (loginValid.validate_login === 1) {
|
||||
// activity_code 方式
|
||||
Object.assign(srcList, {
|
||||
url: getTimesTamp(login.source + `?activity_code=${activityCode.value}`),
|
||||
title: login.moduledesc,
|
||||
})
|
||||
srcList.url = getTimesTamp(login.source + `?activity_code=${activityCode.value}`)
|
||||
srcList.title = login.moduledesc
|
||||
} else if (loginValid.validate_login === 2) {
|
||||
// api_code 方式
|
||||
Object.assign(srcList, {
|
||||
url: getTimesTamp(baseUrl.source + `?activity_code=${activityCode.value}&token=${token}`),
|
||||
title: baseUrl.moduledesc,
|
||||
})
|
||||
srcList.url = getTimesTamp(
|
||||
baseUrl.source + `?activity_code=${activityCode.value}&token=${token}`,
|
||||
)
|
||||
srcList.title = baseUrl.moduledesc
|
||||
}
|
||||
uni.setNavigationBarTitle({
|
||||
title: srcList.title,
|
||||
|
@ -241,20 +193,22 @@ const intervalData = () => {
|
|||
}
|
||||
|
||||
onLoad(() => {
|
||||
const {
|
||||
srcList: srcListU,
|
||||
lottery: lotteryU,
|
||||
activityCode: activityCodeU,
|
||||
contentData: contentDataU,
|
||||
} = useStore.userInfo
|
||||
activityCode.value = getUrlPathName()
|
||||
lottery.value = activityCode.value
|
||||
if (
|
||||
!useStore.userInfo.srcList.url ||
|
||||
(useStore.userInfo.lottery !== lottery.value &&
|
||||
useStore.userInfo.activityCode !== activityCode.value)
|
||||
) {
|
||||
if (!srcListU.url || (lotteryU !== lottery.value && activityCodeU !== activityCode.value)) {
|
||||
initContent()
|
||||
} else {
|
||||
activityCode.value = useStore.userInfo.activityCode
|
||||
Object.assign(srcList, useStore.userInfo.srcList, {
|
||||
url: getTimesTamp(useStore.userInfo.srcList.url),
|
||||
activityCode.value = activityCodeU
|
||||
Object.assign(srcList, srcListU, {
|
||||
url: getTimesTamp(srcListU.url),
|
||||
})
|
||||
Object.assign(contentData, useStore.userInfo.contentData)
|
||||
Object.assign(contentData, contentDataU)
|
||||
uni.setNavigationBarTitle({
|
||||
title: srcList.title,
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue