|
|
@@ -25,6 +25,8 @@ export default function Move() {
|
|
|
const [index, setIndex] = useState(1)
|
|
|
const [hideCurrentRecent, setHideCurrentRecent] = useState(false)
|
|
|
const [moreActive, setMoreActive] = useState(false)
|
|
|
+ const [hours, setHours] = useState<any>([])
|
|
|
+ const [startDate,setStarteDate] = useState('')
|
|
|
const { t } = useTranslation()
|
|
|
const dispatch = useDispatch()
|
|
|
|
|
|
@@ -46,6 +48,11 @@ export default function Move() {
|
|
|
})
|
|
|
timer = setInterval(() => {
|
|
|
setCount((index) => index + 1)
|
|
|
+ const date = new Date()
|
|
|
+ if (date.getMinutes() == 10 && date.getSeconds() == 0) {
|
|
|
+ getMovesCurrent()
|
|
|
+ getMovesHistory()
|
|
|
+ }
|
|
|
}, 1000)
|
|
|
|
|
|
return () => {
|
|
|
@@ -57,6 +64,18 @@ export default function Move() {
|
|
|
getActiveMovesCurrent().then(res => {
|
|
|
setLoaded(true)
|
|
|
setData(res)
|
|
|
+ setStarteDate((res as any).start_date)
|
|
|
+ var array = (res as any).hours
|
|
|
+ var temps: any = []
|
|
|
+ for (var i = array.length - 1; i >= 0; i--) {
|
|
|
+ var obj = array[i]
|
|
|
+ if (obj.status != 'NOT_CHECK') {
|
|
|
+ temps.push(obj)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ setHours(temps)
|
|
|
+
|
|
|
+ // setHours((res as any).hours.reverse())
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -101,7 +120,6 @@ export default function Move() {
|
|
|
getWeRunData(false)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
function getWeRunData(autoCheck = false) {
|
|
|
if (autoCheck) {
|
|
|
return
|
|
|
@@ -136,6 +154,7 @@ export default function Move() {
|
|
|
encryptedData: (res as any).encryptedData,
|
|
|
iv: (res as any).iv,
|
|
|
},
|
|
|
+ start_date: startDate,
|
|
|
date: dayjs().format('YYYYMMDD'),
|
|
|
hour: hour,
|
|
|
timestamp: new Date().getTime(),
|
|
|
@@ -145,22 +164,73 @@ export default function Move() {
|
|
|
title: '上报成功',
|
|
|
icon: 'none'
|
|
|
})
|
|
|
+ getMovesCurrent()
|
|
|
+ getMovesHistory()
|
|
|
})
|
|
|
}).catch(_ => {
|
|
|
dispatch(setResult({ isSuccess: false }) as any)
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ function currentCheckHour() {
|
|
|
+ let currentHour = new Date().getHours()
|
|
|
+ const minute = new Date().getMinutes()
|
|
|
+ if (minute < 10) {
|
|
|
+ currentHour -= 1;
|
|
|
+ if (currentHour < 0) {
|
|
|
+ currentHour = 23
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return currentHour
|
|
|
+ }
|
|
|
+
|
|
|
+ function currentHourChecked() {
|
|
|
+ const currentHour = currentCheckHour()
|
|
|
+ var isChecked = false
|
|
|
+ data.hours.map((item) => {
|
|
|
+ if (item.hour == currentHour && item.status != 'NOT_CHECK') {
|
|
|
+ isChecked = true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return isChecked;
|
|
|
+ }
|
|
|
+
|
|
|
function getStatus() {
|
|
|
const minute = new Date().getMinutes()
|
|
|
if (minute >= 50 || minute < 10) {
|
|
|
+ var isChecked = currentHourChecked()
|
|
|
+ if (isChecked) {
|
|
|
+ return 'upcoming'
|
|
|
+ }
|
|
|
+
|
|
|
return 'open'
|
|
|
}
|
|
|
return 'upcoming'
|
|
|
}
|
|
|
|
|
|
function currentFootDesc() {
|
|
|
+ var isChecked = currentHourChecked()
|
|
|
const minute = new Date().getMinutes()
|
|
|
+
|
|
|
+ if (isChecked && (minute < 10 || minute >= 50)) {
|
|
|
+ let time = new Date()
|
|
|
+ time.setMinutes(50)
|
|
|
+ time.setSeconds(0)
|
|
|
+ time.setMilliseconds(0)
|
|
|
+
|
|
|
+ // 获取总秒数
|
|
|
+ const totalSeconds = Math.floor((time.getTime() + 3600 * 1000 - new Date().getTime()) / 1000);
|
|
|
+
|
|
|
+ // 计算小时、分钟和秒
|
|
|
+ // const hours = String(Math.floor(totalSeconds / 3600)).padStart(2, '0');
|
|
|
+ const minutes = String(Math.floor((totalSeconds % 3600) / 60)).padStart(2, '0');
|
|
|
+ const seconds = String(totalSeconds % 60).padStart(2, '0');
|
|
|
+
|
|
|
+ // return `${hours}:${minutes}:${seconds}`;
|
|
|
+ return `Opening soon ${minutes}:${seconds}`
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
const pre = new Date().getTime()
|
|
|
const next = new Date().getTime() + 3600 * 1000
|
|
|
if (minute >= 50) {
|
|
|
@@ -202,17 +272,39 @@ export default function Move() {
|
|
|
}
|
|
|
|
|
|
function getDuration() {
|
|
|
- const pre = new Date().getTime()
|
|
|
- const next = new Date().getTime() + 3600 * 1000
|
|
|
+ let now = new Date()
|
|
|
+ let pre = new Date().getTime()
|
|
|
+ if (now.getMinutes() < 10) {
|
|
|
+ pre -= 3600 * 1000
|
|
|
+ }
|
|
|
+ let next = pre + 3600 * 1000
|
|
|
+ if (currentHourChecked()) {
|
|
|
+ pre = next
|
|
|
+ next = pre + 3600 * 1000
|
|
|
+ }
|
|
|
return dayjs(pre).format('H:00') + '-' + dayjs(next).format('H:00')
|
|
|
}
|
|
|
|
|
|
+ function getCurrentTarget() {
|
|
|
+ let now = new Date()
|
|
|
+ let pre = new Date().getTime()
|
|
|
+ if (now.getMinutes() < 10) {
|
|
|
+ pre -= 3600 * 1000
|
|
|
+ }
|
|
|
+
|
|
|
+ if (currentHourChecked()){
|
|
|
+ pre += 3600*1000
|
|
|
+ }
|
|
|
+ const hour = new Date(pre).getHours()
|
|
|
+ for (var i = 0; i < data.hours.length; i++) {
|
|
|
+ if (data.hours[i].hour == hour) {
|
|
|
+ return `${data.hours[i].real_steps}/${data.hours[i].target_steps}`
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
function process() {
|
|
|
- let count = 0;
|
|
|
- data.hours.map(item => {
|
|
|
- // if (item.)
|
|
|
- })
|
|
|
- return `${count} / ${data.hours.length}`
|
|
|
+ return `${data.stat.real_hours} / ${data.stat.target_hours}`
|
|
|
}
|
|
|
|
|
|
function currentHourPeriod() {
|
|
|
@@ -228,6 +320,17 @@ export default function Move() {
|
|
|
return hour
|
|
|
}
|
|
|
|
|
|
+ function isExtra(){
|
|
|
+ const hour = currentHourPeriod()
|
|
|
+ var isFind = false
|
|
|
+ data.hours.map((item)=>{
|
|
|
+ if (item.hour==hour){
|
|
|
+ isFind = true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return !isFind
|
|
|
+ }
|
|
|
+
|
|
|
function currentContent() {
|
|
|
const hour = currentHourPeriod()
|
|
|
let info: any = null
|
|
|
@@ -240,8 +343,12 @@ export default function Move() {
|
|
|
return <View className="move-header">
|
|
|
<View className="header-current">
|
|
|
<View className="current_intro">
|
|
|
- <View style={{ color: new Date().getMinutes() < 10 ? getThemeColor(health.mode) : '#b2b2b2' }}>{getDuration()}</View>
|
|
|
- <Text>0/200 steps</Text>
|
|
|
+ <View style={{ color: (new Date().getMinutes() < 10 && getStatus()=='open') ? getThemeColor(health.mode) : '#b2b2b2' }}>{getDuration()}</View>
|
|
|
+ {
|
|
|
+ isExtra()?<Text style={{color:getThemeColor('SLEEP')}}>is extra</Text>:<Text>{getCurrentTarget()} steps</Text>
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
</View>
|
|
|
<View className="log_btn" style={{
|
|
|
backgroundColor: getStatus() == 'open' ? getThemeColor(health.mode) : '#6666661A',
|
|
|
@@ -251,7 +358,7 @@ export default function Move() {
|
|
|
</View>
|
|
|
<View className="current_footer">
|
|
|
<Text>{currentFootDesc()}</Text>
|
|
|
- <Text onClick={()=>{
|
|
|
+ <Text onClick={() => {
|
|
|
jumpPage(`/_health/pages/move_schedule?hours=${JSON.stringify(data.hours)}`)
|
|
|
}}>Show More</Text>
|
|
|
</View>
|
|
|
@@ -261,12 +368,16 @@ export default function Move() {
|
|
|
|
|
|
function currentHistory(item) {
|
|
|
var start = item.hour
|
|
|
+ var isYesterday = start > new Date().getHours()
|
|
|
var end = start + 1
|
|
|
start = (start + '').padStart(2, '0')
|
|
|
end = (end + '').padStart(2, '0')
|
|
|
return <View className="current_history_item">
|
|
|
<View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
|
- <Text className="current_item_period">{start}:00-{end}:00</Text>
|
|
|
+ <Text className="current_item_period">{isYesterday ? '昨天' : ''}{start}:00-{end}:00</Text>
|
|
|
+ {
|
|
|
+ item.is_extra && <Text style={{color:getThemeColor('SLEEP')}}>is Extra</Text>
|
|
|
+ }
|
|
|
<Text>{item.real_steps}/{item.target_steps}</Text>
|
|
|
</View>
|
|
|
|
|
|
@@ -283,15 +394,6 @@ export default function Move() {
|
|
|
</View>
|
|
|
}
|
|
|
|
|
|
- function activeCount() {
|
|
|
- var count = 0;
|
|
|
- data.hours.map(item => {
|
|
|
- if (item.status != 'NOT_CHECK') {
|
|
|
- count++
|
|
|
- }
|
|
|
- })
|
|
|
- return count
|
|
|
- }
|
|
|
|
|
|
function activeHour() {
|
|
|
|
|
|
@@ -311,8 +413,8 @@ export default function Move() {
|
|
|
{
|
|
|
!hideCurrentRecent && <View className="summary_content">
|
|
|
{
|
|
|
- data.hours.map((item, index) => {
|
|
|
- if (item.status == 'NOT_CHECK') return <View key={index} />
|
|
|
+ hours.map((item, index) => {
|
|
|
+ // if (item.status == 'NOT_CHECK') return <View key={index} />
|
|
|
if (index >= 3 && !moreActive) return <View key={index} />
|
|
|
return <View key={index}>
|
|
|
{
|
|
|
@@ -322,9 +424,9 @@ export default function Move() {
|
|
|
})
|
|
|
}
|
|
|
{
|
|
|
- activeCount() > 3 && <View className="recent_btn_bg">
|
|
|
+ hours.length > 3 && <View className="recent_btn_bg">
|
|
|
{
|
|
|
- moreActive ? <View className="recent_btn" onClick={() => setMoreActive(false)}>收起</View> : <View className="recent_btn" onClick={() => setMoreActive(true)}>展开剩余{activeCount() - 3}条</View>
|
|
|
+ moreActive ? <View className="recent_btn" onClick={() => setMoreActive(false)}>收起</View> : <View className="recent_btn" onClick={() => setMoreActive(true)}>展开剩余{hours.length - 3}条</View>
|
|
|
}
|
|
|
<View className="border_footer_line" />
|
|
|
</View>
|
|
|
@@ -353,6 +455,9 @@ export default function Move() {
|
|
|
|
|
|
return <View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
|
<Text className="move-title">Move Every Hour</Text>
|
|
|
+ <Text onClick={() => {
|
|
|
+ jumpPage('./move_setting')
|
|
|
+ }}>Setting</Text>
|
|
|
{
|
|
|
currentContent()
|
|
|
}
|