<template>
	<view class="content">

		<view class="ail">


		</view>

	</view>
</template>

<script>
	import config from '@/config'
	import request from '../../utils/request';
	import {
		getToken
	} from '@/utils/auth'
	export default {
		props: ["pid", "type"],
		data() {
			return {
				id: this.pid,
				tapindex: 0,
				sx: 0,
				type: '',
				goodsname: '',
				goodsId: '',
				itmelist: [],
				partnerId: '',
				appointmentday: '',
				partnerName: '汽车',
				address: '',
				autoplay: true,
				renshu: {
					morningCount: 0,
					afterCount: 0
				}

			}
		},

		// onLoad(option) {
		// 	this.goodsname = option.goodsName
		// 	this.goodsId = option.goodsId
		// 	this.type = option.type
		// 	console.log(this.goodsId, this.goodsname);
		// 	this.getindex()

		// },
		watch: {
			pid(val) {
				console.log('组件内::', val);
				this.goodsId = val
				this.getindex()
			}
		},
		methods: {
			sw(id) {
				this.sx = id
				this.$emit("xia", this.sx)
			},
			async getcarlist() {
				if (!getToken()) {
					return
				}
				const res = await request({
					url: '/appInspection/userOwn/getCars',
					method: 'get',
				})

				this.carlist = res.data
				console.log(this.carlist);
			},
			async getindex() {
				let data = {
					goodsId: this.goodsId,
					type: this.type
				}
				let res = await request({
					url: '/appInspection/goods/appointmentDateList',
					method: 'get',
					params: data
				})
				this.partnerName = res.data.partnerName
				this.address = res.data.address
				this.partnerId = res.data.partnerId
				this.itmelist = res.data.dataList
				this.appointmentday = res.data.dataList[0].dateStr
				console.log(this.appointmentday.substring(5, 10).replace('-', '月'));
				console.log(res.data);
			},
			gettap(index, items) {
				this.$emit("shang", items)
				this.tapindex = index
				this.renshu = items
				this.appointmentday = items.dateStr
				console.log(this.renshu);

			},
			gohomemy() {
				uni.navigateTo({
					url: '/pages/detection/my'
				})
			},
			async gettijiao() {
				let data = {
					goodsTitle: this.goodsname,
					partnerId: this.partnerId,
					appointmentDay: this.appointmentday,
					appointmentPeriod: this.sx
				}
				let res = await request({
					url: '/appInspection/goods/appointmentInspection',
					method: 'post',
					data: data
				})
				console.log(res);
				if (res.code == 200) {
					uni.showToast({
						title: '提交成功'
					})
					// uni.setStorageSync('data',res.data)
					// uni.navigateBack()
					let pages = getCurrentPages(); //获取页面实例
					let nowPage = pages[pages.length - 1]; //当前页面实例
					let prevPage = pages[pages.length - 2]; //上一级页面实例
					prevPage.$vm.Backappoinment(res.data)
					uni.navigateBack({
						delta: 1
					})
				}


			},
			getback() {
				uni.navigateBack()
			}
		}
	}
</script>

<style scoped lang="scss">
	.aa-box {
		margin-top: 15px;
		width: 100%;
		height: 152px;
		background-color: white;
		border-radius: 8px;
		box-sizing: border-box;
		padding: 20px;
		// display: flex;
		// align-items: center;
		// justify-content: center;
	}

	.wdadada {
		width: 100%;
		text-align: center;
		margin-top: 40px;
		font-size: 30px;
	}

	.content {
		width: 100%;

		background-color: #F6F6F6;
		box-sizing: border-box;
		// padding-top: 45px;
	}

	.swiper {
		height: 170px;
	}

	.bai-box {
		box-sizing: border-box;
		padding: 15px;
		background-color: white;
		border-radius: 8px;
		margin-top: 15px;
	}

	.xzlan {
		background: #E3EAFF;
	}

	.ail {
		width: 100%;
		box-sizing: border-box;
		padding: 10px 15px;
		background-color: #F6F6F6;
	}
</style>