Browse Source

权限控制+返回首页

songjie/feature-20250628160649-上线前优化
no99 3 weeks ago
parent
commit
3669258d47
  1. 13
      src/api/AIxiaocaishen.js
  2. 106
      src/views/DBQBmodel.vue
  3. 106
      src/views/Emotionsmodel.vue
  4. 3
      src/views/Selectmodel.vue
  5. 91
      src/views/components/BackToHomeButton.vue
  6. 10
      src/views/homePage.vue

13
src/api/AIxiaocaishen.js

@ -354,3 +354,16 @@ export const getUserInfoAPI = function (params) {
};
// 8.18金币兑换Token end
// 8.25权限控制 start
export const checkStatusAPI = function (headers, params) {
return request({
// url: `${HWurl}/api/workflow/checkStatus`,
url: `http://39.101.133.168:8828/link/api/workflow/checkStatus`,
method: "POST",
data: params,
headers: headers,
});
};
// 8.25权限控制 end

106
src/views/DBQBmodel.vue

@ -10,7 +10,8 @@ import text2 from "@/assets/img/DBQBmodel/-s-场景可预演.png";
import text3 from "@/assets/img/DBQBmodel/-s-交易可掌控.png";
import btnIcon from "@/assets/img/DBQBmodel/-s-开启财运.png";
import { setHeight } from "@/utils/setHeight";
import { checkStatusAPI } from "../api/AIxiaocaishen";
import BackToHomeButton from "@/views/components/BackToHomeButton.vue";
const router = useRouter();
const pageRef = ref(null);
const windowWidth = ref(window.innerWidth);
@ -34,11 +35,58 @@ onUnmounted(() => {
window.removeEventListener("resize", handleResize);
});
const goToHomePage = () => {
// sessionStorage homepage.vue AiEmotion tab
sessionStorage.setItem("activeTabAI", "AIchat");
sessionStorage.setItem("activeIndexAI", "0");
router.push("/homePage");
const noPermissonDialogVisible = ref(false);
const noPermissonDialogObj = ref({});
const goToHomePage = async () => {
try {
let params = {
token: localStorage.getItem("localToken"),
model: 1,
};
const userAgent = navigator.userAgent;
let isMobile =
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
userAgent
);
let Client = "pc";
if (isMobile) {
if (/iPhone|iPad|iPod/i.test(userAgent)) {
Client = "ios";
} else if (/Android/i.test(userAgent)) {
Client = "android";
} else {
Client = "android"; //
}
}
let headers = {
Client: Client,
};
const res = await checkStatusAPI(headers, params);
if (res.code == 200) {
// sessionStorage homepage.vue AiEmotion tab
sessionStorage.setItem("activeTabAI", "AIchat");
sessionStorage.setItem("activeIndexAI", "0");
router.push("/homePage");
} else {
console.log("无权限");
noPermissonDialogVisible.value = true;
noPermissonDialogObj.value.msg = res.msg;
console.log("noPermissonDialogVisible", noPermissonDialogVisible.value);
console.log("noPermissonDialogObj", noPermissonDialogObj.value);
}
} catch (e) {
console.error("获取权限失败", e);
}
};
const closeNoPermissionDialog = () => {
noPermissonDialogVisible.value = false;
};
</script>
@ -48,6 +96,8 @@ const goToHomePage = () => {
class="homepage"
:style="{ backgroundImage: `url(${bgImage})` }"
>
<BackToHomeButton />
<div v-if="false"></div>
<!-- 顶部图标 -->
<img class="top-icon" :src="topIcon" alt="顶部图标" />
@ -69,6 +119,15 @@ const goToHomePage = () => {
</div>
</div>
</div>
<div v-if="noPermissonDialogVisible" class="noPermissionDialog">
<div class="noPermissionContent" @click="closeNoPermissionDialog">
<div class="noPermissionCloseBtn">
<el-icon class="noPermissionIcon"><Close /></el-icon>
</div>
{{ noPermissonDialogObj.msg }}
</div>
</div>
</template>
<style scoped>
@ -156,6 +215,41 @@ const goToHomePage = () => {
height: auto;
}
.noPermissionDialog {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
position: fixed;
bottom: 15%;
/* margin: auto auto; */
color: white;
}
.noPermissionCloseBtn {
border-radius: 5px;
border: 1px solid white;
background-color: #8621d9;
padding: 2px;
display: flex;
justify-content: center;
align-items: center;
position: absolute;
top: -10px;
right: -10px;
}
.noPermissionContent {
position: relative;
border-radius: 5px;
border: 1px solid white;
padding: 10px 30px;
background-color: #261176;
display: flex;
justify-content: center;
align-items: center;
}
/* 手机适配 - 小屏幕时保持纵向排列 */
@media screen and (max-width: 768px) {
.top-icon {

106
src/views/Emotionsmodel.vue

@ -1,5 +1,6 @@
<template>
<div ref="pageRef" class="homepage">
<BackToHomeButton />
<!-- 顶部图标 -->
<img class="top-icon" :src="topIcon" alt="顶部图标" />
@ -25,6 +26,15 @@
</div>
</div>
</div>
<div v-if="noPermissonDialogVisible" class="noPermissionDialog">
<div class="noPermissionContent" @click="closeNoPermissionDialog">
<div class="noPermissionCloseBtn">
<el-icon class="noPermissionIcon"><Close /></el-icon>
</div>
{{ noPermissonDialogObj.msg }}
</div>
</div>
</template>
<script setup>
@ -37,7 +47,9 @@ import conteniconLarge from "@/assets/img/Emotionsmodel/_s_四维 拷贝.png";
import conteniconSmall from "@/assets/img/Emotionsmodel/-s-四维.png";
import btnIcon from "@/assets/img/Emotionsmodel/-s-开启财运.png";
import { setHeight } from "@/utils/setHeight";
import { checkStatusAPI } from "../api/AIxiaocaishen";
import BackToHomeButton from "@/views/components/BackToHomeButton.vue";
const router = useRouter();
const pageRef = ref(null);
const screenWidth = ref(window.innerWidth);
@ -60,11 +72,58 @@ onUnmounted(() => {
window.removeEventListener("resize", handleResize);
});
const goToAiEmotion = () => {
// sessionStorage homepage.vue AiEmotion tab
sessionStorage.setItem("activeTabAI", "AiEmotion");
sessionStorage.setItem("activeIndexAI", "1");
router.push("/homePage");
const noPermissonDialogVisible = ref(false);
const noPermissonDialogObj = ref({});
const goToAiEmotion = async () => {
try {
let params = {
token: localStorage.getItem("localToken"),
model: 2,
};
const userAgent = navigator.userAgent;
let isMobile =
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
userAgent
);
let Client = "pc";
if (isMobile) {
if (/iPhone|iPad|iPod/i.test(userAgent)) {
Client = "ios";
} else if (/Android/i.test(userAgent)) {
Client = "android";
} else {
Client = "android"; //
}
}
let headers = {
Client: Client,
};
const res = await checkStatusAPI(headers, params);
if (res.code == 200) {
// sessionStorage homepage.vue AiEmotion tab
sessionStorage.setItem("activeTabAI", "AiEmotion");
sessionStorage.setItem("activeIndexAI", "1");
router.push("/homePage");
} else {
console.log("无权限");
noPermissonDialogVisible.value = true;
noPermissonDialogObj.value.msg = res.msg;
console.log("noPermissonDialogVisible", noPermissonDialogVisible.value);
console.log("noPermissonDialogObj", noPermissonDialogObj.value);
}
} catch (e) {
console.error("获取权限失败", e);
}
};
const closeNoPermissionDialog = () => {
noPermissonDialogVisible.value = false;
};
</script>
@ -148,6 +207,41 @@ const goToAiEmotion = () => {
height: auto;
}
.noPermissionDialog {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
position: fixed;
bottom: 15%;
/* margin: auto auto; */
color: white;
}
.noPermissionCloseBtn {
border-radius: 5px;
border: 1px solid white;
background-color: #8621d9;
padding: 2px;
display: flex;
justify-content: center;
align-items: center;
position: absolute;
top: -10px;
right: -10px;
}
.noPermissionContent {
position: relative;
border-radius: 5px;
border: 1px solid white;
padding: 10px 30px;
background-color: #261176;
display: flex;
justify-content: center;
align-items: center;
}
@media (max-width: 1024px) {
/* 四维体系整体容器修复 */
.content-container {
@ -179,7 +273,7 @@ const goToAiEmotion = () => {
margin-top: -2vh;
}
/* 四维体系整体容器修复 */
/* 四维体系整体容器修复 */
.content-container {
width: 80%;
height: auto;

3
src/views/Selectmodel.vue

@ -1,5 +1,6 @@
<template>
<div class="homepage">
<BackToHomeButton />
<!-- 顶部主图背景 -->
<!-- <div class="main-icon"></div> -->
@ -36,7 +37,7 @@ import { setHeight } from "@/utils/setHeight";
import { useDataStore } from "@/store/dataList.js";
const { getQueryVariable, setActiveTabIndex, getUserInfo } = useDataStore();
import robot from "@/assets/img/Selectmodel/机器人 拷贝.png";
import BackToHomeButton from "@/views/components/BackToHomeButton.vue";
const router = useRouter();
const pageRef = ref(null);

91
src/views/components/BackToHomeButton.vue

@ -0,0 +1,91 @@
<template>
<div class="backToHomeBtn" @click="backToHome">
<img
src="https://d31zlh4on95l9h.cloudfront.net/images/9cbc5b2eb2327bd04d015c19d8c3f1f9.png"
alt="返回首页"
class="backImg"
/>
<div class="backContent">返回首页</div>
</div>
</template>
<script setup>
import { computed } from "vue";
//
const backToHome = () => {
const userAgent = navigator.userAgent;
let isMobile =
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
userAgent
);
if (isMobile) {
console.log("用户是移动端");
//
if (typeof uni !== "undefined") {
uni.postMessage({
data: {
val: {
name: "JWopenView",
extra: {
data: {
type: 3,
},
},
},
},
});
}
} else {
console.log("用户是pc端");
const env = import.meta.env.VITE_ENV;
console.log("当前的环境为:", env);
if (env == "development" || env == "test") {
window.parent.location.href =
"http://121.89.234.155:8807/hljw/homepage?menu=999999991";
} else {
window.parent.location.href =
"https://web.homilychart.com/product/hljw/homepage?token=" +
encodeURIComponent(localStorage.getItem("localToken"));
}
}
};
</script>
<style scoped>
.backToHomeBtn {
position: fixed;
top: 20px;
right: 20px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
cursor: pointer;
z-index: 20;
}
.backToHomeBtn:hover {
transform: scale(1.05);
}
.backImg {
width: 60%;
height: auto;
}
.backContent {
width: 100%;
text-align: center;
color: white;
font-size: 12px;
white-space: nowrap;
}
@media (max-width: 768px) {
.backToHomeBtn {
top: 0px;
right: 0px;
}
}
</style>

10
src/views/homePage.vue

@ -924,13 +924,9 @@ const backToHome = () => {
window.parent.location.href =
"http://121.89.234.155:8807/hljw/homepage?menu=999999991";
} else {
window.parent.postMessage(
{
type: "NAVIGATE_TO_HOMEPAGE",
menu: "999999991",
},
"*"
);
window.parent.location.href =
"https://web.homilychart.com/product/hljw/homepage?token=" +
encodeURIComponent(localStorage.getItem("localToken"));
}
// window.parent.location.href = window.parent.document.referrer
}

Loading…
Cancel
Save