자유해결사 5 years ago
parent
commit
c22573d81c

+ 2 - 2
android/app/build.gradle

@@ -136,8 +136,8 @@ android {
         applicationId "org.seonsujoa.emptyapp"
         minSdkVersion rootProject.ext.minSdkVersion
         targetSdkVersion rootProject.ext.targetSdkVersion
-        versionCode 1
-        versionName "1.0"
+        versionCode 3
+        versionName "1.2"
         multiDexEnabled true
     }
     splits {

+ 1 - 1
src/navigation/SwitchNavigator.js

@@ -57,7 +57,7 @@ const SwitchNavigator = createStackNavigator(
     
   }, 
   {
-    initialRouteName: "Login",   
+    initialRouteName: "Login",    
  
     mode: 'modal', 
     headerMode: 'none',

+ 2 - 1
src/pages/_1_Login.js

@@ -18,13 +18,14 @@ export default (props)=>{
     }, [])
     let onlogin = async (loginInfo, bfirst )=>{
         // console.log(loginInfo)
-        Net.login(loginInfo) 
+        await Net.login(loginInfo) 
         let bTerms = JSON.parse(await AsyncStorage.getItem("@terms"))
 
         if(bfirst || !bTerms){   
           props.navigation.navigate('AcceptTerms');
         }else{   
           props.navigation.navigate('Root'); 
+        // props.navigation.navigate('AccountInfo');    
         } 
     }
     return (

+ 67 - 23
src/popup/_10_1_AccountInfo.js

@@ -1,16 +1,28 @@
-import React, {useEffect} from 'react';
+import React, {useEffect, useState} from 'react';
+import {Alert} from 'react-native' 
  
 import i18n from  "i18n-js";
 import C from 'rn-class'
 import {LM} from '../provider/Auth'
+import Net from '../provider/Net';
+import _ from 'lodash'
 
+userInfoObj = {
+    name : {
+        value : "",
+        icon : {type:"antdesign" , name:"user"},
+        placeholder : "name"
+    },
+    email : {
+        value : "",
+        icon : {type:"material-community" , name:"email-outline"},
+        placeholder : "email"
+    }
+}
 export default (props)=>{
     let {UpdateyourAccountDetails} = i18n.t("AccountInfo")
-    let userInfoArr =[ 
-                                        { key : ""  , icon : {type:"antdesign" , name:"user" }} , 
-                                        { key : "" , icon : {type:"material-community" , name:"email-outline" } } ,
-                                        { key : "" , icon : {type:"material-community" , name:"lock-outline" }  , input : true } 
-                                    ]
+ 
+    let [userInfo , setUserInfo] = useState({});
    
     let closeFunc  = ()=>{
         props.navigation.goBack();
@@ -22,24 +34,43 @@ export default (props)=>{
 
     }
     let getUserInfo = async ()=>{
-        // console.log(await ) 
+        // console.log(await )
+        let {result} = await Net.me(); 
+        console.log("[" , userInfoObj);
+        userInfoObj.name.value =  result.name;
+        userInfoObj.email.value = result.email;
+        userInfo = userInfoObj;
+        setUserInfo(userInfoObj);  
+        // console.log(userInfo)  
+    }
+    let updateMe = async()=>{
+        let user = await Net.updateMe({name :userInfo.name.value , email : userInfo.email.value});
+        // console.log(user).;
+        if(user.status == 200){
+            Alert.alert("저장 되었습니다.")
+            getUserInfo();
+        }
+        
     }
     useEffect(()=>{
-
-    }, [])
+        getUserInfo();
+    }, [])  
     return (
         <C.View cls="flx1 bgc-color-white ai-c jc-sa"> 
-          <C.EL.Header 
+          <C.EL.Header  
             ccls="bgc-color-transparent" 
             leftComponent={<C.EL.Icon type="antdesign" name="close" onPress={()=>props.navigation.goBack()}/>}  
         >
+        
         </C.EL.Header>
+         <C.EL.Button  ccls="w100 " btncls="r5 mt-10 po-ab" title="Save" onPress={updateMe}/>
         <C.View cls="mt3">
             <C.EL.Avatar  source={require("../res/header_bubble.png")}   size="xlarge" resizeMode="contain"  showEditButton rounded/>
+            
         </C.View>
 
         <C.View cls="mt3">
-            <C.Text cls="f2.5">
+            <C.Text cls="f2.5"> 
                 {UpdateyourAccountDetails}
             </C.Text> 
             <C.Text  cls="f2.5">      
@@ -49,21 +80,33 @@ export default (props)=>{
 
         {/* <C.View cls="mt2 w100% flx1 ai-c">   */}
             {
-                userInfoArr.map((obj, i )=>{
-                    let {key, icon, input } = obj;
+                // console.log(userInfo , " > ") 
+                Object.keys(userInfo).map((key , i )=>{
+                    let {value , icon, placeholder} =  userInfo[key];
+                    console.log(userInfo[key]) 
                     return (
-                        <C.View key={`item_${i}`} cls="w90% h8 br5 mt3 flx-row ai-c"> 
+                        <C.View key={`item_${i}`} cls="w100% h8 br5 mt3 flx-row ai-c jc-c ph10"> 
                             <C.EL.Icon {...icon} ccls="mh4" raised/>
-                            {
-                                input  ? (
-                                    <C.TextInput secureTextEntry  value={key} /> 
-                                ) : (
-                                    <C.Text>{key}</C.Text> 
-                                )
-                            }
-                        </C.View>
+                                <C.EL.Input  value={value}   placeholder={placeholder}  onChangeText={(t)=>{userInfo[key] .value= t;setUserInfo(_.clone(userInfo));   }}/>    
+                        </C.View>      
+
                     )
-                })
+                })  
+                // userInfoArr.map((obj, i )=>{
+                //     let {key, icon, input, value } = obj;
+                //     return (
+                //         <C.View key={`item_${i}`} cls="w90% h8 br5 mt3 flx-row ai-c"> 
+                //             <C.EL.Icon {...icon} ccls="mh4" raised/>
+                //             {
+                //                 input  ? (
+                //                     <C.TextInput  value={value} /> 
+                //                 ) : (
+                //                     <C.Text>{value}</C.Text> 
+                //                 )
+                //             }
+                //         </C.View>
+                //     )
+                // })
             }
 
         {/* </C.View> */}
@@ -72,6 +115,7 @@ export default (props)=>{
 
         </C.View> */} 
 
+           
             <C.EL.Button  title="LogOut" onPress={logout}>
             
             </C.EL.Button>

+ 9 - 4
src/provider/Net.js

@@ -9,7 +9,7 @@ axios.defaults.headers.post['Content-Type'] = 'application/json';
 let meToken = "";
 axios.interceptors.request.use(config =>{
     if(config.url == "/auth" || config.url == "/me"){config.headers.interfaceId = 'auth';}
-    if(config.url == "/me"){ config.url += `?token=${meToken}`;}
+    if(config.url == "/me"){ config.url += `/${meToken}`;}
     if(config.url == "/meditation"){config.headers.interfaceId = 'meditation';}
     // if(config.url == "/bbs"){config.headers.interfaceId = 'bbs';}
     
@@ -35,9 +35,14 @@ class Net {
         
     }
     async me(obj){
-        let {data} =    await axios.get("/me",{} );
-        // console.log(" :::: " , data);       
-    }  
+        let {data} =    await axios.get(`/me/${meToken}` );
+        return data;      
+    }   
+    async updateMe(obj){
+        let {data} =    await axios.post(`/me/${meToken}`, obj );
+        return data;
+    }   
+
 
     async meditation (obj){
         let {data} =    await axios.post("/meditation",obj);