|
@@ -7,6 +7,7 @@ import Taro from "@tarojs/taro";
|
|
|
import { useTranslation } from "react-i18next";
|
|
import { useTranslation } from "react-i18next";
|
|
|
import { deleteWorkoutRecord } from "@/services/workout";
|
|
import { deleteWorkoutRecord } from "@/services/workout";
|
|
|
import { rpxToPx } from "@/utils/tools";
|
|
import { rpxToPx } from "@/utils/tools";
|
|
|
|
|
+import { TimeFormatter } from "@/utils/time_format";
|
|
|
|
|
|
|
|
export default function Component() {
|
|
export default function Component() {
|
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
@@ -23,7 +24,7 @@ export default function Component() {
|
|
|
}, [])
|
|
}, [])
|
|
|
|
|
|
|
|
function twoTimeDuration(start, end) {
|
|
function twoTimeDuration(start, end) {
|
|
|
- var time = Math.floor((end - start) / 1000);
|
|
|
|
|
|
|
+ var time = Math.round((end - start) / 1000);
|
|
|
const hours = Math.floor(time / 3600);
|
|
const hours = Math.floor(time / 3600);
|
|
|
const minutes = Math.floor((time % 3600) / 60);
|
|
const minutes = Math.floor((time % 3600) / 60);
|
|
|
const seconds = Math.floor(time % 60);
|
|
const seconds = Math.floor(time % 60);
|
|
@@ -63,6 +64,10 @@ export default function Component() {
|
|
|
|
|
|
|
|
function getValue(item) {
|
|
function getValue(item) {
|
|
|
var list = item.values
|
|
var list = item.values
|
|
|
|
|
+ if ((record as any).items[0].log_type == 'TIME_SECONDS') {
|
|
|
|
|
+ return list[0].value+'小时'+list[1].value+'分钟'+list[2].value+'秒'
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
var count = 1
|
|
var count = 1
|
|
|
var unit = ''
|
|
var unit = ''
|
|
|
for (var i = 0; i < list.length; i++) {
|
|
for (var i = 0; i < list.length; i++) {
|
|
@@ -95,21 +100,65 @@ export default function Component() {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function getTotalValue(){
|
|
|
|
|
+ if (!record) return ''
|
|
|
|
|
+ if (!(record as any).items[0].summary_stats || (record as any).items[0].summary_stats.length==0){
|
|
|
|
|
+ return ''
|
|
|
|
|
+ }
|
|
|
|
|
+ if ((record as any).items[0].log_type == 'TIME_SECONDS') {
|
|
|
|
|
+ var time = (record as any).items[0].summary_stats[0].value
|
|
|
|
|
+ const hours = Math.floor(time / 3600);
|
|
|
|
|
+ const minutes = Math.floor((time % 3600) / 60);
|
|
|
|
|
+ const seconds = Math.floor(time % 60);
|
|
|
|
|
+ var str = ''
|
|
|
|
|
+ if (hours > 0) {
|
|
|
|
|
+ str = str + hours + '小时'
|
|
|
|
|
+ }
|
|
|
|
|
+ if (minutes > 0) {
|
|
|
|
|
+ str = str + minutes + '分钟'
|
|
|
|
|
+ }
|
|
|
|
|
+ if (seconds > 0) {
|
|
|
|
|
+ str = str + seconds + '秒'
|
|
|
|
|
+ }
|
|
|
|
|
+ return str
|
|
|
|
|
+ }
|
|
|
|
|
+ return (record as any).items[0].summary_stats[0].value+(record as any).items[0].summary_stats[0].unit
|
|
|
|
|
+ // var count = 0
|
|
|
|
|
+ // histories.map(item=>{
|
|
|
|
|
+ // if (item.type=='GROUP'){
|
|
|
|
|
+ // count += parseInt(item.values[0].value)
|
|
|
|
|
+ // }
|
|
|
|
|
+ // })
|
|
|
|
|
+ // return count
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function getRealDuration(){
|
|
|
|
|
+ if (!record) return ''
|
|
|
|
|
+ var seconds = Math.round((histories[histories.length-1].end.timestamp-histories[0].start.timestamp)/1000)
|
|
|
|
|
+ return TimeFormatter.workoutTime(seconds)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function getPlanDuration(){
|
|
|
|
|
+ if (!record) return ''
|
|
|
|
|
+ var seconds = (record as any).items[0].duration/1000
|
|
|
|
|
+ return TimeFormatter.workoutTime(seconds)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return <View style={{ color: '#fff', display: 'flex', flexDirection: 'column' }}>
|
|
return <View style={{ color: '#fff', display: 'flex', flexDirection: 'column' }}>
|
|
|
<Text className="result_detail_text" style={{ color: router.params.themeColor }}>{router.params.title}</Text>
|
|
<Text className="result_detail_text" style={{ color: router.params.themeColor }}>{router.params.title}</Text>
|
|
|
<Text className="result_detail_text" style={{ color: '#fff', opacity: 0.4, marginTop: rpxToPx(10), marginBottom: rpxToPx(20) }}>计时训练</Text>
|
|
<Text className="result_detail_text" style={{ color: '#fff', opacity: 0.4, marginTop: rpxToPx(10), marginBottom: rpxToPx(20) }}>计时训练</Text>
|
|
|
<Text className="result_detail_text">训练统计</Text>
|
|
<Text className="result_detail_text">训练统计</Text>
|
|
|
<View style={{ marginLeft: rpxToPx(32), display: 'flex', flexDirection: 'column' }}>
|
|
<View style={{ marginLeft: rpxToPx(32), display: 'flex', flexDirection: 'column' }}>
|
|
|
<Text>总量</Text>
|
|
<Text>总量</Text>
|
|
|
- <Text style={{ color: router.params.themeColor }}>111</Text>
|
|
|
|
|
|
|
+ <Text style={{ color: router.params.themeColor }}>{getTotalValue()}</Text>
|
|
|
<Text>用时</Text>
|
|
<Text>用时</Text>
|
|
|
<View style={{ flexDirection: 'row', display: 'flex', width: '100%' }}>
|
|
<View style={{ flexDirection: 'row', display: 'flex', width: '100%' }}>
|
|
|
<View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', flex: 1 }}>
|
|
<View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', flex: 1 }}>
|
|
|
- <Text style={{ color: router.params.themeColor }}>111</Text>
|
|
|
|
|
|
|
+ <Text style={{ color: router.params.themeColor }}>{getRealDuration()}</Text>
|
|
|
<Text>实际</Text>
|
|
<Text>实际</Text>
|
|
|
</View>
|
|
</View>
|
|
|
<View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', flex: 1 }}>
|
|
<View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', flex: 1 }}>
|
|
|
- <Text style={{ color: router.params.themeColor }}>111</Text>
|
|
|
|
|
|
|
+ <Text style={{ color: router.params.themeColor }}>{getPlanDuration()}</Text>
|
|
|
<Text>计划</Text>
|
|
<Text>计划</Text>
|
|
|
</View>
|
|
</View>
|
|
|
</View>
|
|
</View>
|