Merge branch 'dev' into feature

This commit is contained in:
xiaogang 2024-07-16 09:29:35 +08:00
commit efdfc91833
1 changed files with 28 additions and 74 deletions

View File

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