<template>
	<view class="body">
		<view class="content">
			<view class="heade">
				欢迎您光顾，请仔细填写您的信息!
			</view>
			<!-- 门店 -->
			<view style="width: 85vw; height: 12vw; display: flex; border-bottom: 1px solid #f8f8f8;" @click="storeInfo">
				<p style="display: flex;"><span style="color: red;  line-height: 11vw;">*</span> <span
						style="font-size: 0.8rem; line-height: 10vw; margin-left: 1vw;">门店</span> <input type="text"
						v-model="storeName" placeholder="请选择门店"
						disabled="true"
						style="font-size: 0.8rem; width: 50vw; height: 10vw; line-height: 10vw; margin-left: 6vw; " />
				</p>
			</view>
			<!-- 姓名 -->
			<view style="width: 85vw; height: 12vw; display: flex; border-bottom: 1px solid #f8f8f8;">
				<p style="display: flex;"><span style="color: red;  line-height: 11vw;">*</span> <span
						style="font-size: 0.8rem; line-height: 10vw; margin-left: 1vw;">姓名</span> <input type="text"
						placeholder="请输入你的姓名" v-model="name"
						style="font-size: 0.8rem; width: 50vw; height: 10vw; line-height: 10vw; margin-left: 6vw; " />
				</p>
			</view>
			<!-- 手机号 -->
			<view style="width: 85vw; height: 12vw; display: flex; border-bottom: 1px solid #f8f8f8;">
				<p style="display: flex;"><span style="color: red;  line-height: 11vw;">*</span> <span
						style="font-size: 0.8rem; line-height: 10vw; margin-left: 1vw;">电话</span> <input type="text"
						placeholder="请输入你的车牌" v-model="tel"
						style="font-size: 0.8rem; width: 50vw; height: 10vw; line-height: 10vw; margin-left: 9vw; " />
				</p>
			</view>
			<!-- 车型 -->
			<view style="width: 85vw; height: 65vw;  border-bottom: 1px solid #f8f8f8;">
				<p style="display: flex;"><span style="color: red;  line-height: 11vw;"></span> <span
						style="font-size: 0.8rem; line-height: 10vw; margin-left: 1vw;">备注</span>
				</p>
				<p style="height: 40vw;">
					<textarea style="width: 75vw; border: 1px solid #f8f8f8; height: 40vw;  overflow: auto;" placeholder="请输入备注信息"
						v-model="content"></textarea>
				</p>
			</view>

			<u-toast ref="uToast" />
			<view class="button" @click="submit">提交</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				shop: '',
				name: '',
				tel: '',
				content: '',
				storeName:''
			}
		},
		onShow(object) {
			if(object){
				this.storeName=object.name
				this.shop=object.id
			}
		},
		onLoad() {
			if (this.$db.get('tel')) {
				this.tel = this.$db.get('tel')
			}
		},
		methods: {
			storeInfo(){
				uni.navigateTo({
					url:'/pages/index/storeList'
				})
			},
			// 提交
			submit() {
				if (!this.$db.get('token')) {
					uni.navigateTo({
						url: '/pages/login/login'
					})
					return
				}
				this.$api.postConsultation({
					shop: this.shop,
					name: this.name,
					tel: this.tel,
					content: this.content
				}, res => {
					if (res.code == 0) {
						this.successToast('提交成功')
						this.$nextTick(() => {
							this.storeName=''
							this.name = ''
							this.shop = ''
							this.content = ''
						})
					} else {
						this.errorToast('请输入必填项')
					}
				})

			},
			successToast(msg) {
				this.$refs.uToast.show({
					title: msg,
					type: 'success',
					duration: 1000
				})
			},
			errorToast(msg) {
				this.$refs.uToast.show({
					title: msg,
					type: 'error',
					duration: 1000
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.body {
		width: 100vw;
		height: 100vh;
		background-color: #f8f8f8;
		display: flex;
		justify-content: center;

		.content {
			width: 95vw;
			height: 80vh;
			background-color: white;
			border-radius: 5px;
			padding: 2vw;

			.heade {
				width: 95vw;
				height: 22vw;
				box-sizing: border-box;
				text-align: center;
				padding: 8vw 15vw 5vw 15vw;
				font-size: 0.9rem;
				color: gray;
				border-bottom: 1px solid #f8f8f8;
				;
			}

			.picture {
				width: 95vw;
				height: 14vh;
				display: flex;
				justify-content: space-around;
				align-items: center;

				.front {
					width: 40vw;
					height: 25vw;
					background-color: #f8f8f8;
					border: 1px dashed #d8d8d8;
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;
				}

				.opposite {
					width: 40vw;
					height: 25vw;
					background-color: #f8f8f8;
					border: 1px dashed #d8d8d8;
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;
				}
			}

			.agreement {
				display: flex;
				font-size: 0.8rem;
				width: 96vw;
				justify-content: center;
				align-items: center;
				height: 10vh;

			}

			.button {
				width: 85vw;
				height: 10vw;
				margin-top: 10vw;
				background-color: red;
				line-height: 10vw;
				border-radius: 5vw;
				color: white;
				text-align: center;
				margin-left: 5vw;
			}
		}
	}
</style>