Leon 2 år sedan
förälder
incheckning
73b1881cfe

+ 4 - 3
src/components/navigation/TabBar.tsx

@@ -54,13 +54,14 @@ export default function Component(props: { index: number }) {
             </View>
 
         </View>
+        <View className={selIndex == 2 ? 'tabbar-item tabbar-item-sel' : 'tabbar-item'} onClick={() => switchTab(2)}>
+            <Text>运动</Text>
+        </View>
         <View className={selIndex == 1 ? 'tabbar-item tabbar-item-sel' : 'tabbar-item'} onClick={() => switchTab(1)}>
             <Text>指标</Text>
         </View>
 
-        <View className={selIndex == 2 ? 'tabbar-item tabbar-item-sel' : 'tabbar-item'} onClick={() => switchTab(2)}>
-            <Text>运动</Text>
-        </View>
+        
         <View className={selIndex == 3 ? 'tabbar-item tabbar-item-sel' : 'tabbar-item'} onClick={() => switchTab(3)}>
             <Text>更多</Text>
         </View>

+ 7 - 0
src/context/locales/zh.js

@@ -309,6 +309,13 @@ export default {
             disable_switch_modal_title:'请先完成当前记录',
             disable_switch_modal_btn:'我知道了'
         },
+        workout:{
+            finish_current:'请先完成当前训练',
+            add_more:'添加更多',
+            choose_workout:'选择运动项',
+            order:'调整排序',
+            choose_workout_desc:'选择健身训练中常练的动作\n或日常活动'
+        },
         track_something: {
             btn_record: '记录',
             picker_datetime: '记录时间',

+ 8 - 4
src/features/trackSomething/components/Metric.tsx

@@ -211,7 +211,7 @@ export default function Component(props: any) {
                     })
                 }
                 {
-                    user.isLogin && <View className="add_more" onClick={addBtnClick}>
+                    user.isLogin && list.length>0 && <View className="add_more" onClick={chooseMore}>
                         <Image style={{ width: rpxToPx(48), height: rpxToPx(48) }} src={require('@assets/images/add2.png')} />
                         <Text className="add_more_text">添加更多</Text>
                     </View>
@@ -230,9 +230,7 @@ export default function Component(props: any) {
             .then(res => {
                 switch (res.tapIndex) {
                     case 0:
-                        global.metricAdd = true
-                        setModalType(MetricModalType.choose)
-                        setShowPageContainer(true)
+                        chooseMore()
 
                         break;
                     case 1:
@@ -248,6 +246,12 @@ export default function Component(props: any) {
 
     }
 
+    function chooseMore() {
+        global.metricAdd = true
+        setModalType(MetricModalType.choose)
+        setShowPageContainer(true)
+    }
+
     function headerView() {
         return <TitleView title={t('page.metric.title')} showAddBtn={loaded && !showErrorPage ? true : false} onClick={addBtnClick}>
         </TitleView>

+ 1 - 0
src/features/trackSomething/components/MetricModalChoose.scss

@@ -21,6 +21,7 @@
     opacity: 0.4;
     font-size: 28px;
     line-height: 28px;
+    text-align: center;
 }
 
 .modal_detail{

+ 15 - 14
src/features/trackSomething/components/MetricModalChoose.tsx

@@ -9,7 +9,8 @@ import { useSelector } from 'react-redux'
 
 export default function Component(props: {
     themeColor: string, cancel: Function, confirm: Function, array: any, limit: any,
-    orders: any, newOrders: any
+    orders: any, newOrders: any,
+    isWorkout?: boolean
 }) {
     const color = props.themeColor ? props.themeColor : '#ff0000'
     const user = useSelector((state: any) => state.user);
@@ -36,13 +37,13 @@ export default function Component(props: {
         for (var i = 0; i < newList.length; i++) {
             array.push(newList[i])
         }
-        console.log(oldList,newList,array)
+        console.log(oldList, newList, array)
         debugger
-        props.confirm(oldList,newList,array,list)
+        props.confirm(oldList, newList, array, list)
     }
 
     function tapItem(obj) {
-        
+
         var check = !obj.is_following
         var count = 0;
         oldList.map(item => {
@@ -60,7 +61,7 @@ export default function Component(props: {
             if (max == count) {
                 Taro.showToast({
                     icon: 'none',
-                    title:`高级会员可选择${count}项以上`
+                    title: `高级会员可选择${count}项以上`
                     // title: t('feature.common.toast.max_metric_count',{count:count}),
                 })
                 return
@@ -70,7 +71,7 @@ export default function Component(props: {
             if (min == count) {
                 Taro.showToast({
                     icon: 'none',
-                    title: t('feature.common.toast.min_metric_count',{count:count}),
+                    title: t('feature.common.toast.min_metric_count', { count: count }),
                 })
                 return
             }
@@ -125,7 +126,7 @@ export default function Component(props: {
         return ''
     }
 
-    function codeNewIndex(code){
+    function codeNewIndex(code) {
         for (var i = 0; i < newList.length; i++) {
             if (newList[i].code == code) {
                 return `序号:${i + 1 + oldList.length}`;
@@ -134,7 +135,7 @@ export default function Component(props: {
         return ''
     }
 
-    function codeOldIndex(code){
+    function codeOldIndex(code) {
         for (var i = 0; i < oldList.length; i++) {
             if (oldList[i].code == code) {
                 return `序号:${i + 1}`;
@@ -146,8 +147,8 @@ export default function Component(props: {
 
     return <View className='modal_content'>
         <View className='modal_title_view'>
-            <Text className='modal_title1'>{t('feature.track_something.metric.choose_metric')}</Text>
-            <Text className='modal_subtitle'>按需选择自己常用的指标</Text>
+            <Text className='modal_title1'>{props.isWorkout ? t('feature.workout.choose_workout') : t('feature.track_something.metric.choose_metric')}</Text>
+            <Text className='modal_subtitle'>{props.isWorkout?t('feature.workout.choose_workout_desc'):'按需选择自己常用的指标'}</Text>
         </View>
         <ScrollView className='modal_detail' scrollY>
             <View>
@@ -167,13 +168,13 @@ export default function Component(props: {
                                         {
                                             user.test_user && <Text>{obj.is_following ? codeIndex(obj.code) : ''}</Text>
                                         }
-                                         {
-                                            user.test_user && <Text style={{color:'green'}}>{obj.is_following ? codeNewIndex(obj.code) : ''}</Text>
+                                        {
+                                            user.test_user && <Text style={{ color: 'green' }}>{obj.is_following ? codeNewIndex(obj.code) : ''}</Text>
                                         }
                                         {
-                                            user.test_user && <Text style={{color:'red'}}>{!obj.is_following &&  codeOldIndex(obj.code)}</Text>
+                                            user.test_user && <Text style={{ color: 'red' }}>{!obj.is_following && codeOldIndex(obj.code)}</Text>
                                         }
-                                        <View className='px1SeperateHeight'/>
+                                        <View className='px1SeperateHeight' />
                                     </View>
                                 })
                             }

+ 124 - 2
src/features/trackTimeDuration/components/Rings.rn.tsx

@@ -1,4 +1,8 @@
 import { View } from "@tarojs/components";
+import Taro from "@tarojs/taro";
+import { useRef } from "react";
+import Svg, { Circle, Path } from 'react-native-svg';
+import { useSelector } from "react-redux";
 
 export type RingCommon = {
     useCase: string;
@@ -30,6 +34,124 @@ export type BgRing = {
     color: string;
 }
 
-export default function Component(){
-    return <View />
+export default function Component(props: {
+    common: RingCommon; currentDot?: CurrentDot;
+    realRing?: RealRing; targetRing?: TargetRing;
+    breathAnimation?: boolean;
+    bgRing: BgRing; canvasId?: string;
+    ctx?: any; setCtx?: any;
+    canvas?: any; setCanvas?: any;
+}) {
+    const r = props.common.radius
+    const strokeWidth = props.common.lineWidth;
+    // const color = props.color || 'orange'
+    const canvasRef = useRef(null);
+    const canvasId = props.canvasId ? 'canvas_' + props.canvasId : 'progress-canvas';
+    const dpr = Taro.getSystemInfoSync().pixelRatio; // 获取设备的像素比
+    const radius = r; // 圆形进度条的半径
+    const lineWidth = strokeWidth; // 圆形进度条的线宽
+    const time = useSelector((state: any) => state.time);
+    const user = useSelector((state: any) => state.user);
+
+    const center = radius + lineWidth / 2 + 3; // 圆心坐标
+
+    function drawContent() {
+        var time = new Date();
+        var seconds = time.getHours() * 3600 + time.getMinutes() * 60 + time.getSeconds();
+        var arc = seconds / 86400 * 2 * Math.PI - Math.PI / 2.0;
+
+
+        return <Svg width={(radius * 2 + lineWidth) + 6} height={(radius * 2 + lineWidth) + 6} fillOpacity={0}>
+            <Circle
+                cx={center}
+                cy={center}
+                r={radius}
+                fillOpacity={0}
+                stroke={props.bgRing.color}
+                strokeWidth={strokeWidth}
+                strokeLinecap="round"
+            />
+            {/* // 绘制target进度环
+        if (props.targetRing) {
+            ctx.beginPath();
+            ctx.arc(center, center, radius, props.targetRing!.startArc,
+                props.targetRing!.startArc + props.targetRing!.durationArc);
+            ctx.lineWidth = lineWidth;
+            ctx.strokeStyle = props.targetRing!.color;
+            ctx.lineCap = 'round'; // 设置为圆角
+            ctx.stroke();
+        } */}
+            {
+                props.targetRing && <Circle
+                    cx={center}
+                    cy={center}
+                    r={radius}
+                    fillOpacity={0}
+                    stroke={props.targetRing!.color}
+                    transform={`rotate(${props.targetRing!.startArc / (2 * Math.PI) * 360} ${center} ${center})`}
+                    strokeDasharray={`${props.targetRing!.durationArc*radius},1000`}
+                    strokeWidth={lineWidth}
+                    strokeLinecap="round"
+                />
+            }
+            {/* //绘制real进度环
+        if (props.realRing) {
+            if (props.realRing.durationArc <0.01) props.realRing.durationArc=0.01;
+            ctx.beginPath();
+            ctx.arc(center, center, radius, props.realRing!.startArc,
+                props.realRing!.startArc + props.realRing!.durationArc);
+            ctx.lineWidth = lineWidth;
+            ctx.strokeStyle = props.realRing!.color;
+            ctx.lineCap = 'round'; // 设置为圆角
+            ctx.stroke();
+        } */}
+            {
+                props.realRing && <Circle
+                    cx={center}
+                    cy={center}
+                    r={radius}
+                    fillOpacity={0}
+                    stroke={props.realRing!.color}
+                    transform={`rotate(${props.realRing!.startArc / (2 * Math.PI) * 360} ${center} ${center})`}
+                    strokeDasharray={`${props.realRing!.durationArc*radius},1000`}
+                    strokeWidth={lineWidth}
+                    strokeLinecap="round"
+                />
+            }
+            {
+                props.currentDot && <Circle
+                    cx={center}
+                    cy={center}
+                    r={radius}
+                    fillOpacity={0}
+                    stroke={props.currentDot!.borderColor}
+                    transform={`rotate(${arc / (2 * Math.PI) * 360} ${center} ${center})`}
+                    strokeDasharray={`0,1000`}
+                    strokeWidth={lineWidth + 6}
+                    strokeLinecap="round"
+                />
+            }
+            {
+                props.currentDot && <Circle
+                    cx={center}
+                    cy={center}
+                    r={radius}
+                    fillOpacity={0}
+                    stroke={props.currentDot!.color}
+                    transform={`rotate(${arc / (2 * Math.PI) * 360} ${center} ${center})`}
+                    strokeDasharray={`0,1000`}
+                    strokeWidth={lineWidth}
+                    strokeLinecap="round"
+                />
+            }
+        </Svg>
+    }
+
+    return <Svg width={(radius * 2 + lineWidth) + 6} height={(radius * 2 + lineWidth) + 6} fillOpacity={0}>
+        {
+            drawContent()
+        }
+    </Svg>
+
+    // return <View style={{ width: 100, height: 100, backgroundColor: 'pink' }}></View>
 }

+ 25 - 8
src/features/workout/Workout.tsx

@@ -113,6 +113,9 @@ export default function Component(props: any) {
         if (list.length > 0) {
             checkAuth()
         }
+        if (!timer){
+            loadWorkoutCache()
+        }
     })
 
     function loadWorkoutCache() {
@@ -177,6 +180,7 @@ export default function Component(props: any) {
             })
             setOrders(list)
             setResultOrders(list)
+            Taro.stopPullDownRefresh()
 
 
         }).catch(e => {
@@ -185,6 +189,7 @@ export default function Component(props: any) {
                 setErrorPage(true)
             }
             setLoaded(true)
+            Taro.stopPullDownRefresh()
         })
 
 
@@ -235,6 +240,13 @@ export default function Component(props: any) {
                     Taro.navigateTo({ url: '/pages/workout/Working?type=stop_watch&restore=true' })
                 }
                 else {
+                    if (workout.status == 'ing'){
+                        Taro.showModal({
+                            content:t('feature.workout.finish_current'),
+                            showCancel:false
+                        })
+                        return
+                    }
                     workoutStart()
                 }
                 
@@ -444,16 +456,14 @@ export default function Component(props: any) {
 
     function addBtnClick() {
         Taro.showActionSheet({
-            itemList: [t('feature.track_something.metric.choose_metric'),
-            t('feature.track_something.metric.order')]
+            itemList: [t('feature.workout.choose_workout'),
+            t('feature.workout.order')]
         })
             .then(res => {
                 switch (res.tapIndex) {
                     case 0:
-                        global.metricAdd = true
-                        setModalType(MetricModalType.choose)
-                        setShowPageContainer(true)
-
+                        
+                        chooseMore()
                         break;
                     case 1:
                         global.metricAdd = false
@@ -468,6 +478,12 @@ export default function Component(props: any) {
 
     }
 
+    function chooseMore(){
+        global.metricAdd = true
+        setModalType(MetricModalType.choose)
+        setShowPageContainer(true)
+    }
+
     function headerView() {
         return <TitleView title={t('page.activity.title')} showAddBtn={loaded && !showErrorPage ? true : false} onClick={addBtnClick}>
         </TitleView>
@@ -583,9 +599,9 @@ export default function Component(props: any) {
             /> */}
 
             {
-                user.isLogin && <View className="add_more" onClick={addBtnClick}>
+                user.isLogin && list.length>0 &&<View className="add_more" onClick={chooseMore}>
                     <Image style={{ width: rpxToPx(48), height: rpxToPx(48) }} src={require('@assets/images/add2.png')} />
-                    <Text className="add_more_text">添加更多</Text>
+                    <Text className="add_more_text">{t('feature.workout.add_more')}</Text>
                 </View>
             }
 
@@ -653,6 +669,7 @@ export default function Component(props: any) {
         switch (modalType) {
             case MetricModalType.choose:
                 return <MetricModalChoose
+                    isWorkout={true}
                     themeColor={themeColor}
                     cancel={modalCancel}
                     confirm={modalConfirm}

+ 20 - 3
src/features/workout/WorkoutContent.tsx

@@ -1,5 +1,22 @@
-import { View } from "@tarojs/components";
+import Modal from "@/components/layout/Modal";
+import { View, Text } from "@tarojs/components";
+import { useState } from "react";
 
-export default function Component(){
-    return  <View></View>
+export default function Component() {
+    const [showDataPicker, setShowDataPicker] = useState(false)
+    const [showTimePicker, setShowTimePicker] = useState(false)
+    return <View style={{ display: 'flex', flexDirection: 'column' }}>
+        <Text>平板支撑</Text>
+        <Text>训练内容</Text>
+        <View onClick={() => { setShowTimePicker(true) }}>
+            <Text>今天 12:12</Text>
+        </View>
+        {
+            showTimePicker && <Modal dismiss={() => setShowTimePicker(false)}><Text></Text></Modal>
+        }
+        {
+            showDataPicker && <Modal dismiss={() => setShowDataPicker(false)}><Text></Text></Modal>
+        }
+
+    </View>
 }

+ 18 - 6
src/features/workout/WorkoutStopWatch.tsx

@@ -84,11 +84,14 @@ export default function Component(props: { targetCount: any, end: Function }) {
             var defaultV = parseInt(obj.default_value)
             for (var i = min; i <= max; i = i + step) {
                 list.push(i + obj.unit)
-                if (defaultV == i + min) {
+            }
+            items.push(list)
+
+            for (var i = 0; i < list.length; i++) {
+                if (parseInt(list[i] + '') == defaultV) {
                     selects.push(i)
                 }
             }
-            items.push(list)
 
         })
         setPcikerValue(selects)
@@ -293,9 +296,19 @@ export default function Component(props: { targetCount: any, end: Function }) {
         uploadWorkout(params).then(res => {
             clearCache()
             dispatch(endSuccess())
-            Taro.redirectTo({
-                url: '/pages/workout/WorkoutDetail?detail=' + JSON.stringify((res as any).latest_record)
-            })
+
+            // var item = workout.item
+            // Taro.redirectTo({
+            //     url: '/pages/common/RecordsHistory?type=workout&refreshList=getCards&title=' + item.name + '&code=' + item.code + '&themeColor=' + item.theme_color
+            // })
+
+            setTimeout(()=>{
+                Taro.navigateTo({
+                    url: '/pages/workout/WorkoutDetail?detail=' + JSON.stringify((res as any).latest_record)
+                })
+            },0)
+
+            
             props.end()
             global.refreshWorkout()
         }).catch(e => { })
@@ -392,7 +405,6 @@ export default function Component(props: { targetCount: any, end: Function }) {
         for (var i = 0; i < array.length; i++) {
             unit += array[i].unit + '·'
         }
-        debugger
         return count + unit.substring(0, unit.length - 1)
     }
 

+ 1 - 1
src/pages/account/Setting.tsx

@@ -35,7 +35,7 @@ export default function Page() {
 
     return <View style={{ color: '#fff',display:'flex',flexDirection:'column' }}>
         <View style={{height:20}}/>
-        <TableCell title={t('page.setting.version')} ><Text style={{ opacity: 0.8 }}>1.2.9</Text></TableCell>
+        <TableCell title={t('page.setting.version')} ><Text style={{ opacity: 0.8 }}>1.3.0</Text></TableCell>
         {/* <Text style={{color:'#9E9E9E',textAlign:'center',fontSize:14}}>v1.2.2</Text> */}
         
         <Footer>

+ 1 - 1
src/pages/clock/Clock.rn.tsx

@@ -399,7 +399,7 @@ export default function IndexPage() {
 
                     <Box>
                         <View className='clock_bg' onClick={tapClock}>
-                            <Clocks />
+                            <Clocks showCoverView={!global.showModal} />
                         </View>
                     </Box>
                     {