feat: 实现退出登录时调用后端接口
在多个组件和工具文件中添加了doLogout调用,确保用户退出时通知后端 更新环境配置文件中的API地址
This commit is contained in:
parent
a464d256a2
commit
a9eef0d69f
|
|
@ -2,8 +2,8 @@
|
|||
ENV = development
|
||||
|
||||
# 本地环境接口地址
|
||||
# VITE_API_URL = http://123.60.153.169:8040/apih5
|
||||
VITE_API_URL = http://4155gf93ll13.vicp.fun/apih5
|
||||
VITE_API_URL = http://123.60.153.169:8040/apih5
|
||||
# VITE_API_URL = http://4155gf93ll13.vicp.fun/apih5
|
||||
# VITE_API_URL = http://123.60.79.143:8041/apih5
|
||||
# VITE_API_URL =http://localhost:8040/apih5
|
||||
# VITE_API_URL = https://cankao.cs.com.cn/apih5
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ ENV = production
|
|||
|
||||
# 线上环境接口地址
|
||||
# VITE_API_URL = https://cankao.cs.com.cn/mini
|
||||
# VITE_API_URL = http://123.60.153.169:8040/apih5
|
||||
VITE_API_URL = https://cankao.cs.com.cn/apih5
|
||||
VITE_API_URL = http://123.60.153.169:8040/apih5
|
||||
# VITE_API_URL = https://cankao.cs.com.cn/apih5
|
||||
|
||||
# VITE_API_URL = http://123.60.79.143:8041/apih5
|
||||
|
||||
|
|
|
|||
|
|
@ -55,13 +55,11 @@ export const getUnlockList = (data: any) => {
|
|||
return Request.post("/user/unlockList", data);
|
||||
};
|
||||
|
||||
|
||||
// 全文搜索
|
||||
export const searchNews = (data: any) => {
|
||||
return Request.post("/news/search", data);
|
||||
};
|
||||
|
||||
|
||||
// 已发布列表
|
||||
export const getReleaseList = (data: any) => {
|
||||
return Request.post("/news/top_news_release_h5_d", data);
|
||||
|
|
@ -76,3 +74,9 @@ export const editTopNews = (data: any) => {
|
|||
export const sendToken = (data: any) => {
|
||||
return Request.post("/common/forward/financial", data);
|
||||
};
|
||||
|
||||
// 退出登录
|
||||
export const doLogout = (data: any) => {
|
||||
console.log("🚀 ~ doLogout ~ data:", data);
|
||||
return Request.post("/common/logout", data);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,11 +4,7 @@
|
|||
<view class="userContainer">
|
||||
<u-avatar :src="avatarImg" size="60"></u-avatar>
|
||||
<view class="userData">
|
||||
<text class="phone">{{
|
||||
!isLoginStatus
|
||||
? "未登录用户"
|
||||
: maskPhoneNumber(Session.get("userPhone"))
|
||||
}}</text>
|
||||
<text class="phone">{{ !isLoginStatus ? "未登录用户" : maskPhoneNumber(Session.get("userPhone")) }}</text>
|
||||
<!-- <view class="setUserData">
|
||||
编辑我的个人资料
|
||||
<u-icon size="12" name="arrow-right"></u-icon>
|
||||
|
|
@ -98,9 +94,7 @@
|
|||
|
||||
<!-- 退出登录的按钮 -->
|
||||
<view class="loginOut" :class="!isLoginStatus && 'loginBtn'">
|
||||
<u-button type="danger" size="large" @click="loginBtnStatus">{{
|
||||
!isLoginStatus ? "点击登录" : "退出登录"
|
||||
}}</u-button>
|
||||
<u-button type="danger" size="large" @click="loginBtnStatus">{{ !isLoginStatus ? "点击登录" : "退出登录" }}</u-button>
|
||||
</view>
|
||||
|
||||
<!-- 登录弹框 -->
|
||||
|
|
@ -127,6 +121,8 @@ import like from "@/assets/images/like.png";
|
|||
import time from "@/assets/images/time.png";
|
||||
import vip from "@/assets/images/vip.png";
|
||||
import { useShareStore } from "@/stores/shareStore";
|
||||
import { doLogout } from "@/api";
|
||||
|
||||
const stores = useShareStore();
|
||||
const curPages = getCurrentPages();
|
||||
|
||||
|
|
@ -177,6 +173,9 @@ const loginOut = () => {
|
|||
icon: "none",
|
||||
duration: 1500,
|
||||
});
|
||||
doLogout({
|
||||
financialAccount: Session.get("userPhone"),
|
||||
});
|
||||
// 清除 cookie
|
||||
Session.clear();
|
||||
uni.removeStorageSync("subStatus");
|
||||
|
|
|
|||
|
|
@ -58,8 +58,7 @@
|
|||
<indexMenuTitle title="资讯评分分布区间"></indexMenuTitle>
|
||||
<Line style="margin-top: 30rpx" :data="lineData"></Line>
|
||||
|
||||
<view
|
||||
style="display: flex; flex-direction: column; text-align: center; justify-content: center; align-items: center; padding-bottom: 30rpx">
|
||||
<view style="display: flex; flex-direction: column; text-align: center; justify-content: center; align-items: center; padding-bottom: 30rpx">
|
||||
<InfoSummary style="width: 85%" :count="newsNum"></InfoSummary>
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -67,9 +66,7 @@
|
|||
<view style="background-color: white; margin-top: 40rpx">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center">
|
||||
<indexMenuTitle title="资讯头条 Top20"></indexMenuTitle>
|
||||
<view
|
||||
style="display: flex; align-items: center; margin-right: 15rpx; font-size: 30rpx; gap: 10rpx; margin-top: 10rpx"
|
||||
@click="showCalendar">
|
||||
<view style="display: flex; align-items: center; margin-right: 15rpx; font-size: 30rpx; gap: 10rpx; margin-top: 10rpx" @click="showCalendar">
|
||||
{{ chooseDate.startDate.split(" ")[0] }}
|
||||
<u-icon name="calendar" size="26" style="margin-right: 10rpx"></u-icon>
|
||||
</view>
|
||||
|
|
@ -84,8 +81,7 @@
|
|||
</view>
|
||||
|
||||
<view style="background-color: white; margin-top: 40rpx">
|
||||
<view
|
||||
style="display: flex; justify-content: space-between; align-items: center; padding-right: 30rpx; height: 100rpx">
|
||||
<view style="display: flex; justify-content: space-between; align-items: center; padding-right: 30rpx; height: 100rpx">
|
||||
<indexMenuTitle title="热门行业池 Top10"></indexMenuTitle>
|
||||
<view style="display: flex; gap: 3rpx">
|
||||
<text class="view-all" @click="onViewAll(0)">查看全部</text>
|
||||
|
|
@ -97,8 +93,7 @@
|
|||
</view>
|
||||
|
||||
<view style="background-color: white; margin-top: 40rpx">
|
||||
<view
|
||||
style="display: flex; justify-content: space-between; align-items: center; padding-right: 30rpx; height: 100rpx">
|
||||
<view style="display: flex; justify-content: space-between; align-items: center; padding-right: 30rpx; height: 100rpx">
|
||||
<indexMenuTitle title="风口概念池 Top10"></indexMenuTitle>
|
||||
<view style="display: flex; gap: 3rpx">
|
||||
<text class="view-all" @click="onViewAll(1)">查看全部</text>
|
||||
|
|
@ -111,12 +106,24 @@
|
|||
|
||||
<view class="logout" @click="loginOut" v-if="Session.get('token')">退出登录</view>
|
||||
|
||||
<LoginPopup :show="LoginShow" @handlePopupClose="handlePopupClose"
|
||||
@handlePopupSuccessCallback="handlePopupSuccessCallback" @handlePopupErrorCallback="handlePopupErrorCallback" />
|
||||
<LoginPopup
|
||||
:show="LoginShow"
|
||||
@handlePopupClose="handlePopupClose"
|
||||
@handlePopupSuccessCallback="handlePopupSuccessCallback"
|
||||
@handlePopupErrorCallback="handlePopupErrorCallback"
|
||||
/>
|
||||
|
||||
<u-calendar :show="calendarShow" min-date="2025-01-01" closeOnClickOverlay :max-date="maxDate"
|
||||
:default-date="chooseDate.startDate" monthNum="12" :key="chooseDate.startDate" @confirm="calendarConfirm"
|
||||
@close="calendarShow = false">
|
||||
<u-calendar
|
||||
:show="calendarShow"
|
||||
min-date="2025-01-01"
|
||||
closeOnClickOverlay
|
||||
:max-date="maxDate"
|
||||
:default-date="chooseDate.startDate"
|
||||
monthNum="12"
|
||||
:key="chooseDate.startDate"
|
||||
@confirm="calendarConfirm"
|
||||
@close="calendarShow = false"
|
||||
>
|
||||
</u-calendar>
|
||||
</view>
|
||||
</template>
|
||||
|
|
@ -284,8 +291,12 @@ const handlePopupSuccessCallback = () => {
|
|||
const handlePopupErrorCallback = () => {
|
||||
console.log("登录失败");
|
||||
};
|
||||
|
||||
import { doLogout } from "@/api";
|
||||
function loginOut() {
|
||||
doLogout({
|
||||
financialAccount: Session.get("userPhone"),
|
||||
});
|
||||
|
||||
Session.clear();
|
||||
window.location.reload();
|
||||
}
|
||||
|
|
@ -305,8 +316,8 @@ onMounted(async () => {
|
|||
|
||||
const { aplus_queue } = window;
|
||||
aplus_queue.push({
|
||||
action: 'aplus.sendPV',
|
||||
arguments: [{ is_auto: false }] // 此处上报的数据暂时在后台没有展示
|
||||
action: "aplus.sendPV",
|
||||
arguments: [{ is_auto: false }], // 此处上报的数据暂时在后台没有展示
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -98,8 +98,12 @@
|
|||
|
||||
<view class="logout" @click="loginOut" v-if="Session.get('token')">退出登录</view>
|
||||
|
||||
<LoginPopup :show="LoginShow" @handlePopupClose="handlePopupClose"
|
||||
@handlePopupSuccessCallback="handlePopupSuccessCallback" @handlePopupErrorCallback="handlePopupErrorCallback" />
|
||||
<LoginPopup
|
||||
:show="LoginShow"
|
||||
@handlePopupClose="handlePopupClose"
|
||||
@handlePopupSuccessCallback="handlePopupSuccessCallback"
|
||||
@handlePopupErrorCallback="handlePopupErrorCallback"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
|
@ -243,8 +247,11 @@ const handlePopupSuccessCallback = () => {
|
|||
const handlePopupErrorCallback = () => {
|
||||
console.log("登录失败");
|
||||
};
|
||||
|
||||
import { doLogout } from "@/api";
|
||||
function loginOut() {
|
||||
doLogout({
|
||||
financialAccount: Session.get("userPhone"),
|
||||
});
|
||||
Session.clear();
|
||||
window.location.reload();
|
||||
}
|
||||
|
|
@ -260,7 +267,7 @@ async function getLineDataFn() {
|
|||
if (lineTabIndex.value == 0) {
|
||||
// 行业
|
||||
getTopIndustryPeriod({
|
||||
start_time: dayjs().subtract(7, 'day').format("YYYY-MM-DD"),
|
||||
start_time: dayjs().subtract(7, "day").format("YYYY-MM-DD"),
|
||||
end_time: dayjs().format("YYYY-MM-DD"),
|
||||
limit_num: 10,
|
||||
}).then((res) => {
|
||||
|
|
@ -269,7 +276,7 @@ async function getLineDataFn() {
|
|||
} else if (lineTabIndex.value == 1) {
|
||||
// 概念
|
||||
getTopConceptPeriod({
|
||||
start_time: dayjs().subtract(7, 'day').format("YYYY-MM-DD"),
|
||||
start_time: dayjs().subtract(7, "day").format("YYYY-MM-DD"),
|
||||
end_time: dayjs().format("YYYY-MM-DD"),
|
||||
limit_num: 10,
|
||||
}).then((res) => {
|
||||
|
|
@ -278,7 +285,7 @@ async function getLineDataFn() {
|
|||
} else if (lineTabIndex.value == 2) {
|
||||
// 媒体
|
||||
getTopSourcePeriod({
|
||||
start_time: dayjs().subtract(7, 'day').format("YYYY-MM-DD"),
|
||||
start_time: dayjs().subtract(7, "day").format("YYYY-MM-DD"),
|
||||
end_time: dayjs().format("YYYY-MM-DD"),
|
||||
limit_num: 10,
|
||||
}).then((res) => {
|
||||
|
|
@ -308,10 +315,9 @@ onMounted(async () => {
|
|||
}
|
||||
getLineDataFn();
|
||||
|
||||
|
||||
aplus_queue.push({
|
||||
action: 'aplus.sendPV',
|
||||
arguments: [{ is_auto: false }] // 此处上报的数据暂时在后台没有展示
|
||||
action: "aplus.sendPV",
|
||||
arguments: [{ is_auto: false }], // 此处上报的数据暂时在后台没有展示
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
import { ref, onMounted, onUnmounted, reactive } from "vue";
|
||||
import { onLoad, onShow } from "@dcloudio/uni-app";
|
||||
import { Session } from "@/utils/storage";
|
||||
|
||||
import { doLogout } from "@/api";
|
||||
|
||||
const tabIndex = ref(0);
|
||||
function tabChange(type) {
|
||||
|
|
@ -45,7 +45,11 @@ function tabChange(type) {
|
|||
});
|
||||
}
|
||||
|
||||
function logout() {
|
||||
async function logout() {
|
||||
await doLogout({
|
||||
financialAccount: Session.get("userPhone"),
|
||||
});
|
||||
|
||||
Session.clear();
|
||||
window.location.reload();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import type { AxiosResponse } from "axios";
|
|||
// import { ElMessage, ElMessageBox, ElNotification } from 'element-plus';
|
||||
import { Session } from "@/utils/storage";
|
||||
import qs from "qs";
|
||||
import { doLogout } from "@/api";
|
||||
|
||||
// 配置新建一个 axios 实例
|
||||
const service = axios.create({
|
||||
|
|
@ -52,6 +53,9 @@ service.interceptors.response.use(
|
|||
|
||||
// `token` 过期或者账号已在别处登录
|
||||
if (res.code === 401 || res.code === 4001) {
|
||||
doLogout({
|
||||
financialAccount: Session.get("userPhone"),
|
||||
});
|
||||
Session.clear(); // 清除浏览器全部临时缓存
|
||||
window.location.href = "/"; // 去登录页
|
||||
console.log("你已被登出,请重新登录");
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import type { AxiosResponse } from "axios";
|
|||
// import { ElMessage, ElMessageBox, ElNotification } from 'element-plus';
|
||||
import { Session } from "@/utils/storage";
|
||||
import qs from "qs";
|
||||
import { doLogout } from "@/api";
|
||||
|
||||
// 配置新建一个 axios 实例
|
||||
const service = axios.create({
|
||||
|
|
@ -52,6 +53,9 @@ service.interceptors.response.use(
|
|||
|
||||
// `token` 过期或者账号已在别处登录
|
||||
if (res.status === 401 || res.status === 4001) {
|
||||
doLogout({
|
||||
financialAccount: Session.get("userPhone"),
|
||||
});
|
||||
Session.clear(); // 清除浏览器全部临时缓存
|
||||
window.location.href = "/"; // 去登录页
|
||||
console.log("你已被登出,请重新登录");
|
||||
|
|
|
|||
Loading…
Reference in New Issue