<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="tips">注：该反馈功能只做收集会员反馈信息，不做解答，如有问题需要解答，可联系服务老师进行沟通。</view>
		<view class="tips">您反馈的信息我们会及时跟进，感谢您的宝贵建议，谢谢！</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: 690rpx;
		background: #fff;
		padding: 24rpx;
		font-size: 28rpx;
		position: relative;
		margin: 20px auto 0;
		border-radius: 12rpx;
		.fontnum{
			font-size: 24rpx;
			color: #999;
			position: absolute;
			right: 28rpx;
			bottom: 16rpx;
		}
	}
	.tips{
		padding: 0 32rpx;
		font-size: 24rpx;
		color: #FF0000;
		margin: 12px 0;
	}
	.submit-btn{
		width: 208rpx;
		height: 80rpx;
		background: #F99C10;
		color: #fff;
		text-align: center;
		line-height: 80rpx;
		border-radius: 12rpx;
		margin: 60rpx auto;
	}
</style>
