|
@@ -120,7 +120,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
global.chooseMixed = () => {
|
|
global.chooseMixed = () => {
|
|
|
setChooseMixedSuccess(true)
|
|
setChooseMixedSuccess(true)
|
|
|
}
|
|
}
|
|
|
- global.checkAccess = (acccessData: any, delOperation = false) => {
|
|
|
|
|
|
|
+ global.checkAccess = (acccessData: any) => {
|
|
|
const currentStatus = acccessData.current.qualification.status
|
|
const currentStatus = acccessData.current.qualification.status
|
|
|
const preStatus = acccessData.previous.qualification.status
|
|
const preStatus = acccessData.previous.qualification.status
|
|
|
access = acccessData
|
|
access = acccessData
|
|
@@ -128,10 +128,16 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
|
|
|
|
|
setSubConfirmText('')
|
|
setSubConfirmText('')
|
|
|
confirmAction = null
|
|
confirmAction = null
|
|
|
- // setAccess(acccessData)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ const { trigger_event } = access.current.qualification;
|
|
|
|
|
+ //删除记录后仍有资格,不做特殊处理。只有删除时为NOT_SATISFIED_AFTER_DELETE时,弹失去资格弹窗
|
|
|
|
|
+ if (trigger_event == 'SATISFIED_AFTER_DELETE'){
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
if (preStatus == 'NOT_QUALIFIED' && currentStatus == 'NOT_QUALIFIED') {
|
|
if (preStatus == 'NOT_QUALIFIED' && currentStatus == 'NOT_QUALIFIED') {
|
|
|
- const { streak_fast_current, streak_fast_base_required } = acccessData.current.qualification.condition
|
|
|
|
|
|
|
+ const { streak_fast_current, streak_fast_min_required } = acccessData.current.qualification.condition
|
|
|
if (streak_fast_current == 0) {
|
|
if (streak_fast_current == 0) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -141,8 +147,8 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
setAlertContent(t('feature.check_access.non_access.desc',
|
|
setAlertContent(t('feature.check_access.non_access.desc',
|
|
|
{
|
|
{
|
|
|
day: streak_fast_current,
|
|
day: streak_fast_current,
|
|
|
- left_day: streak_fast_base_required - streak_fast_current,
|
|
|
|
|
- day_unit: streak_fast_base_required - streak_fast_current == 1 ? 'day' : 'days'
|
|
|
|
|
|
|
+ day_left: streak_fast_min_required - streak_fast_current,
|
|
|
|
|
+ day_unit: streak_fast_min_required - streak_fast_current == 1 ? 'day' : 'days'
|
|
|
}))
|
|
}))
|
|
|
setShowCancel(false)
|
|
setShowCancel(false)
|
|
|
setConfirmText(t('feature.check_access.non_access.btn'))
|
|
setConfirmText(t('feature.check_access.non_access.btn'))
|
|
@@ -202,9 +208,8 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
setConfirmText(t('feature.check_access.stay_qualified.btn'))
|
|
setConfirmText(t('feature.check_access.stay_qualified.btn'))
|
|
|
}
|
|
}
|
|
|
else if (preStatus == 'PROVISIONAL_QUALIFIED' && currentStatus == 'NOT_QUALIFIED') {
|
|
else if (preStatus == 'PROVISIONAL_QUALIFIED' && currentStatus == 'NOT_QUALIFIED') {
|
|
|
- debugger
|
|
|
|
|
// lose(acccessData.current.qualification);
|
|
// lose(acccessData.current.qualification);
|
|
|
- loseGain(acccessData, delOperation);
|
|
|
|
|
|
|
+ loseGain(acccessData);
|
|
|
// setShowFastAlert(true)
|
|
// setShowFastAlert(true)
|
|
|
// setAlertTitle('Premium Access Lost')
|
|
// setAlertTitle('Premium Access Lost')
|
|
|
// setAlertContent(`You've lost premium access to the 'Fasting with Sleep' feature
|
|
// setAlertContent(`You've lost premium access to the 'Fasting with Sleep' feature
|
|
@@ -235,7 +240,59 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
}, 1000)
|
|
}, 1000)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- async function loseGain(access, delOperation = false) {
|
|
|
|
|
|
|
+ async function loseGain(access) {
|
|
|
|
|
+ var showedDisqualifiedAlert = await getStorage('showedDisqualifiedAlert') || false;
|
|
|
|
|
+ if (showedDisqualifiedAlert) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ var desc = ''
|
|
|
|
|
+ const { trigger_event,fast_expire,sleep_expire,condition } = access.current.qualification;
|
|
|
|
|
+ var dt = fast_expire;
|
|
|
|
|
+ if (sleep_expire && sleep_expire<fast_expire){
|
|
|
|
|
+ dt = sleep_expire
|
|
|
|
|
+ }
|
|
|
|
|
+ var date = TimeFormatter.getMonthAndDayByTimestamp(dt,true)
|
|
|
|
|
+
|
|
|
|
|
+ switch (trigger_event) {
|
|
|
|
|
+ case 'FAST_STREAK_LOST':
|
|
|
|
|
+ desc = t('feature.check_access.lost_reason.fast_streak_lost',{date:date});
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'SLEEP_STREAK_LOST':
|
|
|
|
|
+ desc = t('feature.check_access.lost_reason.sleep_streak_lost',{date:date});
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'FAST_SLEEP_STREAKS_LOST':
|
|
|
|
|
+ desc = t('feature.check_access.lost_reason.fast_sleep_streaks_lost',{date:date});
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'SLEEP_STREAK_NOT_GROWING':
|
|
|
|
|
+ debugger
|
|
|
|
|
+ desc = t('feature.check_access.lost_reason.sleep_streak_not_growing');
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'NOT_SATISFIED_AFTER_DELETE':
|
|
|
|
|
+ desc = t('feature.check_access.lost_reason.not_satisfied_after_delete');
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'NA':
|
|
|
|
|
+ default:
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ console.error('失去资格弹窗',trigger_event,desc);
|
|
|
|
|
+ debugger
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ setShowFastAlert(true)
|
|
|
|
|
+ setKeepContent(false)
|
|
|
|
|
+ setAlertTitle(t('feature.check_access.lose_access.title'))
|
|
|
|
|
+ setAlertContent(t('feature.check_access.lose_access.desc', { type: desc,require_days: condition.streak_fast_min_required}))
|
|
|
|
|
+ setShowCancel(false)
|
|
|
|
|
+ setConfirmText(t('feature.check_access.lose_access.cancel'))
|
|
|
|
|
+ // setConfirmText('Become a PRO member')
|
|
|
|
|
+ setSubConfirmText('')
|
|
|
|
|
+ Taro.setStorage({ key: 'showedDisqualifiedAlert', data: true })
|
|
|
|
|
+
|
|
|
|
|
+ changeFastScenaria()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ async function loseGain2(access, delOperation = false) {
|
|
|
var showedDisqualifiedAlert = await getStorage('showedDisqualifiedAlert') || false;
|
|
var showedDisqualifiedAlert = await getStorage('showedDisqualifiedAlert') || false;
|
|
|
if (showedDisqualifiedAlert) {
|
|
if (showedDisqualifiedAlert) {
|
|
|
return;
|
|
return;
|
|
@@ -285,6 +342,12 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
else if (streak_sleep_current == 0 && streak_fast_current == 0) {
|
|
else if (streak_sleep_current == 0 && streak_fast_current == 0) {
|
|
|
desc = 'since you lost both of your fasting and sleep streaks'
|
|
desc = 'since you lost both of your fasting and sleep streaks'
|
|
|
}
|
|
}
|
|
|
|
|
+ /*
|
|
|
|
|
+ 打卡后streak没有按预期同步增长
|
|
|
|
|
+ */
|
|
|
|
|
+ else if ((streak_sleep_current < streak_sleep_required || streak_fast_current < streak_fast_required)) {
|
|
|
|
|
+ desc = 'since the requirement for staying qualified is no longer satisfied'
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -361,6 +424,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
var params: any = {
|
|
var params: any = {
|
|
|
scenario: 'FAST',
|
|
scenario: 'FAST',
|
|
|
trigger_event: 'POPUP_DISQUALIFIED_DISMISS',
|
|
trigger_event: 'POPUP_DISQUALIFIED_DISMISS',
|
|
|
|
|
+ method: 'USER_SET',
|
|
|
schedule: {
|
|
schedule: {
|
|
|
fast: {
|
|
fast: {
|
|
|
start_time: start_time,
|
|
start_time: start_time,
|
|
@@ -457,6 +521,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
const { start_time, end_time } = global.ring.schedule.fast
|
|
const { start_time, end_time } = global.ring.schedule.fast
|
|
|
var params: any = {
|
|
var params: any = {
|
|
|
scenario: 'FAST_SLEEP',
|
|
scenario: 'FAST_SLEEP',
|
|
|
|
|
+ method: 'USER_SET',
|
|
|
trigger_event: 'POPUP_QUALIFIED_UPGRADED_DISMISS',
|
|
trigger_event: 'POPUP_QUALIFIED_UPGRADED_DISMISS',
|
|
|
schedule: {
|
|
schedule: {
|
|
|
fast: {
|
|
fast: {
|
|
@@ -520,6 +585,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
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>
|
|
|
|
|
+ <Text style={{ color: '#fff', fontSize: 12 }}>trigger event:{props.record.access.current.qualification.trigger_event}</Text>
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
|
|
|
|