|
@@ -2,7 +2,7 @@ import showAlert from "@/components/basic/Alert"
|
|
|
import { View, Text } from "@tarojs/components";
|
|
import { View, Text } from "@tarojs/components";
|
|
|
import './CheckAccess.scss'
|
|
import './CheckAccess.scss'
|
|
|
|
|
|
|
|
-import { useContext, useEffect, useState } from "react";
|
|
|
|
|
|
|
+import { memo, useContext, useEffect, useState } from "react";
|
|
|
import { TimeFormatter } from "@/utils/time_format";
|
|
import { TimeFormatter } from "@/utils/time_format";
|
|
|
import { useDispatch, useSelector } from "react-redux";
|
|
import { useDispatch, useSelector } from "react-redux";
|
|
|
import { getPlans, setPlan } from "@/services/trackTimeDuration";
|
|
import { getPlans, setPlan } from "@/services/trackTimeDuration";
|
|
@@ -25,8 +25,8 @@ if (process.env.TARO_ENV == 'rn') {
|
|
|
useNavigation = require("@react-navigation/native").useNavigation
|
|
useNavigation = require("@react-navigation/native").useNavigation
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
|
|
|
|
+const CheckAccess = memo((props: { record: any, count: number }) => {
|
|
|
|
|
+ // export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
const [showFastAlert, setShowFastAlert] = useState(false)
|
|
const [showFastAlert, setShowFastAlert] = useState(false)
|
|
|
const [alertTitle, setAlertTitle] = useState('')
|
|
const [alertTitle, setAlertTitle] = useState('')
|
|
|
const [alertContent, setAlertContent] = useState('')
|
|
const [alertContent, setAlertContent] = useState('')
|
|
@@ -36,7 +36,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
const [confirmText, setConfirmText] = useState('')
|
|
const [confirmText, setConfirmText] = useState('')
|
|
|
const [subConfirmText, setSubConfirmText] = useState('')
|
|
const [subConfirmText, setSubConfirmText] = useState('')
|
|
|
const user = useSelector((state: any) => state.user);
|
|
const user = useSelector((state: any) => state.user);
|
|
|
- const [rnKeep,setRnKeep] = useState(true)
|
|
|
|
|
|
|
+ const [rnKeep, setRnKeep] = useState(true)
|
|
|
|
|
|
|
|
const { t } = useTranslation()
|
|
const { t } = useTranslation()
|
|
|
|
|
|
|
@@ -52,10 +52,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
navigation = useNavigation()
|
|
navigation = useNavigation()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // const [confirmAction, setConfirmAction] = useState<any>(null)
|
|
|
|
|
- // const [access, setAccess] = useState<any>(null)
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
var obj = props.record
|
|
var obj = props.record
|
|
@@ -106,7 +103,8 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
setChooseMixedSuccess(false)
|
|
setChooseMixedSuccess(false)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function viewWillDisappear(){
|
|
|
|
|
|
|
+ function viewWillDisappear() {
|
|
|
|
|
+ debugger
|
|
|
setRnKeep(false)
|
|
setRnKeep(false)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -134,6 +132,13 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
setShowFastAlert(false)
|
|
setShowFastAlert(false)
|
|
|
setKeepContent(false)
|
|
setKeepContent(false)
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ global.paySuccess = ()=>{
|
|
|
|
|
+ cancelAction = null
|
|
|
|
|
+ confirmAction = null
|
|
|
|
|
+ setShowFastAlert(false)
|
|
|
|
|
+ setKeepContent(false)
|
|
|
|
|
+ }
|
|
|
global.checkAccess = (acccessData: any) => {
|
|
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
|
|
@@ -141,10 +146,11 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
|
|
|
|
|
|
|
|
|
|
setSubConfirmText('')
|
|
setSubConfirmText('')
|
|
|
|
|
+ debugger
|
|
|
confirmAction = null
|
|
confirmAction = null
|
|
|
|
|
|
|
|
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;
|
|
@@ -169,9 +175,9 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
setConfirmText(t('feature.check_access.non_access.btn'))
|
|
setConfirmText(t('feature.check_access.non_access.btn'))
|
|
|
}
|
|
}
|
|
|
else if (preStatus == 'NOT_QUALIFIED' && currentStatus == 'PROVISIONAL_QUALIFIED') {
|
|
else if (preStatus == 'NOT_QUALIFIED' && currentStatus == 'PROVISIONAL_QUALIFIED') {
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
const { streak_fast_current } = acccessData.current.qualification.condition
|
|
const { streak_fast_current } = acccessData.current.qualification.condition
|
|
|
- const reason = t('feature.check_access.gain_access.reason',{day: streak_fast_current})
|
|
|
|
|
|
|
+ const reason = t('feature.check_access.gain_access.reason', { day: streak_fast_current })
|
|
|
Taro.setStorage({ key: 'showedDisqualifiedAlert', data: false })
|
|
Taro.setStorage({ key: 'showedDisqualifiedAlert', data: false })
|
|
|
var expire = acccessData.current.qualification.fast_expire
|
|
var expire = acccessData.current.qualification.fast_expire
|
|
|
setShowFastAlert(true)
|
|
setShowFastAlert(true)
|
|
@@ -202,7 +208,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
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') {
|
|
|
var expire = acccessData.current.qualification.fast_expire
|
|
var expire = acccessData.current.qualification.fast_expire
|
|
|
- const reason = t('feature.check_access.gain_access.reason',{day: streak_fast_current})
|
|
|
|
|
|
|
+ const reason = t('feature.check_access.gain_access.reason', { day: streak_fast_current })
|
|
|
setShowFastAlert(true)
|
|
setShowFastAlert(true)
|
|
|
// setKeepContent(false)
|
|
// setKeepContent(false)
|
|
|
setKeepContent(true)
|
|
setKeepContent(true)
|
|
@@ -241,6 +247,14 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
setShowFastAlert(false)
|
|
setShowFastAlert(false)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function pay() {
|
|
|
|
|
+ jumpPage('', 'ProductList', navigation)
|
|
|
|
|
+ setTimeout(()=>{
|
|
|
|
|
+ confirmAction = pay
|
|
|
|
|
+ cancelAction = changeFastScenaria
|
|
|
|
|
+ },200)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
async function loseGain(access) {
|
|
async function loseGain(access) {
|
|
|
var showedDisqualifiedAlert = await getStorage('showedDisqualifiedAlert') || false;
|
|
var showedDisqualifiedAlert = await getStorage('showedDisqualifiedAlert') || false;
|
|
|
if (showedDisqualifiedAlert) {
|
|
if (showedDisqualifiedAlert) {
|
|
@@ -258,7 +272,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
dt = sleep_expire
|
|
dt = sleep_expire
|
|
|
}
|
|
}
|
|
|
var date = TimeFormatter.getMonthAndDayByTimestamp(dt, true)
|
|
var date = TimeFormatter.getMonthAndDayByTimestamp(dt, true)
|
|
|
- var day_unit = Math.max(condition.streak_fast_min_required-1,1)==1?'day':'days';
|
|
|
|
|
|
|
+ var day_unit = Math.max(condition.streak_fast_min_required - 1, 1) == 1 ? 'day' : 'days';
|
|
|
|
|
|
|
|
switch (trigger_event) {
|
|
switch (trigger_event) {
|
|
|
case 'FAST_STREAK_LOST':
|
|
case 'FAST_STREAK_LOST':
|
|
@@ -274,7 +288,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
desc = t('feature.check_access.lost_reason.sleep_streak_not_growing');
|
|
desc = t('feature.check_access.lost_reason.sleep_streak_not_growing');
|
|
|
break;
|
|
break;
|
|
|
case 'NOT_SATISFIED_AFTER_DELETE':
|
|
case 'NOT_SATISFIED_AFTER_DELETE':
|
|
|
- desc = t('feature.check_access.lost_reason.not_satisfied_after_delete',{day:Math.max(condition.streak_fast_min_required-1,1),day_unit:day_unit});
|
|
|
|
|
|
|
+ desc = t('feature.check_access.lost_reason.not_satisfied_after_delete', { day: Math.max(condition.streak_fast_min_required - 1, 1), day_unit: day_unit });
|
|
|
break;
|
|
break;
|
|
|
case 'NA':
|
|
case 'NA':
|
|
|
default:
|
|
default:
|
|
@@ -285,19 +299,27 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
|
|
|
|
|
|
|
|
|
|
setShowFastAlert(true)
|
|
setShowFastAlert(true)
|
|
|
- setKeepContent(false)
|
|
|
|
|
|
|
+ setKeepContent(true)
|
|
|
setAlertTitle(t('feature.check_access.lose_access.title'))
|
|
setAlertTitle(t('feature.check_access.lose_access.title'))
|
|
|
setAlertContent(t('feature.check_access.lose_access.desc', { reason: desc, require_days: condition.streak_fast_min_required }))
|
|
setAlertContent(t('feature.check_access.lose_access.desc', { reason: desc, require_days: condition.streak_fast_min_required }))
|
|
|
- setShowCancel(false)
|
|
|
|
|
- setConfirmText(t('feature.check_access.lose_access.btn'))
|
|
|
|
|
- // setConfirmText('Become a PRO member')
|
|
|
|
|
|
|
+ setShowCancel(true)
|
|
|
|
|
+ setCancelText(t('feature.check_access.lose_access.btn'))
|
|
|
|
|
+ setConfirmText('Become a PRO member')
|
|
|
setSubConfirmText('')
|
|
setSubConfirmText('')
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ cancelAction = changeFastScenaria
|
|
|
|
|
+ confirmAction = pay
|
|
|
|
|
+ }, 100)
|
|
|
|
|
+ // confirmAction = pay
|
|
|
|
|
+ // cancelAction = changeFastScenaria
|
|
|
Taro.setStorage({ key: 'showedDisqualifiedAlert', data: true })
|
|
Taro.setStorage({ key: 'showedDisqualifiedAlert', data: true })
|
|
|
|
|
|
|
|
- changeFastScenaria()
|
|
|
|
|
|
|
+ // changeFastScenaria()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function changeFastScenaria() {
|
|
function changeFastScenaria() {
|
|
|
|
|
+ cancelAction = null
|
|
|
|
|
+ confirmAction = null
|
|
|
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',
|
|
@@ -451,7 +473,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
<View className="fast_alert_title">{alertTitle}</View>
|
|
<View className="fast_alert_title">{alertTitle}</View>
|
|
|
<View className="fast_alert_detail">{alertContent}</View>
|
|
<View className="fast_alert_detail">{alertContent}</View>
|
|
|
<View className={subConfirmText.length > 0 ? 'fast_alert_confirm confirm_multline' : 'fast_alert_confirm'} onClick={confirm}>
|
|
<View className={subConfirmText.length > 0 ? 'fast_alert_confirm confirm_multline' : 'fast_alert_confirm'} onClick={confirm}>
|
|
|
- <Text style={{fontWeight:'bold',color:ColorType.black}}>{confirmText}</Text>
|
|
|
|
|
|
|
+ <Text style={{ fontWeight: 'bold', color: ColorType.black }}>{confirmText}</Text>
|
|
|
{
|
|
{
|
|
|
subConfirmText.length > 0 && <Text className="confirm_sub_text">{subConfirmText}</Text>
|
|
subConfirmText.length > 0 && <Text className="confirm_sub_text">{subConfirmText}</Text>
|
|
|
}
|
|
}
|
|
@@ -485,4 +507,6 @@ export default function CheckAccess(props: { record: any, count: number }) {
|
|
|
</Modal>
|
|
</Modal>
|
|
|
}
|
|
}
|
|
|
</View>
|
|
</View>
|
|
|
-}
|
|
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
|
|
+export default CheckAccess;
|