<template>
	<view class="bg">
		<view class="line-list">
			<view class="form">
				<view class="form-item">
					<view class="form-title">
						姓名:
					</view>
					<input type="text" v-model="form.name" placeholder="请填写您的姓名"
						placeholder-style="color:#999999;font-size:31rpx">
				</view>
				<view class="form-item">
					<view class="form-title">
						手机号:
					</view>
					<input type="number" v-model="form.phone" placeholder="请填写您的联系方式" maxlength="11"
						placeholder-style="color:#999999;font-size:31rpx">
				</view>
			</view>
			<view class="content">
				<view class="content-name">
					反馈内容:
				</view>
				<textarea cols="30" rows="10" v-model="form.content" placeholder="请填写具体的问题内容"
					placeholder-style="color: #999999;font-size: 31rpx;" maxlength="500">

				</textarea>
				<span>{{form.content.length}}/500</span>
			</view>
		</view>

		<view :class="['btn',{'actBtn':form.name&&form.phone&&form.content}]" @click="sendForm()">
			提交
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					name: '',
					phone: '',
					content: '',
				},
			};
		},
		onLoad() {

		},
		methods: {
			sendForm() {
				if (!this.idChinaName(this.form.name)) {
					uni.showToast({
						title: "请输入正确的姓名",
						icon: "none"
					})
					return false
				}
				if (!this.IsTel(this.form.phone)) {
					uni.showToast({
						title: "请输入正确的手机号",
						icon: "none"
					})
					return false
				}
				if (this.form.content.replace(/\s*/g, "").length < 15) {
					uni.showToast({
						title: "请输入15字以上的建议或反馈",
						icon: "none"
					})
					return false
				}
				this.Post({
					username: this.form.name,
					mobile: this.form.phone,
					content: this.form.content
				}, "/api/suggest/add").then(res => {
					if (res) {
						uni.showToast({
							title: res.msg,
							icon: "none"
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	view {
		box-sizing: border-box;
		font-family: PingFang SC;
	}

	.bg {
		min-height: 100vh;
		background-color: rgba(255, 255, 255, 1);
		padding-top: 35rpx;
		overflow: hidden;
		padding-bottom: 160rpx;
	}

	.line-list {
		width: 697rpx;
		margin: 0 auto;

		.form {
			.form-item {
				width: 697rpx;
				height: 120rpx;
				display: flex;
				align-items: center;
				border-bottom: #D8D8D8 solid 1rpx;

				.form-title {
					width: 150rpx;
					font-size: 31rpx;
					font-weight: 500;
					color: #333333;
				}


			}
		}

		.content {
			margin: 0 auto;
			margin-top: 36rpx;
			width: 697rpx;
			position: relative;
			
			span {
				font-weight: 400;
				font-size: 24rpx;
				color: #999999;
				position: absolute;
				right: 22rpx;
				bottom: 14rpx;
			}

			.content-name {
				font-size: 31rpx;
				font-weight: 500;
				color: #333333;
			}

			textarea {
				width: 657rpx;
				height: 243rpx;
				background: #F7F7F7;
				border-radius: 13rpx;
				padding: 20rpx;
				margin-top: 42rpx;
				font-size: 31rpx;
				font-weight: 500;
				color: #333333;
				padding-bottom: 45rpx;
			}
		}
	}
	
	.btn {
		width: 697rpx;
		height: 80rpx;
		background: #CCCCCC;
		border-radius: 40rpx;
		margin: 0 auto;
		margin-top: 160rpx;
		text-align: center;
		line-height: 80rpx;
		font-size: 36rpx;
		font-weight: 500;
		color: #FFFFFF;
		position: absolute;
		left: 26.5rpx;
		bottom: 46rpx;

	}

	.actBtn {
		background: linear-gradient(90deg, #9EE4FE, #7FD491);
	}
</style>
