|
|
@@ -42,9 +42,12 @@ export default function Component(props: { targetCount: any, end: Function }) {
|
|
|
Taro.getStorage({
|
|
|
key: 'lastWorkout', success: function (res) {
|
|
|
var workouts = JSON.parse(res.data)
|
|
|
- debugger
|
|
|
setGroups(workouts)
|
|
|
- setStartTime(workouts[workouts.length - 1].time)
|
|
|
+ var workObj = workouts[workouts.length - 1]
|
|
|
+ setStartTime(workObj.time)
|
|
|
+ if (workObj.type=='REST'){
|
|
|
+ setIsDoing(false)
|
|
|
+ }
|
|
|
}, fail: function (err) {
|
|
|
console.log(err, 'no cache')
|
|
|
}
|
|
|
@@ -352,6 +355,34 @@ export default function Component(props: { targetCount: any, end: Function }) {
|
|
|
resume()
|
|
|
}
|
|
|
|
|
|
+ function total(){
|
|
|
+ var count = 0
|
|
|
+ for (var i =0;i<groups.length;i++){
|
|
|
+ var obj = groups[i]
|
|
|
+ if (obj.type=='REST'){
|
|
|
+ var temp = 0
|
|
|
+ if (obj.value){
|
|
|
+ temp = parseInt(obj.value+'')
|
|
|
+ }
|
|
|
+ if (obj.value2){
|
|
|
+ temp *=parseInt(obj.value2+'')
|
|
|
+ }
|
|
|
+ if (obj.value3){
|
|
|
+ temp *= parseInt(obj.value3+'')
|
|
|
+ }
|
|
|
+ count+=temp
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var unit = ''
|
|
|
+ var array = workout.item.schemas[0].values
|
|
|
+
|
|
|
+ for (var i=0;i<array.length;i++){
|
|
|
+ unit += array[i].unit+'·'
|
|
|
+ }
|
|
|
+ debugger
|
|
|
+ return count+unit.substring(0,unit.length-1)
|
|
|
+ }
|
|
|
+
|
|
|
function pickerContent() {
|
|
|
var color = workout.item.theme_color
|
|
|
var title = '本组训练'
|
|
|
@@ -380,14 +411,14 @@ export default function Component(props: { targetCount: any, end: Function }) {
|
|
|
if (index == 0) {
|
|
|
return <View />
|
|
|
}
|
|
|
- return <View key={index} style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', width: '100%', color: '#fff' }}>
|
|
|
+ return <View key={index} className={item.type == 'REST' ?'item_group':'item_group item_rest'} style={{ justifyContent: 'space-between', color: '#fff' }}>
|
|
|
<Text>{item.type == 'REST' ? `第${item.index}组` : '组间休息'}</Text>
|
|
|
{item.type == 'REST' && <Text style={{ color: workout.item.theme_color }}>{item.value}{item.value2 ? 'x' + item.value2 : ''}{item.value3 ? 'x' + item.value3 : ''}</Text>}
|
|
|
<Text>{twoTimeDuration(groups[index - 1].time, item.time)}</Text>
|
|
|
</View>
|
|
|
})
|
|
|
}
|
|
|
- <Box>
|
|
|
+ <View className="item_group">
|
|
|
{
|
|
|
isDoing ? <View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
|
<Text className="working_index">第{index}组</Text>
|
|
|
@@ -400,10 +431,14 @@ export default function Component(props: { targetCount: any, end: Function }) {
|
|
|
<ChooseScenarioBtn onClick={start} title="开始下一组" background={workout.item.theme_color} />
|
|
|
</View>
|
|
|
}
|
|
|
- </Box>
|
|
|
+ </View>
|
|
|
|
|
|
<Text className="working_end" onClick={terminal}>结束训练</Text>
|
|
|
<View style={{ height: 50 }} />
|
|
|
+
|
|
|
+ <Text>实时训练统计</Text>
|
|
|
+ <Text>总量</Text>
|
|
|
+ <Text>{total()}</Text>
|
|
|
<Text>总用时</Text>
|
|
|
<View style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', width: '100%' }}>
|
|
|
<View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
|