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