<template>
	<view class="container">
		<view class="title">成员基本信息</view>

		<view class="box">
			手机
			<view class="box_input">
				<input type="number" maxlength="11" placeholder="请输入手机号码" v-model="phone" />
			</view>
		</view>

		<view class="box">
			状态
			<picker @change="bindPickerChange" :value="index" :range="array">
				<view class="box_input">
					{{ array[index] }}
					<img src="../../static/images/repairsImg/bottom.png" />
				</view>
			</picker>
		</view>

		<view class="box">
			工种
			<picker @change="bindPickerChange2" :value="index2" :range="array2">
				<view class="box_input">
					{{ array2[index2] }}
					<img src="../../static/images/repairsImg/bottom.png" />
				</view>
			</picker>
		</view>

		<view class="title">接单考核时间</view>

		<view class="box_time">
			<view class="time">
				<input type="text" v-model="receivingTime" />
				<img src="../../static/images/repairsImg/clock.png" />
			</view>
			分钟
		</view>

		<view class="title">维修考核时间</view>

		<view class="box_time">
			<view class="time">
				<input type="text" v-model="repairsTime" />
				<img src="../../static/images/repairsImg/clock.png" />
			</view>
			分钟
		</view>

		<!-- 提交按钮区域 -->
		<view class="btn" @click="handleSub">确认提交</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			// 手机号码
			phone: '13659864589',
			// 接单考核时间
			receivingTime: 0,
			// 维修考核时间
			repairsTime: 0,
			// 状态数组
			array: ['接单中', '停止接单', '订单饱和'],
			// 状态数组当前索引
			index: 0,
			// 工种数组
			array2: ['电工', '水工', '泥工', '空调'],
			// 工种数组当前索引
			index2: 0
		}
	},
	methods: {
		// 确认提交按钮回调
		handleSub() {
			if (!this.phone) {
				uni.showToast({
					title: '请输入手机号码',
					icon: 'none'
				})
				return
			}
			const rePhone = /^[1][3,4,5,7,8,9][0-9]{9}$/
			if (!rePhone.test(this.phone)) {
				uni.showToast({
					title: '手机号码格式有误',
					icon: 'none'
				})
				return
			}
			uni.showModal({
				title: '提示',
				content: '确认提交吗？',
				success: (res) => {
					if (res.confirm) {
						console.log(this.phone)
						console.log(this.array[this.index])
						console.log(this.array2[this.index2])
						console.log(this.receivingTime)
						console.log(this.repairsTime)

						uni.showToast({
							title: '编辑成功',
							icon: 'success'
						})

						setTimeout(() => {
							uni.navigateTo({
								url: '/pagesRepairs/box/box'
							})
						}, 1500)
					}
				}
			})
		},
		// 状态选择框选择回调
		bindPickerChange(e) {
			this.index = e.detail.value
		},
		// 工种选择框选择回调
		bindPickerChange2(e) {
			this.index2 = e.detail.value
		}
	}
}
</script>

<style lang="scss" scoped>
.container {
	box-sizing: border-box;
	padding: 0 30rpx;
	width: 100vw;
	height: 100vh;

	.title {
		display: flex;
		align-items: center;
		height: 112rpx;
		font-size: 36rpx;
		font-weight: bold;
	}

	.box {
		display: flex;
		align-items: center;
		margin-bottom: 30rpx;
		height: 94rpx;
		color: #808080;
		font-size: 32rpx;

		.box_input {
			display: flex;
			justify-content: space-between;
			align-items: center;
			box-sizing: border-box;
			margin-left: 33rpx;
			padding: 0 33rpx;
			width: 542rpx;
			height: 94rpx;
			color: #000000;
			border-radius: 10rpx;
			border: 1rpx solid #cccccc;

			input {
				width: 100%;
				height: 100%;
			}

			img {
				width: 54rpx;
				height: 54rpx;
			}
		}
	}

	.box_time {
		display: flex;
		align-items: center;
		height: 100rpx;
		font-size: 32rpx;
		font-weight: bold;

		.time {
			display: flex;
			justify-content: space-between;
			align-items: center;
			box-sizing: border-box;
			padding: 0 23rpx;
			margin-right: 25rpx;
			width: 237rpx;
			height: 68rpx;
			font-weight: 400;
			border-radius: 4rpx;
			border: 1rpx solid #a6a6a6;

			input {
				flex: 1;
			}

			img {
				width: 40rpx;
				height: 40rpx;
			}
		}
	}

	.btn {
		position: absolute;
		bottom: 66rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		margin: auto;
		width: 690rpx;
		height: 100rpx;
		color: #fff;
		font-size: 32rpx;
		border-radius: 12rpx;
		background-color: #6fb6b8;
	}
}
</style>
