feat: token验证失败阻断

This commit is contained in:
liu.huiying@ebiz-digits.com
2025-03-12 19:29:55 +08:00
parent 7c5a6abf70
commit 34cad55fb8
4 changed files with 66 additions and 38 deletions

View File

@@ -92,22 +92,22 @@ export default {
}); });
}, },
/** // /**
* @desc 跳转到H5页面 // * @desc 跳转到H5页面
* @param {String} h5Url 目标H5链接 // * @param {String} h5Url 目标H5链接
* @param {String} name 导航头中的标题文案 // * @param {String} name 导航头中的标题文案
* @param {Boolean} fullscreen 是否全屏显示(隐藏导航头) // * @param {Boolean} fullscreen 是否全屏显示(隐藏导航头)
* @returns {Boolean} 操作是否成功 // * @returns {Boolean} 操作是否成功
*/ // */
navigateToH5(h5Url, name, fullscreen = false) { // navigateToH5(h5Url, name, fullscreen = false) {
if (fullscreen) { // if (fullscreen) {
h5Url = this.appendQueryParam(h5Url, 'fullscreen', 'true'); // h5Url = this.appendQueryParam(h5Url, 'fullscreen', 'true');
} // }
return this.postMessageToRN({ // return this.postMessageToRN({
type: 'navigate', // type: 'navigate',
url: `authH5?url=${encodeURIComponent(h5Url)}&name=${name}` // url: `authH5?url=${encodeURIComponent(h5Url)}&name=${name}`
}); // });
}, // },
// /** // /**
// * @desc 给URL添加查询参数 // * @desc 给URL添加查询参数

View File

@@ -9,7 +9,8 @@
<RouterView /> <RouterView />
<!-- tabbar --> <!-- tabbar -->
<van-tabbar v-model="active"> <van-tabbar v-model="active">
<van-tabbar-item v-for="tab in table" :key="tab.title" :name="tab.title" :to="tab.path"> <van-tabbar-item v-for="tab in table" :key="tab.title" :name="tab.title" @click="tabPath(tab.path)">
<!-- <van-tabbar-item v-for="tab in table" :key="tab.title" :name="tab.title" :to="tab.path"> -->
<span>{{ tab.title }}</span> <span>{{ tab.title }}</span>
<!-- <template #icon="props"> --> <!-- <template #icon="props"> -->
<template #icon> <template #icon>
@@ -22,8 +23,12 @@
</template> </template>
<script setup> <script setup>
import { RouterView } from 'vue-router'; import { RouterView, useRouter } from 'vue-router';
import { ref } from 'vue'; import { ref } from 'vue';
import utils from '@/assets/js/common';
import { getUserInfo } from '@/api/common/index.js';
import { showFailToast } from 'vant';
const router = useRouter();
const active = ref(); const active = ref();
const table = [ const table = [
@@ -48,6 +53,27 @@ const table = [
icon: 'https://files.axshare.com/gsc/DR6075/de/a0/49/dea049d6ad3e4c2c80af44258c6c76d6/images/%E9%A6%96%E9%A1%B5_1/u24.png?pageId=74b3e5b2-848e-4258-8a34-9e220127c8a6' icon: 'https://files.axshare.com/gsc/DR6075/de/a0/49/dea049d6ad3e4c2c80af44258c6c76d6/images/%E9%A6%96%E9%A1%B5_1/u24.png?pageId=74b3e5b2-848e-4258-8a34-9e220127c8a6'
} }
]; ];
function tabPath(path) {
if (utils.getParameter('digitalYiliToken')) {
const appToken = utils.getParameter('digitalYiliToken');
getUserInfo(appToken).then((res) => {
if (res.data) {
utils.setSessionStorage('userInfo', res.data.data);
router.push({
path
});
} else {
showFailToast(error.response.data?.message || error.data?.message || error.message || '服务器错误');
}
}).catch((error) => {
showFailToast(error?.response?.data?.message || error?.message || '服务器错误');
});
} else {
router.push({
path
});
}
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@@ -7,18 +7,20 @@ import utils from '@/assets/js/common';
import { getUserInfo } from '@/api/common/index.js'; import { getUserInfo } from '@/api/common/index.js';
import { showFailToast } from 'vant'; import { showFailToast } from 'vant';
const contentShow = ref(false); const contentShow = ref(false);
onMounted(async() => {
onMounted(async () => {
if (utils.getParameter('digitalYiliToken')) { if (utils.getParameter('digitalYiliToken')) {
const query = { const appToken = utils.getParameter('digitalYiliToken');
xToken: utils.getParameter('digitalYiliToken') getUserInfo(appToken).then((res) => {
};
getUserInfo(query).then((res) => {
if (res.data) { if (res.data) {
utils.setSessionStorage('userInfo', res.data); contentShow.value = true;
utils.setSessionStorage('userInfo', res.data.data);
} else { } else {
showFailToast(error.data?.message || error.message || '服务器错误'); contentShow.value = false;
showFailToast(error.response.data?.message || error.data?.message || error.message || '服务器错误');
} }
}).catch((error) => {
contentShow.value = false;
showFailToast(error?.response?.data?.message || error?.message || '服务器错误');
}); });
} else { } else {
contentShow.value = true; contentShow.value = true;

View File

@@ -83,7 +83,7 @@ interface PublishInfo {
const publishInfo = ref<PublishInfo>({} as PublishInfo); const publishInfo = ref<PublishInfo>({} as PublishInfo);
type OperateItem = (typeof operateList)[0]; type OperateItem = (typeof operateList)[0];
onMounted(async () => { onMounted(async() => {
getQrcode('Xxgdr5EN') getQrcode('Xxgdr5EN')
.then((res) => { .then((res) => {
if (res.data) { if (res.data) {