leon 1 год назад
Родитель
Сommit
66b21dce1c
2 измененных файлов с 42 добавлено и 24 удалено
  1. 38 22
      src/pages/notification/setting.tsx
  2. 4 2
      src/pages/store/product_list.tsx

+ 38 - 22
src/pages/notification/setting.tsx

@@ -47,6 +47,9 @@ export default function Page() {
     // }, [])
 
     useEffect(() => {
+        if (!user.isLogin) {
+            return;
+        }
         checkSetting()
         getSettings()
         getMemberStatus()
@@ -90,7 +93,7 @@ export default function Page() {
     };
 
     function getMemberStatus() {
-        const {access} = accessObj
+        const { access } = accessObj
         if (access && access.member) {
             if (access.member.status == 'NON_MEMBER') {
                 postNotifySettings({
@@ -218,7 +221,7 @@ export default function Page() {
         jumpPage('', 'ProductList', navigation)
     }
 
-    function pro() {
+    function pro(isLogin:boolean) {
         return <ScrollView style={{ flex: 1 }}>
             {/* <ProductList /> */}
             {/* <Text style={{fontSize:30,color:'#fff'}} onClick={iap}>iap test</Text> */}
@@ -229,15 +232,21 @@ export default function Page() {
                 <Text className="setting_header">Reminders</Text>
                 <View className="setting_cell">
                     <Text className="setting_cell_title" style={{ flex: 1 }}>At my scheduled time</Text>
-                    <Text className="setting_cell_value1">{systemFast ? 'Always' : 'Off'}</Text>
+                    {
+                        isLogin?<Text className="setting_cell_value1">{systemFast ? 'Always' : 'Off'}</Text>:
+                        <Text className="setting_cell_value1">Off</Text>
+                    }
+                    
                 </View>
                 <Text className="setting_footer">A timely reminder so you never miss your scheduled time for fasting or sleep.</Text>
                 <Text className="setting_header">Extra Reminders</Text>
                 <View className="setting_cell">
                     <Text className="setting_cell_title" style={{ flex: 1 }}>If I missed previous action</Text>
-                    <Switch className="myswitch" value={isExtra} color={ColorType.fast} trackColor={{ true: ColorType.fast }} onChange={(e) => {
-                        debugger
-                        // setIsMulti(e.nativeEvent.value)
+                    <Switch className="myswitch" value={isLogin?isExtra:false} color={ColorType.fast} trackColor={{ true: ColorType.fast }} onChange={(e) => {
+                        if (!isLogin){
+                            jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
+                            return
+                        }
                         const value = e.nativeEvent.value
                         postNotifySettings({
                             notification: {
@@ -261,8 +270,12 @@ export default function Page() {
                 <View className="setting_cell_group">
                     <View className="setting_cell_group_item">
                         <Text className="setting_cell_title" style={{ flex: 1 }}>Sunrise</Text>
-                        <Switch className="myswitch" value={isSunrise} color={ColorType.fast} trackColor={{ true: ColorType.fast }} onChange={(e) => {
+                        <Switch className="myswitch" value={isLogin?isSunrise:false} color={ColorType.fast} trackColor={{ true: ColorType.fast }} onChange={(e) => {
                             // setIsMulti(e.nativeEvent.value)
+                            if (!isLogin){
+                                jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
+                                return
+                            }
                             const value = e.nativeEvent.value
                             if (e.nativeEvent.value) {
                                 if (accessObj && accessObj.access && accessObj.access.member.status == 'NON_MEMBER') {
@@ -292,8 +305,12 @@ export default function Page() {
                     </View>
                     <View className="setting_cell_group_item">
                         <Text className="setting_cell_title" style={{ flex: 1 }}>Sunset</Text>
-                        <Switch className="myswitch" value={isSunset} trackColor={{ true: ColorType.fast }} color={ColorType.fast} onChange={(e) => {
+                        <Switch className="myswitch" value={isLogin?isSunset:false} trackColor={{ true: ColorType.fast }} color={ColorType.fast} onChange={(e) => {
                             // setIsMulti(e.nativeEvent.value)
+                            if (!isLogin){
+                                jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
+                                return
+                            }
                             const value = e.nativeEvent.value
                             if (e.nativeEvent.value) {
                                 if (accessObj && accessObj.access && accessObj.member.status == 'NON_MEMBER') {
@@ -322,8 +339,12 @@ export default function Page() {
                     </View>
                     <View className="setting_cell_group_item">
                         <Text className="setting_cell_title" style={{ flex: 1 }}>Solar Noon</Text>
-                        <Switch className="myswitch" value={isSolarNoon} trackColor={{ true: ColorType.fast }} color={ColorType.fast} onChange={(e) => {
+                        <Switch className="myswitch" value={isLogin?isSolarNoon:false} trackColor={{ true: ColorType.fast }} color={ColorType.fast} onChange={(e) => {
                             // setIsMulti(e.nativeEvent.value)
+                            if (!isLogin){
+                                jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
+                                return
+                            }
                             const value = e.nativeEvent.value
                             if (e.nativeEvent.value) {
                                 if (accessObj && accessObj.access && accessObj.member.status == 'NON_MEMBER') {
@@ -371,21 +392,16 @@ export default function Page() {
         return false;
     }
 
-    return <View className="container" style={{ flex: 1 }}>
-        {/* <View className='setting_segment'>
-            <Segment titles={[
-                `Free`,
-                `Pro`,
-            ]}
-                changed={(e) => {
-                    setSegmentIndex(e);
-                    // global.segmentIndex = e
-                    // console.log('segment item click', e)
-                }} />
-        </View> */}
+    if (!user.isLogin)
+        return <View className="container" style={{ flex: 1 }}>
+            {
+                pro(false)
+            }
+        </View>
 
+    return <View className="container" style={{ flex: 1 }}>
         {
-            loaded && pro()
+            loaded && pro(true)
         }
         {
             process.env.TARO_ENV == 'rn' && kIsAndroid && checkSystemChannel() && <View className="setting_tip" onClick={goSetting}>

+ 4 - 2
src/pages/store/product_list.tsx

@@ -4,7 +4,7 @@ import { View, Text, Image } from "@tarojs/components";
 import { useEffect, useState } from "react";
 import { FlatList, Pressable } from "react-native";
 import Purchases from 'react-native-purchases'
-import { useSelector } from "react-redux";
+import { useDispatch, useSelector } from "react-redux";
 import './product_list.scss'
 import { ColorType } from "@/context/themes/color";
 import { payInfo, products } from "@/services/user";
@@ -13,6 +13,7 @@ import showAlert from "@/components/basic/Alert";
 import { useTranslation } from "react-i18next";
 import { AtActivityIndicator } from "taro-ui";
 import NoData from "@/components/view/NoData";
+import { setAccessData } from "@/store/access";
 
 let useNavigation, TouchableOpacity;
 if (process.env.TARO_ENV == 'rn') {
@@ -20,7 +21,7 @@ if (process.env.TARO_ENV == 'rn') {
     TouchableOpacity = require('react-native').TouchableOpacity
 }
 export default function ProductList() {
-
+    const dispatch = useDispatch();
     const [packages, setPackages] = useState([]);
     const user = useSelector((state: any) => state.user);
     // - State for displaying an overlay view
@@ -142,6 +143,7 @@ export default function ProductList() {
                 store: kIsIOS ? 'app_store' : 'play_store',
                 storeProductIdentifier: item.product.identifier //后端要求额外传入商品id,用于同步数据,区别于productIdentifier
             }).then(res => {
+                dispatch(setAccessData(res))
                 global.paySuccess(res)
                 if (process.env.TARO_ENV == 'rn') {
                     navigation.pop(1)