|
|
@@ -10,6 +10,7 @@ import { chooseMode, initTarget, updateStep } from "@/store/set_target";
|
|
|
import { jumpPage } from "../hooks/Common";
|
|
|
import { useDidShow } from "@tarojs/taro";
|
|
|
import Taro from "@tarojs/taro";
|
|
|
+import { set } from "lodash";
|
|
|
|
|
|
let confirmAction: any = null;
|
|
|
let cancelAction: any = null;
|
|
|
@@ -27,8 +28,10 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
const [alertTitle, setAlertTitle] = useState('')
|
|
|
const [alertContent, setAlertContent] = useState('')
|
|
|
const [showCancel, setShowCancel] = useState(false)
|
|
|
+ const [keepContent, setKeepContent] = useState(false)
|
|
|
const [cancelText, setCancelText] = useState('')
|
|
|
const [confirmText, setConfirmText] = useState('')
|
|
|
+ const [subConfirmText, setSubConfirmText] = useState('')
|
|
|
|
|
|
//判断选择混合场景,如果成功了,就弹窗
|
|
|
const [checkChooseMixed, setCheckChooseMixed] = useState(false)
|
|
|
@@ -54,6 +57,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
lose()
|
|
|
}
|
|
|
else if (currentStatus == 'PROVISIONAL_QUALIFIED' && new Date().getTime() > obj.access.current.qualification.expire) {
|
|
|
+ debugger
|
|
|
if (global.indexPageRefresh) {
|
|
|
global.indexPageRefresh()
|
|
|
}
|
|
|
@@ -104,15 +108,20 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
const currentStatus = acccessData.current.qualification.status
|
|
|
const preStatus = acccessData.previous.qualification.status
|
|
|
access = acccessData
|
|
|
+
|
|
|
+ setSubConfirmText('')
|
|
|
// setAccess(acccessData)
|
|
|
|
|
|
if (preStatus == 'NOT_QUALIFIED' && currentStatus == 'NOT_QUALIFIED') {
|
|
|
const { streak_fast_current } = acccessData.current.qualification.condition
|
|
|
-
|
|
|
+ if (streak_fast_current == 0){
|
|
|
+ return;
|
|
|
+ }
|
|
|
setShowFastAlert(true)
|
|
|
+ setKeepContent(false)
|
|
|
setAlertTitle('Well Done')
|
|
|
setAlertContent(`You're on a ${streak_fast_current}-day streak.
|
|
|
- Two more days until unlocking 'Fasting with sleep.'`)
|
|
|
+ ${streak_fast_current==1?'Two more days':'One more day'} until unlocking 'Fasting with sleep.'`)
|
|
|
setShowCancel(false)
|
|
|
setConfirmText('Got it!')
|
|
|
}
|
|
|
@@ -122,18 +131,22 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
Taro.setStorage({ key: 'showLoseGain', data: false })
|
|
|
const { expire } = acccessData.current.qualification
|
|
|
setShowFastAlert(true)
|
|
|
+ setKeepContent(false)
|
|
|
setAlertTitle('Premium Access Unlocked')
|
|
|
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 ${TimeFormatter.countdown(expire)})`)
|
|
|
+ setConfirmText(`Upgrade to Fasting with Sleep`)
|
|
|
+ setSubConfirmText(`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)})`)
|
|
|
+ setSubConfirmText(`Offer Expiring in ${TimeFormatter.countdown(expire)}`)
|
|
|
+ // setConfirmText(`Upgrade to Fasting with Sleep\n(Offer Expiring in ${TimeFormatter.countdown(expire)})`)
|
|
|
}, 1000)
|
|
|
}
|
|
|
else if (preStatus == 'PROVISIONAL_QUALIFIED' && currentStatus == 'PROVISIONAL_QUALIFIED') {
|
|
|
@@ -142,12 +155,13 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
if (ring.current_record.scenario == 'FAST') {
|
|
|
const { expire } = acccessData.current.qualification
|
|
|
setShowFastAlert(true)
|
|
|
+ setKeepContent(false)
|
|
|
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)})`)
|
|
|
+ setConfirmText(`Upgrade to Fasting with Sleep`)
|
|
|
+ setSubConfirmText(`Offer Expiring in ${TimeFormatter.countdown(expire)}`)
|
|
|
setCancelText('Stay with Fasting Only')
|
|
|
confirmAction = upgrade
|
|
|
timer = setInterval(() => {
|
|
|
@@ -155,7 +169,8 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
cancel()
|
|
|
return
|
|
|
}
|
|
|
- setConfirmText(`Upgrade to Fasting with Sleep\n(Offer Expiring in ${TimeFormatter.countdown(expire)})`)
|
|
|
+ setSubConfirmText(`Offer Expiring in ${TimeFormatter.countdown(expire)}`)
|
|
|
+ // setConfirmText(`Upgrade to Fasting with Sleep\n(Offer Expiring in ${TimeFormatter.countdown(expire)})`)
|
|
|
}, 1000)
|
|
|
return;
|
|
|
}
|
|
|
@@ -182,10 +197,12 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
function upgradeSuccess() {
|
|
|
const { expire } = access.current.qualification
|
|
|
setShowFastAlert(true)
|
|
|
+ setKeepContent(false)
|
|
|
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!`)
|
|
|
+ setSubConfirmText('')
|
|
|
timer = setInterval(() => {
|
|
|
|
|
|
if (new Date().getTime() > expire) {
|
|
|
@@ -203,12 +220,14 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
return;
|
|
|
}
|
|
|
setShowFastAlert(true)
|
|
|
+ setKeepContent(false)
|
|
|
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')
|
|
|
+ setSubConfirmText('')
|
|
|
Taro.setStorage({ key: 'showLoseGain', data: true })
|
|
|
|
|
|
changeFastScenaria()
|
|
|
@@ -245,12 +264,14 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
const { prev_input, start_time, end_time } = ring.schedule.sleep
|
|
|
if (prev_input) {
|
|
|
setShowFastAlert(true)
|
|
|
+ setKeepContent(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')
|
|
|
+ setSubConfirmText('')
|
|
|
setTimeout(() => {
|
|
|
confirmAction = goSetting
|
|
|
}, 100)
|
|
|
@@ -301,8 +322,10 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
}
|
|
|
|
|
|
function confirm() {
|
|
|
- debugger
|
|
|
- setShowFastAlert(false)
|
|
|
+ if (!keepContent) {
|
|
|
+ setShowFastAlert(false)
|
|
|
+ }
|
|
|
+
|
|
|
if (timer) {
|
|
|
clearInterval(timer)
|
|
|
timer = null
|
|
|
@@ -312,7 +335,6 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
}
|
|
|
|
|
|
function cancel() {
|
|
|
- debugger
|
|
|
setShowFastAlert(false)
|
|
|
confirmAction = null;
|
|
|
if (timer) {
|
|
|
@@ -328,7 +350,12 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
<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>
|
|
|
+ <View className={subConfirmText.length>0?'fast_alert_confirm confirm_multline':'fast_alert_confirm'} onClick={confirm}>
|
|
|
+ <Text>{confirmText}</Text>
|
|
|
+ {
|
|
|
+ subConfirmText.length>0 && <Text className="confirm_sub_text">{subConfirmText}</Text>
|
|
|
+ }
|
|
|
+ </View>
|
|
|
{
|
|
|
showCancel && <View className="fast_alert_cancel" onClick={cancel}>{cancelText}</View>
|
|
|
}
|