|
@@ -131,7 +131,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
|
|
|
|
|
const { trigger_event } = access.current.qualification;
|
|
const { trigger_event } = access.current.qualification;
|
|
|
//删除记录后仍有资格,不做特殊处理。只有删除时为NOT_SATISFIED_AFTER_DELETE时,弹失去资格弹窗
|
|
//删除记录后仍有资格,不做特殊处理。只有删除时为NOT_SATISFIED_AFTER_DELETE时,弹失去资格弹窗
|
|
|
- if (trigger_event == 'SATISFIED_AFTER_DELETE'){
|
|
|
|
|
|
|
+ if (trigger_event == 'SATISFIED_AFTER_DELETE') {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -245,23 +245,28 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
if (showedDisqualifiedAlert) {
|
|
if (showedDisqualifiedAlert) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+ if (timer) {
|
|
|
|
|
+ clearInterval(timer)
|
|
|
|
|
+ timer = null
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
var desc = ''
|
|
var desc = ''
|
|
|
- const { trigger_event,fast_expire,sleep_expire,condition } = access.current.qualification;
|
|
|
|
|
|
|
+ const { trigger_event, fast_expire, sleep_expire, condition } = access.current.qualification;
|
|
|
var dt = fast_expire;
|
|
var dt = fast_expire;
|
|
|
- if (sleep_expire && sleep_expire<fast_expire){
|
|
|
|
|
|
|
+ if (sleep_expire && sleep_expire < fast_expire) {
|
|
|
dt = sleep_expire
|
|
dt = sleep_expire
|
|
|
}
|
|
}
|
|
|
- var date = TimeFormatter.getMonthAndDayByTimestamp(dt,true)
|
|
|
|
|
|
|
+ var date = TimeFormatter.getMonthAndDayByTimestamp(dt, true)
|
|
|
|
|
|
|
|
switch (trigger_event) {
|
|
switch (trigger_event) {
|
|
|
case 'FAST_STREAK_LOST':
|
|
case 'FAST_STREAK_LOST':
|
|
|
- desc = t('feature.check_access.lost_reason.fast_streak_lost',{date:date});
|
|
|
|
|
|
|
+ desc = t('feature.check_access.lost_reason.fast_streak_lost', { date: date });
|
|
|
break;
|
|
break;
|
|
|
case 'SLEEP_STREAK_LOST':
|
|
case 'SLEEP_STREAK_LOST':
|
|
|
- desc = t('feature.check_access.lost_reason.sleep_streak_lost',{date:date});
|
|
|
|
|
|
|
+ desc = t('feature.check_access.lost_reason.sleep_streak_lost', { date: date });
|
|
|
break;
|
|
break;
|
|
|
case 'FAST_SLEEP_STREAKS_LOST':
|
|
case 'FAST_SLEEP_STREAKS_LOST':
|
|
|
- desc = t('feature.check_access.lost_reason.fast_sleep_streaks_lost',{date:date});
|
|
|
|
|
|
|
+ desc = t('feature.check_access.lost_reason.fast_sleep_streaks_lost', { date: date });
|
|
|
break;
|
|
break;
|
|
|
case 'SLEEP_STREAK_NOT_GROWING':
|
|
case 'SLEEP_STREAK_NOT_GROWING':
|
|
|
debugger
|
|
debugger
|
|
@@ -275,141 +280,14 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- console.error('失去资格弹窗',trigger_event,desc);
|
|
|
|
|
|
|
+ console.error('失去资格弹窗', trigger_event, desc);
|
|
|
debugger
|
|
debugger
|
|
|
|
|
|
|
|
|
|
|
|
|
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: 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;
|
|
|
|
|
- if (showedDisqualifiedAlert) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- var desc = ''
|
|
|
|
|
- // const prev_streak_fast_count = access.previous.qualification.condition.streak_fast_current
|
|
|
|
|
- const prev_streak_sleep_count = access.previous.qualification.condition.streak_sleep_current
|
|
|
|
|
- const { streak_fast_current, streak_fast_required, streak_sleep_current, streak_sleep_required } = access.current.qualification.condition;
|
|
|
|
|
-
|
|
|
|
|
- if (prev_streak_sleep_count == 0) {
|
|
|
|
|
- if (streak_fast_current == 0) {
|
|
|
|
|
- desc = 'since you lost your fasting streak'
|
|
|
|
|
- }
|
|
|
|
|
- else if (streak_fast_current < streak_fast_required) {
|
|
|
|
|
- desc = 'since the requirement for staying qualified is no longer satisfied'
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- desc = `since you didn't begin your sleep streak`
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- /*
|
|
|
|
|
- 删除后不再满足保持资格的条件
|
|
|
|
|
- 断食不再满足
|
|
|
|
|
- 睡眠不再满足
|
|
|
|
|
- 断食和睡眠均不再满足
|
|
|
|
|
- 三个共用一个case
|
|
|
|
|
- */
|
|
|
|
|
- if ((streak_sleep_current < streak_sleep_required || streak_fast_current < streak_fast_required) && delOperation) {
|
|
|
|
|
- desc = 'since the requirement for staying qualified is no longer satisfied'
|
|
|
|
|
- }
|
|
|
|
|
- /*
|
|
|
|
|
- 断食先归零
|
|
|
|
|
- */
|
|
|
|
|
- else if (streak_sleep_current != 0 && streak_fast_current == 0) {
|
|
|
|
|
- desc = 'since you lost your fasting streak'
|
|
|
|
|
- }
|
|
|
|
|
- /*
|
|
|
|
|
- 睡眠先归零
|
|
|
|
|
- */
|
|
|
|
|
- else if (streak_sleep_current == 0 && streak_fast_current != 0) {
|
|
|
|
|
- desc = 'since you lost your sleep streak'
|
|
|
|
|
- }
|
|
|
|
|
- /*
|
|
|
|
|
- 断食和睡眠同时归零
|
|
|
|
|
- */
|
|
|
|
|
- else if (streak_sleep_current == 0 && streak_fast_current == 0) {
|
|
|
|
|
- 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'
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- setShowFastAlert(true)
|
|
|
|
|
- setKeepContent(false)
|
|
|
|
|
- setAlertTitle(t('feature.check_access.lose_access.title'))
|
|
|
|
|
- setAlertContent(t('feature.check_access.lose_access.desc', { type: desc }))
|
|
|
|
|
- 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 lose(condition) {
|
|
|
|
|
- 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 (now > fast_expire && sleep_expire && now > sleep_expire) {
|
|
|
|
|
- type = 'since you lost your fasting and sleep streak'
|
|
|
|
|
- }
|
|
|
|
|
- //单断食失效
|
|
|
|
|
- else if (now > fast_expire) {
|
|
|
|
|
- type = 'since you lost your fasting streak'
|
|
|
|
|
- }
|
|
|
|
|
- //睡眠失效
|
|
|
|
|
- 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 }))
|
|
|
|
|
|
|
+ setAlertContent(t('feature.check_access.lose_access.desc', { type: desc, require_days: condition.streak_fast_min_required }))
|
|
|
setShowCancel(false)
|
|
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')
|
|
@@ -423,7 +301,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',
|
|
scenario: 'FAST',
|
|
|
- trigger_event: 'POPUP_DISQUALIFIED_DISMISS',
|
|
|
|
|
|
|
+ trigger_event: 'POPUP_DISQUALIFIED',
|
|
|
method: 'USER_SET',
|
|
method: 'USER_SET',
|
|
|
schedule: {
|
|
schedule: {
|
|
|
fast: {
|
|
fast: {
|