Leon il y a 2 ans
Parent
commit
11b3eee580

+ 7 - 1
ios/Podfile.lock

@@ -18,6 +18,8 @@ PODS:
     - ExpoModulesCore
   - EXConstants (14.0.2):
     - ExpoModulesCore
+  - EXErrorRecovery (4.0.1):
+    - ExpoModulesCore
   - EXFileSystem (15.1.1):
     - ExpoModulesCore
   - EXFont (11.0.1):
@@ -468,6 +470,7 @@ DEPENDENCIES:
   - EXBrightness (from `../node_modules/expo-brightness/ios`)
   - EXCamera (from `../node_modules/expo-camera/ios`)
   - EXConstants (from `../node_modules/expo-constants/ios`)
+  - EXErrorRecovery (from `../node_modules/expo-error-recovery/ios`)
   - EXFileSystem (from `../node_modules/expo-file-system/ios`)
   - EXFont (from `../node_modules/expo-font/ios`)
   - EXImageLoader (from `../node_modules/expo-image-loader/ios`)
@@ -589,6 +592,8 @@ EXTERNAL SOURCES:
     :path: "../node_modules/expo-camera/ios"
   EXConstants:
     :path: "../node_modules/expo-constants/ios"
+  EXErrorRecovery:
+    :path: "../node_modules/expo-error-recovery/ios"
   EXFileSystem:
     :path: "../node_modules/expo-file-system/ios"
   EXFont:
@@ -716,6 +721,7 @@ SPEC CHECKSUMS:
   EXBrightness: 1725afacfdaeb4724bb949c44384cff0ef0d7d18
   EXCamera: d7e91d5857faee493ca3cf8dafd42572db61849e
   EXConstants: 3c86653c422dd77e40d10cbbabb3025003977415
+  EXErrorRecovery: ae43433feb0608a64dc5b1c8363b3e7769a9ea24
   EXFileSystem: 60602b6eefa6873f97172c684b7537c9760b50d6
   EXFont: 319606bfe48c33b5b5063fb0994afdc496befe80
   EXImageLoader: 84b65e6bd9d3345d6fbb3ab936a546c54496a64d
@@ -793,4 +799,4 @@ SPEC CHECKSUMS:
 
 PODFILE CHECKSUM: c500841d0cd00b84fdb1d6b4c1b8833eab606c22
 
-COCOAPODS: 1.12.1
+COCOAPODS: 1.14.2

+ 10 - 10
src/app.tsx

@@ -9,16 +9,16 @@ import { View } from '@tarojs/components'
 
 
 const App: React.FC<PropsWithChildren> = ({ children }) => {
-  // return <Provider store={store}>{children}</Provider>
-  return <View>
-    <Provider store={store}>
-      <View style={{ position: 'relative' }}>
-        {children}
-        <View style={{ position: 'absolute', left: 0, bottom: 0, width: 100, height: 100, backgroundColor: 'red',zIndex:10000 }}></View>
-      </View>
-    </Provider>
-
-  </View>
+  return <Provider store={store}>{children}</Provider>
+  // return <View>
+  //   <Provider store={store}>
+  //     <View style={{ position: 'relative' }}>
+  //       {children}
+  //       <View style={{ position: 'absolute', left: 0, bottom: 0, width: 100, height: 100, backgroundColor: 'red',zIndex:10000 }}></View>
+  //     </View>
+  //   </Provider>
+
+  // </View>
 }
 // class App extends Component<PropsWithChildren> {
 

+ 12 - 1
src/components/Modal.scss

@@ -1,3 +1,4 @@
+/* #ifdef weapp */
 .modal {
     position: fixed;
     top: 0;
@@ -9,4 +10,14 @@
     display: flex;
     flex-direction: column;
     background-color: rgba($color: #000000, $alpha: 0.5);
-}
+}
+
+/* #endif */ 
+
+
+/* #ifdef rn */ 
+.modal{
+    
+}
+
+/* #endif */ 

+ 1 - 1
src/components/Rings.weapp.tsx

@@ -2,7 +2,7 @@ import { Canvas } from "@tarojs/components";
 import Taro, { useDidShow, useReady } from "@tarojs/taro";
 import { useEffect, useRef } from "react";
 
-export default function Rings(props: { strokeWidth: number; radius: number; color: string; canvasId?: string }) {
+export default function Rings(props: { strokeWidth: number; radius: number; color: string; canvasId?: string;bgColor?:string }) {
     const progress = 0.85
     const r = props.radius || 80
     const strokeWidth = props.strokeWidth || 10;

+ 90 - 43
src/features/trackSomething/components/Activity.tsx

@@ -8,7 +8,7 @@ import Taro from "@tarojs/taro";
 import { activityCards, uploadSteps } from "@/services/trackSomething";
 import { TimeFormatter } from "@/utils/time_format";
 import MetricItem from "./MetricItem";
-import { checkFail, checkStart, checkSuccess, setResult } from "@/store/action_results";
+import { ResultType, checkFail, checkStart, checkSuccess, setResult } from "@/store/action_results";
 import { uploadSessionKey } from "@/services/common";
 
 export default function Component(props: any) {
@@ -18,7 +18,6 @@ export default function Component(props: any) {
     const [stepInfo, setStepInfo] = useState(null)
     const [lastTime, setLastTime] = useState(new Date().getTime())
     const [isCheking, setIsChecking] = useState(false)
-    const [strBtnTitle, setStrBtnTitle] = useState('')
     const [list, setList] = useState([])
     const dispatch = useDispatch();
     // const [title, setTitle] = useState('打卡')
@@ -46,7 +45,7 @@ export default function Component(props: any) {
     }
 
     function checkAuth() {
-        // Taro.checkSession
+        console.log(new Date().getTime())
         if (user.isLogin) {
             // setAuth()
             Taro.getSetting({
@@ -72,6 +71,7 @@ export default function Component(props: any) {
                             getWeRunData(true)
                         }
                     }
+                    console.log(new Date().getTime())
                 }
             })
         }
@@ -99,6 +99,15 @@ export default function Component(props: any) {
     }
 
     function getWeRunData(autoCheck = false) {
+        Taro.checkSession({
+            success: function () {
+              console.log('打卡前获取session_key 未过期')
+            },
+            fail: function () {
+              console.log('打卡前获取session_key 已过期')
+            }
+          })
+
         // setTitle('打卡');
         setAllowRun(true)
         var date = new Date();
@@ -107,36 +116,60 @@ export default function Component(props: any) {
         Taro.getWeRunData({
             success: res => {
                 // console.log('已获取步数的时间戳:' + new Date().getTime())
-                uploadSteps({
+                var params = {
                     is_manual: autoCheck ? 0 : 1,
                     timestamp: time,
                     encryptedData: res.encryptedData,
                     iv: res.iv,
                     date: strDate,
                     cloudID: res.cloudID,
-                }).then(res => {
-
-                    Taro.setStorageSync('lastUploadStepsTime', time)
-
-                    dispatch(setResult({ isSuccess: true }) as any)
-                    setStepInfo((res as any)[(res as any).length - 1])
-                    setLastTime(time)
-                    setIsChecking(false)
-                    getCards();
+                }
+                uploadSteps(params).then(res => {
+                    uploadSuccess(res, autoCheck, time)
                 }).catch(e => {
-                    dispatch(setResult({ isSuccess: false }) as any);
-                    updateSessionKey();
+                    retry(params, autoCheck, time)
+                    Taro.checkSession({
+                        success: function () {
+                          console.log('打卡后获取session_key 未过期')
+                        },
+                        fail: function () {
+                          console.log('打卡后获取session_key 已过期')
+                        }
+                      })
+                    // if (!autoCheck)
+                    //     dispatch(setResult({ isSuccess: false }) as any);
                 });
             }
         })
     }
 
-    function updateSessionKey(){
+    function retry(params, autoCheck, time) {
         Taro.login().then(res => {
-            // code = res.code;
-            uploadSessionKey({ type: 'WX_MP', code: res.code });
+            Taro.getWeRunData({
+                success: res2 => {
+                    params.code = res.code;
+                    params.encryptedData = res2.encryptedData
+                    params.iv = res2.iv
+                    params.cloudID = res2.cloudID
+                    uploadSteps(params).then(res => {
+                        uploadSuccess(res, autoCheck, time)
+                    }).catch(e => {
+                        if (!autoCheck)
+                            dispatch(setResult({ isSuccess: false }) as any);
+                    })
+                }
+            })
+        })
+    }
 
-          })
+    function uploadSuccess(res, autoCheck, time) {
+        Taro.setStorageSync('lastUploadStepsTime', time)
+        if (!autoCheck)
+            dispatch(setResult({ isSuccess: true }) as any)
+        setStepInfo((res as any)[(res as any).length - 1])
+        setLastTime(time)
+        setIsChecking(false)
+        getCards();
     }
 
     function refuseAuth() {
@@ -163,25 +196,40 @@ export default function Component(props: any) {
     var btnTitle = '';
     var isEnable = true;
     if (allowRun) {
-        if (checkResult.type == 'idle') {
-            btnTitle = '打卡'
-            isEnable = true
-        }
-        else if (checkResult.type == 'ing') {
-            btnTitle = '打卡中...'
-            isEnable = false;
-        }
-        else if (checkResult.type == 'success') {
-            btnTitle = '打卡成功'
-            isEnable = false
-        }
-        else if (checkResult.type == 'fail') {
-            btnTitle = '打卡失败'
-            isEnable = false
-        }
-        else if (checkResult.type == 'countdown') {
-            btnTitle = checkResult.title + 's'
-            isEnable = false;
+        switch (checkResult.type) {
+            case ResultType.idle:
+                {
+                    btnTitle = '打卡'
+                    isEnable = true
+
+                }
+                break;
+            case ResultType.ing:
+                {
+                    btnTitle = '打卡中...'
+                    isEnable = false
+                }
+                break;
+            case ResultType.success:
+                {
+                    btnTitle = '打卡成功'
+                    isEnable = false
+                }
+                break;
+            case ResultType.fail:
+                {
+                    btnTitle = '打卡失败'
+                    isEnable = false
+                }
+                break;
+            case ResultType.countdown:
+                {
+                    btnTitle = checkResult.title + 's'
+                    isEnable = false
+                }
+                break;
+            default:
+                break;
         }
     }
     else {
@@ -209,7 +257,7 @@ export default function Component(props: any) {
                 }
 
                 if (!allowRun) {
-                    value = '未开启'
+                    value = '0'
                     desc = '开启步数仅自己可见'
                 }
 
@@ -220,12 +268,11 @@ export default function Component(props: any) {
                     desc={desc}
                     btnText={btnTitle}
                     isDisabled={!isEnable}
-                    // desc={allowRun ? stepInfo ? TimeFormatter.formatTimestamp(lastTime) : '' : '开启步数仅自己可见'}
-                    // btnText={allowRun ? isCheking ? '打卡中...' : '打卡' : '开启'}
-                    // isDisabled={isCheking}
                     themeColor={item.theme_color}
                     onClickDetail={goDetail}
-                    onClick={checkout}
+                    onClick={() => {
+                        checkout()
+                    }}
                 />
             })
         }

+ 3 - 1
src/features/trackSomething/components/Metric.tsx

@@ -107,6 +107,7 @@ export default function Component(props: any) {
         var max = item.max
         var step = item.step
         var value = item.default_value
+        console.log(value)
         var items: number[] = []
         var items2: number[] = []
 
@@ -124,7 +125,8 @@ export default function Component(props: any) {
         for (var i = 0; i <= 9; i++) {
             items2.push(i)
         }
-        value1Index = 10 * (value - Math.floor(value));
+        value1Index = Math.round(10 * (value - Math.floor(value)));
+        console.log(value1Index)
 
         setPickerValue([value0Index, value1Index] as any)
         setPickerItems([items, items2] as any)

+ 3 - 2
src/features/trackSomething/hooks/werun.tsx

@@ -1,6 +1,6 @@
 import Taro from "@tarojs/taro";
 
-export const setAuth = (getRunData:Function,refuseAuth:Function) => {
+export const setAuth = (getRunData: Function, refuseAuth: Function) => {
     Taro.getSetting({
         success: res => {
             //第一步,检测是否有授权 - 没有授权
@@ -9,7 +9,8 @@ export const setAuth = (getRunData:Function,refuseAuth:Function) => {
                 Taro.authorize({
                     scope: 'scope.werun',
                     success: () => {
-                        debugger
+                        console.log("授权了")
+                        getRunData()
                     },
                     fail: () => {
                         Taro.showModal({

+ 94 - 20
src/features/trackTimeDuration/components/ChooseScenario.tsx

@@ -2,6 +2,7 @@ import { View, Text } from "@tarojs/components";
 import Buttons from '@components/Buttons';
 import Texts from '@components/Texts';
 import Rings from '@components/Rings';
+import Rings2, { BgRing, RingCommon, TargetRing } from './Rings';
 import Footer from '@components/Footer';
 import SingleSelect from '../../../components/SingleSelect';
 import { ComponentStatus, TextType } from "@utils/types";
@@ -19,18 +20,18 @@ import { getPlans } from "@/services/trackTimeDuration";
 export default function Component() {
     const { t } = useTranslation()
     const dispatch = useDispatch();
-    const [selIndex,setSelIndex] = useState(0)
-    const [scenarios,setScenarios] = useState<any[]>([])
+    const [selIndex, setSelIndex] = useState(-1)
+    const [scenarios, setScenarios] = useState<any[]>([])
     const selScenario = useSelector((state: any) => state.scenario);
 
-    useReady(()=>{
+    useReady(() => {
         console.log(selScenario)
         if (selScenario) {
-            if (selScenario.name == 'FAST_SLEEP'){
+            if (selScenario.name == 'FAST_SLEEP') {
                 dispatch(setStep('sleep'))
                 setSelIndex(2)
             }
-            else if (selScenario.name == 'SLEEP'){
+            else if (selScenario.name == 'SLEEP') {
                 dispatch(setStep('sleep'))
                 setSelIndex(1)
             }
@@ -39,7 +40,7 @@ export default function Component() {
                 setSelIndex(0)
             }
         }
-        getPlans().then(res=>{
+        getPlans().then(res => {
             const data = res as { scenarios: any[] };
             setScenarios(data.scenarios)
         })
@@ -66,38 +67,108 @@ export default function Component() {
             case 2:
                 style = {
                     background: 'linear-gradient(to right, #AAFF00, #00FFFF)'
-                  }
+                }
                 break;
         }
         return <View>
-            <Buttons title='Next' onClick={next} style={{...style,width:320}}/>
+            <Buttons title='Next' onClick={next} style={{ ...style, width: 320 }} />
         </View>
     }
 
+    function timeToArc(time: string) {
+        var count: number = parseInt(time.split(':')[1]) + parseInt(time.split(':')[0]) * 60
+        // count = count>720?count-720:count
+        return (count as any) / 1440 * 2 * Math.PI - Math.PI / 2
+    }
+
+    function durationToArc(startTime: string, endTime: string) {
+        var start: number = parseInt(startTime.split(':')[1]) + parseInt(startTime.split(':')[0]) * 60
+        var end: number = parseInt(endTime.split(':')[1]) + parseInt(endTime.split(':')[0]) * 60
+        if (end < start) {
+            end += 1440
+        }
+
+        return (end - start) / 1440 * 2 * Math.PI
+    }
+
+    function getScheduleTarget(isFast: boolean) {
+        for (var i = 0; i < scenarios.length; i++) {
+            if (isFast && scenarios[i].name == 'FAST') {
+                return scenarios[i].schedule.fast
+            }
+            else if (!isFast && scenarios[i].name == 'SLEEP') {
+                return scenarios[i].schedule.sleep
+            }
+
+        }
+        return {
+            start_time: '00:00',
+            end_time: '00:00'
+
+        }
+
+    }
+
     function items() {
         const array: any[] = []
+        const common: RingCommon = {
+            useCase: 'ChooseScenario',
+            radius: 33,
+            lineWidth: 8,
+            isFast: true,
+            status: 'WAIT_FOR_START'
+        }
+        const common2: RingCommon = {
+            useCase: 'ChooseScenario',
+            radius: 23,
+            lineWidth: 6,
+            isFast: true,
+            status: 'WAIT_FOR_START'
+        }
+
+        const bgRing: BgRing = {
+            color: '#262626'
+        }
+
+        const targetRing: TargetRing = {
+            color: '#AAFF00',
+            startArc: timeToArc((getScheduleTarget(true) as any).start_time),
+            durationArc: durationToArc((getScheduleTarget(true) as any).start_time, (getScheduleTarget(true) as any).end_time)
+        }
+
+        const targetRing2: TargetRing = {
+            color: '#00FFFF',
+            startArc: timeToArc((getScheduleTarget(false) as any).start_time),
+            durationArc: durationToArc((getScheduleTarget(false) as any).start_time, (getScheduleTarget(false) as any).end_time)
+        }
+        debugger
+
+
         array.push(
-            <View className="item_row">
-                <Rings radius={33} strokeWidth={8} color='#AAFF00' canvasId='0' />
+            <View className="item_row" style={{ opacity: scenarios.length > 0 ? 1 : 0 }}>
+                <Rings2 common={common} bgRing={bgRing} targetRing={targetRing} canvasId='0' />
+                {/* <Rings radius={33} strokeWidth={8} color='#AAFF00' canvasId='0' /> */}
                 <View className="item_txt_bg">
                     <Text className="item_txt" style={{ color: '#AAFF00' }}>{t('page.choose_scenario.fast')}</Text>
                 </View>
             </View>
         );
         array.push(
-            <View className="item_row">
-                <Rings radius={33} strokeWidth={8} color='#00FFFF' canvasId='1' />
+            <View className="item_row" style={{ opacity: scenarios.length > 0 ? 1 : 0 }}>
+                <Rings2 common={common} bgRing={bgRing} targetRing={targetRing2} canvasId='1' />
+                {/* <Rings radius={33} strokeWidth={8} color='#00FFFF' canvasId='1' /> */}
                 <View className="item_txt_bg">
                     <Text className="item_txt" style={{ color: '#00FFFF' }}>{t('page.choose_scenario.sleep')}</Text>
                 </View>
             </View>
         )
         array.push(
-            <View className="item_row">
+            <View className="item_row" style={{ opacity: scenarios.length > 0 ? 1 : 0 }}>
                 <View style={{ position: 'relative', zIndex: 1 }}>
-                    <Rings radius={33} strokeWidth={8} color='#AAFF00' canvasId='3' />
+                    <Rings2 common={common} bgRing={bgRing} targetRing={targetRing} canvasId='3' />
                     <View style={{ display: 'flex', position: 'absolute', left: 0, right: 0, top: 0, bottom: 0, alignItems: 'center', justifyContent: 'center' }}>
-                        <Rings radius={23} strokeWidth={6} color='#00FFFF' canvasId='4' />
+                        {/* <Rings radius={23} strokeWidth={6} color='#00FFFF' canvasId='4' /> */}
+                        <Rings2 common={common2} bgRing={bgRing} targetRing={targetRing2} canvasId='4' />
                     </View>
                 </View>
                 <View className="item_txt_bg">
@@ -111,10 +182,10 @@ export default function Component() {
     function handleItemSelect(index: number) {
         setSelIndex(index)
         dispatch(setScenario(scenarios[index]) as any)
-        if (index == 0){
+        if (index == 0) {
             dispatch(setStep('fast'))
         }
-        else if (index == 1){
+        else if (index == 1) {
             dispatch(setStep('sleep'))
         }
         else {
@@ -127,9 +198,12 @@ export default function Component() {
         <Texts text={t('page.choose_scenario.title')} type={TextType.primary}></Texts>
         <Texts text={t('page.choose_scenario.sub_title')} type={TextType.secondary}></Texts>
         <View style={{ height: 20 }} />
-        <View style={{ position: 'relative', zIndex: 1 }}>
-            <SingleSelect items={items()} itemSelect={handleItemSelect} selIndex={selIndex}/>
-        </View>
+        {
+            <View style={{ position: 'relative', zIndex: 1 }}>
+                <SingleSelect items={items()} itemSelect={handleItemSelect} selIndex={selIndex} />
+            </View>
+        }
+
 
         <Footer child={footerContent()} />
     </View>;

+ 48 - 4
src/features/trackTimeDuration/components/Clock.tsx

@@ -3,11 +3,10 @@ import trackTimeService, { machine } from "@/store/trackTimeMachine";
 import { View, Text } from "@tarojs/components";
 import { useEffect, useState } from "react";
 import { TimeFormatter } from "@/utils/time_format";
+import Rings2, { BgRing, CurrentDot, RingCommon } from './Rings';
 
 export default function Component() {
     const [checkData, setCheckData] = useState(null)
-    const [counter, setCounter] = useState(0)
-    const [timerId, setTimerId] = useState(null)
 
 
     useEffect(() => {
@@ -24,14 +23,59 @@ export default function Component() {
         });
     }, []);
 
+    const common: RingCommon = {
+        useCase: 'Clock',
+        radius: 50,
+        lineWidth: 8,
+        isFast: true,
+        status: 'WAIT_FOR_START'
+    }
+
+    const common2: RingCommon = {
+        useCase: 'Clock',
+        radius: 40,
+        lineWidth: 8,
+        isFast: true,
+        status: 'WAIT_FOR_START'
+    }
+
+    const bgRing: BgRing = {
+        color: '#262626'
+    }
+
+    const currentDot: CurrentDot = {
+        color: '#AAFF00',
+        lineWidth: 8,
+        borderColor: 'black'
+    }
+
+    const currentDot2: CurrentDot = {
+        color: '#00FFFF',
+        lineWidth: 8,
+        borderColor: 'black'
+    }
+
     if (!checkData)
         return <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', width: '100%', marginTop: 20 }}>
-            <Rings radius={50} />
+            {/* <Rings radius={50} /> */}
+            <Rings2 common={common} bgRing={bgRing} currentDot={currentDot} canvasId='clock0'/>
 
         </View>
     return (
         <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', width: '100%', marginTop: 20 }}>
-            <Rings radius={50} />
+            {/* <Rings radius={50} /> */}
+            {/* <Rings2 common={common} bgRing={bgRing} currentDot={currentDot} /> */}
+
+            <View style={{ position: 'relative', zIndex: 1 }}>
+                <Rings2 common={common} bgRing={bgRing} currentDot={(checkData as any).current_record.scenario == 'SLEEP' ? currentDot2 : currentDot} canvasId='clock1' />
+                <View style={{ display: 'flex', position: 'absolute', left: 0, right: 0, top: 0, bottom: 0, alignItems: 'center', justifyContent: 'center' }}>
+                    {/* <Rings radius={23} strokeWidth={6} color='#00FFFF' canvasId='4' /> */}
+                    {
+                        (checkData as any).current_record.scenario == 'FAST_SLEEP' &&
+                        <Rings2 common={common2} bgRing={bgRing} currentDot={currentDot2} canvasId='clock2' />
+                    }
+                </View>
+            </View>
             {
                 (checkData as any).current_record.status == 'WAIT_FOR_START' && <Text style={{ color: '#AAFF00' }}>00:00:00</Text>
             }

+ 0 - 1
src/features/trackTimeDuration/components/More.tsx

@@ -5,7 +5,6 @@ import { useTranslation } from "react-i18next";
 import { useSelector } from "react-redux";
 import trackTimeService, { machine } from "@/store/trackTimeMachine"
 import { recordCheck } from "@/services/trackTimeDuration";
-import { AtFloatLayout } from "taro-ui";
 import LimitPickers from "@/components/LimitPickers";
 import { endFast } from "../actions/TrackTimeActions";
 import Modal from "@/components/Modal";

+ 128 - 0
src/features/trackTimeDuration/components/Rings.tsx

@@ -0,0 +1,128 @@
+import { Canvas } from "@tarojs/components";
+import Taro from "@tarojs/taro";
+import { useDidShow, useReady } from "@tarojs/taro";
+import { useEffect, useRef } from "react";
+
+export type RingCommon = {
+    useCase: string;
+    status: string;
+    isFast?: boolean;
+    radius: number;
+    lineWidth: number;
+}
+
+export type CurrentDot = {
+    color: string;
+    lineWidth: number;
+    borderColor: string;
+}
+
+export type RealRing = {
+    color: string;
+    startArc: number;
+    durationArc: number;
+}
+
+export type TargetRing = {
+    color: string;
+    startArc: number;
+    durationArc: number;
+}
+
+export type BgRing = {
+    color: string;
+}
+
+export default function Rings(props: {
+    common: RingCommon; currentDot?: CurrentDot;
+    realRing?: RealRing; targetRing?: TargetRing; bgRing: BgRing; canvasId?: string;
+}) {
+    const progress = 0.85
+    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; // 圆形进度条的线宽
+
+    useDidShow(() => {
+        // drawCircle()
+    })
+
+    useReady(() => {
+        drawCircle()
+
+    })
+
+    function drawCircle() {
+        const query = Taro.createSelectorQuery();
+        query.select(`.${canvasId}`).fields({ node: true, size: true });
+        query.exec((res) => {
+            if (res[0] == null) return;
+            const _canvas = res[0].node;
+            _canvas.width = res[0].width * dpr;
+            _canvas.height = res[0].height * dpr;
+            const ctx = _canvas.getContext('2d');
+            // const ctx = Taro.createCanvasContext(canvasId);
+
+
+            const center = radius + lineWidth / 2; // 圆心坐标
+            ctx.clearRect(0, 0, radius * 2, radius * 2); // 清除画布
+
+            // 设置画布尺寸
+            ctx.scale(dpr, dpr);
+
+            // 绘制背景圆
+            ctx.beginPath();
+            ctx.arc(center, center, radius, 0, 2 * Math.PI);
+            ctx.lineWidth = lineWidth;
+            ctx.strokeStyle = props.bgRing.color;
+            ctx.lineCap = 'round'; // 设置为圆角
+            ctx.stroke();
+
+            // 绘制target进度圆
+            if (props.common.useCase == 'ChooseScenario') {
+                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();
+            }
+
+            //绘制current_dot点
+            if (props.common.useCase == 'Clock'){
+                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;
+                ctx.beginPath();
+                ctx.arc(center, center, radius, arc,
+                    arc+0.001);
+                ctx.lineWidth = lineWidth;
+                ctx.strokeStyle = props.currentDot!.borderColor;
+                ctx.lineCap = 'round'; // 设置为圆角
+                ctx.stroke();
+
+                ctx.beginPath();
+                ctx.arc(center, center, radius, arc,
+                    arc+0.001);
+                ctx.lineWidth = lineWidth-2;
+                ctx.strokeStyle = props.currentDot!.color;
+                ctx.lineCap = 'round'; // 设置为圆角
+                ctx.stroke();
+            }
+
+
+            // ctx.draw();
+        });
+    }
+
+    useEffect(() => {
+        drawCircle()
+    }, [props.targetRing,props.currentDot]);
+    return <Canvas canvasId={canvasId} id={canvasId} className={canvasId} type="2d" style={{ width: (radius * 2 + lineWidth), height: (radius * 2 + lineWidth), zIndex: 0 }} ref={canvasRef} />
+
+}

+ 1 - 1
src/features/trackTimeDuration/components/Schedule.tsx

@@ -3,7 +3,7 @@ import trackTimeService, { machine } from "@/store/trackTimeMachine"
 import { useEffect, useState } from "react";
 import Taro from "@tarojs/taro";
 import { TimeFormatter } from "@/utils/time_format";
-import "taro-ui/dist/style/components/float-layout.scss";
+// import "taro-ui/dist/style/components/float-layout.scss";
 import { delRecord } from "@/services/trackTimeDuration";
 import Modal from "@/components/Modal";
 

+ 1 - 1
src/features/trackTimeDuration/components/SetSchedule.tsx

@@ -10,7 +10,7 @@ import { useState } from "react";
 import { useDispatch, useSelector } from "react-redux";
 import Footer from "@/components/Footer";
 import PickerViews from "@/components/PickerViews";
-import "taro-ui/dist/style/components/float-layout.scss";
+// import "taro-ui/dist/style/components/float-layout.scss";
 import { durationDatas, durationIndex, durationTime, pickerDurations } from "../hooks/Console";
 import { TimeFormatter } from "@/utils/time_format";
 import Modal from "@/components/Modal";

+ 2 - 2
src/features/trackTimeDuration/components/SetSchedule_backup.tsx

@@ -10,8 +10,8 @@ import { useState } from "react";
 import { useDispatch, useSelector } from "react-redux";
 import Footer from "@/components/Footer";
 import PickerViews from "@/components/PickerViews";
-import { AtFloatLayout } from "taro-ui";
-import "taro-ui/dist/style/components/float-layout.scss";
+// import { AtFloatLayout } from "taro-ui";
+// import "taro-ui/dist/style/components/float-layout.scss";
 import { durationDatas, durationIndex, durationTime, pickerDurations } from "../hooks/Console";
 import { TimeFormatter } from "@/utils/time_format";
 

+ 2 - 3
src/pages/Profile.tsx

@@ -1,4 +1,5 @@
 import Buttons from "@/components/Buttons";
+import { delSession } from "@/services/common";
 import { clear, logout } from "@/services/user";
 import { View,Text } from "@tarojs/components";
 import Taro from "@tarojs/taro";
@@ -23,9 +24,7 @@ export default function Page(){
     }
 
     function reset(){
-        Taro.login({
-            
-        })
+        delSession({type:'WX_MP'})
     }
 
     return <View  className="container">

+ 5 - 5
src/pages/clock.tsx

@@ -68,11 +68,11 @@ export default function IndexPage() {
   }, [user.isLogin])
 
   function checkSession() {
-    Taro.login().then(res => {
-      // code = res.code;
-      uploadSessionKey({ type: 'WX_MP', code: res.code });
-    })
-    return
+    // Taro.login().then(res => {
+    //   // code = res.code;
+    //   uploadSessionKey({ type: 'WX_MP', code: res.code });
+    // })
+    // return
     if (process.env.TARO_ENV === 'weapp') {
       Taro.checkSession({
         success: function () {

+ 19 - 4
src/services/common.tsx

@@ -1,6 +1,7 @@
-import { setResources,setConfigs } from "@/store/common";
-import { API_GLOBAL_CONFIGS, API_STATIC_RESOURCES, API_UPLOAD_SESSION } from "./http/api";
+import { setResources, setConfigs } from "@/store/common";
+import { API_DEL_SESSION, API_GLOBAL_CONFIGS, API_STATIC_RESOURCES, API_UPLOAD_SESSION } from "./http/api";
 import { request } from "./http/request";
+import Taro from "@tarojs/taro";
 
 
 export const staticResources = () => (dispatch: any) => {
@@ -13,10 +14,10 @@ export const staticResources = () => (dispatch: any) => {
 
 }
 
-export const gobalConfigs = () =>(dispatch:any) =>{
+export const gobalConfigs = () => (dispatch: any) => {
     request({
         url: API_GLOBAL_CONFIGS, method: 'GET', data: {
-            keys:'time_duration'
+            keys: 'time_duration'
         }
     }).then(res => {
         // resolve(res);
@@ -31,4 +32,18 @@ export const uploadSessionKey = (params) => {
         }
     }).then(res => {
     })
+}
+
+export const delSession = (params) => {
+    request({
+        url: API_DEL_SESSION + '?type=WX_MP', method: 'DELETE', data: {
+            ...params
+        }
+    }).then(_ => {
+        Taro.showToast({
+            title: '重置成功',
+            icon: 'success',
+            duration: 2000
+        })
+    })
 }

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

@@ -20,6 +20,7 @@ export const API_CLEAR_SLEEP = `${baseUrl}/api/sleep/clear-my-data`
 export const API_CLEAR_MIX = `${baseUrl}/api/clear-data/FAST_SLEEP`
 export const API_CHECK_UNIQUE = `${baseUrl}/api/user/check-unique`
 export const API_UPLOAD_SESSION = `${baseUrl}/api/thirdparty/wx/session`
+export const API_DEL_SESSION = `${baseUrl}/api/thirdparty/wx/session`
 
 //track time duration
 export const API_FAST_PLANS = `${baseUrl}/api/fast/plans`