Leon il y a 2 ans
Parent
commit
1fd4659032

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

@@ -33,7 +33,7 @@ export default function Modal(props: {
     }
     return <View className='modal' catchMove>
 
-        <View style={{ flex: 1 }} onClick={() => props.dismiss()}>
+        <View style={{ flex: 1,width:375,flexShrink:0 }} onClick={() => props.dismiss()}>
             {
                 props.testInfo ? props.testInfo : null
             }

+ 1 - 0
src/components/view/Timeline.scss

@@ -2,6 +2,7 @@
     display: flex;
     flex-direction: column;
     color: #fff;
+    width: 100%;
   }
   
   .timeline-item {

+ 0 - 1
src/custom-tab-bar/index.tsx

@@ -9,7 +9,6 @@ export default function TabBar() {
     const [selIndex, setSelIndex] = useState(global.index?global.index:0)
     console.log(selIndex)
     useEffect(() => {
-        console.log(global.index+'aaaa')
         setSelIndex(global.index?global.index:0)
       }, [global.index])
 

+ 35 - 19
src/features/trackTimeDuration/components/Console.tsx

@@ -64,28 +64,40 @@ export default function Component(props: { isNextStep?: boolean }) {
 
 
     function showPicker() {
+        if (global.testInfotimer) {
+            return
+        }
         global.set_time = new Date().getTime()
-
+        updateNodeInfo()
         global.testInfotimer = setInterval(() => {
-            var node = (<Modal testInfo={testLayout()} children={layoutContent()} dismiss={() => {
-                global.showClockModal(false, null);
-                hidePicker()
-            }} confirm={() => {
-                hidePicker()
-                var picker = limitPickerRef.current;
-                pickerConfirm((picker as any).getConfirmData());
-                global.showClockModal(false, null);
-            }} />);
-            global.showClockModal(true, node);
+            updateNodeInfo()
 
         }, 1000)
 
     }
 
+    function updateNodeInfo() {
+        var node = (<Modal testInfo={testLayout()} children={layoutContent()} dismiss={() => {
+            console.log('aaaaaa')
+            global.showClockModal(false, null);
+            hidePicker()
+        }} confirm={() => {
+            hidePicker()
+            var picker = limitPickerRef.current;
+            pickerConfirm((picker as any).getConfirmData());
+            global.showClockModal(false, null);
+        }} />);
+        global.showClockModal(true, node);
+    }
+
     function hidePicker() {
         global.showClockModal(false, null);
         if (global.testInfotimer) {
             clearInterval(global.testInfotimer)
+            global.testInfotimer = null
+        }
+        else {
+            console.log('global test info timer')
         }
     }
 
@@ -120,7 +132,7 @@ export default function Component(props: { isNextStep?: boolean }) {
 
         }
 
-        if (props.isNextStep){
+        if (props.isNextStep) {
             isFast = true
             isStart = false
         }
@@ -157,7 +169,7 @@ export default function Component(props: { isNextStep?: boolean }) {
 
         var title = getTitle(time)
         var color = getColor(time)
-        if (props.isNextStep){
+        if (props.isNextStep) {
             title = '结束断食'
             color = '#AAFF00'
         }
@@ -180,7 +192,7 @@ export default function Component(props: { isNextStep?: boolean }) {
 
         t = date.getTime();
 
-        if (props.isNextStep){
+        if (props.isNextStep) {
             endFast(t)
             return;
         }
@@ -257,7 +269,7 @@ export default function Component(props: { isNextStep?: boolean }) {
                 <StartSleepBtn onClick={showPicker} />
             }
             {
-                time.status == 'ONGOING1' && <EndFastBtn onClick={showPicker} />
+                time.status == 'ONGOING1' && <EndFastBtn onClick={showPicker} lowLight={time.fast.target_end_time > new Date().getTime()} />
             }
             {
                 time.status == 'ONGOING2' && <EndFastBtn onClick={showPicker} lowLight={time.fast.target_end_time > new Date().getTime()} />
@@ -313,7 +325,7 @@ export default function Component(props: { isNextStep?: boolean }) {
         global.showClockModal2(true, node);
     }
 
-    
+
 
 
     function durationPickerContent() {
@@ -414,7 +426,11 @@ export default function Component(props: { isNextStep?: boolean }) {
 
     if (props.isNextStep) {
         return <Box >
-            <View style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', flexShrink: 0 }}>
+            <View style={{
+                display: 'flex', flexDirection: 'column', alignItems: 'center', flexShrink: 0,
+                opacity: time.status == 'WAIT_FOR_START' ? 0.4 : 1,
+                pointerEvents: time.status == 'WAIT_FOR_START' ? 'none' : 'all'
+            }}>
                 {
                     (time.status == 'WAIT_FOR_START') && <Stepper child={
                         <Text className="stepper_text" style={{ color: '#00FFFF', opacity: textAlpha(time) }} onClick={showDurationPicker}>{durationFormate()}</Text>
@@ -422,13 +438,13 @@ export default function Component(props: { isNextStep?: boolean }) {
                 }
                 {
                     time.status == 'ONGOING1' && <View>
-                        <Text className="counter_text" style={{ color: '#AAFF00', opacity: textAlpha(time) }}>{TimeFormatter.countdown(time.fast.target_end_time)}</Text>
+                        <Text className="counter_text" style={{ color: textNextStepAlpha(time) == 1 ? '#FA5151' : '#AAFF00', opacity: textNextStepAlpha(time) }}>{TimeFormatter.countdown(time.fast.target_end_time)}</Text>
                     </View>
                 }
 
                 {
                     time.status == 'ONGOING2' && <View>
-                        <Text className="counter_text" style={{ color: '#AAFF00', opacity: textAlpha(time) }}>{TimeFormatter.countdown(time.fast.target_end_time)}</Text>
+                        <Text className="counter_text" style={{ color: textNextStepAlpha(time) == 1 ? '#FA5151' : '#AAFF00', opacity: textNextStepAlpha(time) }}>{TimeFormatter.countdown(time.fast.target_end_time)}</Text>
                     </View>
                 }
                 {

+ 18 - 0
src/features/trackTimeDuration/components/Schedule.scss

@@ -23,4 +23,22 @@
 .arrow1{
     width: 48px;
     height: 48px;
+}
+
+.tip_bg2{
+    height: 80px;
+    width: 100%;
+    box-sizing: border-box;
+    // background-color: rgba(250, 81, 81, 0.1);
+    display: flex;
+    flex-direction: column;
+    // padding-left: 40px;
+}
+
+.tip_text2{
+    line-height: 80px;
+    color: #fff;
+    opacity: 0.8;
+    font-size: 28px;
+
 }

+ 67 - 21
src/features/trackTimeDuration/components/Schedule.tsx

@@ -18,6 +18,7 @@ export default function Component(props: { type?: string, data?: any, delSuccess
     const { t } = useTranslation()
     const permission = useSelector((state: any) => state.permission);
     const common = useSelector((state: any) => state.common);
+    const time = useSelector((state: any) => state.time);
     const dispatch = useDispatch();
 
     function all() {
@@ -78,45 +79,90 @@ export default function Component(props: { type?: string, data?: any, delSuccess
             }
         }
         return <View style={{
-            // background:LinearGradient
-            height: 40,
+            height: 18,
             display: 'flex', flexDirection: 'row', width: '100%',
-            justifyContent: 'space-between', alignItems: 'center'
+            justifyContent: 'space-between', alignItems: 'center',
+            marginBottom:6,paddingRight:10,boxSizing:'border-box'
         }}>
-            <Text>{permission.wxPubFollow ? TimeFormatter.getDateAndWeek() : '日程提醒'}</Text>
+            <Text style={{fontSize:18,lineHeight:18,fontWeight:500}}>{permission.wxPubFollow ? TimeFormatter.getDateAndWeek() : '日程提醒'}</Text>
             {
                 !permission.wxPubFollow && <View >
                     <Switch isOn={permission.wxPubFollow} onClick={() => followWxPub()} />
                 </View>
             }
             {
-                permission.wxPubFollow && <Buttons disabled={props.data.status != 'WAIT_FOR_START'} 
-                className={props.data.scenario == 'FAST_SLEEP'?'mixed':''}
-                btnStyle={btnStyle} type={ButtonType.text} title="调整日程" onClick={() => {
-                    if (props.data.name == 'FAST_SLEEP') {
-                        dispatch(setStep('fast'))
-                    }
-                    else if (props.data.name == 'SLEEP') {
-                        dispatch(setStep('sleep'))
-                    }
-                    else {
-                        dispatch(setStep('fast'))
-                    }
-                    Taro.navigateTo({
-                        url: '/pages/clock/SetSchedule'
-                    })
-                }} />
+                permission.wxPubFollow && props.data.status == 'WAIT_FOR_START' && <Buttons disabled={props.data.status != 'WAIT_FOR_START'}
+                    className={props.data.scenario == 'FAST_SLEEP' ? 'mixed' : ''}
+                    btnStyle={btnStyle} type={ButtonType.text} title="调整日程" onClick={() => {
+                        if (props.data.name == 'FAST_SLEEP') {
+                            dispatch(setStep('fast'))
+                        }
+                        else if (props.data.name == 'SLEEP') {
+                            dispatch(setStep('sleep'))
+                        }
+                        else {
+                            dispatch(setStep('fast'))
+                        }
+                        Taro.navigateTo({
+                            url: '/pages/clock/SetSchedule'
+                        })
+                    }} />
             }
         </View>
     }
 
+    function detailCenter() {
+        if (!permission.wxPubFollow) {
+            return <View className="tip_bg2">
+                <Text className="tip_text2">开启后,将显示今天的日程。</Text>
+            </View>
+        }
+
+        var nextCheckTimestamp = 0;
+        if (time.status != 'WAIT_FOR_START') {
+            if (time.status == 'ONGOING') {
+                nextCheckTimestamp = time.scenario == 'FAST' ?
+                    time.fast.target_end_time : time.sleep.target_end_time
+            }
+            else {
+                switch (time.status) {
+                    case 'ONGOING1':
+                        nextCheckTimestamp = time.sleep.target_start_time
+                        break;
+                    case 'ONGOING2':
+                        nextCheckTimestamp = time.sleep.target_end_time
+                        break
+                    case 'ONGOING3':
+                        nextCheckTimestamp = time.fast.target_end_time
+                        break
+                }
+            }
+
+        }
+        var today = new Date();
+        today.setHours(0)
+        today.setMinutes(0)
+        today.setSeconds(0)
+        if (nextCheckTimestamp!=0 && today.getTime()>nextCheckTimestamp){
+            return <View className="tip_bg2">
+                <Text className="tip_text2">完成当前记录,恢复今天的日程。</Text>
+            </View >
+        }
+
+        return <TimelineFastSleep data={props.data} />
+    }
+
+    function detailFooter() {
+
+    }
+
     function detail() {
         return <View style={{ flexDirection: 'column', display: 'flex', alignItems: 'center', position: 'relative' }} onClick={all}>
             {
                 detailHeader()
             }
             {
-                <TimelineFastSleep data={props.data} />
+                detailCenter()
             }
             {
                 props.data.scenario == 'FAST_SLEEP' && (props.data.status == 'WAIT_FOR_START' ? <Text onClick={showStage}>Duration goals by stage</Text> : <Text onClick={showStage}>Current stage</Text>)

+ 30 - 97
src/pages/clock/Clock.tsx

@@ -35,7 +35,6 @@ import { showModal } from '@/store/modal'
 
 export default function IndexPage() {
   const dispatch = useDispatch();
-  const array: any[] = []
   const [checkData, setCheckData] = useState(null)
   const user = useSelector((state: any) => state.user);
   const time = useSelector((state: any) => state.time);
@@ -45,14 +44,15 @@ export default function IndexPage() {
   const [timerId, setTimerId] = useState(null)
   const [needShowAddTip, setNeedShowAddTip] = useState(false)
 
+  const [swiperIndex, setSwiperIndex] = useState(0)
+  const [autoPlay, setAutoPlay] = useState(false)
+
   const [showModal, setShowModal] = useState(false)
   const [modalDetail, setModalDetail] = useState<any>({})
 
   const [showModal2, setShowModal2] = useState(false)
   const [modalDetail2, setModalDetail2] = useState<any>({})
 
-  array.push(<Text>ffff</Text>)
-  // array.push(<Rings radius={50}/>)
   global.dispatch = dispatch;
   useEffect(() => {
     dispatch(staticResources() as any);
@@ -79,15 +79,11 @@ export default function IndexPage() {
       checkAddToMini();
       //检查session是否过期
       checkSession()
+      getCheckData()
     }
   }, [user.isLogin])
 
   function checkSession() {
-    // Taro.login().then(res => {
-    //   // code = res.code;
-    //   uploadSessionKey({ type: 'WX_MP', code: res.code });
-    // })
-    // return
     if (process.env.TARO_ENV === 'weapp') {
       console.log('session request')
       thirdPartRequest(RequestType.RequestTypeCheckSession).then(res => {
@@ -133,6 +129,11 @@ export default function IndexPage() {
 
     const id = setInterval(() => {
       setCounter((prevCounter) => prevCounter + 1);
+      //每天0点刷新一下打卡数据
+      var now = new Date()
+      if (now.getHours()==0 && now.getMinutes()==0){
+        getCheckData()
+      }
     }, 1000);
 
     setTimerId(id as any);
@@ -140,11 +141,9 @@ export default function IndexPage() {
 
 
   useReady(async () => {
-    // console.log('wwwwwwww')
     const userData = await getStorage('userData');
     if (userData) {
       dispatch(getInfoSuccess(JSON.parse(userData as string)) as any);
-      // return JSON.parse(userData as string) as UserState;
       setTimeout(() => {
         checkWXPubFollow()
         getCheckData()
@@ -172,7 +171,7 @@ export default function IndexPage() {
     global.updateTab(0)
     if (user.isLogin) {
       checkWXPubFollow()
-      getCheckData();
+      // getCheckData();
     }
     clearTempScenarioCache()
   })
@@ -185,67 +184,24 @@ export default function IndexPage() {
       machine.context.checkData = res as any;
 
       global.scenario = (res as any).current_record.scenario;
-      // trackTimeService.send({ type: 'RESET' });
-      // trackTimeService.send({ type: (res as any).current_record.scenario });
       const currentState = trackTimeService.getSnapshot();
       let json = {};
       var key = (res as any).current_record.scenario
       var status = (res as any).current_record.status
       json[key] = status
       currentState.value = json;
-      // debugger
       machine.context.currentStatus = `${key}.${status}`;//'mixed.ON_GOING2'
       setCheckData(res as any)
-    })
-    return
-    getChecks().then(res => {
-      if ((res as any).scenario) {
-        dispatch(setScenario((res as any).scenario));
-        global.scenario = (res as any).scenario;
-        // global.checkData = res;
-        // console.log((res as any).scenario.name + ' ' + (res as any).status);
-        // trackTimeService.send({type:(res as any).scenario.name});
-        // setSpecifiedStatus('FAST_SLEEP', 'ON_GOING');
-
-        // 初始化状态机
-        // const initialState = machine.initialState;
-
-        // 设置指定状态为 C->3
-        // const nextState = machine.transition(initialState, 'SET_SPECIFIED_STATE');
-        // const specifiedState = setSpecifiedState(nextState, 'FAST_SLEEP');
-        // setSpecifiedState();
-        // console.log('name:'+(res as any).scenario.name)
-        // machine.reset();
-        trackTimeService.send({ type: 'RESET' });
-
-        trackTimeService.send({ type: (res as any).scenario.name });
-
-        const currentState = trackTimeService.getSnapshot();
-        let json = {};
-        var key = (res as any).scenario.name
-        json[key] = (res as any).status
-        currentState.value = json;
-        // debugger
-        machine.context.currentStatus = `${key}.${(res as any).status}`;//'mixed.ON_GOING2'
-        machine.context.checkData = res as any;
-        // debugger
-        // trackTimeService.send('APPLE');
-        // machine.transition(`${key}.${(res as any).status}`,'' as any);
-
-        // trackTimeService.send({type:'START_FAST'});
-        // trackTimeService.send({type:'START_SLEEP'});
-        // trackTimeService.send({type:'END_SLEEP'});
-        // trackTimeService.send({type:'END_SLEEP'});
-        // trackTimeService.send({type:'START_FAST'});
-        // trackTimeService.send({type:'END_FAST'});
-        // trackTimeService.send({type:'START_SLEEP'});
-
-        // console.log(currentState.value);
-        // debugger
-        // trackTimeService.send('setCurrentStatus', {status:(res as any).status});
-        // setCurrentStatus((res as any).status);
-        // trackTimeService.send({type:'START_FAST'});
+
+      if ((res as any).current_record.status == 'ONGOING1') {
+        setSwiperIndex(1)
+        setAutoPlay(true)
       }
+      else {
+        setSwiperIndex(0)
+        setAutoPlay(false)
+      }
+
     })
   }
 
@@ -255,26 +211,6 @@ export default function IndexPage() {
     })
   }
 
-  function followWxPub() {
-    const resource = common.resources.filter((item: any) => {
-      return item.code == 'follow_wx_pub'
-    })
-
-    Taro.showModal({
-      title: '提示',
-      content: '关注公众号后可接收提醒\n点击确定,前往关注',
-      showCancel: true,
-      success(result) {
-        if (result.confirm) {
-          Taro.navigateTo({
-            url: '/pages/common/H5?title=fast16cc 关注服务号&url=' + resource[0].url,
-          })
-        }
-      },
-    })
-  }
-
-
   async function getStorage(key: string) {
     try {
       const res = await Taro.getStorage({ key });
@@ -288,11 +224,7 @@ export default function IndexPage() {
     if (!user.isLogin) {
       return <View />
     }
-
-    // if ((checkData as any).current_record.scenario == 'FAST_SLEEP') {
     return <Schedule data={(checkData as any).current_record} />
-    // }
-    // return <View />
   }
 
   function needSwiper() {
@@ -332,6 +264,15 @@ export default function IndexPage() {
         {
           needSwiper() ? <Swiper className='swiper' indicatorColor='#333'
             indicatorActiveColor='#999'
+            current={swiperIndex}
+            autoplay={autoPlay}
+            duration={300}
+            interval={2000}
+            onChange={(e) => {
+              setSwiperIndex(e.detail.current)
+              if (e.detail.current == 0)
+                setAutoPlay(false)
+            }}
             indicatorDots>
             <SwiperItem className='swiperItem'>
               <Console />
@@ -347,21 +288,13 @@ export default function IndexPage() {
         }
 
         {/* <Console /> */}
-
-
         <More ref={global.moreRef} />
-        {/* {
-        !permission.wxPubFollow && user.isLogin && <Text style={{ textAlign: 'center', width: '100%' }} onClick={() => followWxPub()}>去关注公众号</Text>
-      } */}
-
         {
           checkData && schedule()
         }
-
-
         {
-          checkData && (checkData as any).latest_record && <RecordFastSleep type='latest' data={(checkData as any).latest_record} delSuccess={getCheckData} />
-          // <Schedule type='latest' delSuccess={getCheckData} />
+          checkData && (checkData as any).latest_record && 
+          <RecordFastSleep type='latest' data={(checkData as any).latest_record} delSuccess={getCheckData} />
         }
         <View style={{ height: 100 }} />
       </View>