|
@@ -70,6 +70,8 @@ export default function Move() {
|
|
|
|
|
|
|
|
useDidShow(() => {
|
|
useDidShow(() => {
|
|
|
checkAuth()
|
|
checkAuth()
|
|
|
|
|
+ getMovesCurrent()
|
|
|
|
|
+ getMovesHistory()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
global.updateMove = () => {
|
|
global.updateMove = () => {
|
|
@@ -286,7 +288,7 @@ export default function Move() {
|
|
|
end = (end + '').padStart(2, '0')
|
|
end = (end + '').padStart(2, '0')
|
|
|
return <View className="current_history_item">
|
|
return <View className="current_history_item">
|
|
|
<View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
<View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
|
- <Text className="current_item_period">{isYesterday ? '昨天' : ''}{start}:00-{end}:00</Text>
|
|
|
|
|
|
|
+ <Text className="current_item_period">{start}:00-{end}:00</Text>
|
|
|
{
|
|
{
|
|
|
item.is_extra && <Text style={{ color: getThemeColor('SLEEP') }}>is Extra</Text>
|
|
item.is_extra && <Text style={{ color: getThemeColor('SLEEP') }}>is Extra</Text>
|
|
|
}
|
|
}
|
|
@@ -313,13 +315,13 @@ export default function Move() {
|
|
|
return <View className="summary">
|
|
return <View className="summary">
|
|
|
<View className="summary_header">
|
|
<View className="summary_header">
|
|
|
<Text>Last {hours.length} Hour{hours.length == 1 ? '' : 's'}</Text>
|
|
<Text>Last {hours.length} Hour{hours.length == 1 ? '' : 's'}</Text>
|
|
|
- <Image className="arrow_hide"
|
|
|
|
|
|
|
+ {/* <Image className="arrow_hide"
|
|
|
onClick={() => {
|
|
onClick={() => {
|
|
|
setHideCurrentRecent(!hideCurrentRecent)
|
|
setHideCurrentRecent(!hideCurrentRecent)
|
|
|
}}
|
|
}}
|
|
|
src={hideCurrentRecent ? require('@assets/_health/arrow_down.png') : require('@assets/_health/arrow_up.png')} />
|
|
src={hideCurrentRecent ? require('@assets/_health/arrow_down.png') : require('@assets/_health/arrow_up.png')} />
|
|
|
<View style={{ flex: 1 }} />
|
|
<View style={{ flex: 1 }} />
|
|
|
- <Text style={{ color: getThemeColor(health.mode) }}>{process()}</Text>
|
|
|
|
|
|
|
+ <Text style={{ color: getThemeColor(health.mode) }}>{process()}</Text> */}
|
|
|
<View className="border_footer_line" />
|
|
<View className="border_footer_line" />
|
|
|
</View>
|
|
</View>
|
|
|
{
|
|
{
|
|
@@ -355,7 +357,45 @@ export default function Move() {
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function formatTimeInterval(startTimestamp, endTimestamp) {
|
|
|
|
|
+ // 计算时间间隔(以秒为单位)
|
|
|
|
|
+ const intervalSeconds = Math.floor((endTimestamp - startTimestamp) / 1000);
|
|
|
|
|
+
|
|
|
|
|
+ // 处理负值的情况
|
|
|
|
|
+ if (intervalSeconds < 0) {
|
|
|
|
|
+ throw new Error("End timestamp must be greater than start timestamp");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 如果时间间隔大于1小时
|
|
|
|
|
+ if (intervalSeconds >= 3600) {
|
|
|
|
|
+ const hours = Math.floor(intervalSeconds / 3600);
|
|
|
|
|
+ const minutes = Math.floor((intervalSeconds % 3600) / 60);
|
|
|
|
|
+ const seconds = intervalSeconds % 60;
|
|
|
|
|
+
|
|
|
|
|
+ return `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 如果时间间隔小于1小时
|
|
|
|
|
+ const minutes = Math.floor(intervalSeconds / 60);
|
|
|
|
|
+ const seconds = intervalSeconds % 60;
|
|
|
|
|
+
|
|
|
|
|
+ return `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
function consoleFooter() {
|
|
function consoleFooter() {
|
|
|
|
|
+ if (isExtra()) {
|
|
|
|
|
+ var now = new Date()
|
|
|
|
|
+ var target = new Date()
|
|
|
|
|
+ target.setHours(data.hours[0].hour)
|
|
|
|
|
+ target.setMinutes(50)
|
|
|
|
|
+ target.setSeconds(0)
|
|
|
|
|
+ target.setMilliseconds(0)
|
|
|
|
|
+ var timestamp = target.getTime()
|
|
|
|
|
+ if (now.getTime()>timestamp){
|
|
|
|
|
+ timestamp += 24*3600*1000
|
|
|
|
|
+ }
|
|
|
|
|
+ return <Text className="console_footer">{formatTimeInterval(new Date().getTime(),timestamp)}</Text>
|
|
|
|
|
+ }
|
|
|
if (getStatus() == 'open') {
|
|
if (getStatus() == 'open') {
|
|
|
if (new Date().getMinutes() < 10) {
|
|
if (new Date().getMinutes() < 10) {
|
|
|
let time = new Date()
|
|
let time = new Date()
|
|
@@ -378,9 +418,6 @@ export default function Move() {
|
|
|
const next = new Date().getTime() + 3600 * 1000
|
|
const next = new Date().getTime() + 3600 * 1000
|
|
|
return <Text className="console_footer">Check In available {dayjs(pre).format('HH:50')}-{dayjs(next).format('HH:10')}</Text>
|
|
return <Text className="console_footer">Check In available {dayjs(pre).format('HH:50')}-{dayjs(next).format('HH:10')}</Text>
|
|
|
}
|
|
}
|
|
|
- else if (isExtra()) {
|
|
|
|
|
- return <Text className="console_footer">to do 倒计时</Text>
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
const minute = new Date().getMinutes()
|
|
const minute = new Date().getMinutes()
|
|
|
var isChecked = currentHourChecked()
|
|
var isChecked = currentHourChecked()
|
|
@@ -418,49 +455,39 @@ export default function Move() {
|
|
|
return <Text className="console_footer">Opening soon {minutes}:{seconds}</Text>
|
|
return <Text className="console_footer">Opening soon {minutes}:{seconds}</Text>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function hoursPassed(timeStr) {
|
|
|
|
|
- // 获取当前时间
|
|
|
|
|
- const now = new Date();
|
|
|
|
|
-
|
|
|
|
|
- // 解析输入时间字符串
|
|
|
|
|
- const [hours, minutes] = timeStr.split(':').map(Number);
|
|
|
|
|
-
|
|
|
|
|
- // 创建一个 Date 对象,设置为今天的输入时间
|
|
|
|
|
- const inputTime = new Date(now.getFullYear(), now.getMonth(), now.getDate(), hours, minutes);
|
|
|
|
|
-
|
|
|
|
|
- // 如果输入时间在当前时间之后,假设它是前一天的时间
|
|
|
|
|
- if (inputTime > now) {
|
|
|
|
|
- inputTime.setDate(inputTime.getDate() - 1);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 计算时间差(以毫秒为单位)
|
|
|
|
|
- const timeDiff = now.getTime() - inputTime.getTime();
|
|
|
|
|
|
|
+ function hourIndex() {
|
|
|
|
|
+ const { time_slots } = data.period
|
|
|
|
|
+ const str = getDuration()
|
|
|
|
|
+ const hour = parseInt(str.substring(0, 2))
|
|
|
|
|
|
|
|
- // 将时间差转换为小时,最大为 23 小时
|
|
|
|
|
- const hours2 = Math.min(Math.floor(timeDiff / (1000 * 60 * 60)), 23);
|
|
|
|
|
|
|
+ var selItem: any = null
|
|
|
|
|
|
|
|
- return hours2 + 1;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ time_slots.map((item) => {
|
|
|
|
|
+ if (item.hour == hour) {
|
|
|
|
|
+ selItem = item;
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
|
|
|
- function hourIndex() {
|
|
|
|
|
- const { start_time, end_time } = data.time_range
|
|
|
|
|
- if (isExtra()) {
|
|
|
|
|
- return hoursPassed(end_time)
|
|
|
|
|
- }
|
|
|
|
|
- return hoursPassed(start_time)
|
|
|
|
|
|
|
+ return <View className="summary_status_bg">
|
|
|
|
|
+ <View className="summary_status_point" style={{ backgroundColor: selItem.type == 'SLEEP' ? getThemeColor('SLEEP') : getThemeColor('ACTIVE') }} />
|
|
|
|
|
+ <Text className="summary_status_text">{selItem.type == 'SLEEP' ? 'SLEEP HOUR ' : 'WAKING HOUR '}{selItem.index}</Text>
|
|
|
|
|
+ </View>
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function becomeTime() {
|
|
function becomeTime() {
|
|
|
var hour = new Date().getHours()
|
|
var hour = new Date().getHours()
|
|
|
var tHour = parseInt(getDuration().substring(0, 2))
|
|
var tHour = parseInt(getDuration().substring(0, 2))
|
|
|
|
|
+ if (isExtra()){
|
|
|
|
|
+ tHour = data.hours[0].hour
|
|
|
|
|
+ }
|
|
|
if (hour > tHour) {
|
|
if (hour > tHour) {
|
|
|
return `Check in begins at ${getDuration().substring(0, 2)}:50 tomorrow`
|
|
return `Check in begins at ${getDuration().substring(0, 2)}:50 tomorrow`
|
|
|
}
|
|
}
|
|
|
return `Check in begins at ${getDuration().substring(0, 2)}:50`
|
|
return `Check in begins at ${getDuration().substring(0, 2)}:50`
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function console() {
|
|
|
|
|
|
|
+ function consolePanel() {
|
|
|
|
|
|
|
|
if (!allowRun) {
|
|
if (!allowRun) {
|
|
|
return <View className="move_console">
|
|
return <View className="move_console">
|
|
@@ -473,10 +500,11 @@ export default function Move() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return <View className="move_console">
|
|
return <View className="move_console">
|
|
|
- <View className="summary_status_bg">
|
|
|
|
|
|
|
+ {/* <View className="summary_status_bg">
|
|
|
<View className="summary_status_point" style={{ backgroundColor: isExtra() ? getThemeColor('SLEEP') : getThemeColor('ACTIVE') }} />
|
|
<View className="summary_status_point" style={{ backgroundColor: isExtra() ? getThemeColor('SLEEP') : getThemeColor('ACTIVE') }} />
|
|
|
<Text className="summary_status_text">{isExtra() ? 'SLEEP HOUR ' : 'WAKING HOUR '}{hourIndex()}</Text>
|
|
<Text className="summary_status_text">{isExtra() ? 'SLEEP HOUR ' : 'WAKING HOUR '}{hourIndex()}</Text>
|
|
|
- </View>
|
|
|
|
|
|
|
+ </View> */}
|
|
|
|
|
+ {hourIndex()}
|
|
|
<Text className="console_duration">{getDuration()}</Text>
|
|
<Text className="console_duration">{getDuration()}</Text>
|
|
|
<Text className="console_desc" style={{
|
|
<Text className="console_desc" style={{
|
|
|
color: isExtra() ? getThemeColor('SLEEP') : getThemeColor('ACTIVE'),
|
|
color: isExtra() ? getThemeColor('SLEEP') : getThemeColor('ACTIVE'),
|
|
@@ -485,7 +513,7 @@ export default function Move() {
|
|
|
isExtra() ? 'Sleep well.' : getStatus() == 'open' ? `Think you've hit ${getCurrentTarget()} steps this hour?` : `Hit ${getCurrentTarget()} steps within the hour`
|
|
isExtra() ? 'Sleep well.' : getStatus() == 'open' ? `Think you've hit ${getCurrentTarget()} steps this hour?` : `Hit ${getCurrentTarget()} steps within the hour`
|
|
|
}</Text>
|
|
}</Text>
|
|
|
{
|
|
{
|
|
|
- getStatus() == 'open' ? <View className="console_checkbtn"
|
|
|
|
|
|
|
+ isExtra() ?<View className="console_checkbtn">{becomeTime()}</View>:getStatus() == 'open' ? <View className="console_checkbtn"
|
|
|
onClick={tapLog}
|
|
onClick={tapLog}
|
|
|
style={{ color: '#fff', backgroundColor: getThemeColor('ACTIVE') }}>I Think So!</View> :
|
|
style={{ color: '#fff', backgroundColor: getThemeColor('ACTIVE') }}>I Think So!</View> :
|
|
|
<View className="console_checkbtn" onClick={tapLog}>{becomeTime()}</View>
|
|
<View className="console_checkbtn" onClick={tapLog}>{becomeTime()}</View>
|
|
@@ -560,12 +588,16 @@ export default function Move() {
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function goDetail(item) {
|
|
|
|
|
+ jumpPage('./move_detail?id='+item.id)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (!loaded || !loadAuth) return <View />
|
|
if (!loaded || !loadAuth) return <View />
|
|
|
|
|
|
|
|
return <View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
return <View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
|
<Text className="move-title">Move Every Hour</Text>
|
|
<Text className="move-title">Move Every Hour</Text>
|
|
|
{
|
|
{
|
|
|
- console()
|
|
|
|
|
|
|
+ consolePanel()
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
tools()
|
|
tools()
|
|
@@ -585,11 +617,11 @@ export default function Move() {
|
|
|
</View>
|
|
</View>
|
|
|
{
|
|
{
|
|
|
list.map((item, index) => {
|
|
list.map((item, index) => {
|
|
|
- return <View key={index} className="history_item">
|
|
|
|
|
|
|
+ return <View key={index} className="history_item" onClick={() => goDetail(item)}>
|
|
|
<Text className="history_item_date">{(item.date + '').substring(6, 8)}</Text>
|
|
<Text className="history_item_date">{(item.date + '').substring(6, 8)}</Text>
|
|
|
<View className="history_item_detail_bg">
|
|
<View className="history_item_detail_bg">
|
|
|
<Image className="history_item_detail_icon" src={require('@assets/_health/walk.png')} />
|
|
<Image className="history_item_detail_icon" src={require('@assets/_health/walk.png')} />
|
|
|
- <Text>每小时活动 {item.real_hours}/{item.target_hours} · Steps {item.stat.real_steps}/{item.stat.target_steps}</Text>
|
|
|
|
|
|
|
+ <Text> Hours Active {item.active_hours} · Total Steps {item.stat.real_steps}</Text>
|
|
|
</View>
|
|
</View>
|
|
|
<View className="border_footer_line" />
|
|
<View className="border_footer_line" />
|
|
|
</View>
|
|
</View>
|