Compare commits

...

2 Commits

Author SHA1 Message Date
xiaogang efdfc91833 Merge branch 'dev' into feature 2024-07-16 09:29:35 +08:00
lf 75a8a4d5fc 优化index 代码 2024-07-12 10:12:34 +08:00
1 changed files with 28 additions and 74 deletions

View File

@ -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,
})