<template>
	<view class="body">
		<view class="item">
			<view class="item-content">
				<view class="text">
					名前
				</view>
			</view>
			<view class="righta">
				<input type="text" v-model="form.nickname" @blur="onBlur"/>
			</view>
		</view>
		<view class="item">
			<view class="item-content">
				<view class="text">
					学年
				</view>
			</view>
			<view class="righta">
				<input type="text" v-model="form.studentYear" @blur="onBlur"/>
				<view class="">
					学年
				</view>
			</view>
		</view>
		<view class="item">
			<view class="item-content">
				<view class="text">
					学籍番号
				</view>
			</view>
			<view class="righta">
				<input type="text" v-model="form.studentNumber" @blur="onBlur"/>
			</view>
		</view>
		<view class="item">
			<view class="item-content">
				<view class="text">
					学部学科
				</view>
			</view>
			<view class="righta">
				<input type="text" v-model="form.department" @blur="onBlur"/>
			</view>
		</view>
		<view class="item">
			<view class="item-content">
				<view class="text">
					課外活動
				</view>
			</view>
			<view class="righta">
				<input type="text" v-model="form.club" @blur="onBlur"/>
			</view>
		</view>
		<view class="item">
			<view class="item-content">
				<view class="text">
					一言
				</view>
			</view>
			<view class="righta">
				<input type="text" v-model="form.signature" @blur="onBlur"/>
			</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
				}
			},
			//失焦修改姓名
			onBlur(){
				this.ModifyInformation(this.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: 40rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		background-color: #000000;
		min-height: 1340rpx;
		font-family: Arial-Regular;
		color: #FFFFFF;
		font-size: 28rpx;
		.item{
			display: flex;
			justify-content: space-between;
			align-items: center;
			width: 678rpx;
			height: 64rpx;
			margin-top: 30rpx;
			border-bottom: 1rpx solid #2D2D2D;
			padding-right: 10rpx;
			padding-left: 10rpx;
			padding-bottom: 6rpx;
			.right{
				display: flex;
				.abc{
					width: 48rpx;
					height: 48rpx;
					border-radius: 24rpx;
				}
			}
			.righta{
				display: flex;
				justify-content: flex-end;
				align-items: center;
				width: 500rpx;
				font-size: 24rpx;
				input{
					width: 360rpx;
					text-align: right;
					font-size: 24rpx;
				}
			}
			.item-content{
				display: flex;
			}
		}
	}
</style>
