wennjie il y a 6 ans
Parent
commit
881d7a22c7

+ 1 - 7
huiliaoAPP/ios/huiliaoAPP.xcodeproj/project.pbxproj

@@ -5,7 +5,6 @@
 	};
 	objectVersion = 46;
 	objects = {
-
 /* Begin PBXBuildFile section */
 		00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
 		00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
@@ -646,6 +645,7 @@
 			isa = PBXGroup;
 			children = (
 				3B01B1EB32104611B4BD75FB /* libimageCropPicker.a */,
+				C77E7DF77A4B4C64BAB6BFC8 /* libRNFileSystem.a */,
 			);
 			name = "Recovered References";
 			sourceTree = "<group>";
@@ -1250,7 +1250,6 @@
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
 				LIBRARY_SEARCH_PATHS = (
 					"$(inherited)",
-					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 				);
 				OTHER_LDFLAGS = (
 					"-ObjC",
@@ -1275,7 +1274,6 @@
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
 				LIBRARY_SEARCH_PATHS = (
 					"$(inherited)",
-					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 				);
 				OTHER_LDFLAGS = (
 					"-ObjC",
@@ -1353,7 +1351,6 @@
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
 				LIBRARY_SEARCH_PATHS = (
 					"$(inherited)",
-					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 				);
 				OTHER_LDFLAGS = (
 					"-ObjC",
@@ -1387,7 +1384,6 @@
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
 				LIBRARY_SEARCH_PATHS = (
 					"$(inherited)",
-					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 				);
 				OTHER_LDFLAGS = (
 					"-ObjC",
@@ -1420,7 +1416,6 @@
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
 				LIBRARY_SEARCH_PATHS = (
 					"$(inherited)",
-					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 				);
 				OTHER_LDFLAGS = (
 					"-ObjC",
@@ -1453,7 +1448,6 @@
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
 				LIBRARY_SEARCH_PATHS = (
 					"$(inherited)",
-					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 				);
 				OTHER_LDFLAGS = (
 					"-ObjC",

+ 1 - 0
huiliaoAPP/package.json

@@ -16,6 +16,7 @@
     "prop-types": "^15.5.10",
     "react": "16.4.1",
     "react-native": "0.56.0",
+    "react-native-filesystem": "^0.1.0",
     "react-native-image-crop-picker": "^0.21.1",
     "react-native-keyboard-aware-scroll-view": "^0.7.0",
     "react-native-qrcode": "^0.2.7",

+ 16 - 8
huiliaoAPP/src/leancloud/index.js

@@ -10,6 +10,8 @@ class LeanCloudAPI {
       this.realtime = null;
       this.imClient = null;
       this.username = null;
+      this.userID = null ;
+      this.password = null;
     }
   
     init() {
@@ -27,7 +29,8 @@ class LeanCloudAPI {
       this.AV.User.logInWithMobilePhone(telphone, password).then((res)=>{
         Toast.success('登录成功',1)
         this.user = res.attributes
-
+        this.userID = res.id
+        this.password = password
         AsyncStorage.setItem('USERINFO',JSON.stringify({telphone,password}))
         AsyncStorage.setItem('USER',JSON.stringify(this.user))
         navigation.dispatch({type:'AV',AV:this.AV})
@@ -37,21 +40,26 @@ class LeanCloudAPI {
         Toast.info(err.rawMessage)
       })
     }
-    updateUser(key,val,id,callback){
-
-      this.AV.Query.doCloudQuery(`update User set ${key}=${val} where id=${id}`)
+    queryPassword(){
+      const query = new AV.Query('_User');
+      query.get(this.userID).then(function (res) {
+        console.log(res)
+        // 成功获得实例
+        // todo 就是 id 为 57328ca079bc44005c2472d0 的 Todo 对象实例
+      }, function (error) {
+        // 异常处理
+      });
+    }
+    updateUser(key,val,callback){
+      this.AV.Query.doCloudQuery(`update _User set ${key}="${val}" where objectId="${this.userID}"`)
       .then(function (data) {
         // data 中的 results 是本次查询返回的结果,AV.Object 实例列表
         var results = data.results;
         callback(results)
       }, function (err) {
         // 异常处理
-        console.error(err);
         Toast.info(err.rawMessage)
       });
-
-
-      callback()
     }
     upFile(name,data,callback) {
       console.log(name, localFile)

+ 3 - 1
huiliaoAPP/src/pages/Login/index.js

@@ -44,7 +44,9 @@ class LoginScreen extends Component{
     const {telphone,password} = this.state
     return (
       <View style={[commonStyle.page,{backgroundColor:'#fff'}]}>
-      <KeyboardAwareScrollView>
+      <KeyboardAwareScrollView
+      extraScrollHeight={50}
+      >
       <StatusBar  
          animated={true} //指定状态栏的变化是否应以动画形式呈现。目前支持这几种样式:backgroundColor, barStyle和hidden  
          hidden={true}  //是否隐藏状态栏。  

+ 11 - 9
huiliaoAPP/src/pages/Mine/Infomation/index.js

@@ -4,8 +4,10 @@ import { List,ActionSheet } from 'antd-mobile-rn';
 import { connect } from 'react-redux';
 import LeanCloudAPI from '../../../leancloud';
 import ImagePicker from 'react-native-image-crop-picker';
-const Buffer = require('buffer').Buffer;
+// const Buffer = require('buffer').Buffer;
 import commonStyle from '../../../styles/styles.js';
+// import FileSystem from 'react-native-filesystem';
+
 
 
 const Item = List.Item;
@@ -55,9 +57,6 @@ class Infomation extends Component {
                 cropperToolbarColor:"#1c90f5",
                 compressImageQuality:0.8,
                 hideBottomControls:true,
-                writeTempFile:true,
-                includeBase64:true,
-                includeExif:true
             }
             switch(buttonIndex){
                 case  0 :
@@ -77,11 +76,14 @@ class Infomation extends Component {
                 ImagePicker.openPicker(opction).then(image => {
                     console.log(image)
                     UserAction.head = image.path
-                    let imgsrc  =  `data:${image.mime};base64,${(new Buffer(image.data)).toString('base64')}`
-
-                    this.setState({
-                        imgsrc
-                    })
+                    // FileSystem.readFile(image.sourceURL).then(res=>{
+                    //     console.log(res)
+                    // },err=>{
+                    //     console.log(err)
+                    // })
+                    // const absoluteFile = FileSystem.absolutePath(image.path);
+                    // console.log('absoluteFile = ', absoluteFile)
+                   
                     // let imgname= (id+new Date().getTime()+image.fileName+"").toLowerCase()
                     // LeanCloudAPI.upFile(imgname,formData,(res)=>{
                     //     console.log(res)

+ 31 - 6
huiliaoAPP/src/pages/Mine/ReName/index.js

@@ -3,6 +3,7 @@ import { StyleSheet, Text, View } from 'react-native';
 import { List ,InputItem, WingBlank,Button} from 'antd-mobile-rn';
 import commonStyle from '../../../styles/styles.js';
 import {connect} from 'react-redux'
+import Leancloud from '../../../leancloud'
 const Item = List.Item;
 const Brief = Item.Brief;
 
@@ -10,30 +11,54 @@ class ReName extends Component {
     constructor(props) {
         super(props);
         this.state = {
-          value: '马冬梅',
+          value: '',
         };
       }
+      componentWillMount(){
+          console.log(this.props)
+        const {UserAction} = this.props
+        const {username} =UserAction
+        this.setState({
+            value :  username
+        })
+
+      }
       static navigationOptions ={
         title:'设置昵称'
       }
-    render(){
+      submit(){
+        console.log(this.props)
         const {UserAction,navigation} = this.props
-        const {username} =UserAction
+        const {id} =UserAction
+        UserAction.username = this.state.value
+        
+        Leancloud.updateUser('username',this.state.value,(e)=>{
+            navigation.dispatch({type:'USER',user:UserAction})
+            navigation.goBack()
+        })
+        // Leancloud
+    }
+    render(){
+        
         return (
             <View style={commonStyle.page}>
                 <List style={commonStyle.list}>  
                     <InputItem
                         clear
-                        value={username}
+                        value={this.state.value}
                         onChange={(value) => {
-                        //   navigation.dispatch('USER',)
+                        this.setState({
+                            value
+                        })
                 
                         }}
                         placeholder="昵称"
                     />
                 </List>
                 <WingBlank style={styles.botton}>
-                    <Button style={styles.pressBotton}>
+                    <Button style={styles.pressBotton} onClick={()=>{
+                        this.submit()
+                    }}>
                         <Text style={styles.save}>保存</Text>
                     </Button>
                 </WingBlank>

+ 58 - 12
huiliaoAPP/src/pages/Mine/RePassword/index.js

@@ -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,
    },

+ 4 - 1
huiliaoAPP/src/pages/Mine/Setting/index.js

@@ -1,6 +1,6 @@
 
 import React,{Component} from 'react';
-import { StyleSheet, Text, View } from 'react-native';
+import { StyleSheet, Text, View,AsyncStorage } from 'react-native';
 import { List,Button } from 'antd-mobile-rn';
 import commonStyle from '../../../styles/styles.js';
 
@@ -14,6 +14,9 @@ export default class Setting extends Component {
       title:'安全设置'
     }
     push(routeName){
+      if(routeName=='Login'){
+        AsyncStorage.clear()
+      }
         const { navigation } =this.props
         navigation.navigate({ routeName })
     }

+ 2 - 0
huiliaoAPP/src/styles/styles.js

@@ -21,6 +21,8 @@ const styles = StyleSheet.create({
     list:{
         height:50,
         marginBottom:10,
+        
+
     },
     item:{
         height:50

+ 4 - 0
huiliaoAPP/yarn.lock

@@ -5471,6 +5471,10 @@ react-native-drawer-layout@1.3.2, react-native-drawer-layout@~1.3.0:
   dependencies:
     react-native-dismiss-keyboard "1.0.0"
 
+react-native-filesystem@^0.1.0:
+  version "0.1.0"
+  resolved "http://registry.npm.taobao.org/react-native-filesystem/download/react-native-filesystem-0.1.0.tgz#b66eebbfa046ac12cb5d2503eda78641fca58c23"
+
 react-native-image-crop-picker@^0.21.1:
   version "0.21.1"
   resolved "https://registry.yarnpkg.com/react-native-image-crop-picker/-/react-native-image-crop-picker-0.21.1.tgz#0903b11644e88cca3d178e3a16b451a310969b8b"