From b24c83282e7c4bdccddb3731a6871a39534ecbc7 Mon Sep 17 00:00:00 2001 From: 17792275749 <812100002@qq.com> Date: Tue, 23 Sep 2025 13:55:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E8=86=B3=E9=A3=9F?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=20=E6=AF=8F=E6=AC=A1=E5=8F=96=E5=9B=9E?= =?UTF-8?q?=E6=9D=A5=E6=95=B0=E6=8D=AE=E5=9C=A8=E6=9C=AC=E5=9C=B0=E7=BC=93?= =?UTF-8?q?=E5=AD=98=EF=BC=8C=E7=84=B6=E5=90=8E=E5=86=8D=E5=8F=96=E5=87=BA?= =?UTF-8?q?=E6=9D=A5=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dietaryNutritionTips9.vue | 92 +++++++++++++------ 1 file changed, 66 insertions(+), 26 deletions(-) diff --git a/src/views/dietaryNutritionTips/dietaryNutritionTips9.vue b/src/views/dietaryNutritionTips/dietaryNutritionTips9.vue index cc34276..5cf271a 100644 --- a/src/views/dietaryNutritionTips/dietaryNutritionTips9.vue +++ b/src/views/dietaryNutritionTips/dietaryNutritionTips9.vue @@ -154,39 +154,79 @@ export default { 'X-Sign': signMd5Utils.getSign(requestUrl, params), 'X-TIMESTAMP': signMd5Utils.getDateTimeToString(requestUrl, params), }).then((res) => { - _this.dataConfig.list = []; - 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 ? _this.formatDateString(res.result.startDay) : "-"; - _this.dataConfig.startDay = "2025年5月7日"; + _this.getSessionStorageData(res); - _this.dataConfig.personnelType = _this.rankingConfig.personnelType; - let dataKey = _this.dataConfig.personnelType === "staff" ? 'nutritionRankingsVos' : 'departRankingsVos'; - let list = res.result[dataKey]; + // 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 = "2025年5月7日"; + // + // _this.dataConfig.personnelType = _this.rankingConfig.personnelType; + // let dataKey = _this.dataConfig.personnelType === "staff" ? 'nutritionRankingsVos' : 'departRankingsVos'; + // let list = res.result[dataKey]; + // + // if (list && list.length) { + // list.map(item => { + // if(item.departName === "行政事务管理处") { + // item.departName = "公共事务中心"; + // } + // }) + // _this.dataConfig.list = list; + // + // _this.$nextTick(() => { + // _this.startOneTimeScroll(); + // }); + // } else { + // _this.startBannerLoop(); + // } + // } else { + // _this.startBannerLoop(); + // } + }).catch((error) => { + console.error("请求失败:", error); + _this.getSessionStorageData(null); + }); + }, - if (list && list.length) { - list.map(item => { - if(item.departName === "行政事务管理处") { - item.departName = "公共事务中心"; - } - }) - _this.dataConfig.list = list; + getSessionStorageData(res) { + let _this = this; + _this.dataConfig.list = []; + _this.dataConfig.personnelType = _this.rankingConfig.personnelType; + let dataKey = _this.dataConfig.personnelType === "staff" ? 'nutritionRankingsVos' : 'departRankingsVos'; + if (res && res.success && res.result) { + console.log('有新数据,并且写入了。'); - _this.$nextTick(() => { - _this.startOneTimeScroll(); - }); - } else { - _this.startBannerLoop(); - } + if (res.result[dataKey] && res.result[dataKey].length) { + res.result[dataKey].map(item => { + if(item.departName === "行政事务管理处") { + item.departName = "公共事务中心"; + } + }) + } + + sessionStorage.setItem(dataKey, JSON.stringify(res.result)); + } + + let data = sessionStorage.getItem(dataKey) || null; + if(data) { + let data_ = JSON.parse(data); + + _this.dataConfig.dinnerType = data_.dinnerType ? data_.dinnerType : "-"; + _this.dataConfig.userNum = data_.userNum ? data_.userNum : "-"; + _this.dataConfig.startDay = "2025年5月7日"; + + if (data_[dataKey] && data_[dataKey].length) { + _this.dataConfig.list = data_[dataKey]; + + _this.$nextTick(() => { + _this.startOneTimeScroll(); + }); } else { _this.startBannerLoop(); } - }).catch((error) => { - console.error("请求失败:", error); - _this.dataConfig.list = []; + } else { _this.startBannerLoop(); - }); + } }, startOneTimeScroll() {