|
@@ -20,8 +20,10 @@ import { MainColorType } from "@/context/themes/color";
|
|
|
import StatusIndicator, { StatusType } from "../base/status_indicator";
|
|
import StatusIndicator, { StatusType } from "../base/status_indicator";
|
|
|
import showActionSheet from "@/components/basic/ActionSheet";
|
|
import showActionSheet from "@/components/basic/ActionSheet";
|
|
|
import ListFooter from "../components/list_footer";
|
|
import ListFooter from "../components/list_footer";
|
|
|
|
|
+import StickyDateList from "../components/sticky_date_list";
|
|
|
|
|
|
|
|
let timer
|
|
let timer
|
|
|
|
|
+let myScrollTop = 0
|
|
|
export default function Move() {
|
|
export default function Move() {
|
|
|
const health = useSelector((state: any) => state.health);
|
|
const health = useSelector((state: any) => state.health);
|
|
|
const [allowRun, setAllowRun] = useState(false)
|
|
const [allowRun, setAllowRun] = useState(false)
|
|
@@ -36,20 +38,29 @@ export default function Move() {
|
|
|
const [moreActive, setMoreActive] = useState(false)
|
|
const [moreActive, setMoreActive] = useState(false)
|
|
|
const [hours, setHours] = useState<any>([])
|
|
const [hours, setHours] = useState<any>([])
|
|
|
const [startDate, setStarteDate] = useState('')
|
|
const [startDate, setStarteDate] = useState('')
|
|
|
|
|
+
|
|
|
|
|
+ const [isPulling, setIsPulling] = useState(false)
|
|
|
|
|
+ const [itemLayouts, setItemLayouts] = useState<any>([])
|
|
|
|
|
+ const [showDate, setShowDate] = useState(false)
|
|
|
|
|
+ const [date, setDate] = useState('')
|
|
|
|
|
+ const [page, setPage] = useState(1)
|
|
|
|
|
+ const [loading, setLoading] = useState(false)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
let navigation, showActionSheetWithOptions;
|
|
let navigation, showActionSheetWithOptions;
|
|
|
const { t } = useTranslation()
|
|
const { t } = useTranslation()
|
|
|
const dispatch = useDispatch()
|
|
const dispatch = useDispatch()
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
getMovesCurrent()
|
|
getMovesCurrent()
|
|
|
- getMovesHistory()
|
|
|
|
|
|
|
+ getMovesHistory(1)
|
|
|
checkAuth()
|
|
checkAuth()
|
|
|
timer = setInterval(() => {
|
|
timer = setInterval(() => {
|
|
|
setCount((index) => index + 1)
|
|
setCount((index) => index + 1)
|
|
|
const date = new Date()
|
|
const date = new Date()
|
|
|
if (date.getMinutes() == 10 && date.getSeconds() == 0) {
|
|
if (date.getMinutes() == 10 && date.getSeconds() == 0) {
|
|
|
getMovesCurrent()
|
|
getMovesCurrent()
|
|
|
- getMovesHistory()
|
|
|
|
|
|
|
+ getMovesHistory(1)
|
|
|
}
|
|
}
|
|
|
}, 1000)
|
|
}, 1000)
|
|
|
|
|
|
|
@@ -58,6 +69,30 @@ export default function Move() {
|
|
|
}
|
|
}
|
|
|
}, [])
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ if (list.length > 0) {
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ measureItemLayouts()
|
|
|
|
|
+ }, 500)
|
|
|
|
|
+ }
|
|
|
|
|
+ }, [list])
|
|
|
|
|
+
|
|
|
|
|
+ function measureItemLayouts() {
|
|
|
|
|
+ const query = Taro.createSelectorQuery()
|
|
|
|
|
+ list.forEach((item, index) => {
|
|
|
|
|
+ query.select(`#history-${index}`).boundingClientRect()
|
|
|
|
|
+ });
|
|
|
|
|
+ query.exec((res) => {
|
|
|
|
|
+ var layouts: any = []
|
|
|
|
|
+ res.forEach((rect, index) => {
|
|
|
|
|
+ if (rect) {
|
|
|
|
|
+ layouts[index] = rect.top + myScrollTop
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ setItemLayouts(layouts)
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
function checkAuth() {
|
|
function checkAuth() {
|
|
|
Taro.getSetting({
|
|
Taro.getSetting({
|
|
|
success: res => {
|
|
success: res => {
|
|
@@ -78,12 +113,12 @@ export default function Move() {
|
|
|
useDidShow(() => {
|
|
useDidShow(() => {
|
|
|
checkAuth()
|
|
checkAuth()
|
|
|
getMovesCurrent()
|
|
getMovesCurrent()
|
|
|
- getMovesHistory()
|
|
|
|
|
|
|
+ getMovesHistory(1)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
global.updateMove = () => {
|
|
global.updateMove = () => {
|
|
|
getMovesCurrent()
|
|
getMovesCurrent()
|
|
|
- getMovesHistory()
|
|
|
|
|
|
|
+ getMovesHistory(1)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function getMovesCurrent() {
|
|
function getMovesCurrent() {
|
|
@@ -105,18 +140,63 @@ export default function Move() {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function getMovesHistory() {
|
|
|
|
|
- getActiveMoves().then(res => {
|
|
|
|
|
- if (index == 1) {
|
|
|
|
|
|
|
+ function getMovesHistory(page) {
|
|
|
|
|
+ setIndex(page)
|
|
|
|
|
+ setIsPulling(true)
|
|
|
|
|
+ setLoading(true)
|
|
|
|
|
+ getActiveMoves({
|
|
|
|
|
+ page: page,
|
|
|
|
|
+ limit: 10,
|
|
|
|
|
+ }
|
|
|
|
|
+ ).then(res => {
|
|
|
|
|
+ if (page == 1) {
|
|
|
setList((res as any).data)
|
|
setList((res as any).data)
|
|
|
setTotal((res as any).total)
|
|
setTotal((res as any).total)
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
setList([...list, ...(res as any).data])
|
|
setList([...list, ...(res as any).data])
|
|
|
}
|
|
}
|
|
|
|
|
+ setIsPulling(false)
|
|
|
|
|
+ setLoading(false)
|
|
|
|
|
+
|
|
|
|
|
+ }).catch(e => {
|
|
|
|
|
+ setLoading(false)
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function more() {
|
|
|
|
|
+ if (loading) return;
|
|
|
|
|
+ if (total == list.length) return;
|
|
|
|
|
+ var index = page;
|
|
|
|
|
+ index++;
|
|
|
|
|
+ setPage(index)
|
|
|
|
|
+ getMovesHistory(index)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function onScroll(e) {
|
|
|
|
|
+ var top = e.detail.scrollTop
|
|
|
|
|
+ myScrollTop = top
|
|
|
|
|
+ if (itemLayouts.length > 0) {
|
|
|
|
|
+ var i = -1
|
|
|
|
|
+ var date = ''
|
|
|
|
|
+ list.forEach((item, index) => {
|
|
|
|
|
+ if (top >= itemLayouts[index] - 50) {
|
|
|
|
|
+ i = index
|
|
|
|
|
+ var currentDate = (list[index].date + '').substring(0, 6)
|
|
|
|
|
+
|
|
|
|
|
+ date = currentDate.substring(0, 4) + '年' + currentDate.substring(4, 6) + '月'
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ setShowDate(i != -1)
|
|
|
|
|
+ setDate(date)
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ setShowDate(false)
|
|
|
|
|
+ setDate('')
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
function tapLog() {
|
|
function tapLog() {
|
|
|
// if (getStatus() != 'open') {
|
|
// if (getStatus() != 'open') {
|
|
@@ -191,7 +271,7 @@ export default function Move() {
|
|
|
// console.log('move result')
|
|
// console.log('move result')
|
|
|
jumpPage('./post_result?data=' + JSON.stringify((res as any).post_result))
|
|
jumpPage('./post_result?data=' + JSON.stringify((res as any).post_result))
|
|
|
getMovesCurrent()
|
|
getMovesCurrent()
|
|
|
- getMovesHistory()
|
|
|
|
|
|
|
+ getMovesHistory(1)
|
|
|
})
|
|
})
|
|
|
}).catch(_ => {
|
|
}).catch(_ => {
|
|
|
dispatch(setResult({ isSuccess: false }) as any)
|
|
dispatch(setResult({ isSuccess: false }) as any)
|
|
@@ -222,7 +302,7 @@ export default function Move() {
|
|
|
}
|
|
}
|
|
|
jumpPage('./post_result?data=' + JSON.stringify((res as any).post_result))
|
|
jumpPage('./post_result?data=' + JSON.stringify((res as any).post_result))
|
|
|
getMovesCurrent()
|
|
getMovesCurrent()
|
|
|
- getMovesHistory()
|
|
|
|
|
|
|
+ getMovesHistory(1)
|
|
|
})
|
|
})
|
|
|
}).catch(_ => {
|
|
}).catch(_ => {
|
|
|
dispatch(setResult({ isSuccess: false }) as any)
|
|
dispatch(setResult({ isSuccess: false }) as any)
|
|
@@ -349,10 +429,10 @@ export default function Move() {
|
|
|
item.status == 'MISSED' && <Text className="missed">Missed</Text>
|
|
item.status == 'MISSED' && <Text className="missed">Missed</Text>
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
- item.status == 'SEDENTARY' && <IconSit width={rpxToPx(44)} color={MainColorType.g02}/>
|
|
|
|
|
|
|
+ item.status == 'SEDENTARY' && <IconSit width={rpxToPx(44)} color={MainColorType.g02} />
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
- item.status == 'ACTIVE' && <IconWalk width={rpxToPx(44)} color={MainColorType.active}/>
|
|
|
|
|
|
|
+ item.status == 'ACTIVE' && <IconWalk width={rpxToPx(44)} color={MainColorType.active} />
|
|
|
}
|
|
}
|
|
|
<View className="border_footer_line" />
|
|
<View className="border_footer_line" />
|
|
|
</View>
|
|
</View>
|
|
@@ -697,45 +777,66 @@ export default function Move() {
|
|
|
jumpPage('./move_detail?id=' + item.id)
|
|
jumpPage('./move_detail?id=' + item.id)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (!loaded || !loadAuth) return <View />
|
|
|
|
|
|
|
+ function historyDate(){
|
|
|
|
|
+ return '22'
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return <View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
|
|
|
- <NewHeader type={NewHeaderType.left} title="Move Every Hour" />
|
|
|
|
|
- {
|
|
|
|
|
- consolePanel()
|
|
|
|
|
- }
|
|
|
|
|
- {
|
|
|
|
|
- tools()
|
|
|
|
|
- }
|
|
|
|
|
- {
|
|
|
|
|
- summary()
|
|
|
|
|
- }
|
|
|
|
|
- {
|
|
|
|
|
- activeHour()
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ function historyMonth(){
|
|
|
|
|
+ return 'May'
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- {
|
|
|
|
|
- list.length > 0 && <View className="history">
|
|
|
|
|
- <View className="history_header">
|
|
|
|
|
- <Text className="h50 bold">Recent</Text>
|
|
|
|
|
- <View className="border_footer_line" />
|
|
|
|
|
- </View>
|
|
|
|
|
- {
|
|
|
|
|
- list.map((item, index) => {
|
|
|
|
|
- return <View key={index} className="history_item" onClick={() => goDetail(item)}>
|
|
|
|
|
- <Text className="history_item_date">{(item.date + '').substring(6, 8)}</Text>
|
|
|
|
|
- <View className="history_item_detail_bg">
|
|
|
|
|
- <IconWalk width={rpxToPx(32)} color={MainColorType.active}/>
|
|
|
|
|
- <Text style={{ fontSize: rpxToPx(26),marginLeft:rpxToPx(16) }}> Hours Active {item.active_hours} · Total Steps {item.stat.real_steps}</Text>
|
|
|
|
|
|
|
+ if (!loaded || !loadAuth) return <View />
|
|
|
|
|
+ return <StickyDateList onRefresherRefresh={() => {
|
|
|
|
|
+ setIsPulling(true)
|
|
|
|
|
+ setPage(1)
|
|
|
|
|
+ getMovesHistory(1)
|
|
|
|
|
+ }} isPulling={isPulling}
|
|
|
|
|
+ onScroll={onScroll}
|
|
|
|
|
+ showDate={showDate}
|
|
|
|
|
+ date={date}
|
|
|
|
|
+ loadMore={more}>
|
|
|
|
|
+
|
|
|
|
|
+ <View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
|
|
|
+ <NewHeader type={NewHeaderType.left} title="Move Every Hour" />
|
|
|
|
|
+ {
|
|
|
|
|
+ consolePanel()
|
|
|
|
|
+ }
|
|
|
|
|
+ {
|
|
|
|
|
+ tools()
|
|
|
|
|
+ }
|
|
|
|
|
+ {
|
|
|
|
|
+ summary()
|
|
|
|
|
+ }
|
|
|
|
|
+ {
|
|
|
|
|
+ activeHour()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ {
|
|
|
|
|
+ list.length > 0 && <View className="history">
|
|
|
|
|
+ <View className="history_header">
|
|
|
|
|
+ <Text className="h42 bold">{t('health.recents')}</Text>
|
|
|
|
|
+ </View>
|
|
|
|
|
+ {
|
|
|
|
|
+ list.map((item, index) => {
|
|
|
|
|
+ return <View key={index} id={`history-${index}`} className="history_item" onClick={() => goDetail(item)}>
|
|
|
|
|
+ {/* <Text className="history_item_date">{(item.date + '').substring(6, 8)}</Text> */}
|
|
|
|
|
+ <View className="cell_date" >
|
|
|
|
|
+ <View className="h42 bold" style={{ lineHeight: rpxToPx(60) + 'px' }}>{historyDate()}</View>
|
|
|
|
|
+ <View className="h24 bold" style={{ marginLeft: rpxToPx(6), marginTop: rpxToPx(11), lineHeight: rpxToPx(49) + 'px' }}>{historyMonth()}</View>
|
|
|
|
|
+ </View>
|
|
|
|
|
+ <View className="history_item_detail_bg">
|
|
|
|
|
+ <IconWalk width={rpxToPx(32)} color={MainColorType.active} />
|
|
|
|
|
+ <Text style={{ fontSize: rpxToPx(26), marginLeft: rpxToPx(16) }}> Hours Active {item.active_hours} · Total Steps {item.stat.real_steps}</Text>
|
|
|
|
|
+ </View>
|
|
|
|
|
+ {/* <View className="border_footer_line" /> */}
|
|
|
</View>
|
|
</View>
|
|
|
- {/* <View className="border_footer_line" /> */}
|
|
|
|
|
- </View>
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- </View>
|
|
|
|
|
- }
|
|
|
|
|
- <ListFooter noMore={(list.length > 0) && (total == list.length)} />
|
|
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ </View>
|
|
|
|
|
+ }
|
|
|
|
|
+ <ListFooter noMore={(list.length > 0) && (total == list.length)} />
|
|
|
|
|
|
|
|
|
|
|
|
|
- </View>
|
|
|
|
|
|
|
+ </View>
|
|
|
|
|
+ </StickyDateList>
|
|
|
}
|
|
}
|