|
|
@@ -4,10 +4,10 @@ import IndexItem from '@/features/trackTimeDuration/components/IndexItem';
|
|
|
import Rings from "@/features/trackTimeDuration/components/Rings";
|
|
|
import './Index.scss'
|
|
|
import { useDispatch, useSelector } from "react-redux";
|
|
|
-import { useReady } from "@tarojs/taro";
|
|
|
+import { useDidShow, useReady } from "@tarojs/taro";
|
|
|
import Taro from "@tarojs/taro";
|
|
|
import { getInfoSuccess } from "@/store/user";
|
|
|
-import { clockHome, getClocks } from "@/services/trackTimeDuration";
|
|
|
+import { clockHome, getClockRecords, getClocks } from "@/services/trackTimeDuration";
|
|
|
import { updateScenario } from "@/store/time";
|
|
|
import { setConfigs } from "@/store/common";
|
|
|
import { setScenario } from "@/store/scenario";
|
|
|
@@ -19,10 +19,14 @@ import { RealRing, CurrentDot } from "@/features/trackTimeDuration/components/Ri
|
|
|
import IndexConsole from "@/features/trackTimeDuration/components/IndexConsole";
|
|
|
import Modal from '@/components/layout/Modal'
|
|
|
import { rpxToPx } from "@/utils/tools";
|
|
|
+import RecordFastSleep from "@/features/trackTimeDuration/components/RecordFastSleep";
|
|
|
+import DayLight from "@/features/trackTimeDuration/components/DayLight";
|
|
|
+import { getInfo } from "@/services/user";
|
|
|
|
|
|
export default function Page() {
|
|
|
const dispatch = useDispatch();
|
|
|
global.dispatch = dispatch;
|
|
|
+
|
|
|
const user = useSelector((state: any) => state.user);
|
|
|
const time = useSelector((state: any) => state.time);
|
|
|
const [showErrorPage, setErrorPage] = useState(false)
|
|
|
@@ -41,6 +45,7 @@ export default function Page() {
|
|
|
const [debugInfo, setDebugInfo] = useState(null)
|
|
|
|
|
|
const [isMulti, setIsMulti] = useState(false)
|
|
|
+ const [records, setRecords] = useState([])
|
|
|
|
|
|
|
|
|
const [multiData, setMultiData] = useState([
|
|
|
@@ -59,6 +64,7 @@ export default function Page() {
|
|
|
])
|
|
|
|
|
|
useEffect(() => {
|
|
|
+ global.showNightRing = false;
|
|
|
setInterval(() => {
|
|
|
setCount((prevCounter) => prevCounter + 1)
|
|
|
}, 1000)
|
|
|
@@ -79,11 +85,31 @@ export default function Page() {
|
|
|
// getCheckData()
|
|
|
|
|
|
// }, 200)
|
|
|
+ getHistory()
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
+ useDidShow(() => {
|
|
|
+ if (user.isLogin)
|
|
|
+ refresh()
|
|
|
+ })
|
|
|
+
|
|
|
+ global.refreshIndex = () => {
|
|
|
+ setCount((prevCounter) => prevCounter + 1)
|
|
|
+ }
|
|
|
+
|
|
|
+ function refresh() {
|
|
|
+ getInfo().then(res => {
|
|
|
+ dispatch(getInfoSuccess(res))
|
|
|
+ }).catch(e => {
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
function getCheckData() {
|
|
|
// getClocks().then(res => {
|
|
|
// // setErrorPage(false)
|
|
|
@@ -101,6 +127,19 @@ export default function Page() {
|
|
|
clockHome().then(res => {
|
|
|
setHomeData(res as any)
|
|
|
})
|
|
|
+
|
|
|
+ getHistory()
|
|
|
+ }
|
|
|
+
|
|
|
+ function getHistory() {
|
|
|
+ if (user.isLogin)
|
|
|
+ getClockRecords({
|
|
|
+ page: 1,
|
|
|
+ limit: 1,
|
|
|
+ part_completed: false
|
|
|
+ }).then(res => {
|
|
|
+ setRecords((res as any).data)
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
const startArc = (time: number) => {
|
|
|
@@ -291,6 +330,10 @@ export default function Page() {
|
|
|
indicator-offset={[0, -30]}
|
|
|
indicator-height={30}
|
|
|
indicatorDots={(homeData as any).fast_sleep.current_record.status == 'WAIT_FOR_START'}
|
|
|
+ onChange={(e) => {
|
|
|
+ var pageIndex = e.detail.current
|
|
|
+ global.changeMixIndex(pageIndex)
|
|
|
+ }}
|
|
|
>
|
|
|
<SwiperItem className='swiperItem'>
|
|
|
<IndexConsole record={(homeData as any).fast_sleep} />
|
|
|
@@ -304,7 +347,7 @@ export default function Page() {
|
|
|
{
|
|
|
isMulti ? <View>
|
|
|
{
|
|
|
- multiData.map((item,index) => {
|
|
|
+ multiData.map((item, index) => {
|
|
|
return <View className={item.checked ? "single_check_sel" : "single_check_nor"} onClick={() => {
|
|
|
item.checked = !item.checked
|
|
|
global.updateMixItem([multiData[0].checked, multiData[1].checked, multiData[2].checked])
|
|
|
@@ -321,19 +364,19 @@ export default function Page() {
|
|
|
}
|
|
|
</View> : <View>
|
|
|
|
|
|
- <View className={selIndex == 0 ? "single_check_sel" : "single_check_nor"} onClick={() => {setSelIndex(0);global.updateMixItem([true, false, false]);setCount((prevCounter) => prevCounter + 1)}}>
|
|
|
+ <View className={selIndex == 0 ? "single_check_sel" : "single_check_nor"} onClick={() => { setSelIndex(0); global.updateMixItem([true, false, false]); setCount((prevCounter) => prevCounter + 1) }}>
|
|
|
<Text className={selIndex == 0 ? "single_check_text_sel" : "single_check_text_nor"}>睡前断食</Text>
|
|
|
{
|
|
|
selIndex == 0 && <Image src={require('@assets/images/check_black.png')} className="single_checked" />
|
|
|
}
|
|
|
</View>
|
|
|
- <View className={selIndex == 1 ? "single_check_sel" : "single_check_nor"} onClick={() => {setSelIndex(1);global.updateMixItem([false, true, false]);setCount((prevCounter) => prevCounter + 1)}}>
|
|
|
+ <View className={selIndex == 1 ? "single_check_sel" : "single_check_nor"} onClick={() => { setSelIndex(1); global.updateMixItem([false, true, false]); setCount((prevCounter) => prevCounter + 1) }}>
|
|
|
<Text className={selIndex == 1 ? "single_check_text_sel" : "single_check_text_nor"}>睡眠中断食</Text>
|
|
|
{
|
|
|
selIndex == 1 && <Image src={require('@assets/images/check_black.png')} className="single_checked" />
|
|
|
}
|
|
|
</View>
|
|
|
- <View className={selIndex == 2 ? "single_check_sel" : "single_check_nor"} onClick={() => {setSelIndex(2);global.updateMixItem([false, false, true]);setCount((prevCounter) => prevCounter + 1)}}>
|
|
|
+ <View className={selIndex == 2 ? "single_check_sel" : "single_check_nor"} onClick={() => { setSelIndex(2); global.updateMixItem([false, false, true]); setCount((prevCounter) => prevCounter + 1) }}>
|
|
|
<Text className={selIndex == 2 ? "single_check_text_sel" : "single_check_text_nor"}>起床后断食</Text>
|
|
|
{
|
|
|
selIndex == 2 && <Image src={require('@assets/images/check_black.png')} className="single_checked" />
|
|
|
@@ -360,8 +403,15 @@ export default function Page() {
|
|
|
}
|
|
|
|
|
|
</Swiper>
|
|
|
-
|
|
|
-
|
|
|
+ {
|
|
|
+ user.isLogin && <DayLight />
|
|
|
+ }
|
|
|
+ <Text className="discovery">最近</Text>
|
|
|
+ {
|
|
|
+ records.length > 0 && <View className="fast_sleep_item_bg">
|
|
|
+ <RecordFastSleep data={records[0]} type='record' delSuccess={() => { }} />
|
|
|
+ </View>
|
|
|
+ }
|
|
|
|
|
|
|
|
|
{/*
|