|
@@ -2,29 +2,67 @@ import { View, Text } from "@tarojs/components";
|
|
|
import './MetricHistory.scss'
|
|
import './MetricHistory.scss'
|
|
|
|
|
|
|
|
export default function Component(props: { records: any[] }) {
|
|
export default function Component(props: { records: any[] }) {
|
|
|
- return <View style={{display:'flex',flexDirection:'column'}}>
|
|
|
|
|
|
|
+ function formateDate(date: string) {
|
|
|
|
|
+ debugger
|
|
|
|
|
+ //yyyyMMdd转换成日期,如果是今天,返回今天,如果是昨天,返回昨天,如果是昨天之前,返回日期
|
|
|
|
|
+ const dt = new Date(date.substring(0,4) + '/' +
|
|
|
|
|
+ date.substring(4,6) + '/' +
|
|
|
|
|
+ date.substring(6));
|
|
|
|
|
+
|
|
|
|
|
+ const now = new Date();
|
|
|
|
|
+
|
|
|
|
|
+ const diff = now.getTime() - dt.getTime();
|
|
|
|
|
+ const day = 1000 * 60 * 60 * 24;
|
|
|
|
|
+
|
|
|
|
|
+ if (diff < day) {
|
|
|
|
|
+ return '今天';
|
|
|
|
|
+ } else if (diff < 2 * day) {
|
|
|
|
|
+ return '昨天';
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return dt.toISOString().slice(0, 10);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ function formateHourMinutes(timestamp: number) {
|
|
|
|
|
+ var date = new Date(timestamp)
|
|
|
|
|
+ var hour = date.getHours()
|
|
|
|
|
+ var minutes = date.getMinutes()
|
|
|
|
|
+ return `${hour < 10 ? '0' + hour : hour}:${minutes < 10 ? '0' + minutes : minutes}`
|
|
|
|
|
+ }
|
|
|
|
|
+ return <View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
|
<View className="operate_view">
|
|
<View className="operate_view">
|
|
|
<Text>时间倒序</Text>
|
|
<Text>时间倒序</Text>
|
|
|
<Text style={{ marginLeft: 5, marginRight: 5 }}> | </Text>
|
|
<Text style={{ marginLeft: 5, marginRight: 5 }}> | </Text>
|
|
|
<Text>时间正序</Text>
|
|
<Text>时间正序</Text>
|
|
|
</View>
|
|
</View>
|
|
|
- <Text className="operate_day">今天</Text>
|
|
|
|
|
- <View className="operate_item">
|
|
|
|
|
- <View className="status_bg">
|
|
|
|
|
- <Text className="status_text">总计</Text>
|
|
|
|
|
- </View>
|
|
|
|
|
- <Text className="value">8888</Text>
|
|
|
|
|
- <Text className="unit">步</Text>
|
|
|
|
|
- <View style={{flex:1}}/>
|
|
|
|
|
- <Text className="time">刚刚</Text>
|
|
|
|
|
- </View>
|
|
|
|
|
- <View className="operate_item">
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ (props.records as any).map(item => {
|
|
|
|
|
+ return <View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
|
|
|
+ <Text className="operate_day">{formateDate(item.date+'')}</Text>
|
|
|
|
|
+ {
|
|
|
|
|
+ item.records.map(record => {
|
|
|
|
|
+ return <View className="operate_item">
|
|
|
|
|
+ <View className="status_bg">
|
|
|
|
|
+ <Text className="status_text">{record.type == 'total' ? '总计' : record.type == 'sync' ? '同步' : '打卡'}</Text>
|
|
|
|
|
+ </View>
|
|
|
|
|
+ <Text className="value">{record.items[0].value}</Text>
|
|
|
|
|
+ <Text className="unit">步</Text>
|
|
|
|
|
+ <View style={{ flex: 1 }} />
|
|
|
|
|
+ <Text className="time">{formateHourMinutes(record.timestamp)}</Text>
|
|
|
|
|
+ </View>
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ </View>
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ {/* <View className="operate_item">
|
|
|
<View className="status_bg">
|
|
<View className="status_bg">
|
|
|
<Text className="status_text">总计</Text>
|
|
<Text className="status_text">总计</Text>
|
|
|
</View>
|
|
</View>
|
|
|
<Text className="value">8888</Text>
|
|
<Text className="value">8888</Text>
|
|
|
<Text className="unit">步</Text>
|
|
<Text className="unit">步</Text>
|
|
|
- <View style={{flex:1}}/>
|
|
|
|
|
|
|
+ <View style={{ flex: 1 }} />
|
|
|
<Text className="time">刚刚</Text>
|
|
<Text className="time">刚刚</Text>
|
|
|
</View>
|
|
</View>
|
|
|
<View className="operate_item">
|
|
<View className="operate_item">
|
|
@@ -33,7 +71,7 @@ export default function Component(props: { records: any[] }) {
|
|
|
</View>
|
|
</View>
|
|
|
<Text className="value">8888</Text>
|
|
<Text className="value">8888</Text>
|
|
|
<Text className="unit">步</Text>
|
|
<Text className="unit">步</Text>
|
|
|
- <View style={{flex:1}}/>
|
|
|
|
|
|
|
+ <View style={{ flex: 1 }} />
|
|
|
<Text className="time">刚刚</Text>
|
|
<Text className="time">刚刚</Text>
|
|
|
</View>
|
|
</View>
|
|
|
<View className="operate_item">
|
|
<View className="operate_item">
|
|
@@ -42,8 +80,8 @@ export default function Component(props: { records: any[] }) {
|
|
|
</View>
|
|
</View>
|
|
|
<Text className="value">8888</Text>
|
|
<Text className="value">8888</Text>
|
|
|
<Text className="unit">步</Text>
|
|
<Text className="unit">步</Text>
|
|
|
- <View style={{flex:1}}/>
|
|
|
|
|
|
|
+ <View style={{ flex: 1 }} />
|
|
|
<Text className="time">刚刚</Text>
|
|
<Text className="time">刚刚</Text>
|
|
|
- </View>
|
|
|
|
|
|
|
+ </View> */}
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|