Leon 2 年之前
父节点
当前提交
54270b09f9

+ 1 - 1
src/assets/svg/check.svg

@@ -1 +1 @@
-<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="18" height="13" viewBox="0 0 18 13"><g><path d="M17.7071,0.292893C18.0976,0.683417,18.0976,1.31658,17.7071,1.70711C17.7071,1.70711,6.70711,12.7071,6.70711,12.7071C6.31658,13.0976,5.68342,13.0976,5.29289,12.7071C5.29289,12.7071,0.292893,7.70711,0.292893,7.70711C-0.0976311,7.31658,-0.0976311,6.68342,0.292893,6.29289C0.683417,5.90237,1.31658,5.90237,1.70711,6.29289C1.70711,6.29289,6,10.5858,6,10.5858C6,10.5858,16.2929,0.292893,16.2929,0.292893C16.6834,-0.0976311,17.3166,-0.0976311,17.7071,0.292893C17.7071,0.292893,17.7071,0.292893,17.7071,0.292893Z" fill-rule="evenodd" fill="#AAFF00" fill-opacity="1"/></g></svg>
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="18" height="13" viewBox="0 0 18 13"><g><path d="M17.7071,0.292893C18.0976,0.683417,18.0976,1.31658,17.7071,1.70711C17.7071,1.70711,6.70711,12.7071,6.70711,12.7071C6.31658,13.0976,5.68342,13.0976,5.29289,12.7071C5.29289,12.7071,0.292893,7.70711,0.292893,7.70711C-0.0976311,7.31658,-0.0976311,6.68342,0.292893,6.29289C0.683417,5.90237,1.31658,5.90237,1.70711,6.29289C1.70711,6.29289,6,10.5858,6,10.5858C6,10.5858,16.2929,0.292893,16.2929,0.292893C16.6834,-0.0976311,17.3166,-0.0976311,17.7071,0.292893C17.7071,0.292893,17.7071,0.292893,17.7071,0.292893Z" fill-rule="evenodd" fill="#ffffff" fill-opacity="1"/></g></svg>

+ 1 - 1
src/components/layout/Box.tsx

@@ -20,7 +20,7 @@ export default function Component(props: {
             return
         }
         Taro.vibrateShort({
-            type: 'heavy'
+            type: 'medium'
         })
     }
 

+ 1 - 1
src/components/layout/Header.tsx

@@ -11,7 +11,7 @@ export default function Component(props: { title: string, action?: Function }) {
         <Text className="header_title">{props.title}</Text>
         {
             time.scenario=='FAST_SLEEP'?<Text className="header_action fast_sleep_text"  onClick={() => { props.action!() }}>{t('feature.track_time_duration.record_fast_sleep.header.btn_show_all')}</Text>:
-            <Text className="header_action" style={{color:getThemeColor(time)}} onClick={() => { props.action!() }}>{t('feature.track_time_duration.record_fast_sleep.header.btn_show_all')}</Text>
+            <Text className="header_action" style={{color:getThemeColor(time)}} onClick={() => { props.action!(); }}>{t('feature.track_time_duration.record_fast_sleep.header.btn_show_all')}</Text>
         }
         
     </View>

+ 1 - 1
src/components/layout/layout.scss

@@ -15,7 +15,7 @@
 
 .layout_title {
     flex-shrink: 0;
-    color: #fff;
+    // color: #fff;
     margin-left: 46px;
     font-size: 72px;
     line-height: 72px;

+ 18 - 9
src/components/layout/layout.tsx

@@ -17,6 +17,7 @@ export default function Layout(props: {
     titleColor?: string,
     header?: React.ReactNode,
     secondPage?: boolean,
+    isFastSleepTheme?: boolean,
     titleShowStyle: NaviBarTitleShowType
 }) {
     const { children, type, triggered } = props;
@@ -66,7 +67,7 @@ export default function Layout(props: {
                 onScrollToLower={() => { props.more ? props.more() : null }}
                 refresherTriggered={triggered}>
                 {
-                    props.title && <View className="layout_title_view" style={{backgroundColor:isDebugMode?'red':'transparent'}}>
+                    props.title && <View className="layout_title_view" style={{ backgroundColor: isDebugMode ? 'red' : 'transparent' }}>
                         <Text className='layout_title'
                             style={{
                                 color: props.titleColor ? props.titleColor : '#fff',
@@ -91,7 +92,7 @@ export default function Layout(props: {
                 onScrollToLower={() => { props.more ? props.more() : null }}
                 refresherTriggered={triggered}>
                 {
-                    props.title && <View className="layout_title_view" style={{backgroundColor:isDebugMode?'red':'transparent'}}>
+                    props.title && <View className="layout_title_view" style={{ backgroundColor: isDebugMode ? 'red' : 'transparent' }}>
                         <Text className='layout_title'
                             style={{
                                 color: props.titleColor ? props.titleColor : '#fff',
@@ -108,13 +109,21 @@ export default function Layout(props: {
         case TemplateType.flex:
             return <View className='flex'>
                 {
-                    props.title && <View className="layout_title_view" style={{backgroundColor:isDebugMode?'red':'transparent'}}>
-                        <Text className='layout_title'
-                            style={{
-                                color: props.titleColor ? props.titleColor : '#fff',
-                                fontSize: props.secondPage ? 28 : 36
-                            }}
-                        >{props.title}</Text>
+                    props.title && <View className="layout_title_view" style={{ backgroundColor: isDebugMode ? 'red' : 'transparent' }}>
+                        {
+                            props.isFastSleepTheme ? <Text className='layout_title fast_sleep_text'
+                                style={{
+                                    fontSize: props.secondPage ? 28 : 36
+                                }}
+                            >{props.title}</Text> :
+                                <Text className='layout_title'
+                                    style={{
+                                        color: props.titleColor ? props.titleColor : '#fff',
+                                        fontSize: props.secondPage ? 28 : 36
+                                    }}
+                                >{props.title}</Text>
+                        }
+
                     </View>
                 }
                 {children}

+ 3 - 3
src/features/common/RecordItem.tsx

@@ -13,9 +13,9 @@ export default function Component(props: { children: React.ReactNode,onClick?:Fu
             props.onClick();
         }
         else {
-            // Taro.vibrateShort({
-                
-            // });
+            Taro.vibrateShort({
+                type:'medium'
+            });
         }
     }
     

+ 2 - 1
src/features/common/SpecBtns.tsx

@@ -165,10 +165,11 @@ export const ChooseScenarioBtn = (props: { onClick: Function, title: string, bac
     )
 }
 
-export const RecordMetricBtn = (props: { onClick: Function, title: string, themeColor: string }) => {
+export const RecordMetricBtn = (props: { onClick: Function, title: string, themeColor: string,isDisable?:boolean }) => {
     return (
         <PostBtn title={props.title} type={ButtonType.elevated}
             onClick={() => { props.onClick() }}
+            lowLight={props.isDisable}
             btnStyle={{
                 height: 42,
                 // width: 100,

+ 18 - 10
src/features/trackSomething/components/Activity.tsx

@@ -30,13 +30,20 @@ export default function Component(props: any) {
     const [latestRecord, setLatestRecord] = useState(null)
     const [triggered, setTriggered] = useState(true)
     const [showErrorPage, setErrorPage] = useState(false)
+    const [count,setCount] = useState(0)
     // const [title, setTitle] = useState('打卡')
 
     //未登录<->已登录 状态切换时,重新拉取一次列表数据
     useEffect(() => {
         dispatch(resetStatus())
         getCards();
-        // checkAuth(false)
+        const now = new Date();
+        const nextMidnight = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 0, 0, 0);
+        const timeUntilMidnight = nextMidnight.getTime() - now.getTime();
+
+        setTimeout(() => {
+            setCount(count+1)
+        }, timeUntilMidnight);
     }, [user.isLogin])
 
     // useEffect(() => {
@@ -146,11 +153,9 @@ export default function Component(props: any) {
 
     function getWeRunData(autoCheck = false) {
         if (autoCheck) {
-            console.log('自动打卡')
             return
         }
         else {
-            console.log('开始打卡')
             dispatch(checkStart());
         }
 
@@ -159,7 +164,6 @@ export default function Component(props: any) {
         var date = new Date();
         var time = date.getTime()
         var strDate = (date.getFullYear() + '') + (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1)) + (date.getDate() < 10 ? '0' + date.getDate() : date.getDate());
-        console.log('开始取步数的时间戳:' + new Date().getTime())
 
 
         thirdPartRequest(RequestType.RequestTypeWXRunData).then(res => {
@@ -175,19 +179,20 @@ export default function Component(props: any) {
                 if ((res as any).error_code == 'WX_STEP_PARSE_FAIL') {
                     retry(params, autoCheck, time)
                     dispatch(checkRetry())
-                    console.log('上报失败  ')
                 }
                 else {
-                    console.log('上报成功 ')
+                    
                     setShowErrorBadge(false)
                     uploadSuccess(res, autoCheck, time)
+                    setTimeout(()=>{
+                        setCount(count+1)
+                    },31000)
                 }
 
             }).catch(e => {
                 retry(params, autoCheck, time)
             });
         }).catch(_ => {
-            console.log('回调失败')
             dispatch(setResult({ isSuccess: false }) as any)
         })
 
@@ -214,6 +219,9 @@ export default function Component(props: any) {
 
                             setShowErrorBadge(false)
                             uploadSuccess(res, autoCheck, time)
+                            setTimeout(()=>{
+                                setCount(count+1)
+                            },31000)
                         }
 
                     }).catch(e => {
@@ -252,7 +260,7 @@ export default function Component(props: any) {
                 return;
             }
             Taro.navigateTo({
-                url: '/pages/common/RecordsHistory?type=activity&refreshList=getCards&title='+item.name+'&themeColor='+item.theme_color
+                url: '/pages/common/RecordsHistory?type=activity&refreshList=getCards&title=' + item.name + '&themeColor=' + item.theme_color
             })
         }
         else {
@@ -352,7 +360,7 @@ export default function Component(props: any) {
                             showDetail = true
                             if (item.latest_record) {
                                 value = item.latest_record.items[0].value
-                                desc =  TimeFormatter.datetimeDescription(item.latest_record.timestamp)
+                                desc = TimeFormatter.datetimeDescription(item.latest_record.timestamp)
                                 unit = '步'
                             }
                             else {
@@ -376,7 +384,7 @@ export default function Component(props: any) {
                         btnText={btnTitle}
                         isDisabled={!isEnable}
                         themeColor={item.theme_color}
-                        onClickDetail={()=>{goDetail(item)}}
+                        onClickDetail={() => { goDetail(item) }}
                         showBadge={showErrorBadge && checkResult.type == 'idle'}
                         showDetail={showDetail}
                         onClick={() => {

+ 15 - 7
src/features/trackSomething/components/Metric.tsx

@@ -40,11 +40,19 @@ export default function Component(props: any) {
     const [setupTime, setSetupTime] = useState(0)
     const [triggered, setTriggered] = useState(true)
     const limitPickerRef = useRef<any>(null);
+    const [count,setCount] = useState(0)
 
 
     //未登录<->已登录 状态切换时,执行一次授权检查
     useEffect(() => {
         getCards();
+        const now = new Date();
+        const nextMidnight = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 0, 0, 0);
+        const timeUntilMidnight = nextMidnight.getTime() - now.getTime();
+
+        setTimeout(() => {
+            setCount(count+1)
+        }, timeUntilMidnight);
     }, [user.isLogin])
 
     const openModal = () => {
@@ -62,7 +70,6 @@ export default function Component(props: any) {
 
     function getCards() {
         setTriggered(true)
-        console.log('get Cards')
         metricCards().then(res => {
             Taro.stopPullDownRefresh()
             setErrorPage(false)
@@ -74,7 +81,6 @@ export default function Component(props: any) {
                 setErrorPage(true)
             }
             setTriggered(false)
-            // console.log('请求超时')
         })
     }
 
@@ -117,7 +123,6 @@ export default function Component(props: any) {
             setTime(now.getTime())
             setMetricItem(item)
             openModal()
-            console.log(item)
         }
         else {
             Taro.navigateTo({
@@ -131,7 +136,6 @@ 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[] = []
 
@@ -150,7 +154,6 @@ export default function Component(props: any) {
             items2.push(i)
         }
         value1Index = Math.round(10 * (value - Math.floor(value)));
-        console.log(value1Index)
 
         setPickerValue([value0Index, value1Index] as any)
         setPickerItems([items, items2] as any)
@@ -188,7 +191,6 @@ export default function Component(props: any) {
         if ((metricItem as any).schemas[0].type == 'DECIMAL') {
             var array = pickerItems;
             var value = array[0][e[0]] + '.' + array[1][e[1]]
-            console.log(value)
 
 
             params = {
@@ -204,7 +206,6 @@ export default function Component(props: any) {
         else {
             var array = pickerItems;
             var value = array[0][e[0]] + ''
-            console.log(value)
             params = {
                 code: (metricItem as any).code,
                 timestamp: time,
@@ -220,6 +221,10 @@ export default function Component(props: any) {
                 }
             })
             setList(list)
+
+            setTimeout(()=>{
+                setCount(count+1)
+            },31000)
             // getCards();
         })
     }
@@ -280,6 +285,9 @@ export default function Component(props: any) {
             setList(JSON.parse(JSON.stringify(list)))
 
             global.postBtnUpdateStatus('idle');
+            setTimeout(()=>{
+                setCount(count+1)
+            },31000)
 
         })
     }

+ 9 - 8
src/features/trackSomething/components/MetricHistory.tsx

@@ -1,4 +1,4 @@
-import { View, Text,Image } from "@tarojs/components";
+import { View, Text, Image } from "@tarojs/components";
 import './MetricHistory.scss'
 import RecordItem from "@/features/common/RecordItem";
 import { deleteMetricRecord } from "@/services/trackSomething";
@@ -45,9 +45,10 @@ export default function Component(props: { records: any[] }) {
 
     function deleteRecord(record: any) {
         deleteMetricRecord({ id: record.id }).then(res => {
-            debugger
             list.map(item => {
-                item.records.splice(item.records.findIndex(item => item.id == record.id), 1)
+                var index = item.records.findIndex(item => item.id == record.id);
+                if (index >= 0)
+                    item.records.splice(index, 1)
             })
             for (let i = list.length; i > 0; i--) {
                 if (list[i - 1].records.length == 0) {
@@ -56,7 +57,7 @@ export default function Component(props: { records: any[] }) {
             }
             // console.log(list)
             setList(JSON.parse(JSON.stringify(list)))
-            // global.refreshMetric()
+            global.refreshMetric()
         })
     }
 
@@ -71,9 +72,9 @@ export default function Component(props: { records: any[] }) {
                 lastYearStr = TimeFormatter.getYearByDate(item.date)
                 return <View style={{ display: 'flex', flexDirection: 'column' }}>
                     {
-                        showYear && <Text className="year" style={{ backgroundColor:isDebugModel?'red':'transparent' }}>{TimeFormatter.getYearByDate(item.date)}</Text>
+                        showYear && <Text className="year" style={{ backgroundColor: isDebugModel ? 'red' : 'transparent' }}>{TimeFormatter.getYearByDate(item.date)}</Text>
                     }
-                    <Text className="operate_day" style={{backgroundColor:isDebugModel?'red':'transparent'}}>{TimeFormatter.getMonthAndDayByDate(item.date)}</Text>
+                    <Text className="operate_day" style={{ backgroundColor: isDebugModel ? 'red' : 'transparent' }}>{TimeFormatter.getMonthAndDayByDate(item.date)}</Text>
                     {
                         item.records.map(record => {
                             return <RecordItem delete={() => deleteRecord(record)}>
@@ -82,7 +83,7 @@ export default function Component(props: { records: any[] }) {
                                        
                                     </View>
                                     <View style={{ width: 12 }} /> */}
-                                    <Text className="value" style={{backgroundColor:isDebugModel?'red':'transparent'}}>{record.items[0].value}</Text>
+                                    <Text className="value" style={{ backgroundColor: isDebugModel ? 'red' : 'transparent' }}>{record.items[0].value}</Text>
                                     {
                                         record.items.length > 1 && <Text className="value">/{record.items[1].value}</Text>
                                     }
@@ -92,7 +93,7 @@ export default function Component(props: { records: any[] }) {
                                     <Text className="unit">{record.items[0].unit}</Text>
                                     <View style={{ flex: 1 }} />
                                     <Text className="time">{formateHourMinutes(record.timestamp)}</Text>
-                                    
+
                                 </View>
                             </RecordItem>
                         })

+ 1 - 1
src/features/trackSomething/components/MetricItem.tsx

@@ -42,7 +42,7 @@ export default function Component(props: {
             }
         </View> */}
         <View style={{ position: 'relative',marginTop:10 }} >
-            <RecordMetricBtn themeColor={props.themeColor} title={props.btnText} onClick={clickBtn}/>
+            <RecordMetricBtn themeColor={props.themeColor} title={props.btnText} onClick={clickBtn} isDisable={props.isDisabled}/>
             {
                 props.showBadge && <View className="badge"></View>
             }

+ 19 - 2
src/features/trackTimeDuration/components/RecordFastSleep.scss

@@ -1,11 +1,28 @@
+.time_operate_item{
+    padding-top: 40px;
+    padding-bottom: 40px;
+    margin-left: 46px;
+    margin-right: 46px;
+    display: flex;
+    flex-direction: row;
+    align-items: center;
+    background-color: #1C1C1C;
+    border-radius: 36px;
+    padding-left: 40px;
+    padding-right: 40px;
+    margin-top: 16px;
+}
+
+
 .fast_sleep_item {
     // display: 'flex',position:'relative', flex-: 'row', alignItems: 'center'
     display: flex;
     position: relative;
     flex-direction: row;
     align-items: center;
-    padding-top: 20px;
-    padding-bottom: 20px;
+    width: 578px;
+    // padding-top: 20px;
+    // padding-bottom: 20px;
 }
 
 .duration_bg {

+ 28 - 13
src/features/trackTimeDuration/components/RecordFastSleep.tsx

@@ -264,7 +264,7 @@ export default function RecordFastSleep(props: { data: any, type: string, delSuc
                 }
             </View>
             {/* <Image className="arrow1" src={require('@/assets/images/arrow.png')} /> */}
-            <View className="record_arrow_bg" style={{backgroundColor:isDebugModel?'red':'transparent'}}>
+            <View className="record_arrow_bg" style={{ backgroundColor: isDebugModel ? 'red' : 'transparent' }}>
                 <Text className='recordTime'>{TimeFormatter.dateDescription(props.data.last_real_check_time, true)}</Text>
                 <Image className="arrow1" src={require('@/assets/images/arrow3.png')} />
             </View>
@@ -272,18 +272,33 @@ export default function RecordFastSleep(props: { data: any, type: string, delSuc
         </View>
     }
 
+    return <View>
+        {header()}
+        <View className="time_operate_item">
+            <RecordItem canDel={record.status == 'COMPLETED'} delete={del}
+                onClick={showDetail}
+            >{recordDetail()}
+            </RecordItem>
+            {
+                showDetailModal && <Modal children={schedules()}
+                    modalType={ModalType.center}
+                    dismiss={() => setShowDetailModal(false)}
+                    confirm={() => { }} />
+            }
+        </View>
+    </View>
 
-    return <Box header={header()}>
-        <RecordItem canDel={record.status == 'COMPLETED'} delete={del}
-            onClick={ showDetail}
-        >{recordDetail()}
-        </RecordItem>
-        {
-            showDetailModal && <Modal children={schedules()}
-                modalType={ModalType.center}
-                dismiss={() => setShowDetailModal(false)}
-                confirm={() => { }} />
-        }
+    // return <Box header={header()}>
+    //     <RecordItem canDel={record.status == 'COMPLETED'} delete={del}
+    //         onClick={showDetail}
+    //     >{recordDetail()}
+    //     </RecordItem>
+    //     {
+    //         showDetailModal && <Modal children={schedules()}
+    //             modalType={ModalType.center}
+    //             dismiss={() => setShowDetailModal(false)}
+    //             confirm={() => { }} />
+    //     }
 
-    </Box>
+    // </Box>
 }

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

@@ -226,7 +226,7 @@ export default function Component(props: { type?: string, data?: any, delSuccess
         }
         else {
             Taro.vibrateShort({
-                type: 'heavy'
+                type: 'medium'
             })
         }
     }

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

@@ -240,17 +240,17 @@ export default function Component() {
     var endCount = parseInt(end.split(':')[0]) * 60 + parseInt(end.split(':')[1])
     if (operateType == 1 && startCount % 15 == 0) {
       Taro.vibrateShort({
-        type: 'heavy',
+        type: 'medium',
       })
     }
     else if (operateType == 2 && endCount % 15 == 0) {
       Taro.vibrateShort({
-        type: 'heavy',
+        type: 'medium',
       })
     }
     else if (operateType == 3 && (startCount % 15 == 0 || endCount % 15 == 0)) {
       Taro.vibrateShort({
-        type: 'heavy',
+        type: 'medium',
       })
     }
 

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

@@ -15,7 +15,6 @@
 }
 
 .fast_sleep_item_bg{
-    margin-top: 16px;
     display: flex;
     flex-direction: column;
     flex-direction: 0;

+ 1 - 1
src/pages/common/RecordsHistory.tsx

@@ -96,7 +96,6 @@ export default function Page() {
     }
 
     function getHistory(page = pageIndex) {
-        debugger
         if (page == 1)
             setTriggered(true)
         if (router.params.type == 'time') {
@@ -251,6 +250,7 @@ export default function Page() {
     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()}