|
@@ -18,6 +18,7 @@ import { getPlans } from "@/services/trackTimeDuration";
|
|
|
|
|
|
|
|
|
|
|
|
|
export default function Component() {
|
|
export default function Component() {
|
|
|
|
|
+ const isFastFirst = true;
|
|
|
const { t } = useTranslation()
|
|
const { t } = useTranslation()
|
|
|
const dispatch = useDispatch();
|
|
const dispatch = useDispatch();
|
|
|
const [selIndex, setSelIndex] = useState(-1)
|
|
const [selIndex, setSelIndex] = useState(-1)
|
|
@@ -30,10 +31,9 @@ export default function Component() {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
useReady(() => {
|
|
useReady(() => {
|
|
|
- console.log(selScenario)
|
|
|
|
|
if (selScenario) {
|
|
if (selScenario) {
|
|
|
if (selScenario.name == 'FAST_SLEEP') {
|
|
if (selScenario.name == 'FAST_SLEEP') {
|
|
|
- dispatch(setStep('sleep'))
|
|
|
|
|
|
|
+ dispatch(setStep(isFastFirst?'fast':'sleep'))
|
|
|
setSelIndex(2)
|
|
setSelIndex(2)
|
|
|
}
|
|
}
|
|
|
else if (selScenario.name == 'SLEEP') {
|
|
else if (selScenario.name == 'SLEEP') {
|
|
@@ -45,16 +45,19 @@ export default function Component() {
|
|
|
setSelIndex(0)
|
|
setSelIndex(0)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ Taro.getStorage({key:'scenarios'}).then(res=>{
|
|
|
|
|
+ if (res){
|
|
|
|
|
+ setScenarios(JSON.parse(res as any))
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
getPlans().then(res => {
|
|
getPlans().then(res => {
|
|
|
const data = res as { scenarios: any[] };
|
|
const data = res as { scenarios: any[] };
|
|
|
|
|
+ Taro.setStorage({key:'scenarios', data:JSON.stringify(data.scenarios as any)})
|
|
|
setScenarios(data.scenarios)
|
|
setScenarios(data.scenarios)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
function next() {
|
|
function next() {
|
|
|
- console.log(scenarios);
|
|
|
|
|
- // var scenario = scenarios[selIndex];
|
|
|
|
|
- // setScenario(scenario)
|
|
|
|
|
Taro.navigateTo({
|
|
Taro.navigateTo({
|
|
|
url: '/pages/SetSchedule'
|
|
url: '/pages/SetSchedule'
|
|
|
})
|
|
})
|
|
@@ -96,6 +99,37 @@ export default function Component() {
|
|
|
return (end - start) / 1440 * 2 * Math.PI
|
|
return (end - start) / 1440 * 2 * Math.PI
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // function getScheduleTarget(isFast: boolean) {
|
|
|
|
|
+ // for (var i = 0; i < scenarios.length; i++) {
|
|
|
|
|
+ // if (isFast && scenarios[i].name == 'FAST') {
|
|
|
|
|
+ // if (global.schedule_fast){
|
|
|
|
|
+ // return global.schedule_fast
|
|
|
|
|
+ // }
|
|
|
|
|
+ // return scenarios[i].schedule.fast
|
|
|
|
|
+ // }
|
|
|
|
|
+ // else if (!isFast && scenarios[i].name == 'SLEEP') {
|
|
|
|
|
+ // if (global.schedule_sleep){
|
|
|
|
|
+ // return global.schedule_sleep
|
|
|
|
|
+ // }
|
|
|
|
|
+ // return scenarios[i].schedule.sleep
|
|
|
|
|
+ // }
|
|
|
|
|
+ // else {
|
|
|
|
|
+ // if (isFast){
|
|
|
|
|
+ // if (global.schedule_fast){
|
|
|
|
|
+ // return global.schedule_fast
|
|
|
|
|
+ // }
|
|
|
|
|
+ // return scenarios[i].schedule.fast
|
|
|
|
|
+ // }
|
|
|
|
|
+ // if (global.schedule_sleep){
|
|
|
|
|
+ // return global.schedule_sleep
|
|
|
|
|
+ // }
|
|
|
|
|
+ // return scenarios[i].schedule.sleep
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
function getScheduleTarget(isFast: boolean) {
|
|
function getScheduleTarget(isFast: boolean) {
|
|
|
for (var i = 0; i < scenarios.length; i++) {
|
|
for (var i = 0; i < scenarios.length; i++) {
|
|
|
if (isFast && scenarios[i].name == 'FAST') {
|
|
if (isFast && scenarios[i].name == 'FAST') {
|
|
@@ -110,12 +144,6 @@ export default function Component() {
|
|
|
}
|
|
}
|
|
|
return scenarios[i].schedule.sleep
|
|
return scenarios[i].schedule.sleep
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- return {
|
|
|
|
|
- start_time: '00:00',
|
|
|
|
|
- end_time: '00:00'
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -140,6 +168,7 @@ export default function Component() {
|
|
|
const bgRing: BgRing = {
|
|
const bgRing: BgRing = {
|
|
|
color: '#262626'
|
|
color: '#262626'
|
|
|
}
|
|
}
|
|
|
|
|
+ debugger
|
|
|
|
|
|
|
|
const targetRing: TargetRing = {
|
|
const targetRing: TargetRing = {
|
|
|
color: '#AAFF00',
|
|
color: '#AAFF00',
|
|
@@ -199,7 +228,7 @@ export default function Component() {
|
|
|
dispatch(setStep('sleep'))
|
|
dispatch(setStep('sleep'))
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
- dispatch(setStep('sleep'))
|
|
|
|
|
|
|
+ dispatch(setStep(isFastFirst?'fast':'sleep'))
|
|
|
}
|
|
}
|
|
|
// dispatch(setScenarioName(scenarios[index].scenario) as any)
|
|
// dispatch(setScenarioName(scenarios[index].scenario) as any)
|
|
|
}
|
|
}
|
|
@@ -209,7 +238,7 @@ export default function Component() {
|
|
|
<Texts text={t('page.choose_scenario.sub_title')} type={TextType.secondary}></Texts>
|
|
<Texts text={t('page.choose_scenario.sub_title')} type={TextType.secondary}></Texts>
|
|
|
<View style={{ height: 20 }} />
|
|
<View style={{ height: 20 }} />
|
|
|
{
|
|
{
|
|
|
- <View style={{ position: 'relative', zIndex: 1 }}>
|
|
|
|
|
|
|
+ scenarios.length>0&&<View style={{ position: 'relative', zIndex: 1 }}>
|
|
|
<SingleSelect items={items()} itemSelect={handleItemSelect} selIndex={selIndex} />
|
|
<SingleSelect items={items()} itemSelect={handleItemSelect} selIndex={selIndex} />
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|