<template>
	<view class="bg">
		<view class="nickname-box">
			<span>姓名：</span>
			<input v-model="nickname" type="text" placeholder="请输入您的姓名" />
		</view>
		<view class="btn" @click="save">保存修改</view>
	</view>
</template>

<script>
	export default {
		name: "changeNickname",
		data: function() {
			return {
				nickname: ""
			}
		},
		methods: {
			save: function() {
				if (!this.nickname) {
					uni.showToast({
						title: '请输入昵称',
						icon: 'none'
					})
					return;
				}
				this.Post({
					nickname: this.nickname
				}, '/api/user/profile').then(res => {
					console.log(res)
					if (res.code == 1) {
						uni.showModal({
							title: '提示',
							content: '保存成功！',
							success: res => {
								if (res.confirm) {
									this.goBack()
								}
							}
						})
					}
				})
			}
		}
	}
</script>

<style scoped>
	.bg {
		min-height: 100vh;
	}

	.nickname-box {
		display: flex;
		padding: 10rpx 30rpx;
		align-items: center;
		background: white;
		margin-bottom: 100rpx;
		font-size: 30rpx;
		height: 70rpx;
	}

	.nickname-box span {
		flex-shrink: 0;
	}

	.nickname-box input {
		flex: 1;
		font-size: 30rpx;
		display: block;
	}

	.btn {
		color: black;
		margin: 0 auto;
		line-height: 80rpx;
		position: relative;
		font-size: 34rpx;
		text-align: center;
		width: 333rpx;
		height: 80rpx;
		background: linear-gradient(90deg, #9EE4FE, #7FD491);
		border-radius: 40rpx;
		color: #FFFFFF;
	}
</style>