Leon 1 рік тому
батько
коміт
b091c94be4

+ 34 - 9
src/features/trackTimeDuration/components/CheckAccess.scss

@@ -22,7 +22,8 @@
     padding: 40px;
     box-sizing: border-box;
     align-items: center;
-    
+    padding-bottom: 16px;
+
 }
 
 .fast_alert_title {
@@ -46,27 +47,51 @@
 
 .fast_alert_confirm {
     width: 578px;
-    height: 84px;
-    border-radius: 42px;
+    height: 96px;
+    border-radius: 48px;
     color: #000D1FFF;
     background-color: $fastColor;
-    font-size: 28px;
+    font-size: 30px;
     font-weight: bold;
     display: flex;
     align-items: center;
     justify-content: center;
     text-align: center;
+    margin-bottom: 24px;
+    flex-direction: column;
+}
+
+.confirm_multline {
+    height: 120px;
+    border-radius: 60px;
+}
+
+.confirm_text {
+    font-size: 32px;
+    font-weight: bold;
+}
+
+.confirm_sub_text {
+    color: #fff;
+    font-size: 20px;
+    background: linear-gradient(180deg, #FFFFFF 0%, rgba(255, 255, 255, 0.4) 100%);
+    -webkit-background-clip: text;
+    -webkit-text-fill-color: transparent;
+    background-clip: text;
+    text-fill-color: transparent;
 }
 
 .fast_alert_cancel {
-    margin-top: 20px;
-    width: 440px;
-    height: 84px;
-    color: #C4CCDA99;
-    font-size: 28px;
+    width: 578px;
+    height: 96px;
+    color: #fff;
+    border-radius: 48px;
+    background-color: #464646;
+    font-size: 30px;
     font-weight: bold;
     display: flex;
     align-items: center;
     justify-content: center;
     text-align: center;
+    margin-bottom: 24px;
 }

+ 38 - 11
src/features/trackTimeDuration/components/CheckAccess.tsx

@@ -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>
                 }

+ 4 - 4
src/pages/clock/ChooseScenario.tsx

@@ -30,8 +30,8 @@ export default function ChooseScenario() {
             var targets: any = {}
             data.scenarios.forEach((item) => {
                 if (item.name == 'FAST') {
-                    
-                    if (item.schedule.fast.duration.prev_input){
+
+                    if (item.schedule.fast.duration.prev_input) {
                         item.schedule.fast.duration.last_value = item.schedule.fast.duration.init_value
                     }
                     targets.fast = item
@@ -58,11 +58,11 @@ export default function ChooseScenario() {
 
     function chooseType(index: number) {
         var obj = global.homeData;
-        if (obj.access.current.qualification.status!= "PROVISIONAL_QUALIFIED"){
+        if (obj.access.current.qualification.status != "PROVISIONAL_QUALIFIED" && index == 1) {
             Taro.showToast({
                 title: '暂无权限',
                 icon: 'none'
-            
+
             })
             vibrate()
             return;

+ 1 - 0
src/pages/clock/Clock.tsx

@@ -126,6 +126,7 @@ export default function Page() {
     }
 
     useEffect(() => {
+        console.log(new Date().toString());
         dispatch(staticResources() as any);
         timer = setInterval(() => {
             var now = new Date()

+ 2 - 0
src/services/http/request.ts

@@ -86,6 +86,8 @@ export async function request<T>(param: RequestParam): Promise<T> {
         header['X-Lang'] = process.env.TARO_ENV == 'rn' ? 'en' : 'zh' //zh en
         header['X-Client-Type'] = process.env.TARO_ENV == 'rn' ? 'APP' : 'WX_APP' //WX_APP APP
         header['X-Client-Version'] = process.env.TARO_ENV == 'rn' ? APP_VERSION : WX_VERSION
+        header['X-Day'] = dayjs().format('YYYYMMDD')
+        header['X-Timestamp'] = new Date().getTime()
         if (token.length > 0) {
             header['Authorization'] = `Bearer ${token}`;
         }