|
@@ -1,6 +1,6 @@
|
|
|
import React,{Component} from 'react';
|
|
|
import { StyleSheet, Text, View,Image } from 'react-native';
|
|
|
-import { List,ActionSheet } from 'antd-mobile-rn';
|
|
|
+import { List,ActionSheet,Toast } from 'antd-mobile-rn';
|
|
|
import { connect } from 'react-redux';
|
|
|
import LeanCloudAPI from '../../../leancloud';
|
|
|
import ImagePicker from 'react-native-image-crop-picker';
|
|
@@ -61,11 +61,13 @@ class Infomation extends Component {
|
|
|
switch(buttonIndex){
|
|
|
case 0 :
|
|
|
ImagePicker.openCamera(opction).then(image => {
|
|
|
-
|
|
|
- UserAction.head = `data:${image.mime};base64,${(new Buffer(image.data)).toString('base64')}`
|
|
|
- LeanCloudAPI.upFile(id+new Date().getTime(),UserAction.head,(res)=>{
|
|
|
- LeanCloudAPI.updateUser('head',res,id,(res1)=>{
|
|
|
- console.log(res1)
|
|
|
+ UserAction.head = image.path
|
|
|
+ let file= {filename:image.filename,height:400,isStored:false,type:image.mime,uri: image.path,width:400,localFile:image.path}
|
|
|
+ let name = (id+new Date().getTime() + image.filename +'').toLocaleLowerCase()
|
|
|
+ Toast.loading('头像修改中',50)
|
|
|
+ LeanCloudAPI.upFile(name,file,(e)=>{
|
|
|
+ LeanCloudAPI.updateUser('head',e,()=>{
|
|
|
+ Toast.success('修改成功')
|
|
|
navigation.dispatch({type:'USER',user:UserAction})
|
|
|
})
|
|
|
})
|
|
@@ -74,24 +76,18 @@ class Infomation extends Component {
|
|
|
case 1 :
|
|
|
|
|
|
ImagePicker.openPicker(opction).then(image => {
|
|
|
- console.log(image)
|
|
|
UserAction.head = image.path
|
|
|
- // 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)
|
|
|
- // // LeanCloudAPI.updateUser('head',res,id,(res1)=>{
|
|
|
- // // console.log(res1)
|
|
|
- // // navigation.dispatch({type:'USER',user:UserAction})
|
|
|
- // // })
|
|
|
- // })
|
|
|
+ let file= {filename:image.filename,height:400,isStored:false,type:image.mime,uri: image.path,width:400,localFile:image.path}
|
|
|
+ let name = (id+new Date().getTime() + image.filename +'').toLocaleLowerCase()
|
|
|
+ Toast.loading('头像修改中',50)
|
|
|
+ LeanCloudAPI.upFile(name,file,(e)=>{
|
|
|
+ LeanCloudAPI.updateUser('head',e,()=>{
|
|
|
+ Toast.success('修改成功')
|
|
|
+ navigation.dispatch({type:'USER',user:UserAction})
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
});
|
|
|
break;
|
|
|
}
|
|
@@ -101,13 +97,11 @@ class Infomation extends Component {
|
|
|
|
|
|
render(){
|
|
|
const {UserAction } =this.props
|
|
|
- const {imgsrc} = this.state
|
|
|
- console.log(imgsrc)
|
|
|
const { id ,username ,head,mobilePhoneNumber} =UserAction
|
|
|
- if(imgsrc){
|
|
|
+ if(head){
|
|
|
source = {
|
|
|
- uri:imgsrc,
|
|
|
- // cache: 'force-cache'
|
|
|
+ uri:head,
|
|
|
+ cache: 'force-cache'
|
|
|
}
|
|
|
}else{
|
|
|
source = require('../../../../assets/icon.png')
|
|
@@ -119,10 +113,12 @@ class Infomation extends Component {
|
|
|
style={commonStyle.item}
|
|
|
onClick={()=>{this.showActionSheet()}}
|
|
|
extra={
|
|
|
- <Image
|
|
|
- source={{uri:imgsrc}}
|
|
|
+ <View style={{ width: 29, height: 29 ,borderRadius:5,overflow:'hidden'}}>
|
|
|
+ <Image
|
|
|
+ source={source}
|
|
|
style={{ width: 29, height: 29 }}
|
|
|
/>
|
|
|
+ </View>
|
|
|
}
|
|
|
arrow="horizontal"
|
|
|
>
|