wennjie 6 years ago
parent
commit
bacd74e713

+ 1 - 4
huiliaoAPP/src/leancloud/index.js

@@ -62,14 +62,11 @@ class LeanCloudAPI {
       });
     }
     upFile(name,data,callback) {
-      console.log(name, localFile)
       const file = new AV.File(name, {
         blob: data
-      },'multipart/form-data');
-      console.log(file)
+      });
       file.save().then(function(file) {
         // 文件保存成功
-        console.log(file.url());
         // var url = file.thumbnailURL(100, 200);
         callback(file.url())
       }, function(err) {

+ 26 - 30
huiliaoAPP/src/pages/Mine/Infomation/index.js

@@ -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"
                     >

+ 1 - 1
huiliaoAPP/src/pages/Mine/QrCode/index.js

@@ -93,7 +93,7 @@ const styles = StyleSheet.create({
       borderRadius:9,
     },
     headTille:{
-      
+      marginLeft:15
     },
     nickName:{
       lineHeight:31,

+ 6 - 4
huiliaoAPP/src/pages/Mine/index.js

@@ -34,10 +34,12 @@ class Mine extends Component {
                         style={styles.headItem}
                         onClick={()=>{this.push('Infomation')}}
                         thumb={
-                            <Image
-                            source={source}
-                            style={{ width: 50, height: 50,marginRight:12 }}
-                            />
+                            <View style={{width:50,height:50,marginRight:12,borderRadius:5,overflow:'hidden'}}>
+                                <Image
+                                source={source}
+                                style={{ width: 50, height: 50 }}
+                                />
+                            </View>
                         }
                         extra={
                         <Image