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

<script>
	export default {
		data() {
			return {
				username:'',
				avatar:''
			}
		},
		methods: {
			changeAvatar(){
				// uni.uploadFile()
				console.log(111);
			},
			editInfo(){
				this.$api.editPersonInfo({
				nickname:this.$data.nickname,
				avatar:this.$data.avatar,
				Headers:wx.getStorageSync('token')
			}).then(res => {
				console.log(res);
			})
			}
		},
		onLoad() {
			let that = this
			this.$data.username = wx.getStorageSync('nickname')
			this.$data.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>
