From e4b8f1b9f0b10453730ce32888e70674e0df4835 Mon Sep 17 00:00:00 2001 From: yuannnh Date: Wed, 5 Feb 2020 19:20:59 +0800 Subject: [PATCH 1/6] =?UTF-8?q?[=E4=B9=89=E8=AF=8A]=20=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E6=AD=A3=E5=9C=A8=E6=8E=A5=E8=AF=8A=E5=B9=B6?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/page/Clinic/index.tsx | 68 +++++++++++++++++++----------------- source/page/Clinic/time.ts | 22 ++++++++++++ 2 files changed, 57 insertions(+), 33 deletions(-) create mode 100644 source/page/Clinic/time.ts diff --git a/source/page/Clinic/index.tsx b/source/page/Clinic/index.tsx index 9d1c2c2..6fcf3e5 100644 --- a/source/page/Clinic/index.tsx +++ b/source/page/Clinic/index.tsx @@ -5,6 +5,7 @@ import { Card } from 'boot-cell/source/Content/Card'; import { CardsPage, AuditBar } from '../../component'; import { clinic, Clinic } from '../../model'; +import { getIsLive } from './time'; @observer @component({ @@ -24,38 +25,39 @@ export class ClinicList extends CardsPage { contacts, remark, ...rest - }: Clinic) => ( - - {name} - - ) : ( - name - ) - } - > -

- 每日接诊起止时间:{startTime} ~ {endTime} -

- {contacts[0] && ( -
    - {contacts.map(({ name, phone }) => ( -
  1. - - {' '} - {name}:{phone} - -
  2. - ))} -
- )} - {remark &&

{remark}

} + }: Clinic) => { + const isLive = getIsLive(startTime, endTime); + return + {name} + + ) : ( + name + ) + } + > +

+ 每日接诊起止时间:{startTime} ~ {endTime}{isLive?正在接诊:null} +

+ {contacts[0] && ( +
    + {contacts.map(({ name, phone }) => ( +
  1. + + {' '} + {name}:{phone} + +
  2. + ))} +
+ )} + {remark &&

{remark}

} - -
- ); + +
+ }; } diff --git a/source/page/Clinic/time.ts b/source/page/Clinic/time.ts new file mode 100644 index 0000000..5d88379 --- /dev/null +++ b/source/page/Clinic/time.ts @@ -0,0 +1,22 @@ +// 目前的时间格式为 hh:mm 的 String, 该方法将其转化为当天的该时间 +export const getTimeFromTimeStr = (timeStr:string) => { + const [hours, minutes] = timeStr.split(':').map(parseInt) + const time = new Date(); + if(hours){ + time.setHours(hours); + } + if(minutes) { + time.setMinutes(minutes) + } + return time; +} + +// 计算当前时间是否介于起始与结束算出时间内 +export const getIsLive = (startTimeStr:string, endTimeStr:string) => { + const now = new Date().getTime(); + const startTime = getTimeFromTimeStr(startTimeStr).getTime(); + const endTime = getTimeFromTimeStr(endTimeStr).getTime(); + return now > startTime && now < endTime; +} + + From c04514df988d797fa2bcf492144fe6e94596174f Mon Sep 17 00:00:00 2001 From: yuannnh Date: Thu, 6 Feb 2020 13:00:58 +0800 Subject: [PATCH 2/6] =?UTF-8?q?[=E4=B9=89=E8=AF=8A]=20=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E6=8E=A5=E8=AF=8A=E6=A0=87=E7=AD=BE=E4=BD=8D=E7=BD=AE=E5=8F=8A?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/page/Clinic/index.css | 11 +++++++++++ source/page/Clinic/index.tsx | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 source/page/Clinic/index.css diff --git a/source/page/Clinic/index.css b/source/page/Clinic/index.css new file mode 100644 index 0000000..6affa01 --- /dev/null +++ b/source/page/Clinic/index.css @@ -0,0 +1,11 @@ +.clinic-card__live-label { + display: flex; + justify-content: center ; + justify-items: center; + width: 60px; + height: 20px; + background-color: #00fa9a; + font-size: 12px; + color:white; + border-radius: 2px; +} \ No newline at end of file diff --git a/source/page/Clinic/index.tsx b/source/page/Clinic/index.tsx index 6fcf3e5..8a3e192 100644 --- a/source/page/Clinic/index.tsx +++ b/source/page/Clinic/index.tsx @@ -6,6 +6,7 @@ import { Card } from 'boot-cell/source/Content/Card'; import { CardsPage, AuditBar } from '../../component'; import { clinic, Clinic } from '../../model'; import { getIsLive } from './time'; +import './index.css' @observer @component({ @@ -40,8 +41,9 @@ export class ClinicList extends CardsPage { ) } > + {isLive?
正在接诊
:null}

- 每日接诊起止时间:{startTime} ~ {endTime}{isLive?正在接诊:null} + 每日接诊起止时间:{startTime} ~ {endTime}

{contacts[0] && (
    From e14cce7abad14d98ff066c46b27c46ddb5276953 Mon Sep 17 00:00:00 2001 From: South Drifted Date: Sat, 20 Jan 2024 11:37:13 +0800 Subject: [PATCH 3/6] Update source/page/Clinic/index.tsx --- source/page/Clinic/index.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/page/Clinic/index.tsx b/source/page/Clinic/index.tsx index c3fce5a..1908f49 100644 --- a/source/page/Clinic/index.tsx +++ b/source/page/Clinic/index.tsx @@ -26,9 +26,8 @@ export class ClinicList extends CardsPage { contacts, remark, ...rest - }: Clinic) => { - const isLive = getIsLive(startTime, endTime); - return ( + { ) } > + {getIsLive(startTime, endTime) &&
    正在接诊
    }

    - 每日接诊起止时间:{startTime} ~ {endTime}{isLive?正在接诊:null} + 每日接诊起止时间:{startTime} ~ {endTime}

    {contacts[0] && (
      @@ -60,5 +60,5 @@ export class ClinicList extends CardsPage { - }; + ); } From eab2ce9f4a57a3bf5684c5ff18dcc61154080ace Mon Sep 17 00:00:00 2001 From: South Drifted Date: Sat, 20 Jan 2024 11:37:25 +0800 Subject: [PATCH 4/6] Update source/page/Clinic/index.tsx --- source/page/Clinic/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/page/Clinic/index.tsx b/source/page/Clinic/index.tsx index 1908f49..1525a50 100644 --- a/source/page/Clinic/index.tsx +++ b/source/page/Clinic/index.tsx @@ -2,11 +2,11 @@ import { component, createCell } from 'web-cell'; import { observer } from 'mobx-web-cell'; import { Card, CardFooter } from 'boot-cell/source/Content/Card'; -import { BGIcon } from 'boot-cell/source/Reminder/FAIcon'; import { CardsPage, AuditBar } from '../../component'; import { clinic, Clinic } from '../../model'; import { getIsLive } from './time'; +import './index.css' @observer @component({ From fbc2ed0d1b974e9a04ee29ea70bb2737920764de Mon Sep 17 00:00:00 2001 From: South Drifted Date: Sat, 20 Jan 2024 11:37:34 +0800 Subject: [PATCH 5/6] Update source/page/Clinic/time.ts --- source/page/Clinic/time.ts | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/source/page/Clinic/time.ts b/source/page/Clinic/time.ts index 5d88379..905066e 100644 --- a/source/page/Clinic/time.ts +++ b/source/page/Clinic/time.ts @@ -1,15 +1,6 @@ // 目前的时间格式为 hh:mm 的 String, 该方法将其转化为当天的该时间 -export const getTimeFromTimeStr = (timeStr:string) => { - const [hours, minutes] = timeStr.split(':').map(parseInt) - const time = new Date(); - if(hours){ - time.setHours(hours); - } - if(minutes) { - time.setMinutes(minutes) - } - return time; -} +export const getTimeFromTimeStr = (timeStr: string) => + new Date(new Date().toJSON().split('T')[0] + 'T' + timeStr); // 计算当前时间是否介于起始与结束算出时间内 export const getIsLive = (startTimeStr:string, endTimeStr:string) => { From 8374b5d8dc5321250f95b92b6d2ae61738705ff7 Mon Sep 17 00:00:00 2001 From: South Drifted Date: Sat, 20 Jan 2024 11:37:44 +0800 Subject: [PATCH 6/6] Update source/page/Clinic/time.ts --- source/page/Clinic/time.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/page/Clinic/time.ts b/source/page/Clinic/time.ts index 905066e..92770fa 100644 --- a/source/page/Clinic/time.ts +++ b/source/page/Clinic/time.ts @@ -3,11 +3,11 @@ export const getTimeFromTimeStr = (timeStr: string) => new Date(new Date().toJSON().split('T')[0] + 'T' + timeStr); // 计算当前时间是否介于起始与结束算出时间内 -export const getIsLive = (startTimeStr:string, endTimeStr:string) => { - const now = new Date().getTime(); - const startTime = getTimeFromTimeStr(startTimeStr).getTime(); - const endTime = getTimeFromTimeStr(endTimeStr).getTime(); +export const getIsLive = (startTimeStr: string, endTimeStr: string) => { + const now = Date.now(), + startTime = +getTimeFromTimeStr(startTimeStr), + endTime = +getTimeFromTimeStr(endTimeStr); + return now > startTime && now < endTime; } -