<template>
    <view class='container'>
		<view>
			<u-textarea v-model="bio" maxlength="50" placeholder="请输入个人介绍" border="surround"></u-textarea>
		</view>
		
		<view @click="onSubmit" class="btn">
			<text>保存</text>
		</view>
    </view>
</template>

<script>
import {
		mapState
	} from "vuex"
export default {
    data() {
    	return {
    		bio: ''
    	};
    },
    onLoad(options) {
    	this.bio = this.user.userInfo.bio
    },
    computed: {
    	...mapState(['user'])
    },
    methods: {
    	onSubmit(){
    		const params = {
    			url: '/api/user/profile',
    			loadingTip: '',
    			data: {
    				bio: this.bio
    			}
    		}
    		this.$request(params).then(res => {
    			// console.log(res)
    			this.$u.toast(res.msg || '修改成功')
    			setTimeout(() => {
    				this.$wskj.goBack(1)
    			}, 600)
    		}).catch(err => {
    			// console.log(err)
    			this.$u.toast(err.msg || '修改失败')
    		})
    	}
    },
};
</script>

<style scoped>
	.container {
		height: 100%;
		padding: 30rpx 30rpx 0;
	}
	
	.btn{
		width: 94%;
		height: 80rpx;
		text-align: center;
		line-height: 80rpx;
		position: absolute;
		bottom: 100rpx;
		left: 50%;
		margin-left: -47%;
		background-color: #FE2C24;
		color: #FFF;
		border-radius: 8rpx;
	}
</style>
