index token问题

This commit is contained in:
lf 2024-06-21 14:44:52 +08:00
parent 6306c5e606
commit cbb90940bd
1 changed files with 10 additions and 14 deletions

View File

@ -33,7 +33,7 @@ const useStore = useUserStore()
let code = 'activity'
let timer = null
const codeType = {
interface: 'api_code',
Interface: 'api_code',
lottery: 'lottery_code',
activity: 'activity_code',
}
@ -128,11 +128,8 @@ const initData = (res) => {
login_content_template: loginValid,
login_content_templates: login,
content_templates: baseUrl,
// eslint-disable-next-line camelcase
activity_code,
} = res.data
// eslint-disable-next-line camelcase
query.value = activity_code
query.value = res.data.activity_code
Object.assign(contentData, res.data)
if (loginValid.validate_login === 1) {
// activity_code
@ -152,7 +149,7 @@ const initData = (res) => {
uni.setNavigationBarTitle({
title: srcList.title,
})
useStore.setUserInfo({ srcList, contentData, query: query.value })
useStore.setUserInfo({ srcList, contentData, query: query.value, token: loginValid.token })
} else {
uni.showToast({
title: res.message,
@ -166,8 +163,7 @@ function getTimesTamp(url) {
return url + (url.includes('?') ? '&timestamp=' : '?timestamp=') + timestamp
}
onLoad(() => {
activityCode.value = getUrlPathName()
const intervalData = () => {
timer = setInterval(async () => {
const params = {}
params[codeType[code]] = activityCode.value || ''
@ -180,16 +176,16 @@ onLoad(() => {
initData(res)
}
}, 60000)
}
onLoad(() => {
activityCode.value = getUrlPathName()
intervalData()
if (!useStore.userInfo.srcList.url || useStore.userInfo.query !== query.value) {
initContent()
} else {
const timestamp = new Date().getTime()
const url =
useStore.userInfo.srcList.url +
(useStore.userInfo.srcList.url.includes('?') ? '&timestamp=' : '?timestamp=') +
timestamp
Object.assign(srcList, useStore.userInfo.srcList, {
url,
url: getTimesTamp(useStore.userInfo.srcList.url),
})
Object.assign(contentData, useStore.userInfo.contentData)
uni.setNavigationBarTitle({