Jelajahi Sumber

1.个人信息界面请求接口

zhangmengjie 5 tahun lalu
induk
melakukan
e0f59fc399
1 mengubah file dengan 8 tambahan dan 11 penghapusan
  1. 8 11
      pages/components/PersonalInfo.js

+ 8 - 11
pages/components/PersonalInfo.js

@@ -645,14 +645,10 @@ export default class PersonalInfo extends BasePage {
   updateState(input_text, type) {
     if (type == 1) {
       this.setState({ nickName: input_text });
-      let formData = new FormData();
-      formData.append("nickName", input_text);
-      this.updateUserInfo(formData);
+      this.updateUserInfo({ nickName: input_text });
     } else if (type == 2) {
       this.setState({ schoolName: input_text });
-      let formData = new FormData();
-      formData.append("school", input_text);
-      this.updateUserInfo(formData);
+      this.updateUserInfo({ school: input_text });
     }
   }
 
@@ -661,17 +657,21 @@ export default class PersonalInfo extends BasePage {
       provinceName: provinces_name,
       citys: citys_name
     });
+    this.updateUserInfo({ province: provinces_name, city: citys_name });
   }
   commitGrade(text, index) {
     this.setState({
       grade_text: text,
       grade_index: index
     });
+    this.updateUserInfo({ grade: index + 1 });
   }
   birthdaycommit(year, month, day) {
     this.setState({
       birthday_time: year + "年" + month + "月" + day + "日"
     });
+    var date = new Date(year + "-" + month + "-" + day);
+    this.updateUserInfo({ birthday: date });
   }
 
   photoback(photo_uri) {
@@ -683,13 +683,10 @@ export default class PersonalInfo extends BasePage {
     });
   }
 
-  updateUserInfo(formData) {
-    console.log(formData)
+  updateUserInfo(object) {
     let opts = {
       method: "PUT", //请求方法
-      body: {
-        nickName: '测试测试'
-      }
+      body: object //请求体
     };
     user.update_UserInfo(opts).then(res => {
       console.log(res);