罗广聪

貌似全部OK了

@@ -70,14 +70,78 @@ export default class Mine extends Component { @@ -70,14 +70,78 @@ export default class Mine extends Component {
70 ); 70 );
71 } 71 }
72 saveResponse1(d) { 72 saveResponse1(d) {
73 - if (this.state.IS_LOGIN == "yes") { 73 + let that = this,
74 - this.setState({ NICKNAME: d }); 74 + formData = new FormData();
  75 + if (that.state.IS_LOGIN != "yes") {
  76 + alert("请先登录账号");
  77 + return false;
  78 + }
  79 + formData.append("user", this.state.USER_ID);
  80 + formData.append("profession", "");
  81 + formData.append("nickname", d);
  82 + return fetch(`https://devpay.brae.co/test/insurance/change`, {
  83 + method: "POST",
  84 + headers: {
  85 + Accept: "application/json",
  86 + "Content-Type": "application/json"
  87 + },
  88 + body: formData
  89 + })
  90 + .then(resp => {
  91 + if (resp.status === 200) {
  92 + return resp.json();
  93 + } else {
  94 + console.error("something went wrong!");
  95 + }
  96 + })
  97 + .then(respJson => {
  98 + if (respJson.enmsg != "ok") {
  99 + alert(respJson.cnmsg);
  100 + } else {
  101 + AsyncStorage.setItem("NICKNAME",d).then(() => {
  102 + console.log("保存修改成功");
  103 + that.setState({ NICKNAME: d });
  104 + })
75 } 105 }
  106 + })
  107 + .catch(err => console.error(err));
76 } 108 }
77 saveResponse2(d) { 109 saveResponse2(d) {
78 - if (this.state.IS_LOGIN == "yes") { 110 + let that = this,
79 - this.setState({ identity: d }); 111 + formData = new FormData();
  112 + if (that.state.IS_LOGIN != "yes") {
  113 + alert("请先登录账号");
  114 + return false;
  115 + }
  116 + formData.append("user", this.state.USER_ID);
  117 + formData.append("profession", d);
  118 + formData.append("nickname", "");
  119 + return fetch(`https://devpay.brae.co/test/insurance/change`, {
  120 + method: "POST",
  121 + headers: {
  122 + Accept: "application/json",
  123 + "Content-Type": "application/json"
  124 + },
  125 + body: formData
  126 + })
  127 + .then(resp => {
  128 + if (resp.status === 200) {
  129 + return resp.json();
  130 + } else {
  131 + console.error("something went wrong!");
  132 + }
  133 + })
  134 + .then(respJson => {
  135 + if (respJson.enmsg != "ok") {
  136 + alert(respJson.cnmsg);
  137 + } else {
  138 + AsyncStorage.setItem("PROFESSION",d).then(() => {
  139 + console.log("保存修改成功");
  140 + that.setState({ PROFESSION: d });
  141 + })
80 } 142 }
  143 + })
  144 + .catch(err => console.error(err));
81 } 145 }
82 render() { 146 render() {
83 const { navigate } = this.props.navigation; 147 const { navigate } = this.props.navigation;
@@ -96,15 +160,9 @@ export default class Mine extends Component { @@ -96,15 +160,9 @@ export default class Mine extends Component {
96 style={styles.mineIcon} 160 style={styles.mineIcon}
97 /> 161 />
98 )} 162 )}
99 - {/* <Image  
100 - source={require("../../assets/Mine/iconpic1.png")}  
101 - style={styles.mineIcon}  
102 - />  
103 - <Image  
104 - source={require("../../assets/Mine/iconpic_gray.png")}  
105 - style={styles.mineIcon}  
106 - /> */}  
107 </View> 163 </View>
  164 +
  165 + {/* 设置昵称和职业 */}
108 <View style={styles.midContainer}> 166 <View style={styles.midContainer}>
109 {/* 更改昵称 */} 167 {/* 更改昵称 */}
110 <TouchableOpacity 168 <TouchableOpacity