From cf0289f56c9d9f7869104edaf6d9187981668007 Mon Sep 17 00:00:00 2001 From: chenJinxu <2183691628@qq.com> Date: Sun, 4 Feb 2024 15:31:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E6=B4=9E=E6=82=89?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=9C=80=E8=BF=917=E5=A4=A9/30=E5=A4=A9?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/filters/filter.js | 19 +++++++++++++ src/filters/index.js | 1 + src/views/insight/index.vue | 54 +++++++++++++++++++++---------------- 3 files changed, 51 insertions(+), 23 deletions(-) diff --git a/src/filters/filter.js b/src/filters/filter.js index f603ae4..a4d895d 100644 --- a/src/filters/filter.js +++ b/src/filters/filter.js @@ -58,3 +58,22 @@ export function calcBMI(height, weight) { } return bmiObj; } + +/** + * + * @param {*} numDays + */ +export function getRangeStartAndEnd(numDays) { + // 获取当前日期对象 + const currentDate = new Date(); + const startDate = new Date(currentDate); + startDate.setDate(currentDate.getDate() - numDays + 1); // 减去numDays-1天以得到numDays天前的日期作为开始日期 + + const endDate = new Date(currentDate); + endDate.setDate(currentDate.getDate()); // 当前日期为结束日期 + + return { + start: startDate, + end: endDate + }; +} diff --git a/src/filters/index.js b/src/filters/index.js index 6f1f749..4238764 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -6,3 +6,4 @@ Object.keys(filter).forEach(k => Vue.filter(k, filter[k])); Vue.prototype.$formatDate = Vue.filter('formatDate'); Vue.prototype.$hidePhone = Vue.filter('hidePhone'); Vue.prototype.$calcBMI = Vue.filter('calcBMI'); +Vue.prototype.$getRangeStartAndEnd = Vue.filter('getRangeStartAndEnd'); diff --git a/src/views/insight/index.vue b/src/views/insight/index.vue index 8b0ba19..2c18678 100644 --- a/src/views/insight/index.vue +++ b/src/views/insight/index.vue @@ -5,7 +5,7 @@
- +