zhangmengjie преди 5 години
родител
ревизия
d7b18ee528
променени са 5 файла, в които са добавени 54 реда и са изтрити 27 реда
  1. 27 3
      pages/components/PersonalInfo.js
  2. 1 9
      pages/components/PersonalInfoDialog.js
  3. 1 1
      pages/components/RegionModal.js
  4. 15 14
      pages/services/api.js
  5. 10 0
      pages/services/user.js

+ 27 - 3
pages/components/PersonalInfo.js

@@ -32,6 +32,7 @@ import Header from "./Header";
 import PersonalInfoDialog from "./PersonalInfoDialog";
 import { NavigationActions, StackActions } from "react-navigation";
 import asyncStorage from "../utils/asyncStorage";
+import user from "../services/user";
 type Props = {};
 
 export default class PersonalInfo extends BasePage {
@@ -48,9 +49,7 @@ export default class PersonalInfo extends BasePage {
     birthday_time: 0,
     photo_uri: require("../images/userInfo/default_photo.png")
   };
-  updateState(data) {
-    this.setState(data);
-  }
+
   render() {
     return (
       <View style={{ backgroundColor: "#F0F1F5", flex: 1 }}>
@@ -643,6 +642,20 @@ export default class PersonalInfo extends BasePage {
     this.props.navigation.dispatch(resetAction);
   }
 
+  updateState(input_text, type) {
+    if (type == 1) {
+      this.setState({ nickName: input_text });
+      let formData = new FormData();
+      formData.append("nickName", input_text);
+      this.updateUserInfo(formData);
+    } else if (type == 2) {
+      this.setState({ schoolName: input_text });
+      let formData = new FormData();
+      formData.append("school", input_text);
+      this.updateUserInfo(formData);
+    }
+  }
+
   cityscommit(provinces_name, citys_name) {
     this.setState({
       provinceName: provinces_name,
@@ -669,6 +682,17 @@ export default class PersonalInfo extends BasePage {
       photo_uri: { uri: photo_uri }
     });
   }
+
+  updateUserInfo(formData) {
+    let opts = {
+      method: "PUT", //请求方法
+      body: formData //请求体
+    };
+    user.update_UserInfo(opts).then(res => {
+      console.log(res);
+      console.log("success");
+    });
+  }
 }
 
 const styles = StyleSheet.create({

+ 1 - 9
pages/components/PersonalInfoDialog.js

@@ -78,15 +78,7 @@ export default class PersonalInfoDialog extends Component<Props> {
     });
   }
   setParentState() {
-    let data;
-    if (this.state.updateType == 1) {
-      data = { nickName: this.state.input_text };
-    } else if (this.state.updateType == 2) {
-      data = {
-        schoolName: this.state.input_text
-      };
-    }
-    this.props.updateParentState(data);
+    this.props.updateParentState(this.state.input_text, this.state.updateType);
     this.setModalVisible(false);
   }
   componentWillMount() {

+ 1 - 1
pages/components/RegionModal.js

@@ -308,7 +308,7 @@ export default class RegionModal extends Component<Props> {
     this.state.city_views = [];
     for (var i = 0; i < citys.length; i++) {
       let index = i;
-      console.log("this.state.city_views_index:" + this.state.city_views_index);
+      // console.log("this.state.city_views_index:" + this.state.city_views_index);
       if (this.state.city_views_index == i) {
         textstyle = styles.item_text_click;
       } else {

+ 15 - 14
pages/services/api.js

@@ -1,17 +1,18 @@
-
 const url = {
-    library_url: 'http://ott80testlibrary.yifangjiaoyu.cn/mobile/page',
-    schedule_url: 'http://ott80test-schedule.yifangjiaoyu.cn/mobile/schedule/'
-}
-
+  library_url: "http://ott80testlibrary.yifangjiaoyu.cn/mobile/page",
+  schedule_url: "http://ott80test-schedule.yifangjiaoyu.cn/mobile/schedule/",
+  user_url: "http://ott80test-base.yifangjiaoyu.cn/mobile/user"
+};
 
 export default class APIConfig {
-    
-    static getLibraryUrl(path){
-        return url.library_url + path
-    }
-    static getScheduleUrl(path){
-        console.log(33333,url.schedule_url + path)
-        return url.schedule_url + path
-    }
-} 
+  static getLibraryUrl(path) {
+    return url.library_url + path;
+  }
+  static getScheduleUrl(path) {
+    console.log(33333, url.schedule_url + path);
+    return url.schedule_url + path;
+  }
+  static getUserUrl(path) {
+    return url.user_url + path;
+  }
+}

+ 10 - 0
pages/services/user.js

@@ -0,0 +1,10 @@
+import APIConfig from "./api.js";
+import efunRequest from "../utils/efunRequest";
+import request from "../utils/request";
+
+export default class user {
+  static update_UserInfo(opts) {
+    console.log(opts);
+    return request(APIConfig.getUserUrl(``), opts);
+  }
+}