<template>
	<view class="body">
		<view class="item" style="border-bottom: 1rpx solid #545454;">
			<view class="item-content">
				<view class="text">
					アイコン
				</view>
			</view>
			<view class="right">
				<upload-img class="abc" :width="48" :height="48" :bgsrc="form.headPhoto"
				:currentImagea="image"	 @chooseimg="handleChooseImg($event)">
				</upload-img>
				<image src="../../static/207.png" mode=""></image>
			</view>
			
		</view>
		<view class="item">
			<view class="item-content">
				<view class="text">
					名前
				</view>
			</view>
			<view class="righta">
				<input type="text" v-model="form.nickname" @blur="onBlur"/>
				<image src="../../static/207.png" mode=""></image>
			</view>
			
		</view>
	</view>
</template>

<script>
	import uploadImg from '@/components/amazarashi-uploadimg/uploadImg.vue'
	export default {
		components: {
			uploadImg
		},
		data() {
			return {
				form:{},
				image:"",
			}
		},
		onLoad() {
			this.userinfo();
		},
		methods: {
			//查询用户信息
			async userinfo() {
				let id=uni.getStorageSync("id")
				const res = await this.$myRequest({
					url: '/api/foreignAuth/userinfo?id='+id,
					header: {
						token: uni.getStorageSync("token"),
						Authorization: uni.getStorageSync("Authorization"),
					},
				})
				if (res.data.code == 200) {
					this.form=res.data.data
				}
			},
			//上传图片1
			handleChooseImg(e) {
				this.form.headPhoto=e.src
				let form={
				}
				form.headPhoto=e.src
				this.ModifyInformation(form)
			},
			//失焦修改姓名
			onBlur(){
				let form={
				}
				form.nickname=this.form.nickname
				this.ModifyInformation(form)
			},
			//修改基本信息
			async ModifyInformation(form) {
				const res = await this.$myRequest({
					url: '/api/MyInfo/ModifyInformation',
					method: "post",
					header: {
						token: uni.getStorageSync("token"),
						Authorization: uni.getStorageSync("Authorization"),
					},
					data: form
				})
				if (res.data.code == 200) {
					uni.showToast({
						title:res.data.msg
					})
					this.userinfo();
					
				}
			},
		}
	}
</script>

<style lang="scss">
    .body{
		padding-top: 80rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		background-color: #000000;
		min-height: 94.6vh;
		font-family: Arial-Regular;
		color: #FFFFFF;
		font-size: 28rpx;
		.item{
			display: flex;
			justify-content: space-between;
			width: 678rpx;
			height: 70rpx;
			margin-top: 30rpx;
			image{
				margin-left: 20rpx;
				margin-right: 24rpx;
				width: 48rpx;
				height: 48rpx;
			}
			.right{
				display: flex;
				.abc{
					width: 48rpx;
					height: 48rpx;
					border-radius: 24rpx;
				}
			}
			.righta{
				display: flex;
				justify-content: flex-end;
				width: 500rpx;
				input{
					width: 360rpx;
					text-align: right;
					font-size: 24rpx;
				}
			}
			.item-content{
				display: flex;
			}
		}
	}
</style>
