import { View, Text, PageContainer, Image } from '@tarojs/components' import './CircadianDetailPopup.scss' import { useEffect, useRef, useState } from 'react' import TimelineFastSleep from './TimelineFastSleep' import { RealRing } from "@/features/trackTimeDuration/components/Rings"; import Rings from "./Rings"; import { bigRingRadius, getBgRing, getCommon, getDot, ringWidth } from '../hooks/RingData'; import { ColorType } from '@/context/themes/color'; import { useTranslation } from 'react-i18next'; import { TimeFormatter } from '@/utils/time_format'; import { getTimezone, rpxToPx } from '@/utils/tools'; import { useSelector } from 'react-redux'; import { durationDatas, durationIndex, getColor, getDurationTitle } from '../hooks/Console'; import Modal from '@/components/layout/Modal.weapp'; import { updateRecord } from '@/services/trackTimeDuration'; import PickerViews from '@/components/input/PickerViews'; import Taro from '@tarojs/taro'; import { IconInfo, IconMinus, IconPlus } from '@/components/basic/Icons'; let LinearGradient if (process.env.TARO_ENV == 'rn') { LinearGradient = require('react-native-linear-gradient').default } export default function CircadianDetailPopup(props: { record: any, schedule?: any, onClose: Function, stageIndex?: number, onlyStage?: boolean }) { const [tabIndex, setTabIndex] = useState(0) const [diffTimeZone, setDiffTimeZone] = useState(false) const [multiTimeZone, setMultiTimeZone] = useState(false) const [detail, setDetail] = useState(JSON.parse(JSON.stringify(props.record))) const [showDurationPicker, setShowDurationPicker] = useState(false) const [fastPickerValue, setFastPickerValue] = useState([0, 0]) const [sleepPickerValue, setSleepPickerValue] = useState([0, 0]) const [showEditPicker, setShowEditPicker] = useState(false) const [schedule, setSchedule] = useState(props.schedule) const [isFast, setIsFast] = useState(true) const durationPickerRef = useRef(null) const common = useSelector((state: any) => state.common); const { t } = useTranslation() useEffect(() => { if (props.record.status == 'COMPLETED') { if ((props.record.sleep && props.record.sleep.status == 'COMPLETED') && props.record.scenario == 'FAST_SLEEP') { setTabIndex(1) } else { setTabIndex(2) } } }, []) useEffect(() => { checkTimezone() // var current_record = props.record if (detail.fast) setFastPickerValue(durationIndex(detail.fast.target_start_time, detail.fast.target_end_time, common)) if (detail.sleep) setSleepPickerValue(durationIndex(detail.sleep.target_start_time, detail.sleep.target_end_time, common)) }, [detail]) useEffect(() => { setDetail(JSON.parse(JSON.stringify(props.record))) }, [props.record]) function checkTimezone() { var currentTZ = getTimezone() var isDiff = false; var isMulti = false; var tempTZ = ''; if (props.record.fast) { if (props.record.fast.real_start_timezone.gmt) { tempTZ = props.record.fast.real_start_timezone.gmt if (props.record.fast.real_start_timezone.gmt != currentTZ) { isDiff = true } } if (props.record.fast.real_end_timezone.gmt) { if (tempTZ != props.record.fast.real_end_timezone.gmt) { isMulti = true } if (props.record.fast.real_end_timezone.gmt != currentTZ) { isDiff = true } } } if (props.record.sleep) { if (props.record.sleep.real_start_timezone.gmt) { if (tempTZ == '') { tempTZ = props.record.sleep.real_start_timezone.gmt } else if (tempTZ != props.record.sleep.real_start_timezone.gmt) { isMulti = true } if (props.record.sleep.real_start_timezone.gmt != currentTZ) { isDiff = true } } if (props.record.sleep.real_end_timezone.gmt) { if (tempTZ != props.record.sleep.real_end_timezone.gmt) { isMulti = true } if (props.record.sleep.real_end_timezone.gmt != currentTZ) { isDiff = true } } } setDiffTimeZone(isDiff) setMultiTimeZone(isMulti) } function getTitle() { if (props.record.status == 'COMPLETED') { var timestamp = props.record.first_real_check_time if (props.record.first_timezone) { timestamp = TimeFormatter.transferTimestamp(timestamp, props.record.first_timezone.gmt) } return TimeFormatter.getDayOfWeek(new Date(timestamp).getDay(), true) } if (props.record.status == 'WAIT_FOR_START') { return t('feature.track_time_duration.common.schedule') } return t('feature.track_time_duration.common.current_schedule') } function getSubTitle() { if (props.record.status == 'COMPLETED') { var timestamp = props.record.first_real_check_time if (props.record.first_timezone) { timestamp = TimeFormatter.transferTimestamp(timestamp, props.record.first_timezone.gmt) } return TimeFormatter.dateDescription(timestamp, true) } return '' } function getBottomText() { if (props.record.status == 'WAIT_FOR_START') { return t('feature.track_time_duration.common.im_ready') } if (props.record.status == 'COMPLETED') { return t('feature.track_time_duration.common.got_it') } return t('feature.track_time_duration.common.okay') } const startArc = (time: number) => { var date = new Date(time); var hour = date.getHours(); var minute = date.getMinutes(); var second = date.getSeconds(); return (hour * 3600 + minute * 60 + second) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0; } function durationArc(start_time: number, end_time: number) { var duration = (end_time - start_time) / 1000; return duration / (24 * 3600) * 2 * Math.PI; } function getStageDuration(index) { var start, end; switch (index) { case 0: if (props.record.status == 'WAIT_FOR_START') { start = props.record.fast.target_start_time end = props.record.sleep.target_start_time } else if (props.record.status == 'ONGOING1') { return TimeFormatter.countdown(props.record.fast.real_start_time) } else { start = props.record.fast.real_start_time end = props.record.sleep.real_start_time } break case 1: if (props.record.status == 'WAIT_FOR_START' || props.record.status == 'ONGOING1') { start = props.record.sleep.target_start_time end = props.record.sleep.target_end_time } else if (props.record.status == 'ONGOING2') { return TimeFormatter.countdown(props.record.sleep.real_start_time) } else { start = props.record.sleep.real_start_time end = props.record.sleep.real_end_time } break case 2: if (props.record.status == 'WAIT_FOR_START' || props.record.status == 'ONGOING1' || props.record.status == 'ONGOING2') { start = props.record.sleep.target_end_time end = props.record.fast.target_end_time } else if (props.record.status == 'ONGOING3') { return TimeFormatter.countdown(props.record.sleep.real_end_time) } else { start = props.record.sleep.real_end_time end = props.record.fast.real_end_time } break case 3: start = props.record.fast.real_start_time end = props.record.fast.real_end_time if (props.record.fast.status == 'NOT_COMPLETED') { return t('feature.track_time_duration.stage.not_completed') } break case 4: if (props.record.sleep.status == 'NOT_STARTED') { return t('feature.track_time_duration.stage.not_started') } else if (props.record.sleep.status == 'NOT_COMPLETED') { return t('feature.track_time_duration.stage.not_completed') } start = props.record.sleep.real_start_time end = props.record.sleep.real_end_time break; } if (start > end) { return t('feature.track_time_duration.console.no_duration_available') // return '-' + TimeFormatter.durationFormate2(start, end) } return TimeFormatter.calculateTimeDifference(start, end) } function completedOverView() { var bgRing = getBgRing() var common = getCommon(null, false) common.radius = bigRingRadius; common.lineWidth = ringWidth; var fastRing: RealRing = null if (props.record.fast) { var timestamp = TimeFormatter.transferTimestamp(props.record.fast.real_start_time, props.record.fast.real_end_timezone.gmt) fastRing = { color: global.fastColor ? global.fastColor : ColorType.fast, startArc: startArc(timestamp),//startArc(props.record.fast.real_start_time), durationArc: durationArc(props.record.fast.real_start_time, props.record.fast.real_end_time) } if (props.record.fast.status == 'NOT_COMPLETED') { fastRing.durationArc = 0.01 } } var sleepRing: RealRing = null if (props.record.sleep && props.record.sleep.status == 'COMPLETED') { var timestamp = TimeFormatter.transferTimestamp(props.record.sleep.real_start_time, props.record.fast ? props.record.fast.real_end_timezone.gmt : props.record.sleep.real_end_timezone.gmt) sleepRing = { color: global.sleepColor ? global.sleepColor : ColorType.sleep, startArc: startArc(timestamp),//startArc(props.record.sleep.real_start_time), durationArc: durationArc(props.record.sleep.real_start_time, props.record.sleep.real_end_time) } } if (props.record.sleep && props.record.sleep.status == 'NOT_COMPLETED') { var timestamp = TimeFormatter.transferTimestamp(props.record.sleep.real_start_time, props.record.fast ? props.record.fast.real_end_timezone.gmt : props.record.sleep.real_end_timezone.gmt) sleepRing = { color: global.sleepColor ? global.sleepColor : ColorType.sleep, startArc: startArc(timestamp),//startArc(props.record.sleep.real_start_time), durationArc: 0.01 } } return { props.record.fast && {t('feature.track_time_duration.record_fast_sleep.item.fast')} {getStageDuration(3)} } { props.record.sleep && {t('feature.track_time_duration.record_fast_sleep.item.sleep')} {getStageDuration(4)} } } function tapDuration(isFast: boolean) { if (isFast) { setIsFast(true) global.pauseIndexTimer = true if (props.record.status == 'WAIT_FOR_START') { setShowDurationPicker(true) } else { setShowEditPicker(true) } } else { setIsFast(false) if (props.record.status == 'WAIT_FOR_START' && props.record.scenario == 'FAST_SLEEP') { Taro.showToast({ title: t('feature.track_time_duration.common.start_fasting_first'), icon: 'none' }) return; } global.pauseIndexTimer = true if (props.record.status == 'WAIT_FOR_START' || props.record.status == 'ONGOING1') { setShowDurationPicker(true) } else { setShowEditPicker(true) } } } function tapMinus(isFast: boolean) { if (isFast) { var fastDuration = detail.fast.target_end_time - detail.fast.target_start_time if (fastDuration == 3600000) { Taro.showToast({ icon: 'none', title: 'feature.common.toast.min_value' }) return } var count = fastDuration - common.duration.step * 60 * 1000 count = count < 3600000 ? 3600000 : count detail.fast.target_end_time = detail.fast.target_start_time + count; setFastPickerValue(durationIndex(detail.fast.target_start_time, detail.fast.target_end_time, common)) if (props.record.status == 'WAIT_FOR_START') { // var start = props.schedule.fast.start_time // var startCount = (parseInt(start.split(':')[0]) * 60 + parseInt(start.split(':')[1])) * 60 * 1000 // var endCount = startCount + count // if (endCount >= 24 * 3600 * 1000) { // endCount -= 24 * 3600 * 1000 // } // endCount = endCount / 60000 // var endHour = Math.floor(endCount / 60) // var endMinute = endCount % 60 // var endTime = TimeFormatter.padZero(endHour) + ':' + TimeFormatter.padZero(endMinute) // console.log(endTime) changeSchedule(count) } } else { if (props.record.status == 'WAIT_FOR_START' && props.record.scenario == 'FAST_SLEEP') { Taro.showToast({ title: t('feature.track_time_duration.common.start_fasting_first'), icon: 'none' }) return; } var sleepDuration = detail.sleep.target_end_time - detail.sleep.target_start_time if (sleepDuration == 3600000) { Taro.showToast({ icon: 'none', title: 'feature.common.toast.min_value' }) return } var count = sleepDuration - common.duration.step * 60 * 1000 count = count < 3600000 ? 3600000 : count detail.sleep.target_end_time = detail.sleep.target_start_time + count; setSleepPickerValue(durationIndex(detail.sleep.target_start_time, detail.sleep.target_end_time, common)) } setDetail(JSON.parse(JSON.stringify(detail))) } function tapPlus(isFast: boolean) { if (isFast) { var fastDuration = detail.fast.target_end_time - detail.fast.target_start_time if (fastDuration == 23 * 3600000) { Taro.showToast({ icon: 'none', title: 'feature.common.toast.max_value' }) return } var count = fastDuration + common.duration.step * 60 * 1000 count = count > 23 * 3600000 ? 23 * 3600000 : count detail.fast.target_end_time = detail.fast.target_start_time + count; setFastPickerValue(durationIndex(detail.fast.target_start_time, detail.fast.target_end_time, common)) if (props.record.status == 'WAIT_FOR_START') { changeSchedule(count) // var start = props.schedule.fast.start_time // var startCount = (parseInt(start.split(':')[0]) * 60 + parseInt(start.split(':')[1])) * 60 * 1000 // var endCount = startCount + count // if (endCount >= 24 * 3600 * 1000) { // endCount -= 24 * 3600 * 1000 // } // endCount = endCount / 60000 // var endHour = Math.floor(endCount / 60) // var endMinute = endCount % 60 // var endTime = TimeFormatter.padZero(endHour) + ':' + TimeFormatter.padZero(endMinute) // console.log(endTime) } } else { if (props.record.status == 'WAIT_FOR_START' && props.record.scenario == 'FAST_SLEEP') { Taro.showToast({ title: t('feature.track_time_duration.common.start_fasting_first'), icon: 'none' }) return; } var sleepDuration = detail.sleep.target_end_time - detail.sleep.target_start_time if (sleepDuration == 23 * 3600000) { Taro.showToast({ icon: 'none', title: 'feature.common.toast.max_value' }) return } var count = sleepDuration + common.duration.step * 60 * 1000 count = count > 23 * 3600000 ? 23 * 3600000 : count detail.sleep.target_end_time = detail.sleep.target_start_time + count; setSleepPickerValue(durationIndex(detail.sleep.target_start_time, detail.sleep.target_end_time, common)) } setDetail(JSON.parse(JSON.stringify(detail))) } function changeSchedule(count: number) { if (!schedule) { return } var obj = JSON.parse(JSON.stringify(schedule)) var start = schedule.fast.start_time var startCount = (parseInt(start.split(':')[0]) * 60 + parseInt(start.split(':')[1])) * 60 * 1000 var endCount = startCount + count if (endCount >= 24 * 3600 * 1000) { endCount -= 24 * 3600 * 1000 } endCount = endCount / 60000 var endHour = Math.floor(endCount / 60) var endMinute = endCount % 60 var endTime = TimeFormatter.padZero(endHour) + ':' + TimeFormatter.padZero(endMinute) obj.fast.end_time = endTime setSchedule(obj) } function sleepRealDuration() { return getStageDuration(4) } function fastOverview() { if (props.record.fast.status == 'WAIT_FOR_START') { return {t('feature.track_time_duration.record_fast_sleep.item.fast')} tapDuration(true)} style={{ flexDirection: 'row', alignItems: 'center', marginTop: rpxToPx(8), display: 'flex', width: '100%' }}> {TimeFormatter.durationFormate(detail.fast.target_start_time, detail.fast.target_end_time)} { if (process.env.TARO_ENV == 'weapp') { e.stopPropagation() } tapMinus(true) }} className='minus' style={{ backgroundColor: ColorType.fast, opacity: 0.6 }}> { if (process.env.TARO_ENV == 'weapp') { e.stopPropagation() } tapPlus(true) }} className='plus' style={{ backgroundColor: ColorType.fast }}> } else if (props.record.status != 'COMPLETED') { return {t('feature.track_time_duration.record_fast_sleep.item.fast')} tapDuration(true)} style={{ flexDirection: 'row', alignItems: 'center', marginTop: rpxToPx(8), display: 'flex', width: '100%' }}> {TimeFormatter.durationFormate(detail.fast.target_start_time, detail.fast.target_end_time)} tapDuration(true)} className="arrow2" src={require('@/assets/images/arrow3.png')} /> {t('feature.track_time_duration.console.countup')} {TimeFormatter.formateTimeNow(props.record.fast.real_start_time)} { props.record.fast.target_end_time < new Date().getTime() ? {t('feature.track_time_duration.console.timeout')} : {t('feature.track_time_duration.console.countdown_not_due')} } { props.record.fast.target_end_time < new Date().getTime() ? {TimeFormatter.countdown(props.record.fast.target_end_time)} : {TimeFormatter.countdown(props.record.fast.target_end_time)} } } } function sleepOverview() { if (props.record.sleep.status == 'WAIT_FOR_START') { return {t('feature.track_time_duration.record_fast_sleep.item.sleep')} tapDuration(false)} style={{ flexDirection: 'row', alignItems: 'center', marginTop: rpxToPx(8), display: 'flex', width: '100%' }}> {TimeFormatter.durationFormate(detail.sleep.target_start_time, detail.sleep.target_end_time)} { if (process.env.TARO_ENV == 'weapp') { e.stopPropagation() } tapMinus(false) }} className='minus' style={{ backgroundColor: ColorType.sleep, opacity: 0.6 }}> { if (process.env.TARO_ENV == 'weapp') { e.stopPropagation() } tapPlus(false) }} className='plus' style={{ backgroundColor: ColorType.sleep }}> } else if (props.record.sleep.status == 'WAIT_FOR_END') { return {t('feature.track_time_duration.record_fast_sleep.item.sleep')} tapDuration(false)} style={{ flexDirection: 'row', alignItems: 'center', marginTop: rpxToPx(8), display: 'flex', width: '100%' }}> {TimeFormatter.durationFormate(detail.sleep.target_start_time, detail.sleep.target_end_time)} tapDuration(false)} className="arrow2" src={require('@/assets/images/arrow3.png')} /> {t('feature.track_time_duration.console.countup')} {TimeFormatter.formateTimeNow(props.record.sleep.real_start_time)} { props.record.sleep.target_end_time < new Date().getTime() ? {t('feature.track_time_duration.console.timeout')} : {t('feature.track_time_duration.console.countdown_not_due')} } { props.record.sleep.target_end_time < new Date().getTime() ? {TimeFormatter.countdown(props.record.sleep.target_end_time)} : {TimeFormatter.countdown(props.record.sleep.target_end_time)} } } else { return {t('feature.track_time_duration.record_fast_sleep.item.sleep')} {sleepRealDuration()} } } function overview() { if (props.record.status == 'COMPLETED') { return completedOverView() } return { props.record.fast && fastOverview() } { props.record.sleep && sleepOverview() } } function showPredictedAlert() { Taro.showModal({ title: t('feature.track_time_duration.console.predicted_alert_title'), content: t('feature.track_time_duration.console.predicted_alert_content'), showCancel: false, confirmText: t('feature.track_time_duration.console.predicted_alert_btn') }) } function stage() { var bgRing = getBgRing() var common = getCommon(null, false) common.radius = bigRingRadius; common.lineWidth = ringWidth; var timestamp, timestamp2, timestamp3 var duration, duration2, duration3; var predicted2 = false; //预估 var predicted3 = false; var currentDot = getDot(null, true) var currentDot2 = getDot(null, true) var currentDot3 = getDot(null, true) if (props.record.status == 'WAIT_FOR_START') { var date = new Date() date.setSeconds(0) date.setMilliseconds(0) var fastStart = props.schedule.fast.start_time var sleepStart = props.schedule.sleep.start_time var sleepEnd = props.schedule.sleep.end_time date.setHours(parseInt(fastStart.split(':')[0])) date.setMinutes(parseInt(fastStart.split(':')[1])) timestamp = date.getTime() date.setHours(parseInt(sleepStart.split(':')[0])) date.setMinutes(parseInt(sleepStart.split(':')[1])) timestamp2 = date.getTime() if (timestamp2 < timestamp) { timestamp2 += 24 * 3600 * 1000 } date.setHours(parseInt(sleepEnd.split(':')[0])) date.setMinutes(parseInt(sleepEnd.split(':')[1])) timestamp3 = date.getTime() if (timestamp3 < timestamp2) { timestamp3 += 24 * 3600 * 1000 } duration = durationArc(props.record.fast.target_start_time, props.record.sleep.target_start_time) duration2 = durationArc(props.record.sleep.target_start_time, props.record.sleep.target_end_time) duration3 = durationArc(props.record.sleep.target_end_time, props.record.fast.target_end_time) currentDot = null currentDot2 = null currentDot3 = null } else if (props.record.status == 'ONGOING1') { var date = new Date() timestamp = props.record.fast.real_start_time timestamp2 = props.record.sleep.target_start_time timestamp3 = props.record.sleep.target_end_time duration = durationArc(props.record.fast.real_start_time, date.getTime()) duration2 = durationArc(props.record.sleep.target_start_time, props.record.sleep.target_end_time) duration3 = durationArc(props.record.sleep.target_end_time, props.record.fast.target_end_time) predicted2 = true predicted3 = true currentDot.color = ColorType.fast currentDot2 = null currentDot3 = null } else if (props.record.status == 'ONGOING2') { var date = new Date() timestamp = props.record.fast.real_start_time timestamp2 = props.record.sleep.real_start_time timestamp3 = props.record.sleep.target_end_time duration = durationArc(props.record.fast.real_start_time, props.record.sleep.real_start_time) duration2 = durationArc(props.record.sleep.real_start_time, date.getTime()) duration3 = durationArc(props.record.sleep.target_end_time, props.record.fast.target_end_time) predicted2 = false predicted3 = true currentDot = null currentDot2.color = ColorType.sleep currentDot3 = null } else if (props.record.status == 'ONGOING3') { var date = new Date() timestamp = props.record.fast.real_start_time timestamp2 = props.record.sleep.real_start_time timestamp3 = props.record.sleep.real_end_time duration = durationArc(props.record.fast.real_start_time, props.record.sleep.real_start_time) duration2 = durationArc(props.record.sleep.real_start_time, props.record.sleep.real_end_time) duration3 = durationArc(props.record.sleep.real_end_time, date.getTime()) currentDot = null currentDot2 = null currentDot3.color = ColorType.fast } else { timestamp = TimeFormatter.transferTimestamp(props.record.fast.real_start_time, props.record.fast.real_end_timezone.gmt) timestamp2 = TimeFormatter.transferTimestamp(props.record.sleep.real_start_time, props.record.fast.real_end_timezone.gmt) timestamp3 = TimeFormatter.transferTimestamp(props.record.sleep.real_end_time, props.record.fast.real_end_timezone.gmt) duration = durationArc(props.record.fast.real_start_time, props.record.sleep.real_start_time) duration2 = durationArc(props.record.sleep.real_start_time, props.record.sleep.real_end_time) duration3 = durationArc(props.record.sleep.real_end_time, props.record.fast.real_end_time) currentDot = null currentDot2 = null currentDot3 = null } const preRing: RealRing = { color: global.fastColor ? global.fastColor : ColorType.fast, startArc: startArc(timestamp), durationArc: duration } let sleepRing: RealRing = { color: global.sleepColor ? global.sleepColor : ColorType.sleep, startArc: startArc(timestamp2), durationArc: duration2 } let wakeRing: RealRing = { color: global.fastColor ? global.fastColor : ColorType.fast, startArc: startArc(timestamp3), durationArc: duration3 } if (duration2 < 0) { sleepRing = null } if (duration3 < 0) { wakeRing = null } return {t('feature.track_time_duration.stage.a')} {getStageDuration(0)} {t('feature.track_time_duration.stage.b')} {getStageDuration(1)} { predicted2 ? !sleepRing ? : {t('feature.track_time_duration.console.predicted')} : null } {t('feature.track_time_duration.stage.c')} {getStageDuration(2)} { predicted3 ? !wakeRing ? : {t('feature.track_time_duration.console.predicted')} : null } } function events() { return } function durationPickerContent() { var color = getColor(props.record) var title = getDurationTitle(props.record, t) return { setShowDurationPicker(false) global.pauseIndexTimer = false }} /> } function editPickerContent() { return { setShowEditPicker(false) global.pauseIndexTimer = false }} /> } function durationChange(e) { global.pauseIndexTimer = false var count = (e[0] + common.duration.min) * 60 + e[1] * common.duration.step // var count = (e[0] + 1) * 60 + e[1] * 5 if (showDurationPicker) { // global.changeTargetDuration(count, isFast) if (isFast) { detail.fast.target_end_time = detail.fast.target_start_time + count * 60 * 1000 if (props.record.status == 'WAIT_FOR_START') { changeSchedule(count * 1000 * 60) } } else { detail.sleep.target_end_time = detail.sleep.target_start_time + count * 60 * 1000 } setDetail(JSON.parse(JSON.stringify(detail))) } else { var params: any = {} if (isFast) { params = { fast: { target_duration: count * 60 * 1000 } } } else { params = { sleep: { target_duration: count * 60 * 1000 } } } updateRecord({ ...params }, props.record.id).then(res => { global.indexPageRefresh() }).catch(e => { }) } setShowDurationPicker(false) setShowEditPicker(false) } function modalContent() { if (showDurationPicker || showEditPicker) { return { setShowDurationPicker(false) setShowEditPicker(false) global.pauseIndexTimer = false }} confirm={() => { }}> { showDurationPicker ? durationPickerContent() : editPickerContent() } } return } function onlyStageContent() { var bgRing = getBgRing() var common = getCommon(null, false) common.radius = bigRingRadius; common.lineWidth = ringWidth; var timestamp, timestamp2, timestamp3 var duration, duration2, duration3; var currentDot = getDot(null, true) if (props.record.status == 'WAIT_FOR_START') { var date = new Date() date.setSeconds(0) date.setMilliseconds(0) var fastStart = props.schedule.fast.start_time var sleepStart = props.schedule.sleep.start_time var sleepEnd = props.schedule.sleep.end_time date.setHours(parseInt(fastStart.split(':')[0])) date.setMinutes(parseInt(fastStart.split(':')[1])) timestamp = date.getTime() date.setHours(parseInt(sleepStart.split(':')[0])) date.setMinutes(parseInt(sleepStart.split(':')[1])) timestamp2 = date.getTime() if (timestamp2 < timestamp) { timestamp2 += 24 * 3600 * 1000 } date.setHours(parseInt(sleepEnd.split(':')[0])) date.setMinutes(parseInt(sleepEnd.split(':')[1])) timestamp3 = date.getTime() if (timestamp3 < timestamp2) { timestamp3 += 24 * 3600 * 1000 } duration = durationArc(props.record.fast.target_start_time, props.record.sleep.target_start_time) duration2 = durationArc(props.record.sleep.target_start_time, props.record.sleep.target_end_time) duration3 = durationArc(props.record.sleep.target_end_time, props.record.fast.target_end_time) currentDot = null; } else if (props.record.status == 'ONGOING1') { var date = new Date() timestamp = props.record.fast.real_start_time timestamp2 = props.record.sleep.target_start_time timestamp3 = props.record.sleep.target_end_time duration = durationArc(props.record.fast.real_start_time, date.getTime()) duration2 = durationArc(props.record.sleep.target_start_time, props.record.sleep.target_end_time) duration3 = durationArc(props.record.sleep.target_end_time, props.record.fast.target_end_time) if (props.stageIndex == 0) { currentDot.color = ColorType.fast } else { currentDot = null } } else if (props.record.status == 'ONGOING2') { var date = new Date() timestamp = props.record.fast.real_start_time timestamp2 = props.record.sleep.real_start_time timestamp3 = props.record.sleep.target_end_time duration = durationArc(props.record.fast.real_start_time, props.record.sleep.real_start_time) duration2 = durationArc(props.record.sleep.real_start_time, date.getTime()) duration3 = durationArc(props.record.sleep.target_end_time, props.record.fast.target_end_time) if (props.stageIndex == 1) { currentDot.color = ColorType.sleep } else { currentDot = null } } else if (props.record.status == 'ONGOING3') { var date = new Date() timestamp = props.record.fast.real_start_time timestamp2 = props.record.sleep.real_start_time timestamp3 = props.record.sleep.real_end_time duration = durationArc(props.record.fast.real_start_time, props.record.sleep.real_start_time) duration2 = durationArc(props.record.sleep.real_start_time, props.record.sleep.real_end_time) duration3 = durationArc(props.record.sleep.real_end_time, date.getTime()) if (props.stageIndex == 2) { currentDot.color = ColorType.fast } else { currentDot = null } } else { timestamp = TimeFormatter.transferTimestamp(props.record.fast.real_start_time, props.record.fast.real_end_timezone.gmt) timestamp2 = TimeFormatter.transferTimestamp(props.record.sleep.real_start_time, props.record.fast.real_end_timezone.gmt) timestamp3 = TimeFormatter.transferTimestamp(props.record.sleep.real_end_time, props.record.fast.real_end_timezone.gmt) duration = durationArc(props.record.fast.real_start_time, props.record.sleep.real_start_time) duration2 = durationArc(props.record.sleep.real_start_time, props.record.sleep.real_end_time) duration3 = durationArc(props.record.sleep.real_end_time, props.record.fast.real_end_time) currentDot = null } const preRing: RealRing = { color: global.fastColor ? global.fastColor : ColorType.fast, startArc: startArc(timestamp), durationArc: duration } const sleepRing: RealRing = { color: global.sleepColor ? global.sleepColor : ColorType.sleep, startArc: startArc(timestamp2), durationArc: duration2 } const wakeRing: RealRing = { color: global.fastColor ? global.fastColor : ColorType.fast, startArc: startArc(timestamp3), durationArc: duration3 } return {/* {getTitle()} {getSubTitle()} */} { props.stageIndex == 0 && {t('feature.track_time_duration.stage.a')} {getStageDuration(0)} } { props.stageIndex == 1 && {t('feature.track_time_duration.stage.b')} {getStageDuration(1)} } { props.stageIndex == 2 && {t('feature.track_time_duration.stage.c')} {getStageDuration(2)} } } if (props.onlyStage) { return onlyStageContent() } return {getTitle()} {getSubTitle()} { setTabIndex(0) }} className={tabIndex == 0 ? 'detail_tabitem_sel' : 'detail_tabitem_nor'}>{t('feature.day_night.overview')} { // props.record.status == 'COMPLETED' && // (props.record.sleep && props.record.sleep.status == 'COMPLETED') && props.record.scenario == 'FAST_SLEEP' && { setTabIndex(1) }} className={tabIndex == 1 ? 'detail_tabitem_sel' : 'detail_tabitem_nor'}>{t('feature.day_night.stages')} } { setTabIndex(2) }} className={tabIndex == 2 ? 'detail_tabitem_sel' : 'detail_tabitem_nor'}>{t('feature.day_night.events')} { tabIndex == 0 ? overview() : tabIndex == 1 ? stage() : events() } { process.env.TARO_ENV == 'weapp' ? { if (process.env.TARO_ENV == 'weapp') { e.stopPropagation() } global.updateFastSleepData(detail, schedule) props.onClose(); }}>{getBottomText()} : { global.updateFastSleepData(detail, schedule) props.onClose(); }}> {getBottomText()} // { // global.updateFastSleepData(detail, schedule) // props.onClose(); // }}>{getBottomText()} } { modalContent() } }