Leon 1 jaar geleden
bovenliggende
commit
a7601db68b

+ 1 - 1
src/context/locales/en.js

@@ -182,7 +182,7 @@ export default {
             },
             lose_access:{
                 title:'Premium Access Lost',
-                desc:'You\'ve lost premium access to the \'Fasting with Sleep\' feature\nsince you lost your {{type}} streak. To regain access, become a PRO or achieve a new 3-day fasting streak.',
+                desc:'You\'ve lost premium access to the \'Fasting with Sleep\' feature\n{{type}}. To regain access, become a PRO or achieve a new 3-day fasting streak.',
                 confirm:'Become a PRO member',
                 cancel:'Achieve New Fasting Streak'
             },

+ 1 - 1
src/context/locales/zh.js

@@ -185,7 +185,7 @@ export default {
             },
             lose_access:{
                 title:'Premium Access Lost',
-                desc:'You\'ve lost premium access to the \'Fasting with Sleep\' feature\nsince you lost your {{type}} streak. To regain access, become a PRO or achieve a new 3-day fasting streak.',
+                desc:'You\'ve lost premium access to the \'Fasting with Sleep\' feature\n{{type}}. To regain access, become a PRO or achieve a new 3-day fasting streak.',
                 confirm:'Become a PRO member',
                 cancel:'Achieve New Fasting Streak'
             },

+ 43 - 13
src/features/trackTimeDuration/components/CheckAccess.tsx

@@ -62,11 +62,18 @@ export default function CheckAccess(props: { record: any, count: number }) {
             }
             else if (currentStatus == 'PROVISIONAL_QUALIFIED') {
                 Taro.setStorage({ key: 'showedDisqualifiedAlert', data: false })
-                if (new Date().getTime() > obj.access.current.qualification.expire && obj.current_record.status == 'WAIT_FOR_START') {
+                const { fast_expire, sleep_expire } = obj.access.current.qualification
+                if (fast_expire && new Date().getTime() > fast_expire && obj.current_record.status == 'WAIT_FOR_START') {
                     if (global.indexPageRefresh) {
                         global.indexPageRefresh()
                     }
                 }
+                if (sleep_expire && new Date().getTime() > sleep_expire && obj.current_record.status == 'WAIT_FOR_START') {
+                    if (global.indexPageRefresh) {
+                        global.indexPageRefresh()
+                    }
+                }
+
             }
 
             if (obj.current_record.status != 'WAIT_FOR_START') {
@@ -144,7 +151,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
                 const { streak_fast_current } = acccessData.current.qualification.condition
 
                 Taro.setStorage({ key: 'showedDisqualifiedAlert', data: false })
-                const { expire } = acccessData.current.qualification
+                var expire = acccessData.current.qualification.fast_expire
                 setShowFastAlert(true)
                 setKeepContent(false)
                 setAlertTitle(t('feature.check_access.gain_access.title'))
@@ -167,7 +174,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
             else if (preStatus == 'PROVISIONAL_QUALIFIED' && currentStatus == 'PROVISIONAL_QUALIFIED') {
                 const { streak_fast_current, streak_sleep_current } = acccessData.current.qualification.condition
                 if (global.ring.current_record.scenario == 'FAST') {
-                    const { expire } = acccessData.current.qualification
+                    var expire = acccessData.current.qualification.fast_expire
                     setShowFastAlert(true)
                     setKeepContent(false)
                     setAlertTitle(t('feature.check_access.gain_access.title'))
@@ -209,7 +216,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
     }, [])
 
     function upgradeSuccess() {
-        const { expire } = access.current.qualification
+        var expire = access.current.qualification.fast_expire
         setShowFastAlert(true)
         setKeepContent(false)
         setAlertTitle(t('feature.check_access.upgrade_pro.title'))
@@ -228,27 +235,50 @@ export default function CheckAccess(props: { record: any, count: number }) {
     }
 
     async function lose(condition) {
-        debugger
+        console.log(condition)
+        const { fast_expire, sleep_expire, streak_fast_current } = condition;
+        const now = new Date().getTime();
         var showedDisqualifiedAlert = await getStorage('showedDisqualifiedAlert') || false;
         if (showedDisqualifiedAlert) {
             return;
         }
 
         var type = ''
-        if (condition.streak_fast_current == 0 && condition.streak_sleep_current == 0) {
-            type = 'fasting and sleep'
+        //断食和睡眠同时失效
+        if (now > fast_expire && sleep_expire && now > sleep_expire) {
+            type = 'since you lost your fasting and sleep streak'
         }
-        else if (condition.streak_fast_current == 0) {
-            type = 'fasting'
+        //单断食失效
+        else if (now > fast_expire) {
+            type = 'since you lost your fasting streak'
         }
-        else if (condition.streak_sleep_current == 0) {
-            type = 'sleep'
+        //睡眠失效
+        else if (sleep_expire && now > sleep_expire) {
+            type = 'since you lost your sleep streak'
         }
+        //清除记录
+        else if (streak_fast_current == 0) {
+            type = 'since you lost your fasting streak'
+        }
+        //睡眠未结束
+        else if (!sleep_expire){
+            type = 'since you didn\'t begin your sleep streak'
+        }
+
+        // if (condition.streak_fast_current == 0 && condition.streak_sleep_current == 0) {
+        //     type = 'fasting and sleep'
+        // }
+        // else if (condition.streak_fast_current == 0) {
+        //     type = 'fasting'
+        // }
+        // else if (condition.streak_sleep_current == 0) {
+        //     type = 'sleep'
+        // }
         setShowFastAlert(true)
         setKeepContent(false)
         setAlertTitle(t('feature.check_access.lose_access.title'))
         setAlertContent(t('feature.check_access.lose_access.desc', { type: type }))
-        // setShowCancel(true)
+        setShowCancel(false)
         setConfirmText(t('feature.check_access.lose_access.cancel'))
         // setConfirmText('Become a PRO member')
         setSubConfirmText('')
@@ -418,7 +448,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
                     showCancel && <View className="fast_alert_cancel" onClick={cancel}>{cancelText}</View>
                 }
                 {
-                    user.test_user && <View style={{display:'flex',flexDirection:'column'}}>
+                    user.test_user && <View style={{ display: 'flex', flexDirection: 'column' }}>
                         <Text style={{ color: '#fff', fontSize: 12 }}>current status:{props.record.access.current.qualification.status}</Text>
                         <Text style={{ color: '#fff', fontSize: 12 }}>previous status:{props.record.access.previous.qualification.status}</Text>
                     </View>

+ 2 - 3
src/pages/clock/SetGoal.tsx

@@ -160,24 +160,23 @@ export default function SetGoal() {
 
     function confirm() {
         var params: any = {
+            method: parseInt(router.params.isSelf + '') == 1 ? 'USER_SET' : 'SUGGEST',
             schedule: {
                 fast: {
                     start_time: fastTarget.start_time,
                     end_time: fastTarget.end_time,
-                    method: parseInt(router.params.isSelf + '') == 1 ? 'USER_SET' : 'SUGGEST',
                     duration: {
                         input_value: target.fast.schedule.fast.duration.init_value,
                     }
                 },
             }
         }
-
         if (target.isMixed) {
             params.scenario = 'FAST_SLEEP'
             params.schedule.sleep = {
                 start_time: sleepTarget.start_time,
                 end_time: sleepTarget.end_time,
-                method: parseInt(router.params.isSelf + '') == 1 ? 'USER_SET' : 'SUGGEST',
+                
                 latency: {
                     input_value: target.sleep.schedule.sleep.latency.init_value,
                 },

+ 6 - 6
src/pages/clock/StreakDetail.tsx

@@ -100,9 +100,9 @@ export default function StreakDetail() {
     function getSubTitles() {
         var first = ''
         var second = ''
-        if (intro.current && intro.current.start_date && intro.current.end_date) {
-            var startStr = intro.current.start_date + ''
-            var endStr = intro.current.end_date + ''
+        if (intro.current && intro.current.date_scope && intro.current.date_scope) {
+            var startStr = intro.current.date_scope.first_start_date + ''
+            var endStr = intro.current.date_scope.first_end_date + ''
             var startObj = dayjs(startStr.substring(0, 4) + '-' + startStr.substring(4, 6) + '-' + startStr.substring(6, 8))
             var endObj = dayjs(endStr.substring(0, 4) + '-' + endStr.substring(4, 6) + '-' + endStr.substring(6, 8))
             if (global.language == 'en') {
@@ -128,9 +128,9 @@ export default function StreakDetail() {
 
         }
 
-        if (intro.longest && intro.longest.start_date && intro.longest.end_date) {
-            var startStr2 = intro.longest.start_date + ''
-            var endStr2 = intro.longest.end_date + ''
+        if (intro.longest && intro.longest.date_scope && intro.longest.date_scope) {
+            var startStr2 = intro.longest.date_scope.first_start_date + ''
+            var endStr2 = intro.longest.date_scope.first_end_date + ''
             var startObj2 = dayjs(startStr2.substring(0, 4) + '-' + startStr2.substring(4, 6) + '-' + startStr2.substring(6, 8))
             var endObj2 = dayjs(endStr2.substring(0, 4) + '-' + endStr2.substring(4, 6) + '-' + endStr2.substring(6, 8))
             if (global.language == 'en') {