加了6,7
This commit is contained in:
@@ -49,6 +49,24 @@ const routes = [
|
||||
},
|
||||
component: () => import('@/views/dietaryNutritionTips/dietaryNutritionTips5.vue')
|
||||
},
|
||||
{
|
||||
path: '/dietaryNutritionTips6',
|
||||
name: 'dietaryNutritionTips6',
|
||||
meta: {
|
||||
title: '膳食营养温馨提示',
|
||||
rootValue: 108
|
||||
},
|
||||
component: () => import('@/views/dietaryNutritionTips/dietaryNutritionTips6.vue')
|
||||
},
|
||||
{
|
||||
path: '/dietaryNutritionTips7',
|
||||
name: 'dietaryNutritionTips7',
|
||||
meta: {
|
||||
title: '膳食营养温馨提示',
|
||||
rootValue: 108
|
||||
},
|
||||
component: () => import('@/views/dietaryNutritionTips/dietaryNutritionTips7.vue')
|
||||
},
|
||||
{
|
||||
path: '/dataBoard',
|
||||
name: 'dataBoard',
|
||||
|
||||
@@ -0,0 +1,528 @@
|
||||
<template>
|
||||
<div id="dietaryNutritionTips">
|
||||
<template v-if="dataConfig.list && dataConfig.list.length">
|
||||
<div class="dietaryNutritionTips-Content">
|
||||
<div class="tips">
|
||||
<div></div>
|
||||
<div>温馨提示</div>
|
||||
<div></div>
|
||||
</div>
|
||||
|
||||
<div class="title">
|
||||
<div></div>
|
||||
<div>
|
||||
<div>体重管理行动({{dataConfig.personnelType === 'staff' ? '员工' : '部门'}})</div>
|
||||
<div>
|
||||
<div>{{ dataConfig.currentDate }}</div>
|
||||
<div>
|
||||
活动开始第<span>{{ dataConfig.doingDay }}</span>天
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div></div>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div class="contentHeader">
|
||||
<div>序号</div>
|
||||
<div>单位(部门)</div>
|
||||
<template v-if="dataConfig.personnelType === 'staff'">
|
||||
<div class="staff-userName">姓名</div>
|
||||
<div class="staff-fraction">体重管理得分</div>
|
||||
</template>
|
||||
<template v-if="dataConfig.personnelType === 'department'">
|
||||
<div class="department-avgFraction">人均体重管理得分</div>
|
||||
</template>
|
||||
</div>
|
||||
<div class="contentBody" ref="scrollContentBody">
|
||||
<div v-for="(item, index) in dataConfig.list" :key="index">
|
||||
<template v-if="dataConfig.personnelType === 'staff'">
|
||||
<div>{{ item.rank }}</div>
|
||||
<div>{{ item.departName }}</div>
|
||||
<div class="staff-userName">{{ item.realName }}</div>
|
||||
<div class="staff-fraction">{{ item.value }}</div>
|
||||
</template>
|
||||
<template v-if="dataConfig.personnelType === 'department'">
|
||||
<div>{{ item.rank }}</div>
|
||||
<div>{{ item.orgName }}</div>
|
||||
<div class="department-avgFraction">{{ item.value }}</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
<div>公共事务中心 宣</div>
|
||||
<div>开始时间:{{ dataConfig.startDay }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<div class="banner">
|
||||
<template v-for="(banner, index) in bannerConfig.list">
|
||||
<div :key="index" :style="{ backgroundImage: 'url(' + banner + ')', display: index === bannerConfig.index ? 'block' : 'none' }"></div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { httpRequest } from "@/XMLHttpRequest";
|
||||
import { getCurrentDate } from "@/utils/times";
|
||||
import signMd5Utils from "@/utils/signMd5";
|
||||
|
||||
export default {
|
||||
name: "dietaryNutritionTips",
|
||||
data() {
|
||||
return {
|
||||
bannerConfig: {
|
||||
list: [
|
||||
'https://yyjk.shuziweidao.com/gateway/file/down/images/1.jpg',
|
||||
'https://yyjk.shuziweidao.com/gateway/file/down/images/2.jpg',
|
||||
'https://yyjk.shuziweidao.com/gateway/file/down/images/3.jpg',
|
||||
'https://yyjk.shuziweidao.com/gateway/file/down/images/4.jpg',
|
||||
],
|
||||
index: 0,
|
||||
setIntervalFun: null
|
||||
},
|
||||
|
||||
rankingConfig: {
|
||||
personnelType: "department", // 员工:staff / 部门:department
|
||||
requestConfig: {
|
||||
agreement: "https",
|
||||
url: "api.cqygjk.com",
|
||||
suffix: "",
|
||||
urlPrefix: "/health-intervene/api/anon",
|
||||
orgCode: "A01A86",
|
||||
pageSize: 0
|
||||
},
|
||||
},
|
||||
|
||||
dataConfig: {
|
||||
personnelType: "department", // 员工:staff / 部门:department
|
||||
currentDate: "",
|
||||
doingDay: "",
|
||||
list: [],
|
||||
startDay: "-",
|
||||
},
|
||||
|
||||
scrollConfig: {
|
||||
scrollAnimationFrameId: null, // 用于存储 requestAnimationFrame 的 ID
|
||||
scrollSpeed: 2, // 滚动速度,每帧移动的像素数
|
||||
// 这里的 scrollWaitTime 将在 startOneTimeScroll 中动态决定
|
||||
// 1秒用于有数据且能滚动,5秒用于无数据或数据不足以滚动
|
||||
dynamicScrollWaitTime: 1 // 动态等待时间,默认为1秒
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.loadDataUrl();
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.stopAllLoops();
|
||||
},
|
||||
methods: {
|
||||
stopAllLoops() {
|
||||
if (this.bannerConfig.setIntervalFun) {
|
||||
clearInterval(this.bannerConfig.setIntervalFun);
|
||||
this.bannerConfig.setIntervalFun = null;
|
||||
}
|
||||
if (this.scrollConfig.scrollAnimationFrameId) {
|
||||
cancelAnimationFrame(this.scrollConfig.scrollAnimationFrameId);
|
||||
this.scrollConfig.scrollAnimationFrameId = null;
|
||||
}
|
||||
// 清除可能存在的 setTimeout,避免重复请求
|
||||
if (this.rankingConfig.setTimeOutFun) {
|
||||
clearTimeout(this.rankingConfig.setTimeOutFun);
|
||||
this.rankingConfig.setTimeOutFun = null;
|
||||
}
|
||||
},
|
||||
|
||||
loadDataUrl() {
|
||||
let _this = this;
|
||||
_this.stopAllLoops(); // 在请求数据前,停止所有正在进行的循环
|
||||
|
||||
_this.dataConfig.currentDate = getCurrentDate();
|
||||
_this.rankingConfig.personnelType = _this.rankingConfig.personnelType === "staff" ? "department" : "staff";
|
||||
_this.rankingConfig.requestConfig.pageSize = _this.rankingConfig.personnelType === "staff" ? 50 : 100;
|
||||
|
||||
let serve = _this.rankingConfig.requestConfig.agreement + "://" + _this.rankingConfig.requestConfig.url;
|
||||
let url = serve + _this.rankingConfig.requestConfig.suffix + _this.rankingConfig.requestConfig.urlPrefix + (_this.rankingConfig.personnelType === "staff" ? "/userRank" : "/deptRank");
|
||||
|
||||
let requestUrl = url + "?orgCode=" + _this.rankingConfig.requestConfig.orgCode + "&pageNo=1&pageSize=" + _this.rankingConfig.requestConfig.pageSize;
|
||||
|
||||
httpRequest("POST", requestUrl, {}, {}).then((res) => {
|
||||
if (res.success && res.result) {
|
||||
_this.dataConfig.doingDay = res.result.doingDay ? res.result.doingDay : "-";
|
||||
_this.dataConfig.startDay = res.result.startDay ? res.result.startDay : "-";
|
||||
|
||||
_this.dataConfig.personnelType = _this.rankingConfig.personnelType;
|
||||
let list = res.result.list;
|
||||
|
||||
if (list && list.length) {
|
||||
_this.dataConfig.list = list;
|
||||
_this.$nextTick(() => {
|
||||
_this.startOneTimeScroll();
|
||||
});
|
||||
} else {
|
||||
// 如果没有数据,清空列表,显示 banner 并启动循环
|
||||
_this.dataConfig.list = [];
|
||||
_this.startBannerLoop();
|
||||
}
|
||||
} else {
|
||||
// 请求失败或无 result,清空列表,显示 banner 并启动循环
|
||||
_this.dataConfig.list = [];
|
||||
_this.startBannerLoop();
|
||||
}
|
||||
console.log(res);
|
||||
}).catch((error) => {
|
||||
console.error("请求失败:", error);
|
||||
// 请求错误,清空列表,显示 banner 并启动循环
|
||||
_this.dataConfig.list = [];
|
||||
_this.startBannerLoop();
|
||||
});
|
||||
},
|
||||
|
||||
startOneTimeScroll() {
|
||||
const container = this.$refs.scrollContentBody;
|
||||
if (!container) return;
|
||||
|
||||
const maxScrollTop = container.scrollHeight - container.clientHeight;
|
||||
|
||||
// 根据是否可滚动来设置动态等待时间
|
||||
if (maxScrollTop <= 0) {
|
||||
console.log('内容不足以滚动,等待 5 秒并请求下一批数据');
|
||||
this.scrollConfig.dynamicScrollWaitTime = 5; // 设置为5秒
|
||||
} else {
|
||||
console.log('内容可滚动,等待 1 秒并请求下一批数据');
|
||||
this.scrollConfig.dynamicScrollWaitTime = 1; // 设置为1秒
|
||||
}
|
||||
|
||||
container.scrollTop = 0; // 确保每次开始都从顶部滚动
|
||||
let currentScrollTop = 0;
|
||||
|
||||
const animateScroll = () => {
|
||||
if (currentScrollTop < maxScrollTop) {
|
||||
currentScrollTop += this.scrollConfig.scrollSpeed;
|
||||
if (currentScrollTop > maxScrollTop) {
|
||||
currentScrollTop = maxScrollTop;
|
||||
}
|
||||
container.scrollTop = currentScrollTop;
|
||||
this.scrollConfig.scrollAnimationFrameId = requestAnimationFrame(animateScroll);
|
||||
} else {
|
||||
// 滚动完成后
|
||||
console.log(`列表滚动完成,等待 ${this.scrollConfig.dynamicScrollWaitTime} 秒并请求下一批数据`);
|
||||
this.scrollConfig.scrollAnimationFrameId = null;
|
||||
this.rankingConfig.setTimeOutFun = setTimeout(() => {
|
||||
this.loadDataUrl();
|
||||
}, this.scrollConfig.dynamicScrollWaitTime * 1000);
|
||||
}
|
||||
};
|
||||
|
||||
this.scrollConfig.scrollAnimationFrameId = requestAnimationFrame(animateScroll);
|
||||
},
|
||||
|
||||
startBannerLoop() {
|
||||
let _this = this;
|
||||
_this.stopAllLoops(); // 在启动 Banner 前,停止所有正在进行的循环
|
||||
|
||||
_this.bannerConfig.index = 0;
|
||||
_this.bannerConfig.setIntervalFun = setInterval(() => {
|
||||
_this.bannerConfig.index = (_this.bannerConfig.index + 1) % _this.bannerConfig.list.length;
|
||||
|
||||
// 当 banner 循环到最后一张并准备回到第一张时,停止轮播并重新加载数据
|
||||
if (_this.bannerConfig.index === 0) {
|
||||
_this.stopAllLoops();
|
||||
_this.loadDataUrl();
|
||||
}
|
||||
}, 3000); // Banner 轮播间隔保持 3 秒
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
#dietaryNutritionTips {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center top;
|
||||
background-image: url("@/assets/images/dietaryNutritionTips/bg.png");
|
||||
|
||||
.dietaryNutritionTips-Content {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 44px 40px 0;
|
||||
box-sizing: border-box;
|
||||
|
||||
.tips {
|
||||
width: 100%;
|
||||
height: 36px;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 96px;
|
||||
|
||||
> div:nth-of-type(1) {
|
||||
width: 120px;
|
||||
height: 4px;
|
||||
background: linear-gradient(270deg, #ffc87c 0%, rgba(42, 199, 159, 0) 100%);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
> div:nth-of-type(2) {
|
||||
color: #ffc87c;
|
||||
height: 36px;
|
||||
font-size: 36px;
|
||||
font-weight: bold;
|
||||
line-height: 36px;
|
||||
margin: 0 36px;
|
||||
}
|
||||
|
||||
> div:nth-of-type(3) {
|
||||
width: 120px;
|
||||
height: 4px;
|
||||
background: linear-gradient(90deg, #ffc87c 0%, rgba(42, 199, 159, 0) 100%);
|
||||
border-radius: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.title {
|
||||
width: 100%;
|
||||
height: 182px;
|
||||
position: fixed;
|
||||
top: 85px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 3;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
> div:nth-of-type(1) {
|
||||
width: 86px;
|
||||
height: 182px;
|
||||
background-size: contain;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-image: url("@/assets/images/dietaryNutritionTips/l.png");
|
||||
}
|
||||
|
||||
> div:nth-of-type(2) {
|
||||
width: 720px;
|
||||
height: 136px;
|
||||
padding: 18px 30px 0;
|
||||
border-radius: 24px;
|
||||
box-sizing: border-box;
|
||||
background: linear-gradient(-90deg, #ffc77b 0%, #fff4e6 47%, #ffc879 100%);
|
||||
|
||||
> div:nth-of-type(1) {
|
||||
color: #8d0503;
|
||||
width: 100%;
|
||||
height: 48px;
|
||||
font-size: 48px;
|
||||
font-weight: bold;
|
||||
line-height: 48px;
|
||||
text-align: center;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
> div:nth-of-type(2) {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
justify-content: space-between;
|
||||
align-items: flex-end;
|
||||
|
||||
> div:nth-of-type(1) {
|
||||
color: #8d0503;
|
||||
height: 32px;
|
||||
font-size: 30px;
|
||||
line-height: 32px;
|
||||
}
|
||||
|
||||
> div:nth-of-type(2) {
|
||||
color: #8d0503;
|
||||
height: 40px;
|
||||
font-size: 30px;
|
||||
line-height: 40px;
|
||||
|
||||
> span {
|
||||
margin: 0 6px;
|
||||
font-size: 40px;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
> div:nth-of-type(3) {
|
||||
width: 86px;
|
||||
height: 182px;
|
||||
background-size: contain;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-image: url("@/assets/images/dietaryNutritionTips/r.png");
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 100%;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
border-radius: 16px;
|
||||
padding: 105px 24px 0;
|
||||
box-sizing: border-box;
|
||||
border: 2px solid #ffc548;
|
||||
background: linear-gradient(
|
||||
180deg,
|
||||
rgba(225, 225, 225, 0) 0%,
|
||||
rgba(225, 225, 225, 0.3) 100%
|
||||
);
|
||||
|
||||
.contentHeader {
|
||||
width: 100%;
|
||||
height: 82px;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
padding: 0 30px;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 40px;
|
||||
border-radius: 16px;
|
||||
background-color: #7e0b08;
|
||||
|
||||
> div {
|
||||
color: #ffc87c;
|
||||
height: 82px;
|
||||
font-size: 32px;
|
||||
font-weight: bold;
|
||||
line-height: 82px;
|
||||
text-align: center;
|
||||
|
||||
&:nth-of-type(1) {
|
||||
width: 85px;
|
||||
margin-right: 25px;
|
||||
}
|
||||
|
||||
&:nth-of-type(2) {
|
||||
flex: 1;
|
||||
width: 0;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
&.staff-userName {
|
||||
width: 120px;
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
||||
&.staff-fraction {
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
&.department-avgFraction {
|
||||
width: 350px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.contentBody {
|
||||
width: 100%;
|
||||
height: calc(100% - 152px); /* 减去 contentHeader 和其 margin-bottom 的高度 */
|
||||
overflow: hidden; /* 关键:隐藏溢出内容,实现滚动效果 */
|
||||
|
||||
/* 以下样式应用于 contentBody 内部的每个列表项 div */
|
||||
> div {
|
||||
width: 100%;
|
||||
height: 40px; /* 行高 */
|
||||
padding: 0 30px;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
margin-bottom: 56px; /* 行间距 */
|
||||
|
||||
> div {
|
||||
color: #ffffff;
|
||||
height: 40px;
|
||||
font-size: 40px;
|
||||
line-height: 40px;
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
|
||||
&:nth-of-type(1) {
|
||||
width: 85px;
|
||||
margin-right: 25px;
|
||||
}
|
||||
|
||||
&:nth-of-type(2) {
|
||||
flex: 1;
|
||||
width: 0;
|
||||
text-align: left;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
&.staff-userName {
|
||||
width: 120px;
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
||||
&.staff-fraction {
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
&.department-avgFraction {
|
||||
width: 350px;
|
||||
}
|
||||
}
|
||||
|
||||
&:last-of-type {
|
||||
margin-bottom: 0 !important; /* 确保最后一行没有下边距,防止影响 totalHeight 计算 */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.footer {
|
||||
width: 100%;
|
||||
height: 95px;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
justify-content: space-between;
|
||||
|
||||
> div {
|
||||
color: #ffffff;
|
||||
height: 95px;
|
||||
font-size: 32px;
|
||||
font-weight: bold;
|
||||
line-height: 95px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.banner {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
|
||||
> div {
|
||||
color: white;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
font-size: 50px;
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
background-position: top center;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,554 @@
|
||||
<template>
|
||||
<div id="dietaryNutritionTips">
|
||||
<template v-if="dataConfig.list && dataConfig.list.length">
|
||||
<div class="dietaryNutritionTips-Content">
|
||||
<div class="tips">
|
||||
<div></div>
|
||||
<div>温馨提示</div>
|
||||
<div></div>
|
||||
</div>
|
||||
|
||||
<div class="title">
|
||||
<div></div>
|
||||
<div>
|
||||
<div>膳食营养行动({{dataConfig.personnelType === 'staff' ? '员工' : '部门'}})</div>
|
||||
<div>
|
||||
<div>{{ dataConfig.currentDate }}</div>
|
||||
<div>{{ dataConfig.dinnerType }}:{{ dataConfig.userNum }}人</div>
|
||||
</div>
|
||||
</div>
|
||||
<div></div>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div class="contentHeader">
|
||||
<div>序号</div>
|
||||
<div>单位(部门)</div>
|
||||
<template v-if="dataConfig.personnelType === 'staff'">
|
||||
<div class="staff-userName">姓名</div>
|
||||
<div class="staff-fraction">膳食营养得分</div>
|
||||
</template>
|
||||
<template v-if="dataConfig.personnelType === 'department'">
|
||||
<div class="department-avgFraction">人均膳食营养得分</div>
|
||||
</template>
|
||||
</div>
|
||||
<div class="contentBody" ref="scrollContentBody">
|
||||
<div v-for="(item, index) in dataConfig.list" :key="index">
|
||||
<template v-if="dataConfig.personnelType === 'staff'">
|
||||
<div>{{ index + 1 }}</div>
|
||||
<div>{{ item.departName }}</div>
|
||||
<div class="staff-userName">{{ maskUserName(item.userName) }}</div>
|
||||
<div class="staff-fraction">{{ item.fraction }}</div>
|
||||
</template>
|
||||
<template v-if="dataConfig.personnelType === 'department'">
|
||||
<div>{{ index + 1 }}</div>
|
||||
<div>{{ item.departName }}</div>
|
||||
<div class="department-avgFraction">{{ item.avgFraction }}</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
<div>公共事务中心 宣</div>
|
||||
<div>开始时间:{{ dataConfig.startDay }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<div class="banner">
|
||||
<template v-for="(banner, index) in bannerConfig.list">
|
||||
<div :key="index" :style="{ backgroundImage: 'url(' + banner + ')', display: index === bannerConfig.index ? 'block' : 'none' }"></div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { httpRequest } from "@/XMLHttpRequest";
|
||||
import { getCurrentDate } from "@/utils/times";
|
||||
import signMd5Utils from "@/utils/signMd5";
|
||||
|
||||
export default {
|
||||
name: "dietaryNutritionTips",
|
||||
data() {
|
||||
return {
|
||||
bannerConfig: {
|
||||
list: [
|
||||
'https://yyjk.shuziweidao.com/gateway/file/down/images/1.jpg',
|
||||
'https://yyjk.shuziweidao.com/gateway/file/down/images/2.jpg',
|
||||
'https://yyjk.shuziweidao.com/gateway/file/down/images/3.jpg',
|
||||
'https://yyjk.shuziweidao.com/gateway/file/down/images/4.jpg',
|
||||
],
|
||||
index: 0,
|
||||
setIntervalFun: null
|
||||
},
|
||||
|
||||
rankingConfig: {
|
||||
personnelType: "department", // 员工:staff / 部门:department
|
||||
requestConfig: {
|
||||
agreement: "https",
|
||||
url: "yyjk.cqygjk.com",
|
||||
suffix: "/gateway",
|
||||
urlPrefix: "/food/userRank",
|
||||
orgCode: "A01A86",
|
||||
canteenId: "1599670511042785282,1746801170592919553",
|
||||
pageSize: 0
|
||||
},
|
||||
},
|
||||
|
||||
dataConfig: {
|
||||
personnelType: "department", // 员工:staff / 部门:department
|
||||
currentDate: "",
|
||||
dinnerType: "",
|
||||
userNum: "-",
|
||||
list: [],
|
||||
startDay: "-",
|
||||
},
|
||||
|
||||
scrollConfig: {
|
||||
scrollAnimationFrameId: null, // 用于存储 requestAnimationFrame 的 ID
|
||||
scrollSpeed: 2, // 滚动速度,每帧移动的像素数
|
||||
// 这里的 scrollWaitTime 将在 startOneTimeScroll 中动态决定
|
||||
// 1秒用于有数据且能滚动,5秒用于无数据或数据不足以滚动
|
||||
dynamicScrollWaitTime: 1 // 动态等待时间,默认为1秒
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.loadDataUrl();
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.stopAllLoops();
|
||||
},
|
||||
methods: {
|
||||
stopAllLoops() {
|
||||
if (this.bannerConfig.setIntervalFun) {
|
||||
clearInterval(this.bannerConfig.setIntervalFun);
|
||||
this.bannerConfig.setIntervalFun = null;
|
||||
}
|
||||
if (this.scrollConfig.scrollAnimationFrameId) {
|
||||
cancelAnimationFrame(this.scrollConfig.scrollAnimationFrameId);
|
||||
this.scrollConfig.scrollAnimationFrameId = null;
|
||||
}
|
||||
// 清除可能存在的 setTimeout,避免重复请求
|
||||
if (this.rankingConfig.setTimeOutFun) {
|
||||
clearTimeout(this.rankingConfig.setTimeOutFun);
|
||||
this.rankingConfig.setTimeOutFun = null;
|
||||
}
|
||||
},
|
||||
|
||||
loadDataUrl() {
|
||||
let _this = this;
|
||||
_this.stopAllLoops(); // 在请求数据前,停止所有正在进行的循环
|
||||
|
||||
_this.dataConfig.currentDate = getCurrentDate();
|
||||
_this.rankingConfig.personnelType = _this.rankingConfig.personnelType === "staff" ? "department" : "staff";
|
||||
_this.rankingConfig.requestConfig.pageSize = _this.rankingConfig.personnelType === "staff" ? 50 : 100;
|
||||
|
||||
let serve = _this.rankingConfig.requestConfig.agreement + "://" + _this.rankingConfig.requestConfig.url;
|
||||
let requestUrl = serve + _this.rankingConfig.requestConfig.suffix + _this.rankingConfig.requestConfig.urlPrefix + (_this.rankingConfig.personnelType === "staff" ? "/getNutritionRankings" : "/getDepartRankings");
|
||||
|
||||
let params = {
|
||||
orgCode: _this.rankingConfig.requestConfig.orgCode,
|
||||
canteenId: _this.rankingConfig.requestConfig.canteenId,
|
||||
no: _this.rankingConfig.requestConfig.pageSize,
|
||||
};
|
||||
|
||||
httpRequest("GET", requestUrl, params, {
|
||||
'X-Sign': signMd5Utils.getSign(requestUrl, params),
|
||||
'X-TIMESTAMP': signMd5Utils.getDateTimeToString(requestUrl, params),
|
||||
}).then((res) => {
|
||||
if (res.success && res.result) {
|
||||
_this.dataConfig.dinnerType = res.result.dinnerType ? res.result.dinnerType : "-";
|
||||
_this.dataConfig.userNum = res.result.userNum ? res.result.userNum : "-";
|
||||
_this.dataConfig.startDay = res.result.startDay ? res.result.startDay : "-";
|
||||
|
||||
_this.dataConfig.personnelType = _this.rankingConfig.personnelType;
|
||||
let dataKey = _this.dataConfig.personnelType === "staff" ? 'nutritionRankingsVos' : 'departRankingsVos';
|
||||
let list = res.result[dataKey];
|
||||
|
||||
if (list && list.length) {
|
||||
_this.dataConfig.list = list;
|
||||
_this.$nextTick(() => {
|
||||
_this.startOneTimeScroll();
|
||||
});
|
||||
} else {
|
||||
// 如果没有数据,清空列表,显示 banner 并启动循环
|
||||
_this.dataConfig.list = [];
|
||||
_this.startBannerLoop();
|
||||
}
|
||||
} else {
|
||||
// 请求失败或无 result,清空列表,显示 banner 并启动循环
|
||||
_this.dataConfig.list = [];
|
||||
_this.startBannerLoop();
|
||||
}
|
||||
console.log(res);
|
||||
}).catch((error) => {
|
||||
console.error("请求失败:", error);
|
||||
// 请求错误,清空列表,显示 banner 并启动循环
|
||||
_this.dataConfig.list = [];
|
||||
_this.startBannerLoop();
|
||||
});
|
||||
},
|
||||
|
||||
startOneTimeScroll() {
|
||||
const container = this.$refs.scrollContentBody;
|
||||
if (!container) return;
|
||||
|
||||
const maxScrollTop = container.scrollHeight - container.clientHeight;
|
||||
|
||||
// 根据是否可滚动来设置动态等待时间
|
||||
if (maxScrollTop <= 0) {
|
||||
console.log('内容不足以滚动,等待 5 秒并请求下一批数据');
|
||||
this.scrollConfig.dynamicScrollWaitTime = 5; // 设置为5秒
|
||||
} else {
|
||||
console.log('内容可滚动,等待 1 秒并请求下一批数据');
|
||||
this.scrollConfig.dynamicScrollWaitTime = 1; // 设置为1秒
|
||||
}
|
||||
|
||||
container.scrollTop = 0; // 确保每次开始都从顶部滚动
|
||||
let currentScrollTop = 0;
|
||||
|
||||
const animateScroll = () => {
|
||||
if (currentScrollTop < maxScrollTop) {
|
||||
currentScrollTop += this.scrollConfig.scrollSpeed;
|
||||
if (currentScrollTop > maxScrollTop) {
|
||||
currentScrollTop = maxScrollTop;
|
||||
}
|
||||
container.scrollTop = currentScrollTop;
|
||||
this.scrollConfig.scrollAnimationFrameId = requestAnimationFrame(animateScroll);
|
||||
} else {
|
||||
// 滚动完成后
|
||||
console.log(`列表滚动完成,等待 ${this.scrollConfig.dynamicScrollWaitTime} 秒并请求下一批数据`);
|
||||
this.scrollConfig.scrollAnimationFrameId = null;
|
||||
this.rankingConfig.setTimeOutFun = setTimeout(() => {
|
||||
this.loadDataUrl();
|
||||
}, this.scrollConfig.dynamicScrollWaitTime * 1000);
|
||||
}
|
||||
};
|
||||
|
||||
this.scrollConfig.scrollAnimationFrameId = requestAnimationFrame(animateScroll);
|
||||
},
|
||||
|
||||
maskUserName(fullName) {
|
||||
if (!fullName || typeof fullName !== 'string' || fullName.length === 0) {
|
||||
return '';
|
||||
}
|
||||
let len = fullName.length;
|
||||
if (len === 1) {
|
||||
return fullName;
|
||||
} else if (len === 2) {
|
||||
return fullName.charAt(0) + '*';
|
||||
} else {
|
||||
let firstChar = fullName.charAt(0);
|
||||
let lastChar = fullName.charAt(len - 1);
|
||||
let maskedPart = '*'.repeat(len - 2);
|
||||
return firstChar + maskedPart + lastChar;
|
||||
}
|
||||
},
|
||||
|
||||
startBannerLoop() {
|
||||
let _this = this;
|
||||
_this.stopAllLoops(); // 在启动 Banner 前,停止所有正在进行的循环
|
||||
|
||||
_this.bannerConfig.index = 0;
|
||||
_this.bannerConfig.setIntervalFun = setInterval(() => {
|
||||
_this.bannerConfig.index = (_this.bannerConfig.index + 1) % _this.bannerConfig.list.length;
|
||||
|
||||
// 当 banner 循环到最后一张并准备回到第一张时,停止轮播并重新加载数据
|
||||
if (_this.bannerConfig.index === 0) {
|
||||
_this.stopAllLoops();
|
||||
_this.loadDataUrl();
|
||||
}
|
||||
}, 3000); // Banner 轮播间隔保持 3 秒
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
#dietaryNutritionTips {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center top;
|
||||
background-image: url("@/assets/images/dietaryNutritionTips/bg.png");
|
||||
|
||||
.dietaryNutritionTips-Content {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 44px 40px 0;
|
||||
box-sizing: border-box;
|
||||
|
||||
.tips {
|
||||
width: 100%;
|
||||
height: 36px;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 96px;
|
||||
|
||||
> div:nth-of-type(1) {
|
||||
width: 120px;
|
||||
height: 4px;
|
||||
background: linear-gradient(270deg, #ffc87c 0%, rgba(42, 199, 159, 0) 100%);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
> div:nth-of-type(2) {
|
||||
color: #ffc87c;
|
||||
height: 36px;
|
||||
font-size: 36px;
|
||||
font-weight: bold;
|
||||
line-height: 36px;
|
||||
margin: 0 36px;
|
||||
}
|
||||
|
||||
> div:nth-of-type(3) {
|
||||
width: 120px;
|
||||
height: 4px;
|
||||
background: linear-gradient(90deg, #ffc87c 0%, rgba(42, 199, 159, 0) 100%);
|
||||
border-radius: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.title {
|
||||
width: 100%;
|
||||
height: 182px;
|
||||
position: fixed;
|
||||
top: 85px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 3;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
> div:nth-of-type(1) {
|
||||
width: 86px;
|
||||
height: 182px;
|
||||
background-size: contain;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-image: url("@/assets/images/dietaryNutritionTips/l.png");
|
||||
}
|
||||
|
||||
> div:nth-of-type(2) {
|
||||
width: 720px;
|
||||
height: 136px;
|
||||
padding: 18px 30px 0;
|
||||
border-radius: 24px;
|
||||
box-sizing: border-box;
|
||||
background: linear-gradient(-90deg, #ffc77b 0%, #fff4e6 47%, #ffc879 100%);
|
||||
|
||||
> div:nth-of-type(1) {
|
||||
color: #8d0503;
|
||||
width: 100%;
|
||||
height: 48px;
|
||||
font-size: 48px;
|
||||
font-weight: bold;
|
||||
line-height: 48px;
|
||||
text-align: center;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
> div:nth-of-type(2) {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
justify-content: space-between;
|
||||
align-items: flex-end;
|
||||
|
||||
> div:nth-of-type(1) {
|
||||
color: #8d0503;
|
||||
height: 32px;
|
||||
font-size: 30px;
|
||||
line-height: 32px;
|
||||
}
|
||||
|
||||
> div:nth-of-type(2) {
|
||||
color: #8d0503;
|
||||
height: 40px;
|
||||
font-size: 30px;
|
||||
line-height: 40px;
|
||||
|
||||
> span {
|
||||
margin: 0 6px;
|
||||
font-size: 40px;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
> div:nth-of-type(3) {
|
||||
width: 86px;
|
||||
height: 182px;
|
||||
background-size: contain;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-image: url("@/assets/images/dietaryNutritionTips/r.png");
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 100%;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
border-radius: 16px;
|
||||
padding: 105px 24px 0;
|
||||
box-sizing: border-box;
|
||||
border: 2px solid #ffc548;
|
||||
background: linear-gradient(
|
||||
180deg,
|
||||
rgba(225, 225, 225, 0) 0%,
|
||||
rgba(225, 225, 225, 0.3) 100%
|
||||
);
|
||||
|
||||
.contentHeader {
|
||||
width: 100%;
|
||||
height: 82px;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
padding: 0 30px;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 40px;
|
||||
border-radius: 16px;
|
||||
background-color: #7e0b08;
|
||||
|
||||
> div {
|
||||
color: #ffc87c;
|
||||
height: 82px;
|
||||
font-size: 32px;
|
||||
font-weight: bold;
|
||||
line-height: 82px;
|
||||
text-align: center;
|
||||
|
||||
&:nth-of-type(1) {
|
||||
width: 85px;
|
||||
margin-right: 25px;
|
||||
}
|
||||
|
||||
&:nth-of-type(2) {
|
||||
flex: 1;
|
||||
width: 0;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
&.staff-userName {
|
||||
width: 120px;
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
||||
&.staff-fraction {
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
&.department-avgFraction {
|
||||
width: 350px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.contentBody {
|
||||
width: 100%;
|
||||
height: calc(100% - 152px); /* 减去 contentHeader 和其 margin-bottom 的高度 */
|
||||
overflow: hidden; /* 关键:隐藏溢出内容,实现滚动效果 */
|
||||
|
||||
/* 以下样式应用于 contentBody 内部的每个列表项 div */
|
||||
> div {
|
||||
width: 100%;
|
||||
height: 40px; /* 行高 */
|
||||
padding: 0 30px;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
margin-bottom: 56px; /* 行间距 */
|
||||
|
||||
> div {
|
||||
color: #ffffff;
|
||||
height: 40px;
|
||||
font-size: 40px;
|
||||
line-height: 40px;
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
|
||||
&:nth-of-type(1) {
|
||||
width: 85px;
|
||||
margin-right: 25px;
|
||||
}
|
||||
|
||||
&:nth-of-type(2) {
|
||||
flex: 1;
|
||||
width: 0;
|
||||
text-align: left;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
&.staff-userName {
|
||||
width: 120px;
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
||||
&.staff-fraction {
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
&.department-avgFraction {
|
||||
width: 350px;
|
||||
}
|
||||
}
|
||||
|
||||
&:last-of-type {
|
||||
margin-bottom: 0 !important; /* 确保最后一行没有下边距,防止影响 totalHeight 计算 */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.footer {
|
||||
width: 100%;
|
||||
height: 95px;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
justify-content: space-between;
|
||||
|
||||
> div {
|
||||
color: #ffffff;
|
||||
height: 95px;
|
||||
font-size: 32px;
|
||||
font-weight: bold;
|
||||
line-height: 95px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.banner {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
|
||||
> div {
|
||||
color: white;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
font-size: 50px;
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
background-position: top center;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user