<div className={styles.cf_tx}>
<label htmlFor="txsc">
<img src={data?(APIHost+data.us_portrait):tx} />
</label>
<input type="file" style={{ display: 'none' }} onChange={(e)=>{(123);this.informationList(e)}} id="txsc" />
<span>点击修改头像</span>
</div>
//上传头像图片需转化为base64位
informationList= async(e)=>{ //base64
//const { dispatch } = this.props;
//const _this = this;
var reader = new FileReader();
reader.readAsDataURL(e.target.files[0]);
Toast.loading("正在上传头像", 0);
reader.onloadend = async (e) => {
const params ={
headimg:reader.result,
type:1
}
const result = await home.xgheader(params);
Toast.hide()
if(result.code == 1){
home.Usercenter({}).then((result) => {
if (result.code === 1) {
this.setState({
data: result.data
})
}
})
Toast.info('上传成功')
}else{
Toast.info('上传失败,请重新上传',1.5)
}
}
}