From df854b12c55dde97d1653a5465f958f699161be0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kaizheng=28=E9=83=91=E5=87=AF=29?= Date: Sat, 22 Feb 2025 23:11:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E5=86=8C=E9=A1=B5=E9=9D=A2=E5=AF=B9?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.js | 32 +++++++++++++------ src/utils/request.js | 2 +- src/views/Login/index.vue | 18 ++++++++--- src/views/SerialDetail/index.vue | 23 ------------- .../VideoPlay/components/ProductList.vue | 2 +- src/views/VideoPlay/index.vue | 20 ------------ 6 files changed, 38 insertions(+), 59 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index 718537f..80ae0d9 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -184,19 +184,33 @@ const router = createRouter({ }); router.beforeEach(async (to, from, next) => { - if (to.meta.noLogin || (to.path === "/page" && to.query.preview)) { + if ( + (to.path !== "/login" && to.meta.noLogin) || + (to.path === "/page" && to.query.preview) + ) { return next(); } - console.log("store.state.token", store.state.token); if (!store.state.token && !to.meta.noLogin) { - next({ - path: "/login", - query: { - redirect: to.fullPath, - }, - }); + if (to.query.refreshToken) { + location.replace( + `${to.query.redirect}${ + to.query.redirect.includes("?") ? "&" : "?" + }token=${to.query.token}&refreshToken=${to.query.refreshToken}` + ); + } else { + next({ + path: "/login", + query: { + redirect: to.fullPath, + }, + }); + } } else { - next(); + if (to.path === "/login" && store.state.token) { + next("/"); + } else { + next(); + } } }); diff --git a/src/utils/request.js b/src/utils/request.js index ef0b406..bd3f6fb 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -52,7 +52,7 @@ service.interceptors.response.use( userLogin(); return response.data; } - } else { + } else if (response.data.code !== 0) { showToast(response.data.message); } return response.data; diff --git a/src/views/Login/index.vue b/src/views/Login/index.vue index 24c9ec5..c8f2506 100644 --- a/src/views/Login/index.vue +++ b/src/views/Login/index.vue @@ -44,7 +44,9 @@ const disabled = ref(true); const fromData = reactive({ userName: "", password: "", - loginType: 1, + token: route.query.token, + refreshToken: route.query.refreshToken, + loginType: route.query.refreshToken ? 2 : 1, // 1:账号密码登录 2:token登录 clientType: 1, }); watch(fromData, (val) => { @@ -57,10 +59,12 @@ watch(fromData, (val) => { // const reg = /^1[34578]\d{9}$/; const login = async () => { - if (!fromData.userName) { - return showToast("请输入账号!"); - } else if (!fromData.password) { - return showToast("请输入密码!"); + if (fromData.loginType === 1) { + if (!fromData.userName) { + return showToast("请输入账号!"); + } else if (!fromData.password) { + return showToast("请输入密码!"); + } } let ret = await getUserInfo({ ...fromData }); if (ret.code === 0) { @@ -73,6 +77,10 @@ const login = async () => { } }; +if (route.query.refreshToken) { + login(); +} + const toMobileRegister = () => { location.href = `${window.config.mobileRegister}${encodeURIComponent( location.href diff --git a/src/views/SerialDetail/index.vue b/src/views/SerialDetail/index.vue index d375c3e..5849c72 100644 --- a/src/views/SerialDetail/index.vue +++ b/src/views/SerialDetail/index.vue @@ -63,10 +63,7 @@ import { querySerialDetail, querySerialContentDetail } from "@/api/serial"; import Container from "@/components/Container.vue"; import useShieldConfig from "@/hooks/useShieldConfig"; import NoLookTip from "@/components/NoLookTip.vue"; -import emitter from "@/utils/emitter"; -import { useStore } from "vuex"; -const store = useStore(); const serial = ref({}); const list = ref([]); const loading = ref(false); @@ -97,26 +94,6 @@ const getSerialDetailFn = async () => { auth.value = authResultVo.auth; - window.shareApi.initWxH5({ - env: window.config.shareEnv, - shareusername: store.state.userInfo.userId, - title: serial.value.name, - summary: serial.value.remark, - linkurl: location.href, - img: serial.value.coverImage, - business: "wzfxgkd", - type: "wechat", - id: serial.value.id, - source: "40156", - authorname: serial.value.advisorName, - authornickname: "h5分享", - successFun: function (res) { - // option.url = res.shorturl; - // window.shareApi.init(option); - console.log("合集分享成功", res); - emitter.emit("onShareInform"); - }, - }); if (authResultVo.auth) { if (authResultVo.riskUrl) { showDialog({ diff --git a/src/views/VideoPlay/components/ProductList.vue b/src/views/VideoPlay/components/ProductList.vue index 6a1067a..fb5df5c 100644 --- a/src/views/VideoPlay/components/ProductList.vue +++ b/src/views/VideoPlay/components/ProductList.vue @@ -32,7 +32,7 @@