Leon %!s(int64=2) %!d(string=hai) anos
pai
achega
0ba876c7fa

+ 19 - 0
src/features/workout/WorkoutStopWatch.scss

@@ -38,4 +38,23 @@
     font-size: 32px;
     line-height: 40px;
     margin-top: 40px;
+}
+
+.item_group{
+    background-color: #1C1C1C;
+    margin-left: 32px;
+    margin-right: 32px;
+    padding-left: 32px;
+    padding-right: 32px;
+    padding-top: 40px;
+    padding-bottom: 40px;
+    border-radius: 26px;
+    display: flex;
+    flex-direction: row;
+    position: relative;
+    margin-bottom: 28px;
+}
+
+.item_rest{
+    background-color: #121212;
 }

+ 40 - 5
src/features/workout/WorkoutStopWatch.tsx

@@ -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' }}>