Leon 1 سال پیش
والد
کامیت
7429a86bdf

+ 34 - 2
src/_health/components/target_progress.tsx

@@ -2,8 +2,9 @@ import { View, Text } from '@tarojs/components'
 import Rings, { RingCommon, BgRing, TargetRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
 import './target_progress.scss'
 import { MainColorType } from '@/context/themes/color';
-import { durationArc, startArc } from '@/utils/ring_utils';
+import { durationArc, durationProgress, startArc, startDegree } from '@/utils/ring_utils';
 import { rpxToPx } from '@/utils/tools';
+import CircleRing from '@/components/basic/CircleRing';
 
 export default function TargetProgress(props: {
     showLine?: boolean,
@@ -22,7 +23,18 @@ export default function TargetProgress(props: {
     onClick?: any
 }) {
 
-    function ring() {
+    function ring(){
+        return <CircleRing 
+            size={26}
+            thickness={4.5}
+            color={props.color ?? MainColorType.fast}
+            backgroundColor={MainColorType.ringBg}
+            startAngle={startDegree(props.startTimestamp ?? 0)}
+            progress={durationProgress(props.startTimestamp ?? 0, props.endTimerstamp ?? 0)}
+        />
+    }
+
+    function ring22() {
         const common: RingCommon = {
             useCase: 'ChooseScenario',
             radius: 12,
@@ -41,10 +53,21 @@ export default function TargetProgress(props: {
             startArc: startArc(props.startTimestamp ?? 0),
             durationArc: durationArc(props.startTimestamp ?? 0, props.endTimerstamp ?? 0)
         }
+
+
         return <Rings common={common} bgRing={bgRing} realRing={realRing} canvasId={props.canvasId ?? 'helloworld'} />
     }
 
     function ring1() {
+        return <CircleRing 
+            size={28}
+            thickness={4}
+            color={MainColorType.fast}
+            backgroundColor={MainColorType.ringBg}
+            startAngle={startDegree(props.first.window_range.start_timestamp ?? 0)}
+            progress={durationProgress(props.first.window_range.start_timestamp ?? 0, props.first.window_range.end_timestamp ?? 0)}
+        />
+
         const common: RingCommon = {
             useCase: 'ChooseScenario',
             radius: 12.5,
@@ -67,6 +90,15 @@ export default function TargetProgress(props: {
     }
 
     function ring2() {
+        return <CircleRing 
+            size={14}
+            thickness={4}
+            color={MainColorType.sleep}
+            backgroundColor={MainColorType.ringBg}
+            startAngle={startDegree(props.second.window_range.start_timestamp ?? 0)}
+            progress={durationProgress(props.second.window_range.start_timestamp ?? 0, props.second.window_range.end_timestamp ?? 0)}
+        />
+
         const common: RingCommon = {
             useCase: 'ChooseScenario',
             radius: 6.5,

+ 3 - 3
src/_health/pages/log_time.tsx

@@ -558,7 +558,7 @@ export default function LogTime() {
         });
         var params: any = {
             check_items: sortedData,
-            op_page: isFastWithSleep ? 'FAST_WITH_SLEEP' : null,
+            op_page: isFastWithSleep ? 'FAST_WITH_SLEEP' : router.params.op_page ? router.params.op_page : null,
             only_check: onlyCheck,
             log_method: getLogMethod(list),
             extra: {
@@ -1021,7 +1021,7 @@ export default function LogTime() {
                                 onClick={() => { setExpandIndex(-1) }}
                             />
                             {
-                                expandIndex == -1 && <View className="border_footer_line" style={{ left: rpxToPx(40),right:rpxToPx(40) }}/>
+                                expandIndex == -1 && <View className="border_footer_line" style={{ left: rpxToPx(40), right: rpxToPx(40) }} />
                             }
                             {/* </View> */}
                         </View>
@@ -1048,7 +1048,7 @@ export default function LogTime() {
                 return <Card>
                     <View style={{ position: 'relative' }}>
                         <View className="card_header" style={{ justifyContent: 'space-between' }}>
-                        <View className="h34" style={{ marginLeft: rpxToPx(12) }}>{t('health.goal')}</View>
+                            <View className="h34" style={{ marginLeft: rpxToPx(12) }}>{t('health.goal')}</View>
                             {/* <View className="h34" style={{ marginLeft: rpxToPx(12) }}>{isFast ? 'Fast Goal' : 'Sleep Goal'}</View> */}
                             {/* <View style={{
                             borderColor: expandIndex == -1 ? isFast ? MainColorType.fast : MainColorType.sleep : 'transparent',

+ 55 - 0
src/components/basic/CircleRing.tsx

@@ -0,0 +1,55 @@
+import { View } from "@tarojs/components";
+import { useEffect } from "react";
+
+let SvgXml;
+if (process.env.TARO_ENV == 'rn') {
+    SvgXml = require("react-native-svg").SvgXml
+}
+
+export default function CircleRing(props: {
+    size: number,
+    thickness: number,
+    startAngle: number,
+    progress: number,
+    color: string,
+    backgroundColor?: string
+}) {
+    const center = props.size / 2;
+    const radius = (props.size - props.thickness) / 2;
+
+
+
+    function detail() {
+        const strokeWidth = props.thickness
+        // 计算圆周长
+        const circumference = 2 * Math.PI * radius;
+
+        const startAngle = props.startAngle
+        const progress = props.progress
+
+        // 计算起始点的坐标
+        const startX = props.size / 2 + radius * Math.cos((startAngle - 90) * (Math.PI / 180));
+        const startY = props.size / 2 + radius * Math.sin((startAngle - 90) * (Math.PI / 180));
+
+        // 计算结束点的坐标
+        const endAngle = startAngle + (progress / 100) * 360;
+        const endX = props.size / 2 + radius * Math.cos((endAngle - 90) * (Math.PI / 180));
+        const endY = props.size / 2 + radius * Math.sin((endAngle - 90) * (Math.PI / 180));
+
+        return `<svg width="${props.size}" height="${props.size}" xmlns="http://www.w3.org/2000/svg">
+        <circle cx="${props.size / 2}" cy="${props.size / 2}" r="${radius}" stroke="${props.backgroundColor ?? 'transparent'}" stroke-width="${strokeWidth}" fill="none" />
+        <path d="M ${startX} ${startY} A ${radius} ${radius} 0 ${progress > 50 ? 1 : 0} 1 ${endX} ${endY}" 
+              stroke="${props.color}" stroke-width="${strokeWidth}" fill="none" stroke-linecap="round" />
+      </svg>`
+    }
+
+
+
+    useEffect(() => {
+    }, [])
+
+    return <View style={{ width: props.size, height: props.size }}>{
+        process.env.TARO_ENV == 'weapp' ? <mysvg src={detail()} colors={[]} /> :
+            <SvgXml xml={detail()} />
+    }</View>
+}

+ 2 - 2
src/features/health/MainConsole.tsx

@@ -162,7 +162,7 @@ export default function MainConsole(props: { type: WindowType }) {
                 {
 
 
-                    jumpPage(`/_health/pages/log_time?index=${health.mode == 'FAST' ? 0 : 1}&single=1&is_start=1&window=${health.mode}`)
+                    jumpPage(`/_health/pages/log_time?index=${health.mode == 'FAST' ? 0 : 1}&single=1&is_start=1&window=${health.mode}&op_page=${health.mode == 'FAST' ?'HOME_FAST':'HOME_SLEEP'}`)
                 }
                 return;
             case 'END':
@@ -170,7 +170,7 @@ export default function MainConsole(props: { type: WindowType }) {
 
                     var sceniaro = getScenario(health.windows, health.mode)
 
-                    jumpPage(`/_health/pages/log_time?type=home&index=${health.mode == 'FAST' ? 3 : 2}&single=${sceniaro.status == 'OG' ? 1 : 0}&is_start=0&window=${health.mode}`)
+                    jumpPage(`/_health/pages/log_time?type=home&index=${health.mode == 'FAST' ? 3 : 2}&single=${sceniaro.status == 'OG' ? 1 : 0}&is_start=0&window=${health.mode}&op_page=${health.mode == 'FAST' ?'HOME_FAST':'HOME_SLEEP'}`)
                 }
                 return;
             case 'MARK_DONE':

+ 10 - 2
src/pages/clock/ClockNew.tsx

@@ -22,6 +22,7 @@ import Taro, { useDidShow } from "@tarojs/taro";
 import { IconClose } from "@/components/basic/Icons";
 import showAlert from "@/components/basic/Alert";
 import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
+import CircleRing from "@/components/basic/CircleRing";
 
 let AppState;
 if (process.env.TARO_ENV == 'rn') {
@@ -68,7 +69,7 @@ export default function ClockNew(props: { children: any, onScroll: any }) {
         }
 
         // setTimeout(() => {
-            checkVersionUpdate();
+        checkVersionUpdate();
         // }, 1000)
     })
 
@@ -269,7 +270,7 @@ export default function ClockNew(props: { children: any, onScroll: any }) {
         const showAlert1 = await getStorage('148alert') || false;
         Taro.setStorage({ key: '148alert', data: true })
 
-        console.log('9529',showAlert1,health.finish_setup)
+        console.log('9529', showAlert1, health.finish_setup)
 
 
         if (!showAlert1 && !health.finish_setup) {
@@ -388,6 +389,13 @@ export default function ClockNew(props: { children: any, onScroll: any }) {
                 {
                     process.env.TARO_ENV == 'weapp' && <MainConsole type={type} />
                 }
+                {/* <View>hell world</View>
+                <CircleRing size={100}
+                    thickness={20}
+                    startAngle={90}
+                    progress={40}
+                    color="#3498db"
+                    backgroundColor="#ecf0f1" /> */}
 
                 <MainHistory ref={historyRef2} updateDate={(e) => {
                     setShowDate(e.show)

+ 1 - 1
src/services/http/api.js

@@ -3,7 +3,7 @@ const online = process.env.TARO_ENV == 'weapp' ? false : false;
 import { WX_VERSION as _WX_VERSION, APP_VERSION as _APP_VERSION, ANDROID_VERSION as _ANDROID_VERSION } from "../../../config/env";
 
 // export const baseUrl = online ? 'https://api.fast.liveplus.fun' : 'https://api.fast.dev.liveplus.fun';
-export const baseUrl = online ? process.env.TARO_ENV == 'rn' ? 'https://api.app.fast.liveplus.fun' : 'https://api.fast.liveplus.fun' : 'https://api.pre.fast.liveplus.fun'//'https://api.fast.dev.liveplus.fun';//'https://api.fast.dev.liveplus.fun';
+export const baseUrl = online ? process.env.TARO_ENV == 'rn' ? 'https://api.app.fast.liveplus.fun' : 'https://api.fast.liveplus.fun' : 'https://api.fast.dev.liveplus.fun';//'https://api.pre.fast.liveplus.fun'//'https://api.fast.dev.liveplus.fun';
 
 export const APP_VERSION = _APP_VERSION
 export const WX_VERSION = _WX_VERSION

+ 13 - 0
src/utils/ring_utils.ts

@@ -10,3 +10,16 @@ export const durationArc = (start_time: number, end_time: number) => {
     var duration = (end_time - start_time) / 1000;
     return duration / (24 * 3600) * 2 * Math.PI;
 }
+
+export const startDegree = (time: number) => {
+    var date = new Date(time);
+    var hour = date.getHours();
+    var minute = date.getMinutes();
+    var second = date.getSeconds();
+    return (hour * 3600 + minute * 60 + second) / (24 * 3600) * 360;
+}
+
+export const durationProgress = (start_time: number, end_time: number) => {
+    var duration = (end_time - start_time) / 1000;
+    return duration / (24 * 3600) * 100;
+}