<template>
	<view class='my-n-page'>
		<view class='my-n-contain'>
			<view class="contain-box">
				<view class='box-title'>填写内容</view>
				<view class='box-tarea'>
					<textarea class='box-con' placeholder="请详细描述您的问题或建议，我们将及时跟进" maxlength="100" @input="sufontnum($event)"></textarea>
					<text class='contain-length'>{{fountNum}}/<text class="length-total">100</text>字</text>
				</view>
				
				<view class='contain-mobile'>
					<view class='mobile-label'>
						<view class='label-icon'>*</view>
						<label class='label-text'>手机号</label>
					</view>
					<input class='moblie-val' placeholder="请输入手机号" maxlength="11"  type="number" :value="mobileVal" @input="changeMobile($event)" placeholder-style="color:#999999;"/>
				</view>
			</view>
		</view>
		<view class='my-n-footer'>
			<view class='footer-btn' @click="needSubmit">确认发布</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				desQuest:'',
				fountNum:0,
				mobileVal:''
			}
		},
		onLoad() {
			
		},
		methods: {
			needSubmit(){
				const self=this
				if(self.desQuest==''){
					self.toast('内容不能为空')
					return false
				}
				if(self.mobileVal==''){
					self.toast('请输入正确的手机号')
					return false
				}
				const params={
					"cell": self.mobileVal,
					"content": self.desQuest
				}
				self.$request('/pawn/need/save','POST',params).then(res => {
						console.log(res,'999')
						self.Back(1)
				}).catch(err=>{
				  console.log(err,'请求出错')
				})
			},
			sufontnum(e){
				if(e.detail.value.length>100){
					
					this.toast('不可超过100个字')
					return false
					
				}else{
					this.desQuest=e.detail.value
				}
				
				this.fountNum=e.detail.value.length
			},
			changeMobile(e){
				const regex = /^1[3456789]\d{9}$/;
				if(!regex.test(e.detail.value)){
					this.toast('请输入正确的手机号')
					return false
				}else{
					this.mobileVal= e.detail.value
				}
				
			}
		}
	}
</script>
<style src='./index.less' lang="less" scoped></style>
