<template>
	<view class="bg">
		<view class="nickname-box">
			<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: '保存成功！',
							confirmColor: '#000000',
							success: res => {
								if (res.confirm) {
									this.goBack()
								}
							}
						})
					}
				})
			}
		}
	}
</script>

<style scoped>
	.bg {
		min-height: 100vh;
		padding-top: 50rpx;
		background-color: white;
	}

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

	.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: #C3282E;
		border-radius: 40rpx;
		color: #FFFFFF;
	}
</style>