Leon il y a 1 an
Parent
commit
5671191d70

+ 10 - 5
src/app.config.ts

@@ -22,7 +22,8 @@ const appConfig = defineAppConfig({
     'pages/workout/WorkoutDetail',
     'pages/workout/Working',
     'pages/workout/History',
-    'pages/account/Member'
+    'pages/account/Member',
+    'pages/explore/Index'
   ],
   subPackages: [
     {
@@ -88,13 +89,17 @@ process.env.TARO_ENV === 'weapp' && (appConfig.tabBar = {
       text: '生物钟',
     },
     {
-      pagePath: 'pages/metric/Metric',
-      text: '指标',
+      pagePath: 'pages/explore/Index',
+      text: '发现',
     },
     {
-      pagePath: 'pages/food/Food',
-      text: '饮食',
+      pagePath: 'pages/metric/Metric',
+      text: '指标',
     },
+    // {
+    //   pagePath: 'pages/food/Food',
+    //   text: '饮食',
+    // },
     {
       // pagePath: 'pages/activity/Activity',
       pagePath: 'pages/workout/Workout',

+ 18 - 9
src/components/navigation/TabBar.tsx

@@ -16,18 +16,24 @@ export default function Component(props: { index: number }) {
                     url: '/pages/clock/Index'
                 })
                 break;
-            case 1:
+            case 2:
+
                 Taro.switchTab({
-                    url: '/pages/metric/Metric'
+                    url: '/pages/explore/Index'
                 })
                 break;
-            case 2:
-
+            case 1:
                 Taro.switchTab({
-                    // url: '/pages/activity/Activity'
-                    url:'/pages/workout/Workout'
+                    url: '/pages/metric/Metric'
                 })
                 break;
+            // case 2:
+
+            //     Taro.switchTab({
+            //         // url: '/pages/activity/Activity'
+            //         url:'/pages/workout/Workout'
+            //     })
+            //     break;
             case 3:
                 Taro.switchTab({
                     url: '/pages/account/Profile'
@@ -45,23 +51,26 @@ export default function Component(props: { index: number }) {
         <View className={selIndex == 0 ? 'tabbar-item tabbar-item-sel' : 'tabbar-item'} onClick={() => switchTab(0)}>
             <Text>生物钟</Text>
         </View>
-        <View className={selIndex == 4 ? 'tabbar-item tabbar-item-sel' : 'tabbar-item'} onClick={() => switchTab(4)}>
+        {/* <View className={selIndex == 4 ? 'tabbar-item tabbar-item-sel' : 'tabbar-item'} onClick={() => switchTab(4)}>
             <View style={{ position: 'relative' }}>
                 <Text>饮食</Text>
                 {
-                    common.showFoodTabBadge && process.env.TARO_ENV=='weapp' && <View className='food-tab-badge' style={{ backgroundColor: ColorType.food }} />
+                    common.showFoodTabBadge && process.env.TARO_ENV == 'weapp' && <View className='food-tab-badge' style={{ backgroundColor: ColorType.food }} />
                 }
             </View>
 
         </View>
         <View className={selIndex == 2 ? 'tabbar-item tabbar-item-sel' : 'tabbar-item'} onClick={() => switchTab(2)}>
             <Text>运动</Text>
+        </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 == 3 ? 'tabbar-item tabbar-item-sel' : 'tabbar-item'} onClick={() => switchTab(3)}>
             <Text>更多</Text>
         </View>

+ 3 - 0
src/context/locales/en.js

@@ -26,6 +26,9 @@ export default {
         workout:{
             title:'Workouts'
         },
+        explore:{
+            title:'Explore'
+        },
         more: {
             title: 'More',
             un_login: 'Not logged in',

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

@@ -26,6 +26,9 @@ export default {
         workout:{
             title:'运动'
         },
+        explore:{
+            title:'发现'
+        },
         more: {
             title: '更多',
             un_login: '未登录',

+ 2 - 1
src/context/themes/color.tsx

@@ -3,7 +3,8 @@ export enum ColorType {
     sleep = '#8961F5',//'#00ffff'
     box = '#121212',
     ring = '#1c1c1c',
-    food = '#FF7A4E',
+    food = '#FF7B00',
+    activity = '#EEC01F',
     workout = 'yellow',
     alert = '#ea6c6c',
     night = '#1446B9',

+ 0 - 93
src/features/trackSomething/components/Discovery.tsx

@@ -1,93 +0,0 @@
-import { View, Text, Image } from "@tarojs/components";
-import { getBgRing, getCommon, getDot, getReal, getSchedule, getTarget } from "@/features/trackTimeDuration/hooks/RingData";
-import { RealRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
-import { ColorType } from "@/context/themes/color";
-import { useSelector } from "react-redux";
-import Rings from "@/features/trackTimeDuration/components/Rings";
-
-export default function Discovery() {
-    const user = useSelector((state: any) => state.user);
-    function bigRing() {
-        var common = getCommon(null, true)
-        common.radius = 42;
-        common.lineWidth = 9;
-        var bgRing = getBgRing()
-        const realRingBig: RealRing = {
-            color: ColorType.day,
-            startArc: 0,
-            durationArc: 2
-        }
-        var sunRise = 24 * 60 + (user.test_user ? 7 * 60 : 6 * 60)
-        var sunSet = user.test_user ? 19 * 60 : 18 * 60
-        var duration = sunRise - sunSet
-        realRingBig.startArc = (sunSet * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
-        realRingBig.durationArc = (duration * 60) / (24 * 3600) * 2 * Math.PI;
-        return <Rings common={common} bgRing={bgRing} realRing={realRingBig} canvasId={'me_big'} />
-    }
-    function smallRing() {
-        var common = getCommon(null, false)
-        common.radius = 28;
-        common.lineWidth = 9;
-        var bgRing = getBgRing()
-        const realRingBig: RealRing = {
-            color: ColorType.day,
-            startArc: 0,
-            durationArc: 2
-        }
-        var sunRise = 24 * 60 + (user.test_user ? 7 * 60 : 6 * 60)
-        var sunSet = user.test_user ? 19 * 60 : 18 * 60
-        var duration = sunRise - sunSet
-        realRingBig.startArc = (sunSet * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
-        realRingBig.durationArc = (duration * 60) / (24 * 3600) * 2 * Math.PI;
-        return <Rings common={common} bgRing={bgRing} realRing={realRingBig} canvasId={'me_small'} />
-    }
-    function dayRing() {
-        var common = getCommon(null, true)
-        common.radius = 56;
-        common.lineWidth = 9;
-        var bgRing = getBgRing()
-
-        const realRingBig: RealRing = {
-            color: ColorType.day,
-            startArc: 0,
-            durationArc: 2
-        }
-        var sunRise = 24 * 60 + (user.test_user ? 7 * 60 : 6 * 60)
-        var sunSet = user.test_user ? 19 * 60 : 18 * 60
-        var duration = sunRise - sunSet
-        realRingBig.startArc = (sunSet * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
-        realRingBig.durationArc = (duration * 60) / (24 * 3600) * 2 * Math.PI;
-        return <Rings common={common} bgRing={bgRing} realRing={realRingBig} canvasId={'me_day'} />
-    }
-
-    function rings() {
-        return <View style={{ position: 'relative', zIndex: 1 }}>
-            {
-                bigRing()
-            }
-            {
-                <View style={{ display: 'flex', position: 'absolute', left: 0, right: 0, top: 0, bottom: 0, alignItems: 'center', justifyContent: 'center' }}>
-                    {
-                        smallRing()
-                    }
-                </View>
-            }
-            {
-                <View style={{ display: 'flex', position: 'absolute', left: -14, top: -14, right: -14, bottom: -14 }}>
-                    {
-                        dayRing()
-                    }
-                </View>
-            }
-
-        </View>
-    }
-    return <View >
-        <View style={{display:'flex',flexDirection:'row'}}>
-        {
-            rings()
-        }
-        </View>
-        
-    </View>
-}

+ 41 - 2
src/features/trackTimeDuration/components/DayLight.tsx

@@ -5,6 +5,7 @@ import Taro from '@tarojs/taro'
 import { useDispatch, useSelector } from 'react-redux'
 import { updateMember } from '@/store/day_night'
 import { systemLocation } from '@/services/common'
+import { clearLocation, latestLocation } from '@/services/user'
 export default function DayLight() {
     const [showRing, setShowRing] = useState(false)
     const [isTomorrow, setIsTomorrow] = useState(false)
@@ -21,7 +22,8 @@ export default function DayLight() {
 
     useEffect(() => {
         setIsMember(user.test_user)
-        dispatch(updateMember({ isMember: user.test_user, authInfo }))
+        if (authInfo)
+            dispatch(updateMember({ isMember: user.test_user, gpsInfo:authInfo }))
         if (user.test_user && authInfo) {
             setSunriseTime((authInfo as any).daylights[0].sunrise)
             setSunsetTime((authInfo as any).daylights[0].sunset)
@@ -32,6 +34,23 @@ export default function DayLight() {
         }
     }, [user.test_user, authInfo])
 
+    useEffect(() => {
+        latestLocation().then(data => {
+            if ((data as any).lat) {
+                (data as any).latitude = (data as any).lat;
+                (data as any).longitude = (data as any).lng;
+                setAuthInfo(data as any)
+                setSunriseTime((data as any).daylights[0].sunrise)
+                setSunsetTime((data as any).daylights[0].sunset)
+                Taro.setStorage({
+                    key: 'gps',
+                    data: JSON.stringify(data as any)
+                })
+                dispatch(updateMember({ isMember: user.test_user, gpsInfo: (data as any) }))
+            }
+        })
+    }, [user.isLogin])
+
     async function getStorage(key: string) {
         try {
             const res = await Taro.getStorage({ key });
@@ -117,6 +136,23 @@ export default function DayLight() {
 
     }
 
+    function clearData() {
+        Taro.showModal({
+            title: '提示',
+            content: '确认清除位置数据?',
+            success: function (res) {
+                if (res.confirm) {
+                    clearLocation().then(res => {
+                        Taro.removeStorage({ key: 'gps' })
+                        setAuthInfo(null)
+                        dispatch(updateMember({ isMember: user.test_user, gpsInfo: null }))
+                    })
+                } else if (res.cancel) {
+                    console.log('用户点击取消')
+                }
+            }
+        })
+    }
 
 
     var split = new Date().toString().split(' ');
@@ -146,7 +182,7 @@ export default function DayLight() {
                     <Text>{sunsetTime}</Text>
                 </View>
                 <View className="daylight_row">
-                    <Text>{isTomorrow ? 'Sunrise tomororow' : 'Sunrise today'}</Text>
+                    <Text>Sunrise tomororow</Text>
                     <Text>{sunriseTime}</Text>
                 </View>
                 <Text className='daylight_note'>{isMember ? 'Calculated based on your location.' : 'Sunset and sunrise times are global average. For actual times at your location, join our Pro program.'}</Text>
@@ -186,6 +222,9 @@ export default function DayLight() {
 
                             </View>
                         }
+                        {
+                            authInfo && <Text style={{ color: '#fff' }} onClick={clearData}>清除位置数据</Text>
+                        }
 
                     </View> :
                         <View className='become_vip' onClick={buy}>

+ 11 - 0
src/features/trackTimeDuration/components/Discovery.scss

@@ -0,0 +1,11 @@
+.food_btn1{
+    margin-left: 46px;
+    margin-right: 46px;
+    height: 84px;
+    border-radius: 42px;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    margin-bottom: 36px;
+
+}

+ 325 - 0
src/features/trackTimeDuration/components/Discovery.tsx

@@ -0,0 +1,325 @@
+import { View, Text, Image, Switch } from "@tarojs/components";
+import { dotIsOuterRange, getBgRing, getCommon, getDot, getReal, getSchedule, getTarget } from "@/features/trackTimeDuration/hooks/RingData";
+import { RealRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
+import { ColorType } from "@/context/themes/color";
+import { useSelector } from "react-redux";
+import Rings from "@/features/trackTimeDuration/components/Rings";
+import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
+import { rpxToPx } from "@/utils/tools";
+import { useEffect, useState } from "react";
+import Taro from "@tarojs/taro";
+import './Discovery.scss'
+import { useTranslation } from "react-i18next";
+import { TimeFormatter } from "@/utils/time_format";
+
+
+let useNavigation;
+if (process.env.TARO_ENV == 'rn') {
+    useNavigation = require("@react-navigation/native").useNavigation
+}
+
+export default function Discovery() {
+    const user = useSelector((state: any) => state.user);
+    const dayNight = useSelector((state: any) => state.dayNight);
+    const [showRing, setShowRing] = useState(false)
+    const [schedule, setSchedule] = useState(null)
+    const { t } = useTranslation()
+
+    let navigation;
+    let timeStamp = new Date().getTime()
+    if (useNavigation) {
+        navigation = useNavigation()
+    }
+
+    useEffect(() => {
+        getContent()
+    }, [])
+
+    useEffect(() => {
+        setSchedule(global.homeData.scenarios)
+    }, [global.homeData])
+
+    async function getStorage(key: string) {
+        try {
+            const res = await Taro.getStorage({ key });
+            return res.data;
+        } catch {
+            return '';
+        }
+    }
+
+    async function getContent() {
+        const isShow = await getStorage('showDayRing') || false
+        setShowRing(isShow)
+    }
+
+    console.log(global.homeData)
+
+    function getFoodTime() {
+        var obj;
+        (schedule as any).map(item => {
+            if (item.name == 'FAST') {
+                obj = item
+            }
+        })
+        return [obj.schedule.fast.end_time, obj.schedule.fast.start_time]
+    }
+
+    function getActivityTime() {
+        var obj;
+        (schedule as any).map(item => {
+            if (item.name == 'SLEEP') {
+                obj = item
+            }
+        })
+        return [obj.schedule.sleep.end_time, obj.schedule.sleep.start_time]
+    }
+
+    function bigRing() {
+        var common = getCommon(null, true)
+        common.radius = 42;
+        common.lineWidth = 9;
+        var bgRing = getBgRing()
+        const realRingBig: RealRing = {
+            color: ColorType.food,
+            startArc: 0,
+            durationArc: 2
+        }
+        var list = getFoodTime()
+        var start = parseInt(list[0].split(':')[0]) * 60 + parseInt(list[0].split(':')[1])
+        var end = parseInt(list[1].split(':')[0]) * 60 + parseInt(list[1].split(':')[1])
+        if (end < start) {
+            end += 24 * 60
+        }
+        var duration = end - start
+        realRingBig.startArc = (start * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
+        realRingBig.durationArc = (duration * 60) / (24 * 3600) * 2 * Math.PI;
+
+        var currentDot = getDot(null, false)
+        var date = new Date()
+        var minutes = date.getHours() * 60 + date.getMinutes()
+        if (minutes < start) {
+            minutes += 1440
+        }
+
+        if (start <= minutes && end > minutes) {
+            currentDot.color = ColorType.food
+        }
+        else {
+            currentDot.color = ColorType.ring
+        }
+        return <Rings common={common} bgRing={bgRing} realRing={realRingBig} currentDot={currentDot} canvasId={timeStamp + '_big'} />
+    }
+    function smallRing() {
+        var common = getCommon(null, false)
+        common.radius = 28;
+        common.lineWidth = 9;
+        var bgRing = getBgRing()
+        const realRingBig: RealRing = {
+            color: ColorType.activity,
+            startArc: 0,
+            durationArc: 2
+        }
+        var list = getActivityTime()
+        var start = parseInt(list[0].split(':')[0]) * 60 + parseInt(list[0].split(':')[1])
+        var end = parseInt(list[1].split(':')[0]) * 60 + parseInt(list[1].split(':')[1])
+        if (end < start) {
+            end += 24 * 60
+        }
+        var duration = end - start
+        realRingBig.startArc = (start * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
+        realRingBig.durationArc = (duration * 60) / (24 * 3600) * 2 * Math.PI;
+
+        var currentDot = getDot(null, false)
+        var date = new Date()
+        var minutes = date.getHours() * 60 + date.getMinutes()
+        if (minutes < start) {
+            minutes += 1440
+        }
+
+        if (start <= minutes && end > minutes) {
+            currentDot.color = ColorType.activity
+        }
+        else {
+            currentDot.color = ColorType.ring
+        }
+        return <Rings common={common} bgRing={bgRing} realRing={realRingBig} currentDot={currentDot} canvasId={timeStamp + '_small'} />
+    }
+    function dayRing() {
+        var common = getCommon(null, true)
+        common.radius = 56;
+        common.lineWidth = 9;
+        var bgRing = getBgRing()
+
+        const realRingBig: RealRing = {
+            color: ColorType.day,
+            startArc: 0,
+            durationArc: 2
+        }
+        var sunRise = 6 * 60
+        var sunSet = 18 * 60
+
+
+        if (dayNight.gpsInfo && user.test_user) {
+            var sunRiseObj = dayNight.gpsInfo.daylights[0].sunrise
+            var sunSetObj = dayNight.gpsInfo.daylights[0].sunset
+            sunRise = parseInt(sunRiseObj.split(':')[0]) * 60 + parseInt(sunRiseObj.split(':')[1])
+            sunSet = parseInt(sunSetObj.split(':')[0]) * 60 + parseInt(sunSetObj.split(':')[1])
+            if (sunSetObj.indexOf('PM') != -1) {
+                sunSet += 12 * 60
+            }
+        }
+
+        var duration = sunSet - sunRise
+
+        realRingBig.startArc = (sunRise * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
+        realRingBig.durationArc = (duration * 60) / (24 * 3600) * 2 * Math.PI;
+
+        var currentDot = getDot(null, false)
+        var date = new Date()
+        var minutes = date.getHours() * 60 + date.getMinutes()
+        if (minutes < sunRise) {
+            minutes += 1440
+        }
+
+        if (sunRise <= minutes && sunSet > minutes) {
+            currentDot.color = ColorType.day
+        }
+        else {
+            currentDot.color = ColorType.ring
+        }
+
+        return <Rings common={common} bgRing={bgRing} realRing={realRingBig} currentDot={currentDot} canvasId={timeStamp + '_day'} />
+    }
+
+    function goAcitivity() {
+        if (user.isLogin) {
+            jumpPage('/pages/activity/Activity', 'Activity', navigation)
+            return
+        }
+        jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
+    }
+
+    function goFood() {
+        if (user.isLogin) {
+            jumpPage('/pages/food/Food', 'Food', navigation)
+            return
+        }
+        jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
+    }
+
+    function dayDuration() {
+        if (dayNight.gpsInfo && dayNight.isMember) {
+            var sunRiseObj = dayNight.gpsInfo.daylights[0].sunrise
+            var sunSetObj = dayNight.gpsInfo.daylights[0].sunset
+            var sunRise = parseInt(sunRiseObj.split(':')[0]) * 60 + parseInt(sunRiseObj.split(':')[1])
+            var sunSet = parseInt(sunSetObj.split(':')[0]) * 60 + parseInt(sunSetObj.split(':')[1])
+            if (sunSetObj.indexOf('PM') != -1) {
+                sunSet += 12 * 60
+            }
+
+            var duration = (sunSet - sunRise) * 60 * 1000
+
+            return TimeFormatter.calculateTimeDifference(new Date().getTime(), new Date().getTime() + duration);
+        } else {
+            return '12小时'
+        }
+    }
+
+    function eatDuration() {
+        var list = getFoodTime()
+        var start = parseInt(list[0].split(':')[0]) * 60 + parseInt(list[0].split(':')[1])
+        var end = parseInt(list[1].split(':')[0]) * 60 + parseInt(list[1].split(':')[1])
+        if (end < start) {
+            end += 24 * 60
+        }
+        var duration = (end - start) * 60 * 1000
+        return TimeFormatter.calculateTimeDifference(new Date().getTime(), new Date().getTime() + duration);
+    }
+
+    function activityDuration() {
+        var list = getActivityTime()
+        var start = parseInt(list[0].split(':')[0]) * 60 + parseInt(list[0].split(':')[1])
+        var end = parseInt(list[1].split(':')[0]) * 60 + parseInt(list[1].split(':')[1])
+        if (end < start) {
+            end += 24 * 60
+        }
+        var duration = (end - start) * 60 * 1000
+        return TimeFormatter.calculateTimeDifference(new Date().getTime(), new Date().getTime() + duration);
+    }
+
+    function rings() {
+        return <View style={{ position: 'relative', zIndex: 1 }}>
+            {
+                bigRing()
+            }
+            {
+                <View style={{ display: 'flex', position: 'absolute', left: 0, right: 0, top: 0, bottom: 0, alignItems: 'center', justifyContent: 'center' }}>
+                    {
+                        smallRing()
+                    }
+                </View>
+            }
+            {
+                showRing && <View style={{ display: 'flex', position: 'absolute', left: -14, top: -14, right: -14, bottom: -14 }}>
+                    {
+                        dayRing()
+                    }
+                </View>
+            }
+
+        </View>
+    }
+    return <View style={{ display: 'flex', flexDirection: 'column' }}>
+        <View style={{ display: 'flex', flexDirection: 'row', marginLeft: 50, marginBottom: 50,alignItems:'center' }}>
+            {
+                schedule && rings()
+            }
+            {schedule && <View className="duration_bg">
+                {
+                    showRing && <Text className="duration_title">白天</Text>
+                }
+                {
+                    showRing &&
+                    <Text className="duration_value" style={{ color: ColorType.day }}>{dayDuration()}</Text>
+                }
+                {
+                    <Text className="duration_title">限时进食</Text>
+                }
+                {
+                    <Text className="duration_value" style={{ color: ColorType.food }}>{eatDuration()}</Text>
+                }
+                {
+                    <Text className="duration_title">活动</Text>
+                }
+                {
+                    <Text className="duration_value" style={{ color: ColorType.activity }}>{activityDuration()}</Text>
+                }
+            </View>
+            }
+        </View>
+        <View className="food_btn1" style={{ backgroundColor: ColorType.food }} onClick={goFood}>
+            <Text style={{fontWeight:'bold'}}>食物日记</Text>
+        </View>
+        <View className="food_btn1" style={{ backgroundColor: ColorType.activity }} onClick={goAcitivity}>
+            <Text style={{fontWeight:'bold'}}>运动训练</Text>
+        </View>
+        <View style={{
+            display: 'flex', flexDirection: 'row',
+            justifyContent: 'space-between',
+            marginLeft: rpxToPx(46), marginRight: rpxToPx(46)
+        }}>
+            <Text style={{ color: '#fff' }}>白天</Text>
+            <Switch checked={showRing}
+                onChange={(e) => {
+                    setShowRing(e.detail.value)
+                    Taro.setStorage({
+                        key: 'showDayRing',
+                        data: e.detail.value
+                    })
+                }}
+            />
+        </View>
+
+    </View>
+}

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

@@ -207,7 +207,7 @@ export default function Component(props: { type: string, data: any, time: any })
         var sunRise = 24 * 60 +  6 * 60
         var sunSet = 18 * 60
 
-        if (dayNight.gpsInfo && dayNight.isMember){
+        if (dayNight.gpsInfo && user.test_user){
             var sunRiseObj = dayNight.gpsInfo.daylights[0].sunrise
             var sunSetObj = dayNight.gpsInfo.daylights[0].sunset
             sunRise = 24*60+parseInt(sunRiseObj.split(':')[0])*60+parseInt(sunRiseObj.split(':')[1])
@@ -333,7 +333,7 @@ export default function Component(props: { type: string, data: any, time: any })
             <View className="duration_bg">
                 {
                     props.type == 'FAST_SLEEP' && user.isLogin && global.showNightRing === true &&
-                    <Text className="duration_title">夜</Text>
+                    <Text className="duration_title">夜</Text>
                 }
                 {
                     props.type == 'FAST_SLEEP' && user.isLogin && global.showNightRing === true &&

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

@@ -44,6 +44,7 @@ export default function WeekCalendar(props: { calendars: any }) {
             <View className="chart_content_bg" />
             <ScrollView className="chart_scroll"
                 onScroll={onScroll}
+                scrollLeft={(props.calendars.length - 1)*rpxToPx(658)}
                 scrollX pagingEnabled={true}
                 enableFlex enhanced>
                 {

+ 2 - 2
src/pages/account/Profile.tsx

@@ -15,7 +15,7 @@ import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
 import Tabbar from "@/components/navigation/TabBar";
 import { getInfoSuccess } from "@/store/user";
 import TitleView from "@/features/trackTimeDuration/components/TitleView";
-import Discovery from "@/features/trackSomething/components/Discovery";
+
 let useNavigation;
 if (process.env.TARO_ENV == 'rn') {
     useNavigation = require("@react-navigation/native").useNavigation
@@ -159,7 +159,7 @@ export default function Page() {
                 </View>
             </Box>
 
-            <Discovery />
+            
 
             <Box>
                 <View className="balance" onClick={tapBalance}>

+ 1 - 1
src/pages/activity/Activity.tsx

@@ -32,7 +32,7 @@ export default function Page() {
     return (
         <View>
             <Activity />
-            <Tabbar index={2} />
+            {/* <Tabbar index={2} /> */}
         </View>
     )
 }

+ 9 - 0
src/pages/clock/Index.config.ts

@@ -0,0 +1,9 @@
+export default definePageConfig({
+    usingComponents: {
+        // 'ec-canvas': '../../lib/ec-canvas/ec-canvas',
+        // 'demo':'../../components/demo'
+    },
+    // "disableScroll": true,
+    "enablePullDownRefresh": false,
+    "navigationBarTitleText": ""
+})

+ 17 - 0
src/pages/clock/Index.scss

@@ -10,6 +10,7 @@
     font-weight: bold;
     font-size: 48px;
     margin-top: 64px;
+    line-height: 48px;
     margin-bottom: 22px;
 }
 
@@ -68,4 +69,20 @@
 
 .swiper1{
     height: 500px;
+}
+
+/* #ifdef weapp */
+.fast_sleep_more {
+    background: linear-gradient(90deg, $fastColor 0%, $sleepColor 100%);
+    -webkit-background-clip: text;
+    background-clip: text;
+    color: transparent;
+}
+/* #endif */
+
+.index_more{
+    margin-right: 46px;
+    line-height: 48px;
+    margin-top: 64px;
+    margin-bottom: 22px;
 }

+ 35 - 3
src/pages/clock/Index.tsx

@@ -24,11 +24,26 @@ import DayLight from "@/features/trackTimeDuration/components/DayLight";
 import { getInfo } from "@/services/user";
 import { TimeFormatter } from "@/utils/time_format";
 import WeekCalendar from "@/features/trackTimeDuration/components/WeekCalendar";
+import { useTranslation } from "react-i18next";
+import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
+
+let GradientText
+let useNavigation;
+
+if (process.env.TARO_ENV == 'rn') {
+    GradientText = require('@/components/basic/GradientText').default
+    useNavigation = require("@react-navigation/native").useNavigation
+}
 
 export default function Page() {
     const dispatch = useDispatch();
     global.dispatch = dispatch;
+    let navigation;
+    if (useNavigation) {
+        navigation = useNavigation()
+    }
 
+    const { t } = useTranslation()
     const user = useSelector((state: any) => state.user);
     const time = useSelector((state: any) => state.time);
     const [showErrorPage, setErrorPage] = useState(false)
@@ -120,6 +135,7 @@ export default function Page() {
     function getCheckData() {
         clockHome().then(res => {
             setHomeData(res as any)
+            global.homeData = res
         })
 
         getHistory()
@@ -128,9 +144,9 @@ export default function Page() {
     function getRecords() {
         var timestamp = TimeFormatter.getMondayTimestamp()
         var list: any = []
-        var offset = 12*3600*1000
+        var offset = 12 * 3600 * 1000
         for (var i = 0; i < 7; i++) {
-            list.push(`${i},${timestamp - 7 * 24 * 3600 * 1000 * i-offset},${timestamp - 7 * 24 * 3600 * 1000 * i + 7 * 24 * 3600 * 1000-offset}`)
+            list.push(`${i},${timestamp - 7 * 24 * 3600 * 1000 * i - offset},${timestamp - 7 * 24 * 3600 * 1000 * i + 7 * 24 * 3600 * 1000 - offset}`)
             // list.push({
             //     start:timestamp-7*24*3600*1000*i,
             //     end:timestamp-7*24*3600*1000*i+24*3600*100,
@@ -324,6 +340,13 @@ export default function Page() {
         </View>
     }
 
+    function more() {
+        jumpPage('/pages/common/RecordsHistory?type=time&title=time', 'RecordsHistory', navigation, {
+            type: 'time',
+            title: 'time'
+        })
+    }
+
     var timestamp = new Date().getTime()
 
     function render() {
@@ -418,8 +441,17 @@ export default function Page() {
             {
                 user.isLogin && <DayLight />
             }
+            <View style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between' }}>
+                {
+                    user.isLogin && <Text className="discovery">最近</Text>
+                }
+                {
+                    process.env.TARO_ENV == 'weapp' && <Text className="fast_sleep_more index_more" onClick={more}>{t('feature.track_time_duration.record_fast_sleep.header.btn_show_all')}</Text>
+                }
+            </View>
             {
-                user.isLogin && <Text className="discovery">最近</Text>
+                process.env.TARO_ENV == 'rn' && <GradientText onClick={more} style={{ fontSize: rpxToPx(32), fontWeight: 'bold' }}>{t('feature.track_time_duration.record_fast_sleep.header.btn_show_all')}</GradientText>
+                //<Text className="header_action fast_sleep_text"  onClick={() => { props.action!() }}>{t('feature.track_time_duration.record_fast_sleep.header.btn_show_all')}</Text>
             }
             {
                 records.length > 0 && <View className="fast_sleep_item_bg">

+ 28 - 3
src/pages/common/RecordsHistory.scss

@@ -1,4 +1,4 @@
-.no_records_bg{
+.no_records_bg {
     position: absolute;
     left: 0;
     top: 0;
@@ -9,13 +9,38 @@
     justify-content: center;
 }
 
-.no_records{
+.no_records {
     color: #fff;
     font-size: 72px;
 }
 
-.fast_sleep_item_bg{
+.fast_sleep_item_bg {
     display: flex;
     flex-direction: column;
     flex-direction: 0;
+}
+
+.filter_bar {
+    display: flex;
+    flex-direction: row;
+    align-items: center;
+    margin-left: 46px;
+    margin-bottom: 30px;
+}
+
+.filter_item_normal {
+    margin-right: 40px;
+    color: #fff;
+    opacity: 0.4;
+    font-size: 32px;
+    line-height: 32px;
+    font-weight: bold;
+}
+
+.filter_item_sel {
+    margin-right: 40px;
+    font-size: 32px;
+    line-height: 32px;
+    font-weight: bold;
+    color: #fff;
 }

+ 54 - 5
src/pages/common/RecordsHistory.tsx

@@ -20,13 +20,14 @@ import WorkoutHistory from "@/features/workout/WorkoutHistory";
 
 let useRoute;
 let useNavigation;
+let scenario = '';
 if (process.env.TARO_ENV == 'rn') {
     useRoute = require("@react-navigation/native").useRoute
     useNavigation = require("@react-navigation/native").useNavigation
 }
 
 export default function Page() {
-    const {t} = useTranslation()
+    const { t } = useTranslation()
     let router
     let navigation;
     if (useNavigation) {
@@ -36,17 +37,17 @@ export default function Page() {
     if (process.env.TARO_ENV == 'rn') {
         router = useRoute()
         var title = ''
-        if (router.params.type == 'time'){
+        if (router.params.type == 'time') {
             title = t('page.clock.title')
         }
-        else if (router.params.type=='metric'){
+        else if (router.params.type == 'metric') {
             title = t('page.metric.title')
         }
         else if (router.params.type == 'workout') {
             title = t('page.workout.title')
         }
         navigation.setOptions({
-            headerBackTitle:title
+            headerBackTitle: title
         });
     }
     else {
@@ -68,6 +69,7 @@ export default function Page() {
     const [summary_stats, setSummaryStats] = useState(null)
     const user = useSelector((state: any) => state.user);
     const [count, setCount] = useState(0)
+    const [filterIndex, setFilterIndex] = useState(0)
 
     useEffect(() => {
         refresh()
@@ -83,6 +85,28 @@ export default function Page() {
         };
     }, [timerId]);
 
+    useEffect(() => {
+        var name = ''
+        switch (filterIndex) {
+            case 0:
+                name = ''
+                break;
+            case 1:
+                name = 'FAST_SLEEP'
+                break;
+            case 2:
+                name = 'FAST'
+                break;
+            case 3:
+                name = 'SLEEP'
+                break;
+        }
+        scenario = name
+        setPageIndex(1)
+        refresh()
+
+    }, [filterIndex])
+
     const startTimer = () => {
         // 避免重复启动定时器
         if (timerId) {
@@ -98,7 +122,7 @@ export default function Page() {
 
 
     useReady(() => {
-        refresh()
+        // refresh()
     })
 
     usePullDownRefresh(() => {
@@ -157,6 +181,7 @@ export default function Page() {
             getClockRecords({
                 page: page,
                 limit: pageSize,
+                scenario: scenario,
                 // completed: true,
                 part_completed: true
             }).then(res => {
@@ -300,12 +325,36 @@ export default function Page() {
         }
     }
 
+    function tapFilter(index) {
+        setFilterIndex(index)
+    }
+
+    function filters() {
+        return <View className="filter_bar">
+            <View onClick={() => { tapFilter(0) }}>
+                <Text className={filterIndex == 0 ? 'filter_item_sel' : 'filter_item_normal'}>全部</Text>
+            </View>
+            <View onClick={() => { tapFilter(1) }}>
+                <Text className={filterIndex == 1 ? 'filter_item_sel' : 'filter_item_normal'}>断食与睡眠</Text>
+            </View>
+            <View onClick={() => { tapFilter(2) }}>
+                <Text className={filterIndex == 2 ? 'filter_item_sel' : 'filter_item_normal'}>断食</Text>
+            </View>
+            <View onClick={() => { tapFilter(3) }}>
+                <Text className={filterIndex == 3 ? 'filter_item_sel' : 'filter_item_normal'}>睡眠</Text>
+            </View>
+        </View>
+    }
+
     function detail() {
         if (router.params.type == 'time') {
             return <View>
                 {
                     user.test_user && <Text style={{ color: '#fff', position: 'absolute', right: 50, top: 0 }} onClick={() => global.clearHistory()}>删除全部</Text>
                 }
+                {
+                    filters()
+                }
                 {
                     records.map((item, index) => {
                         return <View className="fast_sleep_item_bg">

+ 9 - 0
src/pages/explore/Index.config.ts

@@ -0,0 +1,9 @@
+export default definePageConfig({
+    usingComponents: {
+        // 'ec-canvas': '../../lib/ec-canvas/ec-canvas',
+        // 'demo':'../../components/demo'
+    },
+    // "disableScroll": true,
+    "enablePullDownRefresh": false,
+    "navigationBarTitleText": ""
+})

+ 0 - 0
src/features/trackSomething/components/Discovery.scss → src/pages/explore/Index.scss


+ 44 - 0
src/pages/explore/Index.tsx

@@ -0,0 +1,44 @@
+import { View } from "@tarojs/components";
+import Tabbar from "@/components/navigation/TabBar";
+import Layout from "@/components/layout/layout";
+import { useTranslation } from "react-i18next";
+import { NaviBarTitleShowType, TemplateType } from "@/utils/types";
+import TitleView from "@/features/trackTimeDuration/components/TitleView";
+import Discovery from "@/features/trackTimeDuration/components/Discovery";
+import { useEffect, useState } from "react";
+
+export default function Explore() {
+    const { t } = useTranslation()
+    const [count, setCount] = useState(0)
+
+    useEffect(() => {
+        setInterval(() => {
+            setCount((prevCounter) => prevCounter + 1)
+        }, 1000)
+    }, [])
+
+    function detail() {
+        return <View>
+            <Discovery />
+        </View>
+    }
+
+    function headerView() {
+        return <TitleView title={t('page.explore.title')} showAddBtn={false} onClick={() => { }}>
+        </TitleView>
+    }
+    return <View>
+        <View style={{ position: 'relative' }}>
+            <Layout children={detail()}
+                title={t('page.explore.title')}
+                type={TemplateType.customHeader}
+                header={headerView()}
+                // refresh={() => { getCards() }}
+                // triggered={triggered}
+                titleShowStyle={NaviBarTitleShowType.scrollToShow}
+                showPullToRefresh={false}
+            />
+        </View>
+        <Tabbar index={2} />
+    </View>
+}

+ 1 - 1
src/pages/food/Food.tsx

@@ -63,7 +63,7 @@ export default function Page() {
 
     return <View>
         <FoodJournal />
-        <Tabbar index={4} />
+        {/* <Tabbar index={4} /> */}
     </View>
 
     // return <View className="food_bg">

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

@@ -25,6 +25,7 @@ export const API_UPLOAD_SESSION = `${baseUrl}/api/thirdparty/wx/session`
 export const API_DEL_SESSION = `${baseUrl}/api/thirdparty/wx/session`
 export const API_USER_PERMS =  `${baseUrl}/api/user/perms`
 export const API_SYSTEM_LOCATION =  `${baseUrl}/api/system/location`
+export const API_USER_LOCATION =  `${baseUrl}/api/user/location`
 
 //track time duration
 export const API_FAST_PLANS = `${baseUrl}/api/fast/plans`

+ 27 - 1
src/services/user.tsx

@@ -1,5 +1,5 @@
 import Taro from '@tarojs/taro'
-import { API_OAUTH_LOGIN, API_REGISTER, API_LOGIN, API_LOGOUT, API_CLEAR_USER, API_USER_INFO, API_CHECK_UNIQUE, API_CLIENT_ID, API_USER_PERMS } from './http/api'
+import { API_OAUTH_LOGIN, API_REGISTER, API_LOGIN, API_LOGOUT, API_CLEAR_USER, API_USER_INFO, API_CHECK_UNIQUE, API_CLIENT_ID, API_USER_PERMS, API_USER_LOCATION } from './http/api'
 import { request } from './http/request'
 import { clearSuccess, getInfoSuccess, loginSuccess, logoutSuccess, registerSuccess, updateSuccess } from '@/store/user'
 
@@ -121,6 +121,32 @@ export const clear = () => (dispatch: any) => {
     })
 }
 
+export const latestLocation = () => {
+    return new Promise((resolve, reject) => {
+        request({
+            url: API_USER_LOCATION, method: 'GET', data: {}
+        }).then(res => {
+            return resolve(res)
+            // dispatch(getInfoSuccess(res));
+        }).catch(e => {
+            return reject(e)
+        })
+    })
+}
+
+export const clearLocation = () => {
+    return new Promise((resolve, reject) => {
+        request({
+            url: API_USER_LOCATION, method: 'DELETE', data: {}
+        }).then(res => {
+            return resolve(res)
+            // dispatch(getInfoSuccess(res));
+        }).catch(e => {
+            return reject(e)
+        })
+    })
+}
+
 export const getInfo = () => {
     return new Promise((resolve, reject) => {
         request({

+ 1 - 0
src/store/day_night.tsx

@@ -49,6 +49,7 @@ const dayNightSlice = createSlice({
                 state.sunSet = '18:00'
                 state.sunRiseTomorrow = '06:00'
                 state.sunSetTomorrow = '18:00'
+                state.gpsInfo = gpsInfo?gpsInfo:null
             }
         },
     }

+ 7 - 6
src/utils/common.scss

@@ -1,10 +1,11 @@
 $themeColor: #AAFF00;
 $grayColor: #1C1C1C;
-$tipBgColor:#2c2c2c;
+$tipBgColor: #2c2c2c;
 $fastColor: #00ffff;
 $sleepColor: #8961F5;
 $alertColor: #ea6c6c;
-$foodColor: #FF7A4E;
+$foodColor: #ff7b00; //#FF7A4E;
+$activityColor: #EEC01F;
 $alertFastColor: #00ffff66;
 $alertSleepColor: #8961F566;
 
@@ -13,10 +14,10 @@ $ringColor: #1c1c1c;
 $blackColor: #000000;
 $whiteColor: #ffffff;
 
-$boxBorderRadius:36px;
-$boxPadding:40px;
+$boxBorderRadius: 36px;
+$boxPadding: 40px;
 
-$historyItemMarginBottom:16px;
+$historyItemMarginBottom: 16px;
 
 
 /* #ifdef weapp */
@@ -37,5 +38,5 @@ $historyItemMarginBottom:16px;
     background-clip: text;
     color: transparent;
 }
-/* #endif */
 
+/* #endif */