Leon 1 年之前
父節點
當前提交
605cf79606

+ 5 - 2
src/_health/base/new_button.tsx

@@ -16,7 +16,8 @@ export enum NewButtonType {
     link = 'link',  //超链接(有可能带icon)
     label = 'label',
     more = 'more',
-    img = 'image'
+    img = 'image',
+    custom = 'custom',
 }
 
 function hexToHSL(hex) {
@@ -78,6 +79,7 @@ export default function NewButton(props: {
     fontNormal?: boolean,
     labelBorder?: boolean,
     btnStyle?: any,
+    borderRadius?: number,
     postBtn?: boolean
 }) {
 
@@ -89,7 +91,7 @@ export default function NewButton(props: {
             style = {
                 height: props.height ?? rpxToPx(72),
                 width: props.width ?? rpxToPx(198),
-                borderRadius: props.height ? props.height / 2 : rpxToPx(72 / 2),
+                borderRadius: props.borderRadius ? props.borderRadius : props.height ? props.height / 2 : rpxToPx(72 / 2),
                 backgroundColor: isTouched ? hexToHSL(props.color) : props.disable ? '#B2B2B2' : props.color,
                 color: '#fff',
                 fontSize: props.fontSize ?? rpxToPx(30),
@@ -277,6 +279,7 @@ export default function NewButton(props: {
                 <IconMore color={MainColorType.link} width={rpxToPx(34)} />
             </View>
         case NewButtonType.img:
+        case NewButtonType.custom:
             return <View style={{ opacity: isTouched ? 0.6 : 1, ...props.btnStyle, display: 'flex', alignItems: 'center', justifyContent: 'center' }} onClick={(e) => {
                 if (process.env.TARO_ENV == 'weapp') {
                     e.stopPropagation()

+ 1 - 1
src/_record/components/ring_progress.tsx

@@ -229,7 +229,7 @@ export default function RingProgress(props: {
                 const img1 = _canvas.createImage(); // 创建图像对象
                 img1.src = global.checkImg
                 img1.onload = () => {
-                    ctx.drawImage(img1, 162, 30, rpxToPx(400), rpxToPx(340));
+                    ctx.drawImage(img1, rpxToPx(384), rpxToPx(70), rpxToPx(400), rpxToPx(340));
                     ctx.stroke();
                     if (props.shareCover && _canvas) {
                         save(_canvas)

+ 10 - 0
src/_record/pages/log_record.scss

@@ -265,4 +265,14 @@
     box-sizing: border-box;
     display: flex;
     flex-direction: column;
+}
+
+.share_btn1{
+    display: flex;
+    flex-direction: row;
+    align-items: center;
+    justify-content: center;
+    width: 698px;
+    height: 108px;
+    border-radius: 28px;
 }

+ 62 - 29
src/_record/pages/log_record.tsx

@@ -54,6 +54,7 @@ export default function LogRecord() {
     const [selPostCount, setPostCount] = useState(1)
     const [showChoose, setShowChoose] = useState(false)
     const [selTag, setSelTag] = useState<any>(null)
+    const [loading, setLoading] = useState(false)
 
 
 
@@ -359,9 +360,17 @@ export default function LogRecord() {
         // console.log('打卡提交数据', params)
         if (posting) return
         setPosting(true)
+        Taro.showLoading({
+            title: t('health.uploading')
+        })
         addEvents(params).then(res => {
             setShowResult(true)
             setResult(res)
+            setPosting(false)
+            Taro.hideLoading()
+        }).catch(e => {
+            setPosting(false)
+            Taro.hideLoading()
         })
         // createMoment(params).then(res => {
         //     // setTimeout(() => {
@@ -489,7 +498,7 @@ export default function LogRecord() {
 
     return <View style={{ position: 'relative' }}>
         <View className="main_bg" style={{ background: getBackground() }} />
-        <View className="navi_bar" style={{ height: navigationBarHeight,zIndex:1000 }}>
+        <View className="navi_bar" style={{ height: navigationBarHeight, zIndex: 1000 }}>
             <View style={{
                 position: 'absolute',
                 left: 0,
@@ -572,18 +581,30 @@ export default function LogRecord() {
                             setTitle(e.target.value)
                         }} />
                     <View className="form_btns">
-                        <View className="form_cancel h30 bold" onClick={() => {
-                            setStep(0)
-                        }}>取消</View>
-                        <View className={title.length == 0 ? 'form_cancel form_confirm h30 bold' : 'form_cancel h30 bold'}
-                            onClick={() => {
-                                if (title.length == 0) return
-                                setChooseTitle(title)
-                                setPostCount(1)
-                                setStep(2)
-                                addTag()
-                            }}
-                        >确定</View>
+                        <View className="form_cancel">
+                            <NewButton btnStyle={{ flex: 1 }} type={NewButtonType.img}
+                                onClick={() => {
+                                    setStep(0)
+                                }}
+                            >
+                                <View className="h30 bold">取消</View>
+                            </NewButton>
+                        </View>
+                        <View className="form_cancel">
+                            <NewButton btnStyle={{ flex: 1 }} type={NewButtonType.img}
+                                onClick={() => {
+                                    if (title.length == 0) return
+                                    setChooseTitle(title)
+                                    setPostCount(1)
+                                    setStep(2)
+                                    addTag()
+                                }}
+                            >
+                                <View className={title.length == 0 ? 'form_cancel form_confirm h30 bold' : 'form_cancel h30 bold'}
+
+                                >确定</View>
+                            </NewButton>
+                        </View>
                     </View>
                 </View>
             </View>
@@ -606,7 +627,7 @@ export default function LogRecord() {
                                 marginLeft: rpxToPx(12),
                                 marginRight: rpxToPx(12)
                             }} />
-                            <View className="h34 bold">{chooseTitle}</View>
+                            <View className="h34">{chooseTitle}</View>
                             <View style={{ width: rpxToPx(6) }} />
                             <IconArrow width={rpxToPx(34)} color='#000' />
                         </View>
@@ -621,9 +642,10 @@ export default function LogRecord() {
                     <View className="form2">
                         {
                             pics.map((item, index) => {
-                                return <View className="cover" key={index}>
+                                return <View className="cover" style={{ borderRadius: 0 }} key={index}>
                                     <Image src={item.url + scale} mode="aspectFill" className="cover" style={{
-                                        margin: 0
+                                        margin: 0,
+                                        borderRadius: 0
                                     }} key={index} onClick={() => {
                                         Taro.previewImage({
                                             current: pics[index].url,
@@ -670,20 +692,23 @@ export default function LogRecord() {
                     <IconArrow width={rpxToPx(34)} color={MainColorType.g02} />
                     <View className="border_footer_line" style={{ left: rpxToPx(48) }} />
                 </View>
-                <View style={{ flex: 1, marginLeft: rpxToPx(52), marginTop: rpxToPx(35) }}>
 
-                    <NewButton
-                        type={NewButtonType.fill}
-                        color={MainColorType.orange}
-                        width={rpxToPx(646)}
-                        height={rpxToPx(96)}
-                        title={t('health.log_moment')}
-                        onClick={save}
-                    />
-                </View>
+
 
             </View>
         }
+        {
+            step == 2 && <View className="main_footer" style={{ backgroundColor: 'transparent' }}>
+                <NewButton
+                    type={NewButtonType.fill}
+                    color={MainColorType.orange}
+                    width={rpxToPx(646)}
+                    height={rpxToPx(96)}
+                    title={t('health.log_moment')}
+                    onClick={save}
+                />
+            </View>
+        }
         {
             showTimePicker && <PostMomentTime
                 title={t('health.log_time_title')}
@@ -749,13 +774,20 @@ export default function LogRecord() {
                     </View>
                 </View>
                 <ShareBtn>
-                    <NewButton
+                    <NewButton type={NewButtonType.custom}>
+                        <View className="share_btn1" style={{ backgroundColor: MainColorType.success }}>
+                            <Image src={require('@assets/_health/wechat.png')} style={{ width: rpxToPx(48), height: rpxToPx(48) }} />
+                            <View className="white bold h34">Send to friends</View>
+                        </View>
+                    </NewButton>
+                    {/* <NewButton
                         type={NewButtonType.fill}
                         color={MainColorType.success}
                         width={rpxToPx(698)}
                         height={rpxToPx(108)}
+                        borderRadius={rpxToPx(28)}
                         title="Send to friends"
-                    />
+                    /> */}
                 </ShareBtn>
 
                 <View className="h30" style={{ marginTop: rpxToPx(26), color: 'rgba(255,255,255,0.5)' }} onClick={() => {
@@ -776,6 +808,7 @@ export default function LogRecord() {
                 }}
                 chooseText={() => {
                     setStep(2)
+                    setFocus(true)
                 }}
                 chooseImg={(array) => {
                     setPics(array)
@@ -783,5 +816,5 @@ export default function LogRecord() {
                 }}
             />
         }
-    </View>
+    </View >
 }

+ 13 - 1
src/_record/pages/time_record.scss

@@ -42,7 +42,7 @@
 
 .eat_card {
     width: 698px;
-    height: 168px;
+    height: 156px;
     background-color: rgba($color: #ffffff, $alpha: 0.25);
     position: relative;
     border-radius: 42px;
@@ -81,8 +81,10 @@
     display: flex;
     flex-direction: column;
     align-items: center;
+    justify-content: center;
     width: 320px;
     border-radius: 28px;
+    height: 172px;
 }
 
 .share_icon {
@@ -165,4 +167,14 @@
     100%{
         opacity: 1;
     }
+}
+
+.share_btn1{
+    display: flex;
+    flex-direction: row;
+    align-items: center;
+    justify-content: center;
+    width: 698px;
+    height: 108px;
+    border-radius: 28px;
 }

+ 78 - 18
src/_record/pages/time_record.tsx

@@ -18,6 +18,7 @@ import { getDurationArc, getStartArc } from "@/features/health/hooks/health_hook
 import ShareBtn from "@/components/basic/ShareBtn";
 import PickerCard from "../components/picker_card";
 import showActionSheet from "@/components/basic/ActionSheet";
+import { useTranslation } from "react-i18next";
 
 let timer
 let useRoute;
@@ -51,6 +52,10 @@ export default function TimeRecord() {
     const picker2Ref = useRef(showEndDatePicker)
     const picker3Ref = useRef(showDurationPicker)
 
+    const [posting, setPosting] = useState(false)
+
+    const { t } = useTranslation()
+
     let router
     let navigation;
     if (useNavigation) {
@@ -177,8 +182,11 @@ export default function TimeRecord() {
             confirm_time: new Date().getTime()
         }
         // console.log('打卡提交数据', params)
-        // if (posting) return
-        // setPosting(true)
+        if (posting) return
+        setPosting(true)
+        Taro.showLoading({
+            title: t('health.uploading')
+        })
         addEvents(params).then(res => {
             Taro.eventCenter.trigger('refreshClockIndex')
             Taro.eventCenter.trigger('refreshMoments', '')
@@ -192,6 +200,11 @@ export default function TimeRecord() {
             //     title: '成功',
             //     icon: 'success'
             // })
+            setPosting(false)
+            Taro.hideLoading()
+        }).catch(e => {
+            setPosting(false)
+            Taro.hideLoading()
         })
     }
 
@@ -215,6 +228,12 @@ export default function TimeRecord() {
             set_time: global.set_time ? global.set_time : new Date().getTime(),
             confirm_time: new Date().getTime()
         }
+
+        if (posting) return
+        setPosting(true)
+        Taro.showLoading({
+            title: t('health.uploading')
+        })
         addEvents(params).then(res => {
             setShowHighlight(true)
             setTimeout(() => {
@@ -232,6 +251,11 @@ export default function TimeRecord() {
             //     title: '成功',
             //     icon: 'success'
             // })
+            setPosting(false)
+            Taro.hideLoading()
+        }).catch(e => {
+            setPosting(false)
+            Taro.hideLoading()
         })
     }
 
@@ -242,6 +266,11 @@ export default function TimeRecord() {
                 ...params
             }
         }
+        if (posting) return
+        setPosting(true)
+        Taro.showLoading({
+            title: t('health.uploading')
+        })
         addEvents(data).then(res => {
             Taro.eventCenter.trigger('refreshClockIndex')
             Taro.eventCenter.trigger('refreshMoments', '')
@@ -250,6 +279,11 @@ export default function TimeRecord() {
             setShowDurationPicker(false)
             setShowEndDatePicker(false)
             setCount((count) => count + 1)
+            setPosting(false)
+            Taro.hideLoading()
+        }).catch(e => {
+            setPosting(false)
+            Taro.hideLoading()
         })
     }
 
@@ -371,7 +405,7 @@ export default function TimeRecord() {
                         count={count}
                         bgRing={{
                             color: 'rgba(255,255,255,1)',
-                            width: rpxToPx(100)
+                            width: rpxToPx(88)
                         }}
                         real={{
                             color: MainColorType.orange,
@@ -417,13 +451,20 @@ export default function TimeRecord() {
                 {
                     showResult && <View className="shareBtnAni">
                         <ShareBtn>
-                            <NewButton
+                            {/* <NewButton
                                 type={NewButtonType.fill}
                                 color={MainColorType.success}
                                 width={rpxToPx(698)}
                                 height={rpxToPx(108)}
+                                borderRadius={rpxToPx(28)}
                                 title="Send to friends"
-                            />
+                            /> */}
+                            <NewButton type={NewButtonType.custom}>
+                                <View className="share_btn1" style={{ backgroundColor: MainColorType.success }}>
+                                    <Image src={require('@assets/_health/wechat.png')} style={{ width: rpxToPx(48), height: rpxToPx(48) }} />
+                                    <View className="white bold h34">Send to friends</View>
+                                </View>
+                            </NewButton>
                         </ShareBtn>
                     </View>
                 }
@@ -463,6 +504,17 @@ export default function TimeRecord() {
         }
     }
 
+    function naviTitle() {
+        switch (status) {
+            case 'WFS':
+                return scenario == 'FAST' ? 'Upcoming fast' : 'Upcoming sleep'
+            case 'OG':
+                return scenario == 'FAST' ? 'Fasting' : 'Sleeping'
+            case 'DONE':
+                return scenario == 'FAST' ? 'Fast completed' : 'Sleep completed'
+        }
+    }
+
     function render() {
 
         return <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
@@ -489,10 +541,10 @@ export default function TimeRecord() {
                             Taro.navigateBack()
                         }}
                     />
-                    <View className="h36 bold">{status == 'WFS' ? 'upcoming fast' : 'onging fast'}</View>
+                    <View className="h36 bold">{naviTitle()}</View>
                 </View>
             </View>
-            <View style={{ height: navigationBarHeight }} />
+            <View style={{ height: rpxToPx(26) + navigationBarHeight }} />
             <View className="progress_card">
                 <View onClick={() => {
                     tapClock()
@@ -504,17 +556,17 @@ export default function TimeRecord() {
                         count={count}
                         bgRing={{
                             color: 'rgba(255,255,255,0.25)',
-                            width: rpxToPx(100)
+                            width: rpxToPx(88)
                         }}
                         target={{
                             color: 'rgba(255,255,255,0.5)',
-                            width: rpxToPx(100),
+                            width: rpxToPx(88),
                             start: status == 'WFS' ? getStartArc(new Date().getTime()) : getStartArc(info.time.start_timestamp),
                             duration: status == 'WFS' ? getDurationArc(new Date().getTime(), new Date().getTime() + info.time.duration) : getDurationArc(info.time.start_timestamp, info.time.start_timestamp + info.time.duration)
                         }}
                         real={status == 'WFS' ? null : {
                             color: MainColorType.orange,
-                            width: rpxToPx(100),
+                            width: rpxToPx(88),
                             start: getStartArc(info.time.start_timestamp),
                             duration: getDurationArc(info.time.start_timestamp, new Date().getTime())
                         }}
@@ -542,7 +594,7 @@ export default function TimeRecord() {
                 {
                     status == 'WFS' && <NewButton
                         type={NewButtonType.fill}
-                        title="Start fasting"
+                        title={scenario == 'FAST' ? record.actions.FAST_START : record.actions.SLEEP_BEDTIME}
                         width={rpxToPx(490)}
                         height={rpxToPx(96)}
                         color={MainColorType.orange}
@@ -553,7 +605,7 @@ export default function TimeRecord() {
                 {
                     status == 'OG' && <View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}><NewButton
                         type={NewButtonType.fill}
-                        title="End fasting"
+                        title={scenario == 'FAST' ? record.actions.FAST_END : record.actions.SLEEP_WAKE_UP}
                         width={rpxToPx(490)}
                         height={rpxToPx(96)}
                         color={MainColorType.orange}
@@ -565,6 +617,7 @@ export default function TimeRecord() {
                         /> */}
                         <NewButton
                             type={NewButtonType.img}
+                            btnStyle={{ marginRight: -rpxToPx(72) }}
                             onClick={more}
                         >
                             <View style={{ width: rpxToPx(72), height: rpxToPx(72), display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
@@ -598,7 +651,7 @@ export default function TimeRecord() {
                     <View className="h30 bold">Or share your meals</View>
                     <View className="h24 g02" style={{ marginTop: rpxToPx(12) }}>if you haven't started fasting yet</View>
                     <View className="eat_card_arrow">
-                        <IconArrow width={rpxToPx(34)} color={MainColorType.g02} />
+                        <IconArrow width={rpxToPx(34)} color={MainColorType.black_25} />
                     </View>
                 </View>
             }
@@ -644,17 +697,17 @@ export default function TimeRecord() {
                                 count={count}
                                 bgRing={{
                                     color: 'rgba(255,255,255,0.25)',
-                                    width: rpxToPx(100)
+                                    width: rpxToPx(88)
                                 }}
                                 target={{
                                     color: 'rgba(255,255,255,0.5)',
-                                    width: rpxToPx(100),
+                                    width: rpxToPx(88),
                                     start: status == 'WFS' ? getStartArc(new Date().getTime()) : getStartArc(info.time.start_timestamp),
                                     duration: status == 'WFS' ? getDurationArc(new Date().getTime(), new Date().getTime() + info.time.duration) : getDurationArc(info.time.start_timestamp, info.time.start_timestamp + info.time.duration)
                                 }}
                                 real={status == 'WFS' ? null : {
                                     color: MainColorType.orange,
-                                    width: rpxToPx(100),
+                                    width: rpxToPx(88),
                                     start: getStartArc(info.time.start_timestamp),
                                     duration: getDurationArc(info.time.start_timestamp, new Date().getTime())
                                 }}
@@ -712,13 +765,20 @@ export default function TimeRecord() {
                         }
                     </View>
                     <ShareBtn>
-                        <NewButton
+                        {/* <NewButton
                             type={NewButtonType.fill}
                             color={MainColorType.success}
                             width={rpxToPx(698)}
                             height={rpxToPx(108)}
+                            borderRadius={rpxToPx(28)}
                             title="Send to friends"
-                        />
+                        /> */}
+                        <NewButton type={NewButtonType.custom}>
+                            <View className="share_btn1" style={{ backgroundColor: MainColorType.success }}>
+                                <Image src={require('@assets/_health/wechat.png')} style={{ width: rpxToPx(48), height: rpxToPx(48) }} />
+                                <View className="white bold h34">Send to friends</View>
+                            </View>
+                        </NewButton>
                     </ShareBtn>
                 </View>
             }

+ 1 - 0
src/app.config.ts

@@ -5,6 +5,7 @@ const appConfig = defineAppConfig({
 
     'pages/clock/Clock',
     'pages/common/H5',
+    'pages/common/RecordsHistory',
     'pages/account/Profile',
     'pages/metric/Metric',
     'pages/notification/setting',

+ 3 - 2
src/pages/clock/ClockIndex.tsx

@@ -8,7 +8,7 @@ import { useDispatch, useSelector } from "react-redux";
 import { useEffect, useState } from "react";
 import { homeInfo } from "@/services/health";
 import dayjs from "dayjs";
-import { setEvents, setTimeData } from "@/store/record";
+import { setActions, setEvents, setTimeData } from "@/store/record";
 import { TimeFormatter } from "@/utils/time_format";
 import { getInfo } from "@/services/user";
 import Taro from "@tarojs/taro";
@@ -22,7 +22,7 @@ export default function ClockIndex() {
     const [home, setHome] = useState<any>(null)
     const [count, setCount] = useState(0)
     const [currentTimeData, setCurrentTimeData] = useState<any>(null)
-    
+
     const [selScenario, setSelScenario] = useState('')
     const dispatch = useDispatch();
     global.dispatch = dispatch;
@@ -60,6 +60,7 @@ export default function ClockIndex() {
             setHome(res)
             setCount(1)
             dispatch(setEvents((res as any).events))
+            dispatch(setActions((res as any).actions))
         })
     }
 

+ 1 - 1
src/pages/clock/components/choose_actions.scss

@@ -16,7 +16,6 @@
     width: 698px;
     height: 128px;
     border-radius: 64px;
-    background-color: #fff;
     color: #000;
     margin-top: 26px;
     display: flex;
@@ -24,6 +23,7 @@
     align-items: center;
     justify-content: center;
     position: relative;
+    background-color: #f0f0f0;
 }
 
 .cardShowAni {

+ 2 - 1
src/pages/clock/components/choose_actions.tsx

@@ -7,6 +7,7 @@ import Taro from '@tarojs/taro'
 import { baseUrl } from '@/services/http/api'
 import { useTranslation } from 'react-i18next'
 import { jumpPage } from '@/features/trackTimeDuration/hooks/Common'
+import { MainColorType } from '@/context/themes/color'
 
 export default function ChooseActions(props: { close: any, quick: any, chooseText: any, chooseImg: any }) {
     const { t } = useTranslation()
@@ -170,7 +171,7 @@ export default function ChooseActions(props: { close: any, quick: any, chooseTex
         <View className='g01 h30 bold' style={{ marginTop: rpxToPx(26) }}>OR</View>
 
         <NewButton type={NewButtonType.img} onClick={checkin}>
-            <View className='action_btn h30 bold cardShowAni1'>Quick Check in</View>
+            <View className='action_btn h30 bold cardShowAni' style={{ backgroundColor: MainColorType.g02 }}>Quick Check in</View>
         </NewButton>
 
 

+ 7 - 0
src/pages/common/RecordsHistory.config.ts

@@ -0,0 +1,7 @@
+export default definePageConfig({
+    "disableScroll": false,
+    "navigationBarTitleText":"",
+    "enablePullDownRefresh":true,
+    "navigationBarBackgroundColor":"#f5f5f5"
+    // "enablePageMeta":true
+})

+ 51 - 0
src/pages/common/RecordsHistory.scss

@@ -0,0 +1,51 @@
+.no_records_bg {
+    position: absolute;
+    left: 0;
+    top: 100;
+    right: 0;
+    height: 60vh;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+}
+
+.no_records {
+    color: #fff;
+    font-size: 72px;
+}
+
+.fast_sleep_item_bg {
+    display: flex;
+    flex-direction: column;
+}
+
+.filter_bar {
+    display: flex;
+    flex-direction: row;
+    align-items: center;
+    margin-left: 46px;
+    margin-bottom: 20px;
+    margin-top: -10px;
+}
+
+.filter_bar_item{
+    padding-bottom: 10px;
+    padding-top: 10px;
+}
+
+.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;
+}

+ 451 - 0
src/pages/common/RecordsHistory.tsx

@@ -0,0 +1,451 @@
+import { clearTimeRecords, getClockRecords } from "@/services/trackTimeDuration";
+import { View, Text, ScrollView, PageMeta, NavigationBar } from "@tarojs/components";
+import { usePullDownRefresh, useReachBottom, useReady, useRouter } from "@tarojs/taro";
+import { useEffect, useState } from "react";
+import Schedule from '@/features/trackTimeDuration/components/Schedule'
+import MetricHistory from "@/features/trackSomething/components/MetricHistory";
+import ActivityHistory from "@/features/trackSomething/components/ActivityHistory";
+import { activityRecords, clearMetricRecords, cleartActivityRecords, metricRecords } from "@/services/trackSomething";
+import Taro from "@tarojs/taro";
+import Layout from "@/components/layout/layout";
+import NoData from "@/components/view/NoData";
+import { NaviBarTitleShowType, TemplateType } from "@/utils/types";
+import { useSelector } from "react-redux";
+// import RecordFastSleep from "@/features/trackTimeDuration/components/RecordFastSleep";
+import './RecordsHistory.scss'
+import { useTranslation } from "react-i18next";
+import './RecordsHistory.scss'
+import { clearWorkoutRecords, workoutRecords } from "@/services/workout";
+// import WorkoutHistory from "@/features/workout/WorkoutHistory";
+import showAlert from "@/components/basic/Alert";
+import { rpxToPx } from "@/utils/tools";
+import NoRecord from "@/_health/components/no_record";
+
+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()
+    let router
+    let navigation;
+    if (useNavigation) {
+        navigation = useNavigation()
+    }
+
+    if (process.env.TARO_ENV == 'rn') {
+        router = useRoute()
+        // var title = ''
+        // if (router.params.type == 'time') {
+        //     title = t('page.clock.title')
+        // }
+        // 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
+        // });
+    }
+    else {
+        router = useRouter()
+    }
+    const pageSize = 10
+    const [pageIndex, setPageIndex] = useState(1)
+    const [records, setRecords] = useState<any[]>([])
+    const [counter, setCounter] = useState(0)
+    const [timerId, setTimerId] = useState(null)
+    const [showErrorPage, setShowErrorPage] = useState(false)
+    const { refreshList } = router.params
+    const [triggered, setTriggered] = useState(false)
+    const [showModal, setShowModal] = useState(false)
+    const [modalDetail, setModalDetail] = useState<any>({})
+    const [total, setTotal] = useState(0)
+    const [isLoading, setIsLoading] = useState(false)
+    const [loaded, setLoaded] = useState(false)
+    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()
+    }, [])
+
+    // useEffect(() => {
+    //     startTimer();
+    //     return () => {
+    //         // 在组件卸载时清除定时器
+    //         if (timerId) {
+    //             clearInterval(timerId);
+    //         }
+    //     };
+    // }, [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) {
+    //         return;
+    //     }
+
+    //     const id = setInterval(() => {
+    //         setCounter((prevCounter) => prevCounter + 1);
+    //     }, 1000);
+
+    //     setTimerId(id as any);
+    // };
+
+
+    useReady(() => {
+        // refresh()
+    })
+
+    usePullDownRefresh(() => {
+        refresh()
+    })
+
+    useReachBottom(() => {
+        more()
+        // setPageIndex(pageIndex+1)
+        // getHistory()
+    })
+
+    function refresh() {
+        setIsLoading(true)
+        setPageIndex(1)
+        getHistory(1)
+    }
+
+    function more() {
+        if (total <= records.length || isLoading) {
+            return;
+        }
+        setIsLoading(true)
+        var page = pageIndex + 1
+        setPageIndex(page)
+        getHistory(page)
+    }
+
+    global.reloadWorkoutList = () => {
+        workoutRecords(
+            {
+                page: 1,
+                limit: pageIndex * pageSize,
+                code: router.params.code
+            }
+        ).then(res => {
+            Taro.stopPullDownRefresh()
+            setTriggered(false)
+            setLoaded(true)
+            setTotal((res as any).total)
+            setSummaryStats((res as any).summary_stats)
+
+            setRecords((res as any).data)
+            setCount((res as any).total)
+
+            setIsLoading(false)
+        })
+    }
+
+    function getHistory(page = pageIndex) {
+        if (page == 1)
+            setTriggered(true)
+
+        if (router.params.type == 'time') {
+            getClockRecords({
+                page: page,
+                limit: pageSize,
+                scenario: scenario,
+                completed: true,
+                // part_completed: true
+            }).then(res => {
+                Taro.stopPullDownRefresh()
+                setTriggered(false)
+                setLoaded(true)
+                setTotal((res as any).total)
+                if (page == 1) {
+                    setRecords([])
+                    setRecords((res as any).data)
+                } else {
+                    setRecords(records.concat((res as any).data))
+                }
+                setIsLoading(false)
+            })
+        }
+        else if (router.params.type == 'activity') {
+            activityRecords(
+                {
+                    page: page,
+                    limit: pageSize,
+                    code: '_walk'
+                }
+            ).then(res => {
+                Taro.stopPullDownRefresh()
+                setTriggered(false)
+                setLoaded(true)
+                setTotal((res as any).total)
+                if (page == 1) {
+                    setRecords((res as any).data)
+                } else {
+                    setRecords(records.concat((res as any).data))
+                }
+                setIsLoading(false)
+            })
+        }
+        else if (router.params.type == 'metric') {
+            // var data = global.selMetricItem;
+            // debugger
+            metricRecords(
+                {
+                    page: page,
+                    limit: pageSize,
+                    code: router.params.code
+                }
+            ).then(res => {
+                Taro.stopPullDownRefresh()
+                setTriggered(false)
+                setLoaded(true)
+                setTotal((res as any).total)
+                if (page == 1) {
+                    setRecords((res as any).data)
+                } else {
+                    setRecords(records.concat((res as any).data))
+                }
+                setIsLoading(false)
+            })
+        }
+        else if (router.params.type == 'workout') {
+            workoutRecords(
+                {
+                    page: page,
+                    limit: pageSize,
+                    code: router.params.code
+                }
+            ).then(res => {
+                Taro.stopPullDownRefresh()
+                setTriggered(false)
+                setLoaded(true)
+                setTotal((res as any).total)
+                setSummaryStats((res as any).summary_stats)
+                if (page == 1) {
+                    setRecords((res as any).data)
+                    setCount((res as any).total)
+                } else {
+                    setRecords(records.concat((res as any).data))
+                }
+                setIsLoading(false)
+            })
+        }
+
+    }
+
+    function removeItem(item) {
+        setRecords(records.filter(i => i.id != item.id))
+    }
+
+    global.delFastSleep = (item) => {
+        removeItem(item)
+        global.refrehWeekly()
+        global.refreshStreaks()
+    }
+
+    global.clearHistory = () => {
+        // var page = Taro.getCurrentPages()[0]
+        // debugger
+        // page.refresh()
+        debugger
+        showAlert({
+            title: t('feature.common.modal.delete_all_title'),
+            content: t('feature.common.modal.delete_all_content'),
+            showCancel: true,
+            confirm: () => {
+                doClear()
+            }
+        })
+
+    }
+
+    function doClear() {
+        if (router.params.type == 'activity') {
+            cleartActivityRecords({
+                code: '_walk'
+            }).then(res => {
+                refresh()
+                global.refreshActivity()
+
+                // router.params.refreshList()
+                // Taro.getCurrentPages()[0].refresh()
+            })
+        }
+        else if (router.params.type == 'metric') {
+            clearMetricRecords({
+                code: router.params.code
+            }).then(res => {
+                refresh()
+                global.refreshMetric()
+                // Taro.getCurrentPages()[0].refresh()
+            })
+        }
+        else if (router.params.type == 'time') {
+            clearTimeRecords().then(res => {
+                refresh()
+
+                global.refrehWeekly()
+
+                if (global.refreshStreaks) {
+                    global.refreshStreaks()
+                }
+                if (global.checkAccess) {
+                    const currentStatus = (res as any).access.current.qualification.status
+                    const preStatus = (res as any).access.previous.qualification.status
+                    if (currentStatus == 'NOT_QUALIFIED' && preStatus == 'NOT_QUALIFIED') {
+
+                    }
+                    else {
+                        global.checkAccess((res as any).access)
+                    }
+                }
+
+                if (global.indexPageRefresh) {
+                    global.indexPageRefresh()
+                }
+
+                // global.refreshTime()
+                // global.refreshMetric()
+                // Taro.getCurrentPages()[0].refresh()
+            })
+        }
+        else if (router.params.type == 'workout') {
+            clearWorkoutRecords({
+                code: router.params.code
+            }).then(res => {
+                refresh()
+                global.refreshWorkout()
+                // global.refreshMetric()
+                // Taro.getCurrentPages()[0].refresh()
+            })
+        }
+    }
+
+    function tapFilter(index) {
+        setFilterIndex(index)
+    }
+
+    function filters() {
+        return <View className="filter_bar">
+            <View className="filter_bar_item" onClick={() => { tapFilter(0) }}>
+                <Text onClick={() => { tapFilter(0) }} className={filterIndex == 0 ? 'filter_item_sel' : 'filter_item_normal'}>{t('feature.track_time_duration.record_fast_sleep.tab_all')}</Text>
+            </View>
+            <View className="filter_bar_item" onClick={() => { tapFilter(1) }}>
+                <Text onClick={() => { tapFilter(1) }} className={filterIndex == 1 ? 'filter_item_sel' : 'filter_item_normal'}>{t('feature.track_time_duration.record_fast_sleep.tab_fast_sleep')}</Text>
+            </View>
+            <View className="filter_bar_item" onClick={() => { tapFilter(2) }}>
+                <Text onClick={() => { tapFilter(2) }} className={filterIndex == 2 ? 'filter_item_sel' : 'filter_item_normal'}>{t('feature.track_time_duration.record_fast_sleep.tab_fast')}</Text>
+            </View>
+            <View className="filter_bar_item" onClick={() => { tapFilter(3) }}>
+                <Text onClick={() => { tapFilter(3) }} className={filterIndex == 3 ? 'filter_item_sel' : 'filter_item_normal'}>{t('feature.track_time_duration.record_fast_sleep.tab_sleep')}</Text>
+            </View>
+        </View>
+    }
+
+    function detail() {
+        if (router.params.type == 'time') {
+            return <View>
+                {
+                    process.env.TARO_ENV == 'weapp' && user.test_user && <Text style={{ color: '#000', position: 'absolute', right: 50, top: 0 }} onClick={() => global.clearHistory()}>删除全部</Text>
+                }
+                {
+                    filters()
+                }
+                {/* {
+                    records.map((item, index) => {
+                        return <View className="fast_sleep_item_bg">
+                            <RecordFastSleep key={index}
+                                data={item}
+                                index={index}
+                                type='record'
+                            />
+                        </View>
+                    })
+                } */}
+            </View>
+        }
+        if (router.params.type == 'metric') {
+            return <MetricHistory records={records} />
+        }
+        if (router.params.type == 'activity') {
+            return <ActivityHistory records={records} />
+        }
+        // if (router.params.type == 'workout') {
+        //     return <WorkoutHistory records={records} count={count} summary_stats={summary_stats} />
+        // }
+    }
+
+    function getTitle() {
+        if (router.params.type == 'time') {
+            return t('page.records_history.time_title')
+        }
+        else if (router.params.type == 'metric') {
+            return router.params.title
+        }
+        else if (router.params.type == 'workout') {
+            return router.params.title
+        }
+        else {
+            return router.params.title
+        }
+    }
+
+    return <View style={{ position: 'relative' }}>
+        <Layout children={showErrorPage ? <NoData refresh={() => { refresh() }} /> : detail()}
+            // title={router.params.title}
+            isFastSleepTheme={router.params.type == 'time'}
+            secondPage={true}
+            titleColor={router.params.themeColor ? router.params.themeColor : '#fff'}
+            title={getTitle()}
+            type={TemplateType.flex}
+            refresh={() => { refresh() }}
+            triggered={triggered}
+            more={() => { more() }}
+            titleShowStyle={NaviBarTitleShowType.scrollToShow}
+        />
+        {
+            loaded && records.length == 0 && <NoRecord />
+            // <View className="no_records_bg">
+            //     <Text className="no_records">{t('feature.common.no_data.no_record')}</Text>
+            // </View>
+        }
+
+        {
+            showModal && modalDetail
+        }
+    </View>
+}

+ 8 - 8
src/pages/moment/moment.config.ts

@@ -3,14 +3,14 @@ export default definePageConfig({
         // 'ec-canvas': '../../lib/ec-canvas/ec-canvas',
         // 'demo':'../../components/demo'
     },
-    "componentFramework": "glass-easel",
-    "renderer": "skyline",
-    "rendererOptions": {
-        "skyline": {
-            "disableABTest": true,
-            "defaultDisplayBlock": true
-        }
-    },
+    // "componentFramework": "glass-easel",
+    // "renderer": "skyline",
+    // "rendererOptions": {
+    //     "skyline": {
+    //         "disableABTest": true,
+    //         "defaultDisplayBlock": true
+    //     }
+    // },
     "navigationBarTitleText": "",
     "navigationBarBackgroundColor": "#f5f5f5",
     "backgroundColor": "#ffffff",

+ 10 - 5
src/store/record.tsx

@@ -3,13 +3,15 @@ import { createSlice } from "@reduxjs/toolkit";
 
 
 interface RecordState {
-    time:any,
-    events:any,
+    time: any,
+    events: any,
+    actions: any,
 }
 
 const initialState: RecordState = {
-    time:null,
-    events:null,
+    time: null,
+    events: null,
+    actions: null
 }
 
 const recordSlice = createSlice({
@@ -23,9 +25,12 @@ const recordSlice = createSlice({
         setEvents(state, action) {
             state.events = action.payload
         },
+        setActions(state, action) {
+            state.actions = action.payload
+        },
 
     }
 });
 
 export default recordSlice.reducer;
-export const { setTimeData,setEvents } = recordSlice.actions;
+export const { setTimeData, setEvents, setActions } = recordSlice.actions;