<template>
	<view>
		<view class="box">
			<input placeholder="请输入车牌号" @input="input1" v-model="value1"></input>
			<input placeholder="请输入原因" @input="input3" v-model="value3"></input>
			<text style="width:690upx;font-size:32upx;font-family:PingFang SC;color:rgba(42,42,42,1);padding:15upx 0upx;">车辆状态</text>
			<view class="list">
				<view v-for="(item,index) in list" @click="screen(item.id,index)" :class="index1==index?'active':''">
					<text>{{item.name}}</text>
				</view>
			</view>
			<view class="btn" @click="btn">
				<text>提交</text>
			</view>
		</view>
	</view>
</template>

<script>
	var app = getApp()
	export default {
		data() {
			return {
				list: [],
				index1: null,
				bike_no: '',
				id: '',
				value1: '',
				value3: ''
			}
		},
		methods: {
			input1: function(e) {
				this.value1 = e.detail.value;
			},
			input3: function(e) {
				this.value3 = e.detail.value;
			},
			screen: function(id,index) {
				this.index1 = index
				this.id = id
			},
			btn: function() {
				var that = this;
				if (that.value1 == '') {
					uni.showToast({
						title: '请输入车牌号',
						icon: 'none'
					})
					return;
				} else if (that.value3 == '') {
					uni.showToast({
						title: '请输入原因',
						icon: 'none'
					})
					return;
				} else if (that.id == '') {
					uni.showToast({
						title: '请选择状态',
						icon: 'none'
					})
					return;
				}
				uni.showLoading({
					title: '加载中...',
				})
				var data = {
					bike_no: that.value1,
					trouble_part: that.id,
					reason: that.value3
				}
				app.request('bike/bikeRepair', data, 'POST').then(res => {
					uni.hideLoading();
					if (res.statusCode == 200) {
						uni.showToast({
							title: '报修完成',
							icon: 'none'
						})
						setTimeout(function() {
							uni.navigateBack()
						}, 2000)
					}
				})
			},
		},
		onLoad: function(options) {
			var that = this;
			that.value1 = options.bike_no
			uni.showLoading({
				title: '加载中...',
			})
			app.request('bike/repairOptions', '', 'GET').then(res => {
				uni.hideLoading();
				if (res.statusCode == 200) {
					that.list = res.data;
				}
			})
			uni.setNavigationBarTitle({
				title: '报修页面'
			})
		},
	}
</script>

<style>
	.box {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.box input {
		width: 690upx;
		height: 90upx;
		background: rgba(255, 255, 255, 1);
		box-shadow: 0px 0px 4upx 0px rgba(141, 141, 141, 1);
		border-radius: 10upx;
		font-size: 28upx;
		padding-left: 20upx;
		margin-top: 30upx;
	}

	.box .list {
		width: 690upx;
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
	}

	.box .list view {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 58upx;
		background: rgba(255, 255, 255, 1);
		box-shadow: 0px 0px 18upx 0px rgba(208, 208, 208, 1);
		border-radius: 29upx;
		font-size: 28upx;
		color: rgba(92, 92, 92, 1);
		padding: 0upx 20upx;
		margin-top: 32upx;
	}

	.box .list .active {
		background: #ccc;
		color: white;
	}

	.box .btn {
		width: 420upx;
		height: 88upx;
		background: rgba(24, 213, 185, 1);
		box-shadow: 0px 0px 20upx 0px rgba(100, 239, 218, 1);
		border-radius: 44upx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 32upx;
		color: rgba(255, 255, 255, 1);
		margin-top: 200upx;
	}
</style>
