<template>
	<view>
		<u-navbar
			title="个性签名"
			placeholder
			:autoBack="true"
		>
			<view class="u-nav-slot" slot="right">
				<u-button type="primary" @click="save">保存</u-button>
			</view>
		</u-navbar>
		<u--textarea 
			count 
			confirmType="done" 
			focus 
			autoHeight 
			height="500"
			maxlength="100" 
			border="none" 
			:adjustPosition="false"
			class="textarea"
			placeholder="个性签名"
			v-model="bio"
			>
		</u--textarea>
	</view>
</template>

<script>
	import {mapGetters} from "vuex";
	import {businessInfoUpdate} from "@/api/login";
	export default {
		computed: {
			...mapGetters([
				"storeSelfInfo"
			])
		},
		data() {
			return {
				bio:"",
			}
		},
		onLoad() {
			this.bio = this.storeSelfInfo.bio||"";
		},
		methods: {
			back(){
				uni.navigateBack();
			},
			save(){
				console.log(this.bio);
				businessInfoUpdate({
					userID: this.storeSelfInfo.userID,
					bio:this.bio,
				}).then(res=>{
					this.$store.commit("user/SET_SELF_INFO",{
						...this.storeSelfInfo,
						bio:this.bio,
					});
					uni.navigateBack();
				}).catch(e=>{
					uni.showToast({
						title: "保存失败",
						icon: "none"
					});
				});
			}
		}
	}
</script>

<style scoped lang="scss">
	.textarea{
	}
	.u-nav-slot{
		.u-button{
			height: 60rpx;
		}
	}
</style>