first commit
This commit is contained in:
93
src/layouts/GlobalLayout.vue
Normal file
93
src/layouts/GlobalLayout.vue
Normal file
@@ -0,0 +1,93 @@
|
||||
<template>
|
||||
<router-view />
|
||||
<van-popup v-model:show="showPopup" round @click-overlay="onClickOverlay">
|
||||
<div class="popup-content text-center p-8">
|
||||
<div v-html="currentNotify?.content"></div>
|
||||
<div class="flex justify-center">
|
||||
<van-button type="primary" @click="showPopup = false" class="w-24">关闭</van-button>
|
||||
</div>
|
||||
</div>
|
||||
</van-popup>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
|
||||
// 响应式变量
|
||||
const showPopup = ref(false)
|
||||
const notify = ref([])
|
||||
const currentNotify = ref(null)
|
||||
|
||||
// 获取当前页面路径
|
||||
const route = useRoute()
|
||||
|
||||
// 获取通知数据
|
||||
onMounted(() => {
|
||||
getGlobalNotify()
|
||||
})
|
||||
|
||||
// 获取通知数据
|
||||
const getGlobalNotify = async () => {
|
||||
const { data, error } = await useApiFetch("/notification/list")
|
||||
.get()
|
||||
.json()
|
||||
|
||||
if (data.value && !error.value) {
|
||||
if (data.value !== 200) {
|
||||
notify.value = data.value.data.notifications
|
||||
checkNotification() // 在获取数据后检查通知
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 判断当前时间是否在通知的时间范围内
|
||||
const isWithinTimeRange = (startTime, endTime) => {
|
||||
const now = new Date()
|
||||
|
||||
// 获取当前时间的小时和分钟
|
||||
const currentMinutes = now.getHours() * 60 + now.getMinutes()
|
||||
|
||||
// 将 startTime 和 endTime 转换为分钟数
|
||||
const startParts = startTime.split(':').map(Number)
|
||||
const endParts = endTime.split(':').map(Number)
|
||||
const startMinutes = startParts[0] * 60 + startParts[1]
|
||||
const endMinutes = endParts[0] * 60 + endParts[1]
|
||||
|
||||
// 如果 endTime 小于 startTime,表示跨越了午夜
|
||||
if (endMinutes < startMinutes) {
|
||||
// 判断当前时间是否在 [startTime, 23:59:59] 或 [00:00:00, endTime] 之间
|
||||
return currentMinutes >= startMinutes || currentMinutes < endMinutes
|
||||
}
|
||||
|
||||
// 普通情况,直接判断时间是否在范围内
|
||||
return currentMinutes >= startMinutes && currentMinutes <= endMinutes
|
||||
}
|
||||
// 检查通知并更新showPopup
|
||||
const checkNotification = () => {
|
||||
// 遍历通知数组,找到第一个符合条件的通知
|
||||
for (let notification of notify.value) {
|
||||
// 判断时间是否符合当前时间
|
||||
const isTimeValid = isWithinTimeRange(notification.startTime, notification.endTime)
|
||||
// 判断页面是否符合
|
||||
|
||||
if (isTimeValid && notification.notificationPage === route.path) {
|
||||
currentNotify.value = notification
|
||||
showPopup.value = true
|
||||
break // 只显示第一个符合的通知
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 监听路由变化
|
||||
watch(() => route.path, () => {
|
||||
checkNotification() // 每次路由变化时重新判断通知
|
||||
})
|
||||
|
||||
// 关闭弹窗
|
||||
const onClickOverlay = () => {
|
||||
showPopup.value = false
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
185
src/layouts/HomeLayout.vue
Normal file
185
src/layouts/HomeLayout.vue
Normal file
@@ -0,0 +1,185 @@
|
||||
<template>
|
||||
<div class="home-layout min-h-screen flex flex-col">
|
||||
<!-- Header -->
|
||||
<div class="header">
|
||||
<img class="logo rounded-full overflow-hidden" src="/logo.png" alt="Logo" />
|
||||
<div class="brand-text">
|
||||
<h1 class="title">幸福查</h1>
|
||||
<p class="slogan">幸福就去查</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Content Area -->
|
||||
<div class="content flex flex-col flex-1">
|
||||
<router-view />
|
||||
</div>
|
||||
|
||||
<!-- Vant Tabbar -->
|
||||
|
||||
<van-tabbar v-model="tabbar" @change="tabChange">
|
||||
<van-tabbar-item v-for="(item, index) in menu" :key="index" :name="item.name" :icon="item.icon">{{
|
||||
item.title }}
|
||||
</van-tabbar-item>
|
||||
</van-tabbar>
|
||||
|
||||
<!-- Complaint Button -->
|
||||
<div @click="toComplaint" class="complaint-button">
|
||||
<img src="@/assets/images/homelayout/ts.png" alt="投诉" class="w-4 h-4 mr-1 inline-block" />
|
||||
<span class="">投诉</span>
|
||||
</div>
|
||||
<div class="disclaimer">
|
||||
<div class="flex flex-col items-center">
|
||||
<div class="flex items-center">
|
||||
<img class="w-4 h-4 mr-2" src="@/assets/images/public_security_record_icon.png" alt="公安备案" />
|
||||
<text>琼公网安备46010002000584号</text>
|
||||
</div>
|
||||
<div>
|
||||
<a class="text-blue-500" href="https://beian.miit.gov.cn">
|
||||
琼ICP备2025059533号-2
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div>海口龙华海宇网络技术服务工作室版权所有</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted, watch } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router"; // 引入 Vue Router
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const tabbar = ref("index");
|
||||
const menu = reactive([
|
||||
{ title: "首页", icon: "home-o", name: "index" },
|
||||
{ title: "更多", icon: "more-o", name: "more" },
|
||||
{ title: "资产", icon: "gold-coin-o", name: "agent" },
|
||||
{ title: "我的", icon: "user-o", name: "me" }
|
||||
]);
|
||||
|
||||
// 根据当前路由设置 Tabbar 的高亮项
|
||||
onMounted(() => {
|
||||
const currentPage = route.name; // 获取当前路由的名称
|
||||
tabbar.value = currentPage;
|
||||
});
|
||||
|
||||
// 监听路由变化,更新 tabbar
|
||||
watch(() => route.name, (newName) => {
|
||||
if (newName) {
|
||||
tabbar.value = newName;
|
||||
}
|
||||
});
|
||||
|
||||
const onClickOverlay = () => { };
|
||||
// 跳转到相应页面
|
||||
const tabChange = (name, a, b, c) => {
|
||||
if (name === "more") {
|
||||
showConfirmDialog({
|
||||
title: '更多报告',
|
||||
message:
|
||||
'是否前往天远查查询更多报告',
|
||||
})
|
||||
.then(() => {
|
||||
window.location.href = "https://www.tianyuancha.cn";
|
||||
})
|
||||
.catch(() => {
|
||||
tabbar.value = route.name;
|
||||
})
|
||||
return;
|
||||
}
|
||||
router.push({ name }); // 使用 Vue Router 进行跳转
|
||||
};
|
||||
|
||||
// 跳转到投诉页面
|
||||
const toComplaint = () => {
|
||||
window.location.href =
|
||||
"https://work.weixin.qq.com/kfid/kfc8a32720024833f57"; // 跳转到客服页面
|
||||
// router.push({ name: 'complaint' }); // 使用 Vue Router 进行跳转
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.home-layout {
|
||||
@apply from-sky-100/20 to-white bg-gradient-to-b
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: linear-gradient(135deg, #ffffff 0%, #fafbfc 100%);
|
||||
padding: 0.75rem 1.25rem;
|
||||
min-height: 3.5rem;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
.logo {
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
margin-right: 0.75rem;
|
||||
object-fit: cover;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
.brand-text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
gap: 0.15rem;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
|
||||
font-size: 1.5rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.12em;
|
||||
color: #0f172a;
|
||||
line-height: 1.25;
|
||||
text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
|
||||
.slogan {
|
||||
font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
|
||||
font-size: 0.7rem;
|
||||
color: #94a3b8;
|
||||
letter-spacing: 0.28em;
|
||||
font-weight: 400;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.content {
|
||||
/* min-height: calc(100vh - 3rem); */
|
||||
}
|
||||
|
||||
.complaint-button {
|
||||
position: fixed;
|
||||
bottom: 6rem;
|
||||
right: 1rem;
|
||||
background: #ff6b6b;
|
||||
border-radius: 1.5rem;
|
||||
padding: 0.25rem 1rem;
|
||||
color: white;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
|
||||
z-index: 2000;
|
||||
}
|
||||
|
||||
.complaint-button i {
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
|
||||
.disclaimer {
|
||||
/* margin-top: 24px; */
|
||||
padding: 10px;
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
text-align: center;
|
||||
border-top: 1px solid #e0e0e0;
|
||||
padding-bottom: 60px;
|
||||
background: #ffffff;
|
||||
margin-bottom: 50px;
|
||||
}
|
||||
</style>
|
||||
32
src/layouts/PageLayout.vue
Normal file
32
src/layouts/PageLayout.vue
Normal file
@@ -0,0 +1,32 @@
|
||||
<template>
|
||||
<div class="from-sky-100/20 to-white bg-gradient-to-b min-h-screen">
|
||||
<van-nav-bar fixed :border="false" placeholder :title="pageTitle" left-arrow @click-left="onClickLeft"
|
||||
z-index="9999" />
|
||||
<router-view />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch, onMounted } from "vue";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const pageTitle = ref(""); // 用来保存页面标题
|
||||
|
||||
const onClickLeft = () => {
|
||||
// 使用 router 的返回功能
|
||||
router.back();
|
||||
};
|
||||
onMounted(() => { });
|
||||
// 监听路由变化并更新标题
|
||||
watch(
|
||||
() => route.meta.title,
|
||||
(newTitle) => {
|
||||
pageTitle.value = newTitle || "默认标题";
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
Reference in New Issue
Block a user