Explorar o código

fix some bugs

leon hai 1 ano
pai
achega
c20db1e77a

+ 31 - 16
src/_health/components/add_label.tsx

@@ -12,6 +12,9 @@ import { getThemeColor } from "@/features/health/hooks/health_hooks";
 import NewTimePicker from "../base/new_timepicker";
 import showAlert from "@/components/basic/Alert";
 import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
+import NewModal from "../base/new_modal";
+import Card from "./card";
+import { rpxToPx } from "@/utils/tools";
 
 export default function AddLabel(props: {
     labels: any,
@@ -67,7 +70,7 @@ export default function AddLabel(props: {
                 if (global.refreshSchedules2) {
                     global.refreshSchedules2()
                 }
-                if (props.confirm){
+                if (props.confirm) {
                     props.confirm((res as any).schedules[0])
                 }
             }
@@ -104,10 +107,18 @@ export default function AddLabel(props: {
     }
 
     function timeContent() {
-        return <View>
-            <View className="header1">Set Time</View>
-            <View style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between' }}>
-                <Text>全天时间</Text>
+        return <Card>
+            <View style={{
+                position: 'relative',
+                display: 'flex', flexDirection: 'row',
+                height: rpxToPx(128),
+                alignItems: 'center',
+                boxSizing: 'border-box',
+                paddingLeft: rpxToPx(54),
+                paddingRight: rpxToPx(54),
+                justifyContent: 'space-between'
+            }}>
+                <Text className="h34">全天时间</Text>
                 <Switch
                     color={props.color ? props.color : getThemeColor(health.mode)}
                     onChange={(e) => {
@@ -115,6 +126,7 @@ export default function AddLabel(props: {
                         // item.reminder = e.detail.value
                         // setList([...list])
                     }} />
+                <View className="border_footer_line"/>
             </View>
             {
                 isFullday ? <View>
@@ -130,16 +142,15 @@ export default function AddLabel(props: {
                     </View>
                 </View> :
                     <View style={{ flexDirection: 'column', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
-                        {/* <Text onClick={}>{dayjs().format('HH:mm')}</Text>
-                        <Text>Picker placeholder</Text> */}
-                        <NewTimePicker onChange={e => {
-                            console.log(e)
-                            setStrTime(e)
-                        }} />
+                        <NewTimePicker
+                            color={props.color ? props.color : getThemeColor(health.mode)}
+                            onChange={e => {
+                                console.log(e)
+                                setStrTime(e)
+                            }} />
                     </View>
             }
-            <View className="pop_footer" style={{ backgroundColor: props.color ? props.color : getThemeColor(health.mode) }} onClick={() => done()}>完成</View>
-        </View>
+        </Card>
     }
 
     return <View>
@@ -158,15 +169,19 @@ export default function AddLabel(props: {
         </View>
         <View className="pop_footer" style={{ backgroundColor: props.color ? props.color : getThemeColor(health.mode) }} onClick={tapDone}>{props.justLabel ? '完成' : '下一步'}</View>
         {
-            showTimePicker && <Modal testInfo={null}
+            showTimePicker && <NewModal
+                title="Set Time"
+                themeColor={props.color ? props.color : getThemeColor(health.mode)}
+                btnTitle='完成'
                 dismiss={() => {
                     setShowTimePicker(false)
                 }}
-                confirm={() => { }}>
+                confirm={done}
+            >
                 {
                     timeContent()
                 }
-            </Modal>
+            </NewModal>
         }
     </View>
 }

+ 8 - 0
src/_health/pages/active_plan.config.ts

@@ -0,0 +1,8 @@
+export default definePageConfig({
+    usingComponents: {
+        // 'ec-canvas': '../../lib/ec-canvas/ec-canvas',
+        // 'demo':'../../components/demo'
+    },
+    "navigationBarTitleText": "",
+    "navigationBarBackgroundColor": "#f5f5f5"
+})

+ 9 - 2
src/_health/pages/active_plan.tsx

@@ -8,6 +8,7 @@ import AddLabel from "../components/add_label";
 import { getLabelsEvent, getSchedules } from "@/services/health";
 import { useSelector } from "react-redux";
 import Taro from "@tarojs/taro";
+import NewHeader, { NewHeaderType } from "../components/new_header";
 
 let useRoute;
 let useNavigation;
@@ -61,13 +62,17 @@ export default function ActivePlan() {
     if (!loaded) return <View />
 
     return <View style={{ display: 'flex', flexDirection: 'column', flex: 1 }}>
-        <Text>Plan my daily life</Text>
-        <Text>Header: List top 3 activities that matter most to me/I want to practice to every day</Text>
+        <NewHeader 
+            type={NewHeaderType.left_subtitle}
+            title="Plan my daily life"
+            subtitle="Header: List top 3 activities that matter most to me/I want to practice to every day"
+        />
         {
             list.length == 0 && <View className="plan_item" onClick={tapEdit}>
                 <Text>1</Text>
                 <Text style={{ flex: 1 }}>{schedule.title}</Text>
                 <Text style={{ color: getThemeColor('ACTIVE') }}>Tap to customize</Text>
+                <View className="border_footer_line"/>
             </View>
         }
         {
@@ -76,6 +81,7 @@ export default function ActivePlan() {
                     <Text>{1 + index}</Text>
                     <Text style={{ flex: 1 }}>{item.title}</Text>
                     <Text>{item.time ? item.time : item.time_label}</Text>
+                    <View className="border_footer_line"/>
                 </View>
             })
         }
@@ -83,6 +89,7 @@ export default function ActivePlan() {
             list.length > 0 && list.length < 3 && <View className="plan_item" onClick={tapEdit}>
                 <Text style={{color: getThemeColor('ACTIVE')}}>+</Text>
                 <Text style={{ flex: 1,color: getThemeColor('ACTIVE') }}>Daily Activity</Text>
+                <View className="border_footer_line"/>
             </View>
         }
 

+ 2 - 1
src/_health/pages/long_fast.tsx

@@ -113,7 +113,8 @@ export default function LongFast() {
     function tapMore() {
         var listItems = ['编辑目标', t('health.delete_current_record')]
         if (long_fast.status == 'OG') {
-            listItems.push(t('health.edit_fast_goal'))
+            listItems.push('结束断食')
+            // listItems.push(t('health.edit_fast_goal'))
         }
         showActionSheet({
             title: t('health.more_actions'),

+ 42 - 6
src/_health/pages/move.tsx

@@ -178,6 +178,10 @@ export default function Move() {
                 timestamp: new Date().getTime(),
                 schedule_id: schedule_id
             }).then(res => {
+                if ((res as any).error_code == 'WX_STEP_PARSE_FAIL') {
+                    retry(hour, schedule_id)
+                    return
+                }
                 // Taro.showToast({
                 //     title: '上报成功',
                 //     icon: 'none'
@@ -193,6 +197,38 @@ export default function Move() {
         })
     }
 
+    function retry(hour, schedule_id) {
+        Taro.login().then(res0 => {
+            thirdPartRequest(RequestType.RequestTypeWXRunData).then(res => {
+                uploadActiveMoves({
+                    code: res0.code,
+                    wechat_run: {
+                        encryptedData: (res as any).encryptedData,
+                        iv: (res as any).iv,
+                    },
+                    start_date: startDate,
+                    date: dayjs().format('YYYYMMDD'),
+                    hour: hour,
+                    timestamp: new Date().getTime(),
+                    schedule_id: schedule_id
+                }).then(res => {
+                    if ((res as any).error_code == 'WX_STEP_PARSE_FAIL') {
+                        Taro.showToast({
+                            title: '获取失败',
+                            icon: 'none'
+                        })
+                        return
+                    }
+                    jumpPage('./post_result?data=' + JSON.stringify((res as any).post_result))
+                    getMovesCurrent()
+                    getMovesHistory()
+                })
+            }).catch(_ => {
+                dispatch(setResult({ isSuccess: false }) as any)
+            })
+        })
+    }
+
     function currentCheckHour() {
         let currentHour = new Date().getHours()
         const minute = new Date().getMinutes()
@@ -493,12 +529,12 @@ export default function Move() {
         })
 
         return <View className="summary_status_bg">
-            <StatusIndicator 
+            <StatusIndicator
                 type={StatusType.normal}
                 color={selItem.type == 'SLEEP' ? getThemeColor('SLEEP') : getThemeColor('ACTIVE')}
                 text={`${selItem.type == 'SLEEP' ? 'SLEEP HOUR ' : 'WAKING HOUR '}${selItem.index}`}
-                // fontSize={}
-                // fontColor={}
+            // fontSize={}
+            // fontColor={}
             />
             {/* <View className="summary_status_point" style={{ backgroundColor: selItem.type == 'SLEEP' ? getThemeColor('SLEEP') : getThemeColor('ACTIVE') }} /> */}
             {/* <Text className="summary_status_text">{selItem.type == 'SLEEP' ? 'SLEEP HOUR ' : 'WAKING HOUR '}{selItem.index}</Text> */}
@@ -589,18 +625,18 @@ export default function Move() {
         return `Upcoming (${data.hours.length - hours.length > 0 ? data.hours.length - hours.length : ''})`
     }
 
-    function showMore(){
+    function showMore() {
         showActionSheet({
             showActionSheetWithOptions: showActionSheetWithOptions,
             title: t('health.more_actions'),
             itemList: [t('health.change_step_goal')],
             success: (res) => {
-                if (res==0){
+                if (res == 0) {
                     jumpPage('./move_setting_time')
                 }
             }
         });
-        
+
     }
 
     function tools() {

+ 2 - 0
src/_health/pages/schedules.tsx

@@ -391,6 +391,8 @@ export default function Schedules() {
                                     var array = JSON.parse(JSON.stringify(list))
                                     array.splice(i, 1)
                                     setList(array)
+
+                                    global.refreshWindow()
                                 })
                             }}
                         // onClick={() => {

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 16 - 0
src/components/basic/Icons.tsx


+ 2 - 0
src/features/health/History.scss

@@ -35,6 +35,7 @@
     display: flex;
     flex-direction: column;
     flex-shrink: 0;
+    flex: 1;
 }
 
 .history_item_duration {
@@ -72,6 +73,7 @@
     flex-wrap: wrap;
     margin-bottom: 20px;
     flex-shrink: 0;
+    flex: 1;
 }
 
 .media_item {

+ 12 - 4
src/features/health/HistoryItem.tsx

@@ -8,7 +8,7 @@ import { getThemeColor } from "./hooks/health_hooks";
 import Rings, { RingCommon, BgRing, TargetRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
 import { MainColorType } from "@/context/themes/color";
 import { durationArc, startArc } from "./util";
-import { IconMore } from "@/components/basic/Icons";
+import { IconLongFast, IconMore } from "@/components/basic/Icons";
 import showActionSheet from "@/components/basic/ActionSheet";
 import { delRecord, makeDone } from "@/services/health";
 import showAlert from "@/components/basic/Alert";
@@ -29,12 +29,17 @@ export default function HistoryItem(props: {
     let showActionSheetWithOptions;
     function preview(obj) {
         var list: any = []
+
         props.data.events.map((item) => {
-            item.moment.media.map((media) => {
-                list.push(media.url)
+            item.moments && item.moments.map(moment => {
+                moment.media && moment.media.map((obj) => {
+                    list.push(obj.url)
+                })
             })
+
         })
 
+
         Taro.previewImage({
             current: obj.url,
             urls: list
@@ -173,7 +178,7 @@ export default function HistoryItem(props: {
         }
         return ''
     }
- 
+
     return <View className="history_item2">
         <View className="history_date">{historyDate()}</View>
         <View className="history_content">
@@ -215,6 +220,9 @@ export default function HistoryItem(props: {
                 {
                     props.fast_type != 'LF' && ring()
                 }
+                {
+                    props.fast_type == 'LF' && <IconLongFast color={MainColorType.fast} width={rpxToPx(32)}/>
+                }
                 {
                     props.data.window_range.end_timestamp && <Text className="history_item_duration">{formatMilliseconds(props.data.window_range.end_timestamp - props.data.window_range.start_timestamp)}</Text>
                 }

+ 42 - 15
src/features/health/MainConsole.tsx

@@ -1,5 +1,5 @@
 import { WindowStatusType, WindowType } from "@/utils/types";
-import { View, Text, Image } from "@tarojs/components";
+import { View, Text, Image, Swiper, SwiperItem } from "@tarojs/components";
 import dayjs from "dayjs";
 import { useEffect, useRef, useState } from "react";
 import { useDispatch, useSelector } from "react-redux";
@@ -54,7 +54,7 @@ export default function MainConsole(props: { type: WindowType }) {
 
     }, [props.type])
 
-    global.chooseLocation = ()=>{
+    global.chooseLocation = () => {
         chooseLocation()
     }
 
@@ -204,6 +204,12 @@ export default function MainConsole(props: { type: WindowType }) {
                 onClick={() => record(item)} />
         }
 
+        if (item.action && item.action == 'NA') {
+            if (health.mode == 'FAST' || health.mode == 'SLEEP') {
+                return <IconArrow width={rpxToPx(34)} color={MainColorType.g03} />
+            }
+        }
+
         return <View />
     }
 
@@ -612,17 +618,38 @@ export default function MainConsole(props: { type: WindowType }) {
             case 'ACTIVE':
                 list = active.timeline
                 if (active.onboard == false) {
-                    return <OnBoard title={list[0].title}
-                        desc="Subtitle"
-                        btnTitle="Action"
-                        onClick={() => {
-                            if (!user.isLogin) {
-                                jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
-                                return
-                            }
-                            jumpPage('/_health/pages/active_plan?schedule=' + JSON.stringify(list.length > 0 ? list[0] : '{}'))
-                        }}
-                    />
+                    var seconds = new Date().getSeconds()
+
+                    return <Swiper autoplay>
+                        {
+                            list.map((item, index) => {
+                                return <SwiperItem key={index}>
+                                    <OnBoard title={item.title}
+                                        desc={item.time_label}
+                                        btnTitle="Action"
+                                        onClick={() => {
+                                            if (!user.isLogin) {
+                                                jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
+                                                return
+                                            }
+                                            jumpPage('/_health/pages/active_plan?schedule=' + JSON.stringify(item))
+                                        }}
+                                    />
+                                </SwiperItem>
+                            })
+                        }
+                    </Swiper>
+                    // return <OnBoard title={list[0].title}
+                    //     desc="Subtitle"
+                    //     btnTitle="Action"
+                    //     onClick={() => {
+                    //         if (!user.isLogin) {
+                    //             jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
+                    //             return
+                    //         }
+                    //         jumpPage('/_health/pages/active_plan?schedule=' + JSON.stringify(list.length > 0 ? list[0] : '{}'))
+                    //     }}
+                    // />
                 }
                 break;
         }
@@ -707,8 +734,8 @@ export default function MainConsole(props: { type: WindowType }) {
         var scenario = getScenario(health.windows, health.mode)
         debugger
         Taro.chooseLocation({
-            latitude: scenario.extra.choose_location ? parseFloat(scenario.extra.lat+'') : undefined,
-            longitude: scenario.extra.choose_location ? parseFloat(scenario.extra.lng+'') : undefined,
+            latitude: scenario.extra.choose_location ? parseFloat(scenario.extra.lat + '') : undefined,
+            longitude: scenario.extra.choose_location ? parseFloat(scenario.extra.lng + '') : undefined,
             success: function (res) {
                 uploadLocation(res)
             },

+ 12 - 2
src/features/health/MainHistory.tsx

@@ -12,7 +12,7 @@ import { getThemeColor } from "./hooks/health_hooks";
 import { TimeFormatter } from "@/utils/time_format";
 import dayjs from "dayjs";
 import { MainColorType } from "@/context/themes/color";
-import { IconCellArrow } from "@/components/basic/Icons";
+import { IconArrow, IconCellArrow } from "@/components/basic/Icons";
 import NoData from "@/_health/components/no_data";
 
 let lastMode = ''
@@ -23,9 +23,16 @@ export default function MainHistory(props: { type?: string, fast_type?: string }
     const [loaded, setLoaded] = useState(false)
     const refDemo = useRef()
     const health = useSelector((state: any) => state.health);
+    const user = useSelector((state: any) => state.user);
     const healthRef = useRef(health)
 
 
+    useEffect(()=>{
+        if (!user.isLogin){
+            setList([])
+        }
+    },[user.isLogin])
+
     global.refreshHistory = () => {
         refresh()
     }
@@ -131,6 +138,8 @@ export default function MainHistory(props: { type?: string, fast_type?: string }
     if (!loaded || health.mode == 'DAY' || health.mode == 'NIGHT')
         return <View />
 
+    if (!user.isLogin) return <View />
+
     return <View style={{ width: rpxToPx(750), marginTop: rpxToPx(35) }}>
         {/* <Calendar year={2024} month={8}/> */}
         {/* <View style={{
@@ -172,7 +181,8 @@ export default function MainHistory(props: { type?: string, fast_type?: string }
                             return <Image src={item} key={index} className="archived_img" mode="aspectFill" />
                         })
                     }
-                    <IconCellArrow color={MainColorType.g03} width={rpxToPx(34)} />
+                    <IconArrow color={MainColorType.g03} width={rpxToPx(34)}/>
+                    {/* <IconCellArrow color={MainColorType.g03} width={rpxToPx(34)} /> */}
                     {/* <Image src={require('@assets/_health/cell_arrow.png')} style={{
                         width: rpxToPx(24),
                         height: rpxToPx(24),

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

@@ -391,7 +391,7 @@ export default function Page() {
                 <Text style={{ flex: 1 }}>Settings</Text>
                 <IconCellArrow color={MainColorType.g03} width={rpxToPx(34)}/>
             </View>
-            <View style={{ height: 40 }}></View>
+            <View style={{ height: 140,flexShrink:0 }}></View>
 
         </View>
     }

+ 4 - 0
src/pages/clock/ClockNew.tsx

@@ -66,6 +66,10 @@ export default function ClockNew() {
 
     useEffect(() => {
         getWindows();
+        if (global.refreshHistory) {
+            global.refreshHistory()
+        }
+
     }, [user.isLogin])
 
     global.refreshWindow = () => {

+ 2 - 2
src/pages/store/product_list.scss

@@ -2,8 +2,8 @@
     display: flex;
     flex-direction: column;
     margin-bottom: 20px;
-    margin-left: 46px;
-    margin-right: 46px;
+    margin-left: 26px;
+    margin-right: 26px;
     background-color: #ffffff;
     border-radius: 24px;
     padding-left: 40px;

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio