|
@@ -62,11 +62,18 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
}
|
|
}
|
|
|
else if (currentStatus == 'PROVISIONAL_QUALIFIED') {
|
|
else if (currentStatus == 'PROVISIONAL_QUALIFIED') {
|
|
|
Taro.setStorage({ key: 'showedDisqualifiedAlert', data: false })
|
|
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) {
|
|
if (global.indexPageRefresh) {
|
|
|
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') {
|
|
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
|
|
const { streak_fast_current } = acccessData.current.qualification.condition
|
|
|
|
|
|
|
|
Taro.setStorage({ key: 'showedDisqualifiedAlert', data: false })
|
|
Taro.setStorage({ key: 'showedDisqualifiedAlert', data: false })
|
|
|
- const { expire } = acccessData.current.qualification
|
|
|
|
|
|
|
+ var expire = acccessData.current.qualification.fast_expire
|
|
|
setShowFastAlert(true)
|
|
setShowFastAlert(true)
|
|
|
setKeepContent(false)
|
|
setKeepContent(false)
|
|
|
setAlertTitle(t('feature.check_access.gain_access.title'))
|
|
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') {
|
|
else if (preStatus == 'PROVISIONAL_QUALIFIED' && currentStatus == 'PROVISIONAL_QUALIFIED') {
|
|
|
const { streak_fast_current, streak_sleep_current } = acccessData.current.qualification.condition
|
|
const { streak_fast_current, streak_sleep_current } = acccessData.current.qualification.condition
|
|
|
if (global.ring.current_record.scenario == 'FAST') {
|
|
if (global.ring.current_record.scenario == 'FAST') {
|
|
|
- const { expire } = acccessData.current.qualification
|
|
|
|
|
|
|
+ var expire = acccessData.current.qualification.fast_expire
|
|
|
setShowFastAlert(true)
|
|
setShowFastAlert(true)
|
|
|
setKeepContent(false)
|
|
setKeepContent(false)
|
|
|
setAlertTitle(t('feature.check_access.gain_access.title'))
|
|
setAlertTitle(t('feature.check_access.gain_access.title'))
|
|
@@ -209,7 +216,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
}, [])
|
|
}, [])
|
|
|
|
|
|
|
|
function upgradeSuccess() {
|
|
function upgradeSuccess() {
|
|
|
- const { expire } = access.current.qualification
|
|
|
|
|
|
|
+ var expire = access.current.qualification.fast_expire
|
|
|
setShowFastAlert(true)
|
|
setShowFastAlert(true)
|
|
|
setKeepContent(false)
|
|
setKeepContent(false)
|
|
|
setAlertTitle(t('feature.check_access.upgrade_pro.title'))
|
|
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) {
|
|
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;
|
|
var showedDisqualifiedAlert = await getStorage('showedDisqualifiedAlert') || false;
|
|
|
if (showedDisqualifiedAlert) {
|
|
if (showedDisqualifiedAlert) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
var type = ''
|
|
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)
|
|
setShowFastAlert(true)
|
|
|
setKeepContent(false)
|
|
setKeepContent(false)
|
|
|
setAlertTitle(t('feature.check_access.lose_access.title'))
|
|
setAlertTitle(t('feature.check_access.lose_access.title'))
|
|
|
setAlertContent(t('feature.check_access.lose_access.desc', { type: type }))
|
|
setAlertContent(t('feature.check_access.lose_access.desc', { type: type }))
|
|
|
- // setShowCancel(true)
|
|
|
|
|
|
|
+ setShowCancel(false)
|
|
|
setConfirmText(t('feature.check_access.lose_access.cancel'))
|
|
setConfirmText(t('feature.check_access.lose_access.cancel'))
|
|
|
// setConfirmText('Become a PRO member')
|
|
// setConfirmText('Become a PRO member')
|
|
|
setSubConfirmText('')
|
|
setSubConfirmText('')
|
|
@@ -418,7 +448,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
showCancel && <View className="fast_alert_cancel" onClick={cancel}>{cancelText}</View>
|
|
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 }}>current status:{props.record.access.current.qualification.status}</Text>
|
|
|
<Text style={{ color: '#fff', fontSize: 12 }}>previous status:{props.record.access.previous.qualification.status}</Text>
|
|
<Text style={{ color: '#fff', fontSize: 12 }}>previous status:{props.record.access.previous.qualification.status}</Text>
|
|
|
</View>
|
|
</View>
|