<template>
	<view class="content">
		<view class="row1 flex">
			<view class="left">
				昵称
			</view>
			<u-input v-model="userInfo.nickname" :border="false" focus class="input" />
		</view>
		<view class="row2">
			<view class="btn" @click="edit">
				保存
			</view>
		</view>
		<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				value: '',
				userInfo: {
					nickname: ''
				}
			};
		},
		onLoad() {
			this.userInfo = uni.getStorageSync("userInfo")
		},
		methods: {
			edit() {
				this.$request.baseRequest('admin.unimall.commonUserInfo', 'update', {
					commonUserInfo: JSON.stringify(this.userInfo)
				}, failres => {
					uni.hideLoading()
					uni.showToast({
					  icon:"none",
					  title: failres.errmsg,
					  duration: 3000
					});
				}).then(res => {
					this.userInfo = res.data
					uni.setStorageSync("userInfo", this.userInfo)
					uni.showToast({
					  icon:"success",
					  title: '修改成功！',
					  duration: 2000,
					  complete:function(){
					    uni.switchTab({
					      url: "/pages/my/my"
					    })
					  }
					})
				})
			}
		}
	}
</script>

<style lang="scss">
	.row1 {
		background: #fff;
		padding: 20rpx;
	}

	.input {
		font-size: 28rpx;
	}

	.row2 {
		padding: 20rpx;
	}

	.btn {
		color: #fff;
		padding: 20rpx;
		border-radius: 8px;
		background: #eaad1a;
		text-align: center;
		font-size: 36rpx;

	}
</style>