|
@@ -16,6 +16,7 @@ import { IconCheck } from "@/components/basic/Icons";
|
|
|
import Rings2, { BgRing, RingCommon, TargetRing } from '@/features/trackTimeDuration/components/Rings';
|
|
import Rings2, { BgRing, RingCommon, TargetRing } from '@/features/trackTimeDuration/components/Rings';
|
|
|
import { useTranslation } from "react-i18next";
|
|
import { useTranslation } from "react-i18next";
|
|
|
import showAlert from "@/components/basic/Alert";
|
|
import showAlert from "@/components/basic/Alert";
|
|
|
|
|
+import { userAccess } from "@/services/user";
|
|
|
|
|
|
|
|
|
|
|
|
|
let LinearGradient
|
|
let LinearGradient
|
|
@@ -53,8 +54,11 @@ export default function ChooseScenario() {
|
|
|
|
|
|
|
|
getClocks().then(res => {
|
|
getClocks().then(res => {
|
|
|
setSelected((res as any).current_record.scenario == 'FAST_SLEEP' ? 1 : 0)
|
|
setSelected((res as any).current_record.scenario == 'FAST_SLEEP' ? 1 : 0)
|
|
|
- setAccess((res as any).access)
|
|
|
|
|
|
|
+ // setAccess((res as any).access)
|
|
|
dispatch(chooseMode({ isMixed: (res as any).current_record.scenario == 'FAST_SLEEP' }))
|
|
dispatch(chooseMode({ isMixed: (res as any).current_record.scenario == 'FAST_SLEEP' }))
|
|
|
|
|
+ userAccess().then(res => {
|
|
|
|
|
+ setAccess(res)
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
getPlans().then(res => {
|
|
getPlans().then(res => {
|
|
|
const data = res as { scenarios: any[] };
|
|
const data = res as { scenarios: any[] };
|
|
@@ -74,6 +78,20 @@ export default function ChooseScenario() {
|
|
|
})
|
|
})
|
|
|
dispatch(initTarget(targets))
|
|
dispatch(initTarget(targets))
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
|
|
+ if (process.env.TARO_ENV == 'rn') {
|
|
|
|
|
+ // AppState.addEventListener('change', handleAppStateChange);
|
|
|
|
|
+ navigation.addListener('focus', () => {
|
|
|
|
|
+ userAccess().then(res => {
|
|
|
|
|
+ setAccess(res)
|
|
|
|
|
+ })
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // 当页面即将消失时执行
|
|
|
|
|
+ navigation.addListener('blur', () => {
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
}, [])
|
|
}, [])
|
|
|
|
|
|
|
|
useDidShow(() => {
|
|
useDidShow(() => {
|
|
@@ -92,14 +110,17 @@ export default function ChooseScenario() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function chooseType(index: number) {
|
|
function chooseType(index: number) {
|
|
|
- const { qualification } = access.current
|
|
|
|
|
- if (qualification.status != "PROVISIONAL_QUALIFIED" && index == 1) {
|
|
|
|
|
|
|
+ const { qualification } = access.fast_sleep.current
|
|
|
|
|
+ if (qualification.status != "PROVISIONAL_QUALIFIED" && qualification.status != 'QUALIFIED_UNTIL_EXPIRE' && index == 1) {
|
|
|
const { streak_fast_min_required } = qualification.condition;
|
|
const { streak_fast_min_required } = qualification.condition;
|
|
|
showAlert({
|
|
showAlert({
|
|
|
title: t('feature.choose_scenario.alert_title'),
|
|
title: t('feature.choose_scenario.alert_title'),
|
|
|
content: t('feature.choose_scenario.alert_content', { day: streak_fast_min_required, day_unit: streak_fast_min_required == 1 ? 'day' : 'days' }),
|
|
content: t('feature.choose_scenario.alert_content', { day: streak_fast_min_required, day_unit: streak_fast_min_required == 1 ? 'day' : 'days' }),
|
|
|
showCancel: false,
|
|
showCancel: false,
|
|
|
confirmText: t('feature.choose_scenario.alert_btn'),
|
|
confirmText: t('feature.choose_scenario.alert_btn'),
|
|
|
|
|
+ confirm: () => {
|
|
|
|
|
+ jumpPage('', 'ProductList', navigation)
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -175,42 +196,42 @@ export default function ChooseScenario() {
|
|
|
}}>
|
|
}}>
|
|
|
<Rings2 common={common} bgRing={bgRing} targetRing={selected == 0 ? targetRing : null} canvasId={new Date().getTime()} />
|
|
<Rings2 common={common} bgRing={bgRing} targetRing={selected == 0 ? targetRing : null} canvasId={new Date().getTime()} />
|
|
|
</View>
|
|
</View>
|
|
|
- <View style={{ display: 'flex', flexDirection: 'column',marginTop:rpxToPx(8) }}>
|
|
|
|
|
- <Text className="choose_item_title" style={{color:ColorType.fast}}>{t('feature.choose_scenario.fasting')}</Text>
|
|
|
|
|
|
|
+ <View style={{ display: 'flex', flexDirection: 'column', marginTop: rpxToPx(8) }}>
|
|
|
|
|
+ <Text className="choose_item_title" style={{ color: ColorType.fast }}>{t('feature.choose_scenario.fasting')}</Text>
|
|
|
<Text className="choose_item_desc">{t('feature.choose_scenario.fast_desc')}</Text>
|
|
<Text className="choose_item_desc">{t('feature.choose_scenario.fast_desc')}</Text>
|
|
|
</View>
|
|
</View>
|
|
|
- <View className="choose_corner_tag" style={{fontWeight:'bold'}}>{t('feature.choose_scenario.free')}</View>
|
|
|
|
|
|
|
+ <View className="choose_corner_tag" style={{ fontWeight: 'bold' }}>{t('feature.choose_scenario.free')}</View>
|
|
|
{
|
|
{
|
|
|
selected == 0 && <View className="choose_item_check_bg">
|
|
selected == 0 && <View className="choose_item_check_bg">
|
|
|
<IconCheck color={ColorType.fast} width={24} height={24} />
|
|
<IconCheck color={ColorType.fast} width={24} height={24} />
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
|
</View>
|
|
</View>
|
|
|
- <View className={selected == 1 ? 'item1 item_sel1' : 'item1'} style={{borderColor:selected==1?ColorType.sleep:'transparent'}} onClick={() => chooseType(1)}>
|
|
|
|
|
|
|
+ <View className={selected == 1 ? 'item1 item_sel1' : 'item1'} style={{ borderColor: selected == 1 ? ColorType.sleep : 'transparent' }} onClick={() => chooseType(1)}>
|
|
|
<View style={{
|
|
<View style={{
|
|
|
flexShrink: 0, display: 'flex', width: 74, height: 74, marginRight: rpxToPx(24),
|
|
flexShrink: 0, display: 'flex', width: 74, height: 74, marginRight: rpxToPx(24),
|
|
|
position: 'relative', zIndex: 1, alignItems: 'center', justifyContent: 'center',
|
|
position: 'relative', zIndex: 1, alignItems: 'center', justifyContent: 'center',
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
}}>
|
|
}}>
|
|
|
<Rings2 common={common} bgRing={bgRing} targetRing={selected == 1 ? targetRing : null} canvasId={new Date().getTime() + 2} />
|
|
<Rings2 common={common} bgRing={bgRing} targetRing={selected == 1 ? targetRing : null} canvasId={new Date().getTime() + 2} />
|
|
|
<View style={{ display: 'flex', position: 'absolute', left: 0, right: 0, top: 0, bottom: 0, alignItems: 'center', justifyContent: 'center' }}>
|
|
<View style={{ display: 'flex', position: 'absolute', left: 0, right: 0, top: 0, bottom: 0, alignItems: 'center', justifyContent: 'center' }}>
|
|
|
<Rings2 common={common2} bgRing={bgRing} targetRing={selected == 1 ? targetRing2 : null} canvasId={new Date().getTime() + 4} />
|
|
<Rings2 common={common2} bgRing={bgRing} targetRing={selected == 1 ? targetRing2 : null} canvasId={new Date().getTime() + 4} />
|
|
|
</View>
|
|
</View>
|
|
|
</View>
|
|
</View>
|
|
|
- <View style={{ display: 'flex', flexDirection: 'column', flex: 1,marginTop:rpxToPx(8) }}>
|
|
|
|
|
|
|
+ <View style={{ display: 'flex', flexDirection: 'column', flex: 1, marginTop: rpxToPx(8) }}>
|
|
|
<Text className="choose_item_title fast_sleep_item_text">{t('feature.choose_scenario.fast_sleep')}</Text>
|
|
<Text className="choose_item_title fast_sleep_item_text">{t('feature.choose_scenario.fast_sleep')}</Text>
|
|
|
<Text className="choose_item_desc">{t('feature.choose_scenario.fast_sleep_desc')}</Text>
|
|
<Text className="choose_item_desc">{t('feature.choose_scenario.fast_sleep_desc')}</Text>
|
|
|
|
|
|
|
|
|
|
|
|
|
</View>
|
|
</View>
|
|
|
{
|
|
{
|
|
|
- process.env.TARO_ENV == 'weapp' ? <View className="choose_corner_tag limit_offer" style={{fontWeight:'bold'}}>{t('feature.choose_scenario.limit_time_offer')}</View> :
|
|
|
|
|
|
|
+ process.env.TARO_ENV == 'weapp' ? <View className="choose_corner_tag limit_offer" style={{ fontWeight: 'bold' }}>{t('feature.choose_scenario.limit_time_offer')}</View> :
|
|
|
<LinearGradient className="choose_corner_tag"
|
|
<LinearGradient className="choose_corner_tag"
|
|
|
colors={[ColorType.fast, ColorType.sleep]}
|
|
colors={[ColorType.fast, ColorType.sleep]}
|
|
|
start={{ x: 0, y: 0 }}
|
|
start={{ x: 0, y: 0 }}
|
|
|
end={{ x: 1, y: 0 }}
|
|
end={{ x: 1, y: 0 }}
|
|
|
>
|
|
>
|
|
|
- <Text style={{ fontSize: rpxToPx(20),fontWeight:'bold',color:ColorType.black }}>{t('feature.choose_scenario.limit_time_offer')}</Text>
|
|
|
|
|
|
|
+ <Text style={{ fontSize: rpxToPx(20), fontWeight: 'bold', color: ColorType.black }}>{t('feature.choose_scenario.limit_time_offer')}</Text>
|
|
|
</LinearGradient>
|
|
</LinearGradient>
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
@@ -223,12 +244,12 @@ export default function ChooseScenario() {
|
|
|
<View style={{ flex: 1 }} />
|
|
<View style={{ flex: 1 }} />
|
|
|
<Footer>
|
|
<Footer>
|
|
|
<View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
|
<View style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
|
|
- <ChooseScenarioBtn
|
|
|
|
|
- onClick={goSuggestion}
|
|
|
|
|
- title={t('feature.choose_scenario.next')}
|
|
|
|
|
- background={background}
|
|
|
|
|
- />
|
|
|
|
|
-
|
|
|
|
|
|
|
+ <ChooseScenarioBtn
|
|
|
|
|
+ onClick={goSuggestion}
|
|
|
|
|
+ title={t('feature.choose_scenario.next')}
|
|
|
|
|
+ background={background}
|
|
|
|
|
+ />
|
|
|
|
|
+
|
|
|
{/* {
|
|
{/* {
|
|
|
process.env.TARO_ENV == 'rn' && selected == 1 && <View onClick={goSuggestion}>
|
|
process.env.TARO_ENV == 'rn' && selected == 1 && <View onClick={goSuggestion}>
|
|
|
<LinearGradient
|
|
<LinearGradient
|