leon hace 1 año
padre
commit
d12158068a

+ 17 - 12
src/features/trackTimeDuration/components/CheckAccess.scss

@@ -9,40 +9,43 @@
     display: flex;
     align-items: center;
     justify-content: center;
-    background-color: #000D1FF2;
+    background-color: #000000e0;
     z-index: 100000;
 }
 
 .fast_alert_content {
     display: flex;
     flex-direction: column;
-    width: 536px;
-    background-color: #313F52FF;
-    border-radius: 32px;
-    padding-left: 40px;
-    padding-right: 40px;
-    padding-top: 64px;
-    padding-bottom: 40px;
+    width: 658px;
+    background-color: #1C1C1C;
+    border-radius: 40px;
+    padding: 40px;
     box-sizing: border-box;
     align-items: center;
+    
 }
 
 .fast_alert_title {
     color: #fff;
-    font-size: 32px;
+    font-size: 56px;
+    line-height: 60px;
     font-weight: bold;
-    margin-bottom: 30px;
+    margin-bottom: 20px;
+    text-align: center;
 }
 
 .fast_alert_detail {
     color: #fff;
+    opacity: 0.6;
     font-size: 28px;
+    line-height: 48px;
     font-weight: bold;
-    margin-bottom: 36px;
+    margin-bottom: 20px;
+    text-align: center;
 }
 
 .fast_alert_confirm {
-    width: 440px;
+    width: 578px;
     height: 84px;
     border-radius: 42px;
     color: #000D1FFF;
@@ -52,6 +55,7 @@
     display: flex;
     align-items: center;
     justify-content: center;
+    text-align: center;
 }
 
 .fast_alert_cancel {
@@ -64,4 +68,5 @@
     display: flex;
     align-items: center;
     justify-content: center;
+    text-align: center;
 }

+ 265 - 49
src/features/trackTimeDuration/components/CheckAccess.tsx

@@ -3,8 +3,26 @@ import { View, Text } from "@tarojs/components";
 import './CheckAccess.scss'
 
 import { useContext, useEffect, useState } from "react";
+import { TimeFormatter } from "@/utils/time_format";
+import { useDispatch, useSelector } from "react-redux";
+import { getPlans, setPlan } from "@/services/trackTimeDuration";
+import { chooseMode, initTarget, updateStep } from "@/store/set_target";
+import { jumpPage } from "../hooks/Common";
+import { useDidShow } from "@tarojs/taro";
+import Taro from "@tarojs/taro";
 
-export default function CheckAccess() {
+let confirmAction: any = null;
+let cancelAction: any = null;
+let timer;
+let access;
+let useNavigation, AppState;
+if (process.env.TARO_ENV == 'rn') {
+    AppState = require("react-native").AppState
+    useNavigation = require("@react-navigation/native").useNavigation
+}
+
+
+export default function CheckAccess(props: { record: any, count: number }) {
     const [showFastAlert, setShowFastAlert] = useState(false)
     const [alertTitle, setAlertTitle] = useState('')
     const [alertContent, setAlertContent] = useState('')
@@ -12,11 +30,81 @@ export default function CheckAccess() {
     const [cancelText, setCancelText] = useState('')
     const [confirmText, setConfirmText] = useState('')
 
+    //判断选择混合场景,如果成功了,就弹窗
+    const [checkChooseMixed, setCheckChooseMixed] = useState(false)
+    const [chooseMixedSuccess, setChooseMixedSuccess] = useState(false)
+
+    const ring = useSelector((state: any) => state.ring);
+    const dispatch = useDispatch();
+
+    let navigation;
+    if (useNavigation) {
+        navigation = useNavigation()
+    }
+
+    // const [confirmAction, setConfirmAction] = useState<any>(null)
+    // const [access, setAccess] = useState<any>(null)
 
     useEffect(() => {
+        var obj = props.record
+        if (obj.access) {
+            const currentStatus = obj.access.current.qualification.status
+            const preStatus = obj.access.previous.qualification.status
+            if (preStatus == 'PROVISIONAL_QUALIFIED' && currentStatus == 'NOT_QUALIFIED' && obj.current_record.status == 'WAIT_FOR_START') {
+                lose()
+            }
+            else if (currentStatus == 'PROVISIONAL_QUALIFIED' && new Date().getTime() > obj.access.current.qualification.expire) {
+                if (global.indexPageRefresh) {
+                    global.indexPageRefresh()
+                }
+
+            }
+        }
+    }, [props.count])
+
+    // const handleAppStateChange = (nextAppState) => {
+    //     console.log(nextAppState)
+    //     if (nextAppState != 'active') {
+    //         return
+    //     }
+    // };
+
+    function viewWillAppear() {
+        if (checkChooseMixed && chooseMixedSuccess) {
+            upgradeSuccess()
+        }
+        setCheckChooseMixed(false)
+        setChooseMixedSuccess(false)
+    }
+
+    useDidShow(() => {
+        console.log('user did show');
+        viewWillAppear()
+    })
+
+    useEffect(() => {
+        if (process.env.TARO_ENV == 'rn') {
+            // AppState.addEventListener('change', handleAppStateChange);
+            navigation.addListener('focus', () => {
+                viewWillAppear()
+                debugger
+            });
+
+            // 当页面即将消失时执行
+            navigation.addListener('blur', () => {
+                debugger
+            });
+
+        }
+
+        global.chooseMixed = () => {
+            setChooseMixedSuccess(true)
+        }
         global.checkAccess = (acccessData: any) => {
             const currentStatus = acccessData.current.qualification.status
             const preStatus = acccessData.previous.qualification.status
+            access = acccessData
+            // setAccess(acccessData)
 
             if (preStatus == 'NOT_QUALIFIED' && currentStatus == 'NOT_QUALIFIED') {
                 const { streak_fast_current } = acccessData.current.qualification.condition
@@ -27,96 +115,224 @@ export default function CheckAccess() {
                     Two more days until unlocking 'Fasting with sleep.'`)
                 setShowCancel(false)
                 setConfirmText('Got it!')
-
-                // showAlert({
-                //     title: 'Well Done',
-                //     content: `You're on a ${streak_fast_current}-day streak.
-                //         Two more days until unlocking 'Fasting with sleep.'`,
-                //     showCancel: false,
-                //     confirmText: 'Got it!',
-                // })
-                return;
             }
             else if (preStatus == 'NOT_QUALIFIED' && currentStatus == 'PROVISIONAL_QUALIFIED') {
+                const { streak_fast_current } = acccessData.current.qualification.condition
 
+                Taro.setStorage({ key: 'showLoseGain', data: false })
+                const { expire } = acccessData.current.qualification
                 setShowFastAlert(true)
                 setAlertTitle('Premium Access Unlocked')
-                setAlertContent(`You've unlocked 'Fasting with Sleep' since you're on a x-day streak.`)
+                setAlertContent(`You've unlocked 'Fasting with Sleep' since you're on a ${streak_fast_current}-day streak.`)
                 setShowCancel(true)
                 setCancelText('Stay with Fasting Only')
-                setConfirmText('Upgrade to Fasting with Sleep\n(Offer Expiring in 21:59:59)')
-
-                // showAlert({
-                //     title: 'Premium Access Unlocked',
-                //     content: `You've unlocked 'Fasting with Sleep' since you're on a x-day streak.
-                //     Are you ready to up the game?`,
-                //     showCancel: true,
-                //     cancelText: 'Stay',
-                //     confirmText: 'Upgrade',
-                //     confirm: upgrade
-                // })
-                return;
+                setConfirmText(`Upgrade to Fasting with Sleep\n(Offer Expiring in ${TimeFormatter.countdown(expire)})`)
+                confirmAction = upgrade
+                timer = setInterval(() => {
+                    if (new Date().getTime() > expire) {
+                        cancel()
+                        return
+                    }
+                    setConfirmText(`Upgrade to Fasting with Sleep\n(Offer Expiring in ${TimeFormatter.countdown(expire)})`)
+                }, 1000)
             }
             else if (preStatus == 'PROVISIONAL_QUALIFIED' && currentStatus == 'PROVISIONAL_QUALIFIED') {
                 const { streak_fast_current, streak_sleep_current } = acccessData.current.qualification.condition
 
+                if (ring.current_record.scenario == 'FAST') {
+                    const { expire } = acccessData.current.qualification
+                    setShowFastAlert(true)
+                    setAlertTitle('Premium Access Unlocked')
+                    setAlertContent(`You've unlocked 'Fasting with Sleep' since you're on a ${streak_fast_current}-day streak.
+                    \nAre you ready to up the game?`)
+                    setShowCancel(true)
+                    setConfirmText(`Upgrade to Fasting with Sleep
+                    (Offer Expiring in ${TimeFormatter.countdown(expire)})`)
+                    setCancelText('Stay with Fasting Only')
+                    confirmAction = upgrade
+                    timer = setInterval(() => {
+                        if (new Date().getTime() > expire) {
+                            cancel()
+                            return
+                        }
+                        setConfirmText(`Upgrade to Fasting with Sleep\n(Offer Expiring in ${TimeFormatter.countdown(expire)})`)
+                    }, 1000)
+                    return;
+                }
+
                 setShowFastAlert(true)
                 setAlertTitle('Well Done')
                 setAlertContent(`You're on a ${streak_fast_current}-day fasting streak${streak_sleep_current > 0 ? ' and a ' + streak_sleep_current + '-day sleep streak' : ''}.\nKeep 'em going to stay in the game.'`)
                 setShowCancel(false)
                 setConfirmText('Got it!')
-                // showAlert({
-                //     title: 'Well Done',
-                //     content: `You're on a ${streak_fast_current}-day fasting streak${streak_sleep_current > 0 ? ' and a ' + streak_sleep_current + '-day sleep streak' : ''}.
-                //     Keep 'em going to stay in the game.'`,
-                //     showCancel: false,
-                //     confirmText: 'Got it!',
-                // })
-                return;
             }
             else if (preStatus == 'PROVISIONAL_QUALIFIED' && currentStatus == 'NOT_QUALIFIED') {
-                setShowFastAlert(true)
-                setAlertTitle('Premium Access Lost')
-                setAlertContent(`You've lost premium access to the 'Fasting with Sleep' feature
-                since you lost your fasting streak. To regain access, become a PRO or achieve a new 3-day fasting streak.`)
-                setShowCancel(true)
-                setCancelText('Achieve')
-                setConfirmText('Become')
-                // showAlert({
-                //     title: 'Premium Access Lost',
-                //     content: `You've lost premium access to the 'Fasting with Sleep' feature
-                //     since you lost your fasting streak. To regain access, become a PRO or achieve a new 3-day fasting streak.`,
-                //     showCancel: true,
-                //     cancelText:'Achieve',
-                //     confirmText: 'Become',
-                // })
-                return;
+                lose();
+                // setShowFastAlert(true)
+                // setAlertTitle('Premium Access Lost')
+                // setAlertContent(`You've lost premium access to the 'Fasting with Sleep' feature
+                // since you lost your fasting streak. To regain access, become a PRO or achieve a new 3-day fasting streak.`)
+                // setShowCancel(true)
+                // setCancelText('Achieve New Fasting Streak')
+                // setConfirmText('Become a PRO member')
             }
         }
     }, [])
 
+    function upgradeSuccess() {
+        const { expire } = access.current.qualification
+        setShowFastAlert(true)
+        setAlertTitle('Congrats on Your PRO Status!')
+        setAlertContent(`To preserve this status, continue your fasting streak in ${TimeFormatter.countdown(expire)} and begin your sleep streak. Remember to keep both of them going.`)
+        setShowCancel(false)
+        setConfirmText(`I got this!`)
+        timer = setInterval(() => {
+
+            if (new Date().getTime() > expire) {
+                debugger
+                cancel()
+                return
+            }
+            setAlertContent(`To preserve this status, continue your fasting streak in ${TimeFormatter.countdown(expire)} and begin your sleep streak. Remember to keep both of them going.`)
+        }, 1000)
+    }
+
+    async function lose() {
+        var showDayRing = await getStorage('showLoseGain') || false;
+        if (showDayRing) {
+            return;
+        }
+        setShowFastAlert(true)
+        setAlertTitle('Premium Access Lost')
+        setAlertContent(`You've lost premium access to the 'Fasting with Sleep' feature
+                since you lost your fasting streak. To regain access, become a PRO or achieve a new 3-day fasting streak.`)
+        setShowCancel(true)
+        setCancelText('Achieve New Fasting Streak')
+        setConfirmText('Become a PRO member')
+        Taro.setStorage({ key: 'showLoseGain', data: true })
+
+        changeFastScenaria()
+    }
+
+    function changeFastScenaria() {
+        const { start_time, end_time } = ring.schedule.fast
+        var params: any = {
+            scenario: 'FAST',
+            schedule: {
+                fast: {
+                    start_time: start_time,
+                    end_time: end_time,
+                },
+            }
+        }
+        setPlan(params).then(res => {
+            if (global.indexPageRefresh) {
+                global.indexPageRefresh()
+            }
+        })
+    }
+
+    async function getStorage(key: string) {
+        try {
+            const res = await Taro.getStorage({ key });
+            return res.data;
+        } catch {
+            return '';
+        }
+    }
+
     function upgrade() {
+        const { prev_input, start_time, end_time } = ring.schedule.sleep
+        if (prev_input) {
+            setShowFastAlert(true)
+            setAlertTitle('Update Sleep Schedule')
+            setAlertContent(`Your sleep schedule was ${start_time} - ${end_time}.
+            Do you want to update to a new schedule?`)
+            setShowCancel(true)
+            setCancelText('Keep old schedule')
+            setConfirmText('Update new shedule')
+            setTimeout(() => {
+                confirmAction = goSetting
+            }, 100)
+        }
+        else {
+            goSetting()
+        }
+        // const { expire } = access.current.qualification
+        // setShowFastAlert(true)
+        // setAlertTitle('Congrats on Your PRO Status!')
+        // setAlertContent(`To preserve this status, continue your fasting streak in ${TimeFormatter.countdown(expire)} and begin your sleep streak. Remember to keep both of them going.`)
+        // setShowCancel(false)
+        // setConfirmText(`I got this!`)
+        // timer = setInterval(() => {
+        //     debugger
+        //     if (new Date().getTime() > expire) {
+        //         cancel()
+        //         return
+        //     }
+        //     setAlertContent(`To preserve this status, continue your fasting streak in ${TimeFormatter.countdown(expire)} and begin your sleep streak. Remember to keep both of them going.`)
+        // }, 1000)
+    }
+
+    function goSetting() {
+        getPlans().then(res => {
+            const data = res as { scenarios: any[] };
+            console.log(data)
+            var targets: any = {}
+            data.scenarios.forEach((item) => {
+                if (item.name == 'FAST') {
+
+                    if (item.schedule.fast.duration.prev_input) {
+                        item.schedule.fast.duration.last_value = item.schedule.fast.duration.init_value
+                    }
+                    targets.fast = item
+                }
+                else if (item.name == 'SLEEP') {
+                    targets.sleep = item
+                }
+            })
+            dispatch(initTarget(targets))
+            dispatch(updateStep({ step: 2 }))
+            dispatch(chooseMode({ isMixed: true }))
+            setCheckChooseMixed(true)
+            jumpPage(`/pages/clock/Suggest`, 'Suggest', navigation, {})
+        })
 
     }
 
     function confirm() {
+        debugger
         setShowFastAlert(false)
+        if (timer) {
+            clearInterval(timer)
+            timer = null
+        }
+        if (confirmAction) confirmAction()
+        confirmAction = null;
     }
 
     function cancel() {
+        debugger
         setShowFastAlert(false)
+        confirmAction = null;
+        if (timer) {
+            clearInterval(timer)
+            timer = null
+        }
+        if (cancelAction) cancelAction()
+        cancelAction = null;
     }
 
     function alertPop() {
         return <View className="fast_alert_container">
-            <View className="fast_alert_content">
+            <View className="fast_alert_content" catchMove>
                 <View className="fast_alert_title">{alertTitle}</View>
                 <View className="fast_alert_detail">{alertContent}</View>
                 <View className="fast_alert_confirm" onClick={confirm}>{confirmText}</View>
                 {
                     showCancel && <View className="fast_alert_cancel" onClick={cancel}>{cancelText}</View>
                 }
-                
+
             </View>
         </View>
     }

+ 125 - 109
src/features/trackTimeDuration/components/IndexConsole.tsx

@@ -35,8 +35,7 @@ let max = 0
 let defaultTimestamp = 0
 let isTimeout = false
 let stageIndex = 0
-export default function IndexConsole(props: { record: any }) {
-    
+export default function IndexConsole(props: { record: any, count: number }) {
     const user = useSelector((state: any) => state.user);
     const { status } = props.record.current_record;
     const currentRecord = props.record.current_record;
@@ -62,12 +61,12 @@ export default function IndexConsole(props: { record: any }) {
     }
 
     useDidShow(() => {
-        if (process.env.TARO_ENV=='weapp'){
+        if (process.env.TARO_ENV == 'weapp') {
             wxPubFollow({ force_refresh: true }).then(res => {
                 dispatch(setWXFollow((res as any).wx_pub_followed));
             })
         }
-        
+
     })
 
     useEffect(() => {
@@ -613,13 +612,20 @@ export default function IndexConsole(props: { record: any }) {
                     global.refrehWeekly()
                     global.refreshStreaks()
                     refreshDayNight()
+                    var obj = global.checkAccess
+                    if (obj) {
+                        console.log('applw')
+                    }
+                    else {
+                        console.log('apple')
+                    }
                     global.checkAccess((res as any).access)
                     // checkAccessProvisional((res as any).access,showFastAlert)
                 }).catch((e) => {
                     setBtnDisable(false)
                     var picker = limitPickerRef.current;
                     (picker as any).resetPickerData()
-                    
+
 
                 })
                 break
@@ -660,53 +666,139 @@ export default function IndexConsole(props: { record: any }) {
         </Modal>
     }
 
+    function single() {
+        if (props.record.scenario.name == 'FAST') {
+            return <View style={{ marginTop: rpxToPx(0) }}>
+                {
+                    status == 'WAIT_FOR_START' &&
+                    <View onClick={tapStartFast} className='console_btn'>
+                        <Text style={{ fontWeight: 'bold' }}>{t('feature.track_time_duration.common.start_fast')}</Text>
+                    </View>
+                }
+                {/* {
+                    status != 'WAIT_FOR_START' && <View className='btn_line' />
+                } */}
+                {
+                    status == 'ONGOING' && <View onClick={tapEndFast} className={status == 'ONGOING' ? 'console_btn' : 'console_btn btn_disable'}>
+                        <Text style={{ fontWeight: 'bold' }}>{t('feature.track_time_duration.common.end_fast')}</Text>
+                    </View>
+                }
+                {
+                    showTimePicker && modalContent()
+                }
+            </View>
+        }
+        else if (props.record.scenario.name == 'SLEEP') {
+            return <View style={{ marginTop: rpxToPx(0) }}>
+                {
+                    status == 'WAIT_FOR_START' &&
+                    <View onClick={tapStartSleep} className='console_btn btn_sleep'>
+                        <Text style={{ fontWeight: 'bold' }}>{t('feature.track_time_duration.common.start_sleep')}</Text>
+                    </View>
+                }
+                {/* {
+                    status != 'WAIT_FOR_START' && <View className='btn_line' />
+                } */}
+                {
+                    status == 'ONGOING' && <View onClick={tapEndSleep} className={status == 'ONGOING' ? 'console_btn btn_sleep' : 'console_btn btn_sleep btn_disable'}>
+                        <Text style={{ fontWeight: 'bold' }}>{t('feature.track_time_duration.common.end_sleep')}</Text>
+                    </View>
+                }
+
+                {
+                    showTimePicker && modalContent()
+                }
+
+            </View>
+        }
+    }
 
-    if (props.record.scenario.name == 'FAST') {
+    function mixed() {
         return <View style={{ marginTop: rpxToPx(0) }}>
+
+            {
+                status == 'WAIT_FOR_START' ?
+                    <View onClick={tapStartFast} className='console_btn'>
+                        <Text style={{ fontWeight: 'bold', fontSize: rpxToPx(32) }}>{t('feature.track_time_duration.common.start_fast')}</Text>
+                    </View> :
+                    <View onClick={() => { tapStage(0) }} className='stage_btn'>
+                        <Text style={{ flex: 1, color: '#fff' }}>{t('feature.track_time_duration.stage.a')}</Text>
+                        {
+                            status == 'ONGOING1' ?
+                                <Text style={{ color: '#fff' }}>{TimeFormatter.countdown(currentRecord.fast.real_start_time)}</Text> :
+                                <Text style={{ color: '#fff' }}>{TimeFormatter.calculateTimeDifference(currentRecord.fast.real_start_time, currentRecord.sleep.real_start_time)}</Text>
+                        }
+
+                    </View>
+            }
+            <View className='btn_line' />
             {
-                status == 'WAIT_FOR_START' &&
-                <View onClick={tapStartFast} className='console_btn'>
-                    <Text style={{ fontWeight: 'bold' }}>{t('feature.track_time_duration.common.start_fast')}</Text>
+                (status == 'WAIT_FOR_START' || status == 'ONGOING1') &&
+                <View onClick={tapStartSleep} className={status == 'ONGOING1' ? 'console_btn btn_sleep' : 'console_btn btn_sleep btn_disable'}>
+                    {
+                        status != 'ONGOING1' && <Image className='lock' src={require('@assets/images/lock.png')} />
+                    }
+                    <Text style={{ fontWeight: 'bold', fontSize: rpxToPx(32) }}>{t('feature.track_time_duration.common.start_sleep')}</Text>
                 </View>
             }
-            {/* {
-                status != 'WAIT_FOR_START' && <View className='btn_line' />
-            } */}
             {
-                status == 'ONGOING' && <View onClick={tapEndFast} className={status == 'ONGOING' ? 'console_btn' : 'console_btn btn_disable'}>
-                    <Text style={{ fontWeight: 'bold' }}>{t('feature.track_time_duration.common.end_fast')}</Text>
+                (status != 'WAIT_FOR_START' && status != 'ONGOING1') &&
+                <View onClick={() => { tapStage(1) }} className='stage_btn'>
+                    <Text style={{ flex: 1, color: '#fff' }}>{t('feature.track_time_duration.stage.b')}</Text>
+                    {
+                        status == 'ONGOING2' ? <Text style={{ color: '#fff' }}>{TimeFormatter.countdown(currentRecord.sleep.real_start_time)}</Text> :
+                            <Text style={{ color: '#fff' }}>{TimeFormatter.calculateTimeDifference(currentRecord.sleep.real_start_time, currentRecord.sleep.real_end_time)}</Text>
+                    }
+
+
                 </View>
             }
+            {(expand || (status != 'WAIT_FOR_START' && status != 'ONGOING1')) && <View className='btn_line' />}
             {
-                showTimePicker && modalContent()
+                (expand || (status != 'WAIT_FOR_START' && status != 'ONGOING1')) && (status == 'WAIT_FOR_START' || status == 'ONGOING1' || status == 'ONGOING2') &&
+                <View onClick={tapEndSleep} className={status == 'ONGOING2' ? 'console_btn btn_sleep' : 'console_btn btn_sleep btn_disable'}>
+                    {
+                        status != 'ONGOING2' && <Image className='lock' src={require('@assets/images/lock.png')} />
+                    }
+                    <Text style={{ fontWeight: 'bold', fontSize: rpxToPx(32) }}>{t('feature.track_time_duration.common.end_sleep')}</Text>
+                </View>
             }
-        </View>
-    }
-    else if (props.record.scenario.name == 'SLEEP') {
-        return <View style={{ marginTop: rpxToPx(0) }}>
             {
-                status == 'WAIT_FOR_START' &&
-                <View onClick={tapStartSleep} className='console_btn btn_sleep'>
-                    <Text style={{ fontWeight: 'bold' }}>{t('feature.track_time_duration.common.start_sleep')}</Text>
+                status == 'ONGOING3' &&
+                <View onClick={() => { tapStage(2) }} className='stage_btn'>
+                    <Text style={{ flex: 1, color: '#fff' }}>{t('feature.track_time_duration.stage.c')}</Text>
+                    <Text style={{ color: '#fff' }}>{TimeFormatter.countdown(currentRecord.sleep.real_end_time)}</Text>
                 </View>
             }
-            {/* {
-                status != 'WAIT_FOR_START' && <View className='btn_line' />
-            } */}
+            {(expand || status == 'ONGOING3' || status == 'ONGOING') && <View className='btn_line' />}
             {
-                status == 'ONGOING' && <View onClick={tapEndSleep} className={status == 'ONGOING' ? 'console_btn btn_sleep' : 'console_btn btn_sleep btn_disable'}>
-                    <Text style={{ fontWeight: 'bold' }}>{t('feature.track_time_duration.common.end_sleep')}</Text>
+                (expand || status == 'ONGOING3' || status == 'ONGOING') &&
+                <View onClick={tapEndFast} className={status == 'ONGOING3' ? 'console_btn' : 'console_btn btn_disable'}>
+                    {
+                        status == 'WAIT_FOR_START' && <Image className='lock' src={require('@assets/images/lock.png')} />
+                    }
+                    <Text style={{ fontWeight: 'bold', fontSize: rpxToPx(32) }}>{t('feature.track_time_duration.common.end_fast')}</Text>
+                </View>
+            }
+            {
+                (status == 'WAIT_FOR_START' || status == 'ONGOING1' || status == 'ONGOING2') &&
+                <View>
+                    {
+                        !expand && <Text className='expand' onClick={() => { setExpand(true) }}>{expandBtnText()}</Text>
+                    }
                 </View>
             }
-
             {
                 showTimePicker && modalContent()
             }
+            {
+                showStageModal && stageContent()
+            }
+
 
         </View>
     }
 
-
     function stageContent() {
         return <Modal
             testInfo={null}
@@ -732,87 +824,11 @@ export default function IndexConsole(props: { record: any }) {
         setShowStageModal(true)
     }
 
-
-    return <View style={{ marginTop: rpxToPx(0) }}>
-        {
-            status == 'WAIT_FOR_START' ?
-                <View onClick={tapStartFast} className='console_btn'>
-                    <Text style={{ fontWeight: 'bold', fontSize: rpxToPx(32) }}>{t('feature.track_time_duration.common.start_fast')}</Text>
-                </View> :
-                <View onClick={() => { tapStage(0) }} className='stage_btn'>
-                    <Text style={{ flex: 1, color: '#fff' }}>{t('feature.track_time_duration.stage.a')}</Text>
-                    {
-                        status == 'ONGOING1' ?
-                            <Text style={{ color: '#fff' }}>{TimeFormatter.countdown(currentRecord.fast.real_start_time)}</Text> :
-                            <Text style={{ color: '#fff' }}>{TimeFormatter.calculateTimeDifference(currentRecord.fast.real_start_time, currentRecord.sleep.real_start_time)}</Text>
-                    }
-
-                </View>
-        }
-        <View className='btn_line' />
-        {
-            (status == 'WAIT_FOR_START' || status == 'ONGOING1') &&
-            <View onClick={tapStartSleep} className={status == 'ONGOING1' ? 'console_btn btn_sleep' : 'console_btn btn_sleep btn_disable'}>
-                {
-                    status != 'ONGOING1' && <Image className='lock' src={require('@assets/images/lock.png')} />
-                }
-                <Text style={{ fontWeight: 'bold', fontSize: rpxToPx(32) }}>{t('feature.track_time_duration.common.start_sleep')}</Text>
-            </View>
-        }
-        {
-            (status != 'WAIT_FOR_START' && status != 'ONGOING1') &&
-            <View onClick={() => { tapStage(1) }} className='stage_btn'>
-                <Text style={{ flex: 1, color: '#fff' }}>{t('feature.track_time_duration.stage.b')}</Text>
-                {
-                    status == 'ONGOING2' ? <Text style={{ color: '#fff' }}>{TimeFormatter.countdown(currentRecord.sleep.real_start_time)}</Text> :
-                        <Text style={{ color: '#fff' }}>{TimeFormatter.calculateTimeDifference(currentRecord.sleep.real_start_time, currentRecord.sleep.real_end_time)}</Text>
-                }
-
-
-            </View>
-        }
-        {(expand || (status != 'WAIT_FOR_START' && status != 'ONGOING1')) && <View className='btn_line' />}
-        {
-            (expand || (status != 'WAIT_FOR_START' && status != 'ONGOING1')) && (status == 'WAIT_FOR_START' || status == 'ONGOING1' || status == 'ONGOING2') &&
-            <View onClick={tapEndSleep} className={status == 'ONGOING2' ? 'console_btn btn_sleep' : 'console_btn btn_sleep btn_disable'}>
-                {
-                    status != 'ONGOING2' && <Image className='lock' src={require('@assets/images/lock.png')} />
-                }
-                <Text style={{ fontWeight: 'bold', fontSize: rpxToPx(32) }}>{t('feature.track_time_duration.common.end_sleep')}</Text>
-            </View>
-        }
-        {
-            status == 'ONGOING3' &&
-            <View onClick={() => { tapStage(2) }} className='stage_btn'>
-                <Text style={{ flex: 1, color: '#fff' }}>{t('feature.track_time_duration.stage.c')}</Text>
-                <Text style={{ color: '#fff' }}>{TimeFormatter.countdown(currentRecord.sleep.real_end_time)}</Text>
-            </View>
-        }
-        {(expand || status == 'ONGOING3' || status == 'ONGOING') && <View className='btn_line' />}
-        {
-            (expand || status == 'ONGOING3' || status == 'ONGOING') &&
-            <View onClick={tapEndFast} className={status == 'ONGOING3' ? 'console_btn' : 'console_btn btn_disable'}>
-                {
-                    status == 'WAIT_FOR_START' && <Image className='lock' src={require('@assets/images/lock.png')} />
-                }
-                <Text style={{ fontWeight: 'bold', fontSize: rpxToPx(32) }}>{t('feature.track_time_duration.common.end_fast')}</Text>
-            </View>
-        }
-        {
-            (status == 'WAIT_FOR_START' || status == 'ONGOING1' || status == 'ONGOING2') &&
-            <View>
-                {
-                    !expand && <Text className='expand' onClick={() => { setExpand(true) }}>{expandBtnText()}</Text>
-                }
-            </View>
-        }
-        {
-            showTimePicker && modalContent()
-        }
+    return <View>
         {
-            showStageModal && stageContent()
+            props.record.scenario.name == 'FAST_SLEEP' ? mixed() : single()
         }
-        <CheckAccess />
-
+        <CheckAccess record={props.record} count={props.count} />
     </View>
+
 }

+ 15 - 3
src/pages/clock/ChooseScenario.tsx

@@ -6,13 +6,16 @@ import { ColorType } from "@/context/themes/color";
 import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
 import { getPlans } from "@/services/trackTimeDuration";
 import { chooseMode, initTarget, updateStep } from "@/store/set_target";
-import { useDispatch } from "react-redux";
+import { useDispatch, useSelector } from "react-redux";
 import { useDidShow } from "@tarojs/taro";
 import { TimeFormatter } from "@/utils/time_format";
 import Footer from "@/components/layout/Footer";
+import Taro from "@tarojs/taro";
+import { vibrate } from "@/utils/tools";
 
 export default function ChooseScenario() {
     const [selected, setSelected] = useState(0);
+    const ring = useSelector((state: any) => state.ring);
     const dispatch = useDispatch();
     var navigation: any = null
     if (process.env.TARO_ENV === 'rn') {
@@ -43,18 +46,27 @@ export default function ChooseScenario() {
 
     useDidShow(() => {
         dispatch(updateStep({ step: 0 }))
+        dispatch(chooseMode({ isMixed: selected == 1 }))
     })
 
 
 
     function goSuggestion() {
-
-
         dispatch(updateStep({ step: 0 }))
         jumpPage(`/pages/clock/Suggest`, 'Suggest', navigation, {})
     }
 
     function chooseType(index: number) {
+        var obj = global.homeData;
+        if (obj.access.current.qualification.status!= "PROVISIONAL_QUALIFIED"){
+            Taro.showToast({
+                title: '暂无权限',
+                icon: 'none'
+            
+            })
+            vibrate()
+            return;
+        }
         setSelected(index)
 
         dispatch(chooseMode({ isMixed: index == 1 }))

+ 4 - 2
src/pages/clock/Clock.tsx

@@ -207,6 +207,7 @@ export default function Page() {
     }, [])
 
     useEffect(() => {
+        console.log(user.isLogin)
         getCheckData()
         // global.pauseIndexTimer = !user.isLogin
 
@@ -563,10 +564,11 @@ export default function Page() {
         global.homeData = list[0]
         global.currentStatus = list[0].current_record.status;
         var array = list[1].scenarios
-        var schedule = null
+        var schedule:any = null
         array.map(item => {
             if (item.name == 'FAST_SLEEP') {
                 schedule = item.schedule;
+                schedule.sleep.prev_input = item.prev_input;
             }
         })
         if (user.isLogin) {
@@ -863,7 +865,7 @@ export default function Page() {
                         <IndexItem type="FAST_SLEEP" data={homeData} time={timestamp} showStage={false} />
                         {
 
-                            user.isLogin ? <IndexConsole record={homeData} /> : <StageSelector />
+                            user.isLogin ? <IndexConsole record={homeData} count={count}/> : <StageSelector />
                         }
 
                     </View>

+ 1 - 0
src/pages/clock/SetGoal.tsx

@@ -215,6 +215,7 @@ export default function SetGoal() {
     }
 
     function popAlert() {
+        global.chooseMixed()
         Taro.navigateBack({ delta: 6 }).then(res => {
 
         })