<template>
	<view class="view">
		<div class="card">
			<div class="row" style="margin-bottom: 30rpx;">
				<div class="left">姓名</div>
				<div class="right"><u-input  v-model="name" placeholder="请输入姓名" @blur="blur"></u-input></div>
			</div>
			<u-line></u-line>
			<div class="row" style="margin-top: 30rpx;">
				<div class="left">联系方式</div>
				<div class="right"><u-input v-model="address" placeholder="请输入联系方式"></u-input></div>
			</div>
		</div>
		
		<div class="card textarea">
			<u-textarea v-model="textarea" :value="textarea" placeholder="请输入您要反馈的内容" height="120" maxlength="300"></u-textarea>
		</div>
		
		<div class="card upload">
			<div class="left">
				<div class="imgbox" @click="upload()">
					<image v-if="img" :src="$util.img(img)" mode="" style="width: 100%;height: 100%;"></image>
					<image v-if="!img" :src="$util.img('/upload/weapp/user/jia1.png')" mode=""></image>
					<div v-if="!img" class="text">上传图片</div>
				</div>
			</div>
			<div class="right">
				<div>1、图片大小不得超过4M </div>
				<div>2、支持PNG\JPG等格式</div>
				<div>3、最多上传1张相关照片</div>
			</div>
		</div>
		
		<div class="submit" @click="btn">提交</div>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				textarea : '',
				name:'',
				address:'',
				img:'',
				
			}
		},
		methods: {
			btn(){
				let _this=this
				if(!this.name.length>0){
					this.$util.showToast({
						title: '请输入姓名'
					});
					return
				}
				if(!this.address.length>0){
					this.$util.showToast({
						title: '请输入联系方式'
					});
					return
				}
				if(!this.textarea.length>0){
					this.$util.showToast({
						title: '请输入您要反馈的内容'
					});
					return
				}
				if(!this.img.length>0){
					this.$util.showToast({
						title: '请上传图片'
					});
					return
				}
				this.$api.sendRequest({
					url: '/api/config/findServiceContent',
					data: {
						name:this.name,
						phone:this.address,
						content:this.textarea,
						image:this.img
					},
					success(res) {
						_this.$util.showToast({
							title: '提交成功'
						});
					}
				})
			},
			blur(value){
				// this.name=value
			},
			upload(type,size=1){
				this.$util.upload(size,{
					 path: 'otherImage'
				},res=>{
					this.img=res[0]
					
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.submit{
		font-size: 28rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
		line-height: 80rpx;
		text-align: center;
		height: 80rpx;
		background: #21BBF3;
		border-radius: 40rpx;
		position: fixed;
		bottom: 32rpx;
		width: calc(100% - 64rpx);
		left: 32rpx;
	}
	.card {
		margin: 32rpx;
		padding: 32rpx;
		background-color: #fff;
		border-radius: 16rpx;
	}
	.row {
		display: flex;
		.left {
			width: 150rpx;
		}
		.right {
			flex-grow:1;
			
			::v-deep {
				.u-input{
					border: 0;
					
				} 
				.u-input__content__field-wrapper__field {
					text-align: right !important;
				}
				.u-input--radius {
					padding: 0 6rpx !important;
				}
			}
		}
	}
	.textarea {
		::v-deep {
			.uni-textarea-placeholder {
				font-size: 28rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #BFBFBF;
			}
			.u-textarea {
				background: #F6F6F6;
				border-radius: 16rpx;
				border: 0;
			}
		}
	}
	.upload {
		display: flex;
		.left {
			.imgbox {
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				width: 160rpx;
				height: 160rpx;
				background: #F6F6F6;
				border-radius: 16rpx;
				
				font-size: 24rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #BFBFBF;
				
				image {
					width: 36rpx;
					height: 36rpx;
				}
				.text {
					margin-top: 20rpx;
				}
			}
		}
		.right {
			margin-left: 24rpx;
			
			font-size: 24rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #999999;
			line-height: 36rpx;
		}
	}
</style>
