|
@@ -1,10 +1,10 @@
|
|
|
import React,{Component} from 'react';
|
|
|
|
|
|
-import { StyleSheet, Text, View } from 'react-native';
|
|
|
-import Button from 'antd-mobile-rn/lib/button';
|
|
|
-import { List ,InputItem, WhiteSpace, WingBlank} from 'antd-mobile-rn';
|
|
|
+import { StyleSheet, Text, View ,AsyncStorage} from 'react-native';
|
|
|
+import { List ,InputItem, WhiteSpace, WingBlank,Button,Toast} from 'antd-mobile-rn';
|
|
|
import {connect} from 'react-redux';
|
|
|
import commonStyle from '../../../styles/styles.js';
|
|
|
+import Leancloud from '../../../leancloud/index.js';
|
|
|
const Item = List.Item;
|
|
|
const Brief = Item.Brief;
|
|
|
|
|
@@ -13,17 +13,44 @@ class RePassword extends Component {
|
|
|
super(props);
|
|
|
this.state = {
|
|
|
value: '15528300169',
|
|
|
+ password:'',
|
|
|
+ newpassword:''
|
|
|
};
|
|
|
}
|
|
|
static navigationOptions ={
|
|
|
title:'修改密码'
|
|
|
}
|
|
|
+ componentWillMount(){
|
|
|
+ const {UserAction } =this.props
|
|
|
+ this.setState({
|
|
|
+ value:UserAction.mobilePhoneNumber
|
|
|
+ })
|
|
|
+ }
|
|
|
+ submit(){
|
|
|
+ const {password ,newpassword } =this.state
|
|
|
+ const {navigation} =this.props
|
|
|
+
|
|
|
+ if(password!=Leancloud.password){
|
|
|
+ return alert('原密码错误')
|
|
|
+ }
|
|
|
+ if(newpassword.length<8){
|
|
|
+ return alert('密码长度有误!请重试')
|
|
|
+ }
|
|
|
+ Leancloud.updateUser('password',this.state.newpassword,(e)=>{
|
|
|
+
|
|
|
+ Toast.success('密码修改成功,请重新登录')
|
|
|
+ AsyncStorage.clear()
|
|
|
+ navigation.navigate({ routeName:'Login' })
|
|
|
+ })
|
|
|
+ // Leancloud
|
|
|
+ }
|
|
|
render(){
|
|
|
const {UserAction} = this.props
|
|
|
return (
|
|
|
<View style={commonStyle.PAGE}>
|
|
|
- <List style={commonStyle.list}>
|
|
|
+ <List style={styles.list}>
|
|
|
<InputItem
|
|
|
+ style={styles.item}
|
|
|
// clear
|
|
|
type='phone'
|
|
|
editable={false}
|
|
@@ -32,30 +59,38 @@ class RePassword extends Component {
|
|
|
placeholder="手机号"
|
|
|
/>
|
|
|
</List>
|
|
|
- <List style={commonStyle.list}>
|
|
|
+ <List style={styles.list}>
|
|
|
<InputItem
|
|
|
clear
|
|
|
- // value={this.state.value}
|
|
|
type='password'
|
|
|
- onChange={() => {
|
|
|
+ style={styles.item}
|
|
|
+ onChange={(password) => {
|
|
|
+
|
|
|
+ this.setState({
|
|
|
+ password
|
|
|
+ })
|
|
|
|
|
|
}}
|
|
|
placeholder="请输入原密码"
|
|
|
/>
|
|
|
</List>
|
|
|
- <List style={commonStyle.list}>
|
|
|
+ <List style={styles.list}>
|
|
|
<InputItem
|
|
|
clear
|
|
|
- // value={this.state.value}
|
|
|
type='password'
|
|
|
- onChange={() => {
|
|
|
-
|
|
|
+ style={styles.item}
|
|
|
+ onChange={(newpassword) => {
|
|
|
+ this.setState({
|
|
|
+ newpassword
|
|
|
+ })
|
|
|
}}
|
|
|
placeholder="请输入新密码(8位及以上)"
|
|
|
/>
|
|
|
</List>
|
|
|
<WingBlank style={styles.botton}>
|
|
|
- <Button style={styles.pressBotton}>
|
|
|
+ <Button style={styles.pressBotton} onClick={()=>{
|
|
|
+ this.submit()
|
|
|
+ }}>
|
|
|
<Text style={styles.save}>保存</Text>
|
|
|
</Button>
|
|
|
</WingBlank>
|
|
@@ -70,6 +105,17 @@ const mapStateToProps = ({UserAction} )=> {
|
|
|
export default connect(mapStateToProps)(RePassword);
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
+ list:{
|
|
|
+ // height:50,
|
|
|
+ // alignItems: 'center',
|
|
|
+ justifyContent: 'center',
|
|
|
+ marginBottom:10,
|
|
|
+
|
|
|
+ },
|
|
|
+ item:{
|
|
|
+ height:50,
|
|
|
+ paddingTop:5
|
|
|
+ },
|
|
|
botton:{
|
|
|
marginTop:29,
|
|
|
},
|