From 48b1aa58d1b9c65d23958ec7a7eb10a65a6cde5d Mon Sep 17 00:00:00 2001 From: Robin-Wubin Date: Fri, 5 Jan 2024 13:40:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(date-picker):=20=20=E4=BF=AE=E5=A4=8D=20hou?= =?UTF-8?q?r-minute=20=E7=B1=BB=E5=9E=8B=E4=B8=8B=E9=80=89=E9=A1=B9?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E9=97=AE=E9=A2=98=20(#2784)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/__VUE/datepicker/index.taro.vue | 8 +++++++- src/packages/__VUE/datepicker/index.vue | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/packages/__VUE/datepicker/index.taro.vue b/src/packages/__VUE/datepicker/index.taro.vue index d047f97ad4..167edac13c 100644 --- a/src/packages/__VUE/datepicker/index.taro.vue +++ b/src/packages/__VUE/datepicker/index.taro.vue @@ -221,7 +221,7 @@ export default create({ selectedValue: (string | number)[]; selectedOptions: PickerOption[]; }) => { - if (['date', 'datetime', 'datehour', 'month-day', 'year-month'].includes(props.type)) { + if (['date', 'datetime', 'datehour', 'month-day', 'year-month', 'hour-minute'].includes(props.type)) { let formatDate: (number | string)[] = []; selectedValue.forEach((item) => { formatDate.push(item); @@ -243,6 +243,12 @@ export default create({ date = new Date(year, month, day, Number(formatDate[3]), Number(formatDate[4])); } else if (props.type === 'datehour') { date = new Date(year, month, day, Number(formatDate[3])); + } else if (props.type === 'hour-minute') { + date = new Date(state.currentDate); + const year = date.getFullYear(); + const month = date.getMonth(); + const day = date.getDate(); + date = new Date(year, month, day, Number(formatDate[0]), Number(formatDate[1])); } state.currentDate = formatValue(date as Date); } diff --git a/src/packages/__VUE/datepicker/index.vue b/src/packages/__VUE/datepicker/index.vue index 4a09376101..0a6f3d69a4 100644 --- a/src/packages/__VUE/datepicker/index.vue +++ b/src/packages/__VUE/datepicker/index.vue @@ -221,7 +221,7 @@ export default create({ selectedValue: (string | number)[]; selectedOptions: PickerOption[]; }) => { - if (['date', 'datetime', 'datehour', 'month-day', 'year-month'].includes(props.type)) { + if (['date', 'datetime', 'datehour', 'month-day', 'year-month', 'hour-minute'].includes(props.type)) { let formatDate: (number | string)[] = []; selectedValue.forEach((item) => { formatDate.push(item); @@ -243,6 +243,12 @@ export default create({ date = new Date(year, month, day, Number(formatDate[3]), Number(formatDate[4])); } else if (props.type === 'datehour') { date = new Date(year, month, day, Number(formatDate[3])); + } else if (props.type === 'hour-minute') { + date = new Date(state.currentDate); + const year = date.getFullYear(); + const month = date.getMonth(); + const day = date.getDate(); + date = new Date(year, month, day, Number(formatDate[0]), Number(formatDate[1])); } state.currentDate = formatValue(date as Date); }