<template>
	<view>
		<view class="avatar">
			<u-avatar @click="changeAvatar()" :src="Info.avatar"></u-avatar>
		</view>
		<view class="name-edit">
			<text>用户名：</text>
			<u-input border="surround"  v-model="Info.username"></u-input>
		</view>
		<view class="send">
			<u-button @click="editInfo(Info)" color="linear-gradient(to right, #E86262, #CC3333)">提交</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data(){
			return {
				Info:{
					avatar:[],
					username:''
				}
			}
		},
		methods: {
			changeAvatar(){
				uni.chooseImage({
					success: (chooseImageRes) => {
						this.Info.avatar = chooseImageRes.tempFilePaths.toString() ;
					}
				});
			},
			editInfo(data){
				let resdata=JSON.stringify(data);  
				this.$api.editPersonInfo(resdata).then(res => {
				console.log(resdata);
				console.log(res)
			})
			},
		},
		onLoad() {
			let that = this
			this.$data.Info.username = wx.getStorageSync('nickname')
			this.$data.Info.avatar = wx.getStorageSync('avatar')
			
		}
	}
</script>

<style>
	.avatar{
		width: 100%;
		height: 200rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.name-edit{
		display: flex;
		flex-direction: column;
		justify-content: center;
	}
	.send{
		width: 50%;
		transform: translateX(50%) translateY(50%);

	}
</style>
