content: /**
   * Created by Liyazhou on 16/8/28.
   */
  
  import React from 'react';
  import {View, Text, ScrollView, StyleSheet, TouchableOpacity, TextInput, AlertIOS, AsyncStorage} from 'react-native';
  import Util from './../util';
  import Service from './../service';
  
  export default class ModifyPassword extends React.Component {
  
      _getOldPassword(val) {
          this.setState({
              oldPassword: val,
          });
      }
      _getNewPassword(val) {
          this.setState({
              newPassword: val,
          });
      }
      _resetPassword() {
          let path = Service.host + Service.updatePassword;
          let that = this;
          AsyncStorage.getItem('token', function (err, data) {
              if (!err) {
                  Util.post(path,{token: data, password: this.state.newPassword, oldPassword:this.state.oldPassword}, function (data) {
                      if (data.status) {
                          AlertIOS.alert('成功', data.data);
                      } else {
                          AlertIOS.alert('失败', data.data);
                      }
                  });
              } else {
                  AlertIOS.alert('失败', data.data);
              }
          })
      }
      render() {
          return <ScrollView>
              <View style={{height:35, marginTop:30}}>
                  <TextInput style={styles.input}
                             password={true}
                             placeholder={'原始密码'}
                             onChangeText={(text)=>this._getOldPassword(text)}>
                  </TextInput>
              </View>
  
              <View style={{height:35, top:5}}>
                  <TextInput style={styles.input}
                             password={true}
                             onChangeText={(text)=>this._getNewPassword(text)}
                             placeholder={'新密码'}></TextInput>
              </View>
  
              <View>
                  <TouchableOpacity onPress={()=>this._resetPassword()}>
                      <View style={styles.btn}>
                          <Text style={{color: '#fff'}}>
                              修改密码
                          </Text>
                      </View>
                  </TouchableOpacity>
              </View>
          </ScrollView>
      }
  }
  
  const styles = StyleSheet.create({
      input: {
          flex:1,
          marginLeft:20,
          marginRight:20,
          height:50,
          borderWidth:1,
          borderColor:'#ddd',
          borderRadius:4,
          paddingLeft:5,
          fontSize:13,
      },
      btn: {
          justifyContent:'center',
          alignItems:'center',
          marginTop:20,
          backgroundColor:'#1db8ff',
          height:38,
          marginLeft:20,
          marginRight:20,
          borderRadius:4,
      },
  });