fix(rank): 修复未定义token时的登录弹窗逻辑
处理当Session中token为"undefined"字符串时的异常情况,移除无效token并显示登录弹窗
This commit is contained in:
parent
f67fee4aa5
commit
a00988529d
|
|
@ -16,11 +16,16 @@
|
||||||
</u-input> -->
|
</u-input> -->
|
||||||
|
|
||||||
<div class="r_input" v-if="pageType == 4">
|
<div class="r_input" v-if="pageType == 4">
|
||||||
<input v-model="form.keyword" placeholder="请输入搜索内容" class="input" @keyup.enter="getNewsList"
|
<input
|
||||||
@clear="getNewsList" @blur="getNewsList" />
|
v-model="form.keyword"
|
||||||
|
placeholder="请输入搜索内容"
|
||||||
|
class="input"
|
||||||
|
@keyup.enter="getNewsList"
|
||||||
|
@clear="getNewsList"
|
||||||
|
@blur="getNewsList"
|
||||||
|
/>
|
||||||
<div class="input_button" @click="getNewsList">搜索</div>
|
<div class="input_button" @click="getNewsList">搜索</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="line"></view>
|
<view class="line"></view>
|
||||||
|
|
@ -43,9 +48,9 @@
|
||||||
<view>
|
<view>
|
||||||
<text class="time">{{ item.source }}</text>
|
<text class="time">{{ item.source }}</text>
|
||||||
<text class="time" style="margin-left: 30rpx" v-if="pageType != 4">{{
|
<text class="time" style="margin-left: 30rpx" v-if="pageType != 4">{{
|
||||||
dayjs(item.publish_time).format("YYYY-MM-DD HH:MM:ss") }}</text>
|
dayjs(item.publish_time).format("YYYY-MM-DD HH:MM:ss")
|
||||||
<text class="time" style="margin-left: 30rpx" v-if="pageType == 4">{{
|
}}</text>
|
||||||
formatTime(item.time) }}</text>
|
<text class="time" style="margin-left: 30rpx" v-if="pageType == 4">{{ formatTime(item.time) }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<text class="score" v-if="pageType != 4">{{ item.news_score }}</text>
|
<text class="score" v-if="pageType != 4">{{ item.news_score }}</text>
|
||||||
|
|
@ -54,14 +59,27 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<div style="width: 100%; display: flex; justify-content: center"
|
<div
|
||||||
v-if="pageType == 4 && newsList && newsList.length > 0">
|
style="width: 100%; display: flex; justify-content: center"
|
||||||
<el-pagination v-model:current-page="currentPage" :page-size="form.size" layout="prev, pager, next"
|
v-if="pageType == 4 && newsList && newsList.length > 0"
|
||||||
:total="form.total" @current-change="currentChange" @size-change="sizeChange" />
|
>
|
||||||
|
<el-pagination
|
||||||
|
v-model:current-page="currentPage"
|
||||||
|
:page-size="form.size"
|
||||||
|
layout="prev, pager, next"
|
||||||
|
:total="form.total"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</view>
|
</view>
|
||||||
<LoginPopup :show="LoginShow" mode="center" @handlePopupClose="handlePopupClose"
|
<LoginPopup
|
||||||
@handlePopupSuccessCallback="handlePopupSuccessCallback" @handlePopupErrorCallback="handlePopupErrorCallback" />
|
:show="LoginShow"
|
||||||
|
mode="center"
|
||||||
|
@handlePopupClose="handlePopupClose"
|
||||||
|
@handlePopupSuccessCallback="handlePopupSuccessCallback"
|
||||||
|
@handlePopupErrorCallback="handlePopupErrorCallback"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -93,15 +111,19 @@ const newsList = ref([]);
|
||||||
|
|
||||||
function formatTime(timestamp) {
|
function formatTime(timestamp) {
|
||||||
const date = new Date(Number(timestamp).toString().length === 10 ? timestamp * 1000 : timestamp);
|
const date = new Date(Number(timestamp).toString().length === 10 ? timestamp * 1000 : timestamp);
|
||||||
return [
|
return (
|
||||||
date.getFullYear(),
|
[
|
||||||
(date.getMonth() + 1).toString().padStart(2, '0'),
|
date.getFullYear(),
|
||||||
date.getDate().toString().padStart(2, '0')
|
(date.getMonth() + 1).toString().padStart(2, "0"),
|
||||||
].join('-') + ' ' + [
|
date.getDate().toString().padStart(2, "0"),
|
||||||
date.getHours().toString().padStart(2, '0'),
|
].join("-") +
|
||||||
date.getMinutes().toString().padStart(2, '0'),
|
" " +
|
||||||
date.getSeconds().toString().padStart(2, '0')
|
[
|
||||||
].join(':');
|
date.getHours().toString().padStart(2, "0"),
|
||||||
|
date.getMinutes().toString().padStart(2, "0"),
|
||||||
|
date.getSeconds().toString().padStart(2, "0"),
|
||||||
|
].join(":")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getNewsList() {
|
async function getNewsList() {
|
||||||
|
|
@ -143,6 +165,10 @@ function currentChange(page) {
|
||||||
|
|
||||||
onMounted(async (e) => {
|
onMounted(async (e) => {
|
||||||
console.log("🚀 ~ route.query:", route.query);
|
console.log("🚀 ~ route.query:", route.query);
|
||||||
|
console.log(`🚀 ~ Session.get("token"):`, Session.get("token"));
|
||||||
|
if (Session.get("token") == "undefined") {
|
||||||
|
Session.remove("token");
|
||||||
|
}
|
||||||
if (route.query?.token && (!Session.get("token") || Session.get("token") == "undefined")) {
|
if (route.query?.token && (!Session.get("token") || Session.get("token") == "undefined")) {
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: "加载中",
|
title: "加载中",
|
||||||
|
|
@ -172,12 +198,11 @@ onMounted(async (e) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (!Session.get("token")) {
|
if (!Session.get("token") || Session.get("token") == "undefined") {
|
||||||
LoginShow.value = true;
|
LoginShow.value = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 解构路由参数,排除token
|
// 解构路由参数,排除token
|
||||||
const { token, ...otherQuery } = route.query;
|
const { token, ...otherQuery } = route.query;
|
||||||
// 若存在token,替换路由清除参数
|
// 若存在token,替换路由清除参数
|
||||||
|
|
@ -269,7 +294,9 @@ const handlePopupErrorCallback = () => {
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
font-family: PingFangSC, PingFang SC;
|
font-family:
|
||||||
|
PingFangSC,
|
||||||
|
PingFang SC;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
|
|
@ -292,7 +319,9 @@ const handlePopupErrorCallback = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
.nol_num {
|
.nol_num {
|
||||||
font-family: PingFangSC, PingFang SC;
|
font-family:
|
||||||
|
PingFangSC,
|
||||||
|
PingFang SC;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
color: #93a2b3;
|
color: #93a2b3;
|
||||||
|
|
@ -313,7 +342,9 @@ const handlePopupErrorCallback = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
.item_title {
|
.item_title {
|
||||||
font-family: PingFangSC, PingFang SC;
|
font-family:
|
||||||
|
PingFangSC,
|
||||||
|
PingFang SC;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
color: #1a1a1a;
|
color: #1a1a1a;
|
||||||
|
|
@ -321,7 +352,9 @@ const handlePopupErrorCallback = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
.item_summary {
|
.item_summary {
|
||||||
font-family: PingFangSC, PingFang SC;
|
font-family:
|
||||||
|
PingFangSC,
|
||||||
|
PingFang SC;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
color: #333333;
|
color: #333333;
|
||||||
|
|
@ -353,7 +386,9 @@ const handlePopupErrorCallback = () => {
|
||||||
margin-bottom: 10rpx;
|
margin-bottom: 10rpx;
|
||||||
|
|
||||||
.time {
|
.time {
|
||||||
font-family: PingFangSC, PingFang SC;
|
font-family:
|
||||||
|
PingFangSC,
|
||||||
|
PingFang SC;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: #919191;
|
color: #919191;
|
||||||
|
|
@ -363,7 +398,9 @@ const handlePopupErrorCallback = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
.score {
|
.score {
|
||||||
font-family: PingFangSC, PingFang SC;
|
font-family:
|
||||||
|
PingFangSC,
|
||||||
|
PingFang SC;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
color: #ffa800;
|
color: #ffa800;
|
||||||
|
|
@ -386,8 +423,6 @@ const handlePopupErrorCallback = () => {
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
background: #0062d9;
|
background: #0062d9;
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.input {
|
.input {
|
||||||
|
|
@ -409,7 +444,9 @@ const handlePopupErrorCallback = () => {
|
||||||
background: #007aff;
|
background: #007aff;
|
||||||
|
|
||||||
color: white;
|
color: white;
|
||||||
font-family: PingFangSC, PingFang SC;
|
font-family:
|
||||||
|
PingFangSC,
|
||||||
|
PingFang SC;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
|
|
@ -432,7 +469,7 @@ const handlePopupErrorCallback = () => {
|
||||||
|
|
||||||
:deep(.el-input__inner::placeholder) {
|
:deep(.el-input__inner::placeholder) {
|
||||||
color: #ccced3;
|
color: #ccced3;
|
||||||
font-family: 'PingFang SC';
|
font-family: "PingFang SC";
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue