存为session

This commit is contained in:
lf 2024-06-21 18:06:15 +08:00
parent a61f2a8ba0
commit a7140ad0de
2 changed files with 20 additions and 15 deletions

View File

@ -74,8 +74,10 @@ const getUrlPathName = () => {
}
window.parent.addEventListener('message', function (event) {
let srcData = {}
const timestamp = new Date().getTime()
let srcData = {
url: '',
title: '',
}
if (event.data.data.type === 'login') {
srcData = {
url: contentData.content_templates.source + `?activity_code=${query.value}`,
@ -94,20 +96,22 @@ window.parent.addEventListener('message', function (event) {
title: contentData.user_content_templates.moduledesc,
}
} else if (event.data.data.type === 'couponBack') {
srcData = {
url: contentData.content_templates.source + `?activity_code=${query.value}`,
title: contentData.content_templates.moduledesc,
}
return initContent()
// srcData = {
// url: contentData.content_templates.source + `?activity_code=${query.value}`,
// title: contentData.content_templates.moduledesc,
// }
} else if (event.data.data.type === 'logout') {
srcData = {
url: contentData.login_content_templates.source,
title: contentData.login_content_templates.moduledesc,
}
}
srcList.url =
srcList.url + (srcList.url.includes('?') ? '&timestamp=' : '?timestamp=') + timestamp
nextTick(() => {
Object.assign(srcList, srcData)
Object.assign(srcList, {
url: getTimesTamp(srcData.url),
title: srcList.title,
})
uni.setNavigationBarTitle({
title: srcList.title,
})
@ -115,14 +119,14 @@ window.parent.addEventListener('message', function (event) {
})
})
const initContent = async () => {
async function initContent() {
const params = {}
params[codeType[code]] = activityCode.value || ''
const res: any = await getContent(params)
initData(res)
}
const initData = (res) => {
function initData(res) {
if (res.code === 200) {
const {
login_content_template: loginValid,

View File

@ -4,10 +4,11 @@ import { createPersistedState } from 'pinia-plugin-persistedstate' // 数据持
const store = createPinia()
store.use(
createPersistedState({
storage: {
getItem: uni.getStorageSync,
setItem: uni.setStorageSync,
},
storage: sessionStorage,
// storage: {
// getItem: uni.getStorageSync,
// setItem: uni.setStorageSync,
// },
}),
)