|
@@ -4,7 +4,7 @@ import Taro, { useRouter, useShareAppMessage } from "@tarojs/taro";
|
|
|
import { rpxToPx } from "@/utils/tools";
|
|
import { rpxToPx } from "@/utils/tools";
|
|
|
import { MainColorType } from "@/context/themes/color";
|
|
import { MainColorType } from "@/context/themes/color";
|
|
|
import NewButton, { NewButtonType } from "@/_health/base/new_button";
|
|
import NewButton, { NewButtonType } from "@/_health/base/new_button";
|
|
|
-import { useEffect, useState } from "react";
|
|
|
|
|
|
|
+import { useEffect, useRef, useState } from "react";
|
|
|
import NewDateTimePicker from "@/_health/base/new_date_time_picker";
|
|
import NewDateTimePicker from "@/_health/base/new_date_time_picker";
|
|
|
import dayjs from "dayjs";
|
|
import dayjs from "dayjs";
|
|
|
import RingProgress from "../components/ring_progress";
|
|
import RingProgress from "../components/ring_progress";
|
|
@@ -12,11 +12,12 @@ import NewDurationPicker, { DurationPickerType } from "@/_health/base/new_durati
|
|
|
import { IconArrow, IconClose } from "@/components/basic/Icons";
|
|
import { IconArrow, IconClose } from "@/components/basic/Icons";
|
|
|
import { useSelector } from "react-redux";
|
|
import { useSelector } from "react-redux";
|
|
|
import { TimeFormatter } from "@/utils/time_format";
|
|
import { TimeFormatter } from "@/utils/time_format";
|
|
|
-import { addEvents } from "@/services/health";
|
|
|
|
|
|
|
+import { addEvents, delWindowId } from "@/services/health";
|
|
|
import Modal from "@/components/layout/Modal.weapp";
|
|
import Modal from "@/components/layout/Modal.weapp";
|
|
|
import { getDurationArc, getStartArc } from "@/features/health/hooks/health_hooks";
|
|
import { getDurationArc, getStartArc } from "@/features/health/hooks/health_hooks";
|
|
|
import ShareBtn from "@/components/basic/ShareBtn";
|
|
import ShareBtn from "@/components/basic/ShareBtn";
|
|
|
import PickerCard from "../components/picker_card";
|
|
import PickerCard from "../components/picker_card";
|
|
|
|
|
+import showActionSheet from "@/components/basic/ActionSheet";
|
|
|
|
|
|
|
|
let timer
|
|
let timer
|
|
|
let useRoute;
|
|
let useRoute;
|
|
@@ -43,6 +44,11 @@ export default function TimeRecord() {
|
|
|
const [showShare, setShowShare] = useState(false)
|
|
const [showShare, setShowShare] = useState(false)
|
|
|
const [shareUrl, setShareUrl] = useState('')
|
|
const [shareUrl, setShareUrl] = useState('')
|
|
|
|
|
|
|
|
|
|
+ const statusRef = useRef(status)
|
|
|
|
|
+ const picker1Ref = useRef(showDatePicker)
|
|
|
|
|
+ const picker2Ref = useRef(showEndDatePicker)
|
|
|
|
|
+ const picker3Ref = useRef(showDurationPicker)
|
|
|
|
|
+
|
|
|
let router
|
|
let router
|
|
|
let navigation;
|
|
let navigation;
|
|
|
if (useNavigation) {
|
|
if (useNavigation) {
|
|
@@ -68,6 +74,13 @@ export default function TimeRecord() {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ statusRef.current = status;
|
|
|
|
|
+ picker1Ref.current = showDatePicker
|
|
|
|
|
+ picker2Ref.current = showEndDatePicker
|
|
|
|
|
+ picker3Ref.current = showDurationPicker
|
|
|
|
|
+ }, [status, showDatePicker, showEndDatePicker, showDurationPicker])
|
|
|
|
|
+
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
const { events } = record
|
|
const { events } = record
|
|
@@ -80,7 +93,8 @@ export default function TimeRecord() {
|
|
|
})
|
|
})
|
|
|
downloadFile()
|
|
downloadFile()
|
|
|
timer = setInterval(() => {
|
|
timer = setInterval(() => {
|
|
|
- if (showDatePicker || showEndDatePicker || showDurationPicker) return
|
|
|
|
|
|
|
+ if (picker1Ref.current || picker2Ref.current || picker3Ref.current) return
|
|
|
|
|
+ if (statusRef.current == 'DONE') return
|
|
|
setCount(count => count + 1)
|
|
setCount(count => count + 1)
|
|
|
}, 1000)
|
|
}, 1000)
|
|
|
return () => {
|
|
return () => {
|
|
@@ -150,6 +164,7 @@ export default function TimeRecord() {
|
|
|
// setPosting(true)
|
|
// setPosting(true)
|
|
|
addEvents(params).then(res => {
|
|
addEvents(params).then(res => {
|
|
|
Taro.eventCenter.trigger('refreshClockIndex')
|
|
Taro.eventCenter.trigger('refreshClockIndex')
|
|
|
|
|
+ Taro.eventCenter.trigger('refreshMoments', '')
|
|
|
setShowHighlight(true)
|
|
setShowHighlight(true)
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
|
setShowHighlight(false)
|
|
setShowHighlight(false)
|
|
@@ -189,6 +204,7 @@ export default function TimeRecord() {
|
|
|
setShowHighlight(false)
|
|
setShowHighlight(false)
|
|
|
}, 3000)
|
|
}, 3000)
|
|
|
Taro.eventCenter.trigger('refreshClockIndex')
|
|
Taro.eventCenter.trigger('refreshClockIndex')
|
|
|
|
|
+ Taro.eventCenter.trigger('refreshMoments', '')
|
|
|
setInfo((res as any).data)
|
|
setInfo((res as any).data)
|
|
|
setStatus((res as any).data.status)
|
|
setStatus((res as any).data.status)
|
|
|
setShareUrl('')
|
|
setShareUrl('')
|
|
@@ -208,10 +224,34 @@ export default function TimeRecord() {
|
|
|
}
|
|
}
|
|
|
addEvents(data).then(res => {
|
|
addEvents(data).then(res => {
|
|
|
Taro.eventCenter.trigger('refreshClockIndex')
|
|
Taro.eventCenter.trigger('refreshClockIndex')
|
|
|
|
|
+ Taro.eventCenter.trigger('refreshMoments', '')
|
|
|
setInfo((res as any).data)
|
|
setInfo((res as any).data)
|
|
|
setShowDatePicker(false)
|
|
setShowDatePicker(false)
|
|
|
setShowDurationPicker(false)
|
|
setShowDurationPicker(false)
|
|
|
setShowEndDatePicker(false)
|
|
setShowEndDatePicker(false)
|
|
|
|
|
+ setCount((count) => count + 1)
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function more() {
|
|
|
|
|
+ showActionSheet({
|
|
|
|
|
+ title: '操作',
|
|
|
|
|
+ itemList: ['放弃', '重新开始'],
|
|
|
|
|
+ success: (res) => {
|
|
|
|
|
+ switch (res) {
|
|
|
|
|
+ case 0:
|
|
|
|
|
+ delWindowId(info.id).then(res => {
|
|
|
|
|
+ setInfo((res as any).data)
|
|
|
|
|
+ setStatus((res as any).data.status)
|
|
|
|
|
+ })
|
|
|
|
|
+ break
|
|
|
|
|
+ case 1:
|
|
|
|
|
+ delWindowId(info.id).then(res => {
|
|
|
|
|
+ start()
|
|
|
|
|
+ })
|
|
|
|
|
+ break
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -225,22 +265,28 @@ export default function TimeRecord() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function ringExtra() {
|
|
function ringExtra() {
|
|
|
|
|
+ if (status == 'DONE') {
|
|
|
|
|
+ return {
|
|
|
|
|
+ value: '',
|
|
|
|
|
+ footer: '',
|
|
|
|
|
+ color: MainColorType.orange,
|
|
|
|
|
+ result: TimeFormatter.formateDurationBySeconds(info.time.end_timestamp / 1000 - info.time.start_timestamp / 1000),
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
if (status == 'WFS') {
|
|
if (status == 'WFS') {
|
|
|
const count = info.time.duration / 1000
|
|
const count = info.time.duration / 1000
|
|
|
var str = TimeFormatter.formateDurationBySeconds(count)
|
|
var str = TimeFormatter.formateDurationBySeconds(count)
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
- header: '',
|
|
|
|
|
- value: str,
|
|
|
|
|
- footer: 'Edit',
|
|
|
|
|
|
|
+ target: str,
|
|
|
|
|
+ goal: 'Edit Goal',
|
|
|
color: MainColorType.orange
|
|
color: MainColorType.orange
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
var percent = 100 * (new Date().getTime() - info.time.start_timestamp) / info.time.duration
|
|
var percent = 100 * (new Date().getTime() - info.time.start_timestamp) / info.time.duration
|
|
|
percent = parseInt(percent + '')
|
|
percent = parseInt(percent + '')
|
|
|
return {
|
|
return {
|
|
|
- header: '',
|
|
|
|
|
- value: TimeFormatter.countdown(info.time.start_timestamp),
|
|
|
|
|
|
|
+ progress: TimeFormatter.countdown(info.time.start_timestamp),
|
|
|
footer: `ELAPSED ${percent}%`,
|
|
footer: `ELAPSED ${percent}%`,
|
|
|
color: MainColorType.g02
|
|
color: MainColorType.g02
|
|
|
}
|
|
}
|
|
@@ -267,7 +313,7 @@ export default function TimeRecord() {
|
|
|
function doneComponent() {
|
|
function doneComponent() {
|
|
|
if (status == 'DONE') {
|
|
if (status == 'DONE') {
|
|
|
return <View className="share_bg" style={{ justifyContent: 'flex-start' }}>
|
|
return <View className="share_bg" style={{ justifyContent: 'flex-start' }}>
|
|
|
- {
|
|
|
|
|
|
|
+ {/* {
|
|
|
shareUrl.length == 0 && <View className="share_canvas"><RingProgress
|
|
shareUrl.length == 0 && <View className="share_canvas"><RingProgress
|
|
|
radius={125} canvasId="helloworld_share2"
|
|
radius={125} canvasId="helloworld_share2"
|
|
|
//scale={0.75}
|
|
//scale={0.75}
|
|
@@ -290,7 +336,7 @@ export default function TimeRecord() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
/></View>
|
|
/></View>
|
|
|
- }
|
|
|
|
|
|
|
+ } */}
|
|
|
|
|
|
|
|
<View className="navi_bar" style={{ height: navigationBarHeight }}>
|
|
<View className="navi_bar" style={{ height: navigationBarHeight }}>
|
|
|
<View style={{
|
|
<View style={{
|
|
@@ -319,10 +365,33 @@ export default function TimeRecord() {
|
|
|
|
|
|
|
|
</View>
|
|
</View>
|
|
|
<View className="share_card" style={{ background: MainColorType.orange, marginTop: rpxToPx(26) + navigationBarHeight }}>
|
|
<View className="share_card" style={{ background: MainColorType.orange, marginTop: rpxToPx(26) + navigationBarHeight }}>
|
|
|
- {
|
|
|
|
|
|
|
+ {/* {
|
|
|
shareUrl.length > 0 ? <Image src={shareUrl} style={{ width: rpxToPx(900), height: rpxToPx(720) }} /> :
|
|
shareUrl.length > 0 ? <Image src={shareUrl} style={{ width: rpxToPx(900), height: rpxToPx(720) }} /> :
|
|
|
<View style={{ width: rpxToPx(900), height: rpxToPx(720), backgroundColor: MainColorType.g02 }} />
|
|
<View style={{ width: rpxToPx(900), height: rpxToPx(720), backgroundColor: MainColorType.g02 }} />
|
|
|
- }
|
|
|
|
|
|
|
+ } */}
|
|
|
|
|
+ <RingProgress
|
|
|
|
|
+ radius={rpxToPx(250)} canvasId="helloworld_share2"
|
|
|
|
|
+ //scale={0.75}
|
|
|
|
|
+ count={count}
|
|
|
|
|
+ bgRing={{
|
|
|
|
|
+ color: 'rgba(255,255,255,1)',
|
|
|
|
|
+ width: rpxToPx(100)
|
|
|
|
|
+ }}
|
|
|
|
|
+ real={{
|
|
|
|
|
+ color: MainColorType.orange,
|
|
|
|
|
+ width: rpxToPx(16),
|
|
|
|
|
+ start: getStartArc(info.time.start_timestamp),
|
|
|
|
|
+ duration: getDurationArc(info.time.start_timestamp, info.time.end_timestamp)
|
|
|
|
|
+ }}
|
|
|
|
|
+ extra={ringExtra()}
|
|
|
|
|
+ shareBg={[MainColorType.orange]}
|
|
|
|
|
+ isCompleted
|
|
|
|
|
+ shareCover={
|
|
|
|
|
+ url => {
|
|
|
|
|
+ setShareUrl(url)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ />
|
|
|
{
|
|
{
|
|
|
<View className="operate_content" style={{ marginTop: rpxToPx(40) }}>
|
|
<View className="operate_content" style={{ marginTop: rpxToPx(40) }}>
|
|
|
<View className="operate_item" onClick={() => {
|
|
<View className="operate_item" onClick={() => {
|
|
@@ -332,7 +401,7 @@ export default function TimeRecord() {
|
|
|
<View className="h44 bold" style={{ marginTop: rpxToPx(8), marginBottom: rpxToPx(8) }}>{TimeFormatter.dateTimeFormate(info.time.start_timestamp, true)}</View>
|
|
<View className="h44 bold" style={{ marginTop: rpxToPx(8), marginBottom: rpxToPx(8) }}>{TimeFormatter.dateTimeFormate(info.time.start_timestamp, true)}</View>
|
|
|
<View className="h30 bold" style={{ color: MainColorType.white }}>Edit Start</View>
|
|
<View className="h30 bold" style={{ color: MainColorType.white }}>Edit Start</View>
|
|
|
</View>
|
|
</View>
|
|
|
- <View className="operate_item" onClick={() => {
|
|
|
|
|
|
|
+ <View className="operate_item" style={{ backgroundColor: showHighlight ? '#ffffff80' : 'transparent' }} onClick={() => {
|
|
|
setShowEndDatePicker(true)
|
|
setShowEndDatePicker(true)
|
|
|
}}>
|
|
}}>
|
|
|
<View className="g02 h24">FINISHED</View>
|
|
<View className="g02 h24">FINISHED</View>
|
|
@@ -382,7 +451,7 @@ export default function TimeRecord() {
|
|
|
Taro.navigateBack()
|
|
Taro.navigateBack()
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
|
- <View className="h36 bold">upcoming fast</View>
|
|
|
|
|
|
|
+ <View className="h36 bold">{status == 'WFS' ? 'upcoming fast' : 'onging fast'}</View>
|
|
|
</View>
|
|
</View>
|
|
|
</View>
|
|
</View>
|
|
|
<View style={{ height: navigationBarHeight }} />
|
|
<View style={{ height: navigationBarHeight }} />
|
|
@@ -392,22 +461,22 @@ export default function TimeRecord() {
|
|
|
// setShowDurationPicker(true)
|
|
// setShowDurationPicker(true)
|
|
|
}}>
|
|
}}>
|
|
|
<RingProgress
|
|
<RingProgress
|
|
|
- radius={125} canvasId="helloworld"
|
|
|
|
|
|
|
+ radius={rpxToPx(250)} canvasId="helloworld"
|
|
|
//scale={0.75}
|
|
//scale={0.75}
|
|
|
count={count}
|
|
count={count}
|
|
|
bgRing={{
|
|
bgRing={{
|
|
|
color: 'rgba(255,255,255,0.25)',
|
|
color: 'rgba(255,255,255,0.25)',
|
|
|
- width: 35
|
|
|
|
|
|
|
+ width: rpxToPx(100)
|
|
|
}}
|
|
}}
|
|
|
target={{
|
|
target={{
|
|
|
color: 'rgba(255,255,255,0.5)',
|
|
color: 'rgba(255,255,255,0.5)',
|
|
|
- width: 35,
|
|
|
|
|
|
|
+ width: rpxToPx(100),
|
|
|
start: status == 'WFS' ? getStartArc(new Date().getTime()) : getStartArc(info.time.start_timestamp),
|
|
start: status == 'WFS' ? getStartArc(new Date().getTime()) : getStartArc(info.time.start_timestamp),
|
|
|
duration: status == 'WFS' ? getDurationArc(new Date().getTime(), new Date().getTime() + info.time.duration) : getDurationArc(info.time.start_timestamp, info.time.start_timestamp + info.time.duration)
|
|
duration: status == 'WFS' ? getDurationArc(new Date().getTime(), new Date().getTime() + info.time.duration) : getDurationArc(info.time.start_timestamp, info.time.start_timestamp + info.time.duration)
|
|
|
}}
|
|
}}
|
|
|
real={status == 'WFS' ? null : {
|
|
real={status == 'WFS' ? null : {
|
|
|
color: MainColorType.orange,
|
|
color: MainColorType.orange,
|
|
|
- width: 35,
|
|
|
|
|
|
|
+ width: rpxToPx(100),
|
|
|
start: getStartArc(info.time.start_timestamp),
|
|
start: getStartArc(info.time.start_timestamp),
|
|
|
duration: getDurationArc(info.time.start_timestamp, new Date().getTime())
|
|
duration: getDurationArc(info.time.start_timestamp, new Date().getTime())
|
|
|
}}
|
|
}}
|
|
@@ -416,7 +485,7 @@ export default function TimeRecord() {
|
|
|
</View>
|
|
</View>
|
|
|
{
|
|
{
|
|
|
status == 'OG' && <View className="operate_content">
|
|
status == 'OG' && <View className="operate_content">
|
|
|
- <View className="operate_item" onClick={() => {
|
|
|
|
|
|
|
+ <View className="operate_item" style={{ backgroundColor: showHighlight ? '#ffffff80' : 'transparent' }} onClick={() => {
|
|
|
setShowDatePicker(true)
|
|
setShowDatePicker(true)
|
|
|
}}>
|
|
}}>
|
|
|
<View className="g02 h24">STARTED</View>
|
|
<View className="g02 h24">STARTED</View>
|
|
@@ -444,7 +513,7 @@ export default function TimeRecord() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- status == 'OG' && <NewButton
|
|
|
|
|
|
|
+ status == 'OG' && <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}><NewButton
|
|
|
type={NewButtonType.fill}
|
|
type={NewButtonType.fill}
|
|
|
title="End fasting"
|
|
title="End fasting"
|
|
|
width={rpxToPx(490)}
|
|
width={rpxToPx(490)}
|
|
@@ -452,6 +521,8 @@ export default function TimeRecord() {
|
|
|
color={MainColorType.orange}
|
|
color={MainColorType.orange}
|
|
|
onClick={end}
|
|
onClick={end}
|
|
|
/>
|
|
/>
|
|
|
|
|
+ <View onClick={more}>More</View>
|
|
|
|
|
+ </View>
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
status == 'OG' && <View className="share_icon">
|
|
status == 'OG' && <View className="share_icon">
|
|
@@ -517,22 +588,22 @@ export default function TimeRecord() {
|
|
|
{
|
|
{
|
|
|
shareUrl == '' && <View className="share_canvas">
|
|
shareUrl == '' && <View className="share_canvas">
|
|
|
<RingProgress
|
|
<RingProgress
|
|
|
- radius={125} canvasId="helloworld_share"
|
|
|
|
|
|
|
+ radius={rpxToPx(250)} canvasId="helloworld_share"
|
|
|
//scale={0.75}
|
|
//scale={0.75}
|
|
|
count={count}
|
|
count={count}
|
|
|
bgRing={{
|
|
bgRing={{
|
|
|
color: 'rgba(255,255,255,0.25)',
|
|
color: 'rgba(255,255,255,0.25)',
|
|
|
- width: 35
|
|
|
|
|
|
|
+ width: rpxToPx(100)
|
|
|
}}
|
|
}}
|
|
|
target={{
|
|
target={{
|
|
|
color: 'rgba(255,255,255,0.5)',
|
|
color: 'rgba(255,255,255,0.5)',
|
|
|
- width: 35,
|
|
|
|
|
|
|
+ width: rpxToPx(100),
|
|
|
start: status == 'WFS' ? getStartArc(new Date().getTime()) : getStartArc(info.time.start_timestamp),
|
|
start: status == 'WFS' ? getStartArc(new Date().getTime()) : getStartArc(info.time.start_timestamp),
|
|
|
duration: status == 'WFS' ? getDurationArc(new Date().getTime(), new Date().getTime() + info.time.duration) : getDurationArc(info.time.start_timestamp, info.time.start_timestamp + info.time.duration)
|
|
duration: status == 'WFS' ? getDurationArc(new Date().getTime(), new Date().getTime() + info.time.duration) : getDurationArc(info.time.start_timestamp, info.time.start_timestamp + info.time.duration)
|
|
|
}}
|
|
}}
|
|
|
real={status == 'WFS' ? null : {
|
|
real={status == 'WFS' ? null : {
|
|
|
color: MainColorType.orange,
|
|
color: MainColorType.orange,
|
|
|
- width: 35,
|
|
|
|
|
|
|
+ width: rpxToPx(100),
|
|
|
start: getStartArc(info.time.start_timestamp),
|
|
start: getStartArc(info.time.start_timestamp),
|
|
|
duration: getDurationArc(info.time.start_timestamp, new Date().getTime())
|
|
duration: getDurationArc(info.time.start_timestamp, new Date().getTime())
|
|
|
}}
|
|
}}
|
|
@@ -622,7 +693,7 @@ export default function TimeRecord() {
|
|
|
/>
|
|
/>
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
- showEndDatePicker && <PickerCard onClose={() => { setShowDatePicker(false) }}
|
|
|
|
|
|
|
+ showEndDatePicker && <PickerCard onClose={() => { setShowEndDatePicker(false) }}
|
|
|
value={info.time.end_timestamp}
|
|
value={info.time.end_timestamp}
|
|
|
type="datetime"
|
|
type="datetime"
|
|
|
onConfirm={(e) => {
|
|
onConfirm={(e) => {
|