<template>
	<view class="index">
		<view class="inp-box">
			<textarea 
				@input="sumfontnum" 
				maxlength="100" 
				@blur="bindTextAreaBlur" 
				placeholder-style="color:#999999;" 
				placeholder="请填写您宝贵的反馈意见"
				 v-model="content"/>
			<view class="fontnum">{{fontnum}}/100</view>
		</view>
		<view class="submit-btn" @click="submitClick()">提交</view>
	</view>
</template>

<script>
	import { feedBack } from '@/api/knowledge'
	export default{
		data(){
			return {
				content:'',
				fontnum:0
			}
		},
		methods:{
			bindTextAreaBlur: function (e) {
				console.log(e.detail.value)
			},
			sumfontnum(e){
				this.fontnum = e.detail.value.length
			},
			submitClick(){
				feedBack({content:this.content}).then((res)=>{
					if(res.success){
						uni.showToast({
							title: '反馈成功！',
							duration:2000
						})
						setTimeout(()=>{
							uni.navigateBack({
								delta:1
							})
						},2000)
					} else{
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				})
			},
		}
	}
</script>

<style lang="less" scoped>
	.inp-box{
		width: 100%;
		background: #fff;
		padding: 24rpx;
		font-size: 28rpx;
		position: relative;
		.fontnum{
			font-size: 24rpx;
			color: #999;
			position: absolute;
			right: 28rpx;
			bottom: 16rpx;
		}
	}
	.submit-btn{
		width: 208rpx;
		height: 80rpx;
		background: #F99C10;
		color: #fff;
		text-align: center;
		line-height: 80rpx;
		border-radius: 4rpx;
		margin: 30rpx auto;
	}
</style>
