From a7140ad0ded6b155b68d01464e40603a859bcb87 Mon Sep 17 00:00:00 2001 From: lf <1534621107@qq.com> Date: Fri, 21 Jun 2024 18:06:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=98=E4=B8=BAsession?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/index/index.vue | 26 +++++++++++++++----------- src/store/index.ts | 9 +++++---- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 9ae0903..c16e832 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -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('?') ? '×tamp=' : '?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, diff --git a/src/store/index.ts b/src/store/index.ts index 74b1b2f..eacaf90 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -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, + // }, }), )