<template>
	<view>
		<!-- 模态框 -->
		<view class="cu-modal" :class="show?'show':''">
			<view class="cu-dialog">
				<view class="cu-bar bg-white justify-end solid-bottom">
					<view class="content">上门/服务规则</view>
					<view class="action" data-modal="showOnDoorNoticeModal" @tap="hideModal">
						<text class="cuIcon-close text-red"></text>
					</view>
				</view>
				<view class="padding-xl text-left bg-white">
					<view>1、上门/服务不得使用客户家的工具/用品(别说客户不介意)；不得谈论产品价格、服务费及师傅报酬等超服务内容的言论，否则引起不必要的纠纷或退货你全责。</view>
					<view>2 、推销商是你的免费业务员与订单来源，也是你的代理商、经销商，其对本单动态监管；不得无故退单、撬单，不踩双方利益红线。</view>
					<view class="text-main-color flex align-center justify-center">
						<text>您可预告客户您约</text>
						<picker class="relative-view" mode="selector" :range="minList" @change="minChange">
							<input class="custom-input radius-input" v-model="waitMin" disabled>
								<view class="text-lg input-arrow"><text class="cuIcon-triangledownfill"></text></view>
							</input>
						</picker>
						<text>分钟左右到达</text>
					</view>
					<view class="text-center">确认后系统同步通知客户你正在上门...</view>
				</view>
				<view class="cu-bar bg-white solid-top">
					<view class="action margin-0 flex-sub text-black" data-modal="showOnDoorNoticeModal"
						@tap="hideModal">取消</view>
					<view class="modal-bottom-oper margin-0 flex-sub text-main-color solid-left" data-modal="showOnDoorNoticeModal" @tap="workBegin">确认</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import myUniCombox from '@/components/uni-combox/my-uni-combox.vue';
	
	export default {
		name: 'onDoorImmediately',
		emits: ['confirmFeedback'],
		props: {
			show: {
				type: Boolean,
				default: false
			},
			data: {
				type: Object,
				default: {}
			}
		},
		components: {
			myUniCombox
		},
		data() {
			return {
				minList: [0, 15, 30, 45, 60, 80, 100],
				waitMin: 0
			}
		},
		methods: {
			hideModal(e) {
				uni.$emit(this.$globalFun.HIDE_MODAL, e);
			},
			minChange(e) {
				this.waitMin = this.minList[e.detail.value];
			},
			async workBegin(e) {
				let order = this.data;
				let curDate = new Date();
				let formatCurDate = curDate.getFullYear() + '-' + (curDate.getMonth() + 1) + '-' + curDate.getDate()
					+ ' ' + curDate.getHours() + ':' + curDate.getMinutes() + ':' + curDate.getSeconds();
				let params = {
					id: order.orderDetailId,
					orderStatus: 3,
					workBeginTime: formatCurDate
				}
				let res = await this.$request.updateDetailOrder(params);
				if (res && res.code === 0) {
					// this.reloadMasterOrderPage();
					uni.showToast({
						icon: 'success',
						duration: 1000
					})
					this.hideModal(e);
					this.$emit('confirmFeedback');
				}
			}
		}
	}
</script>

<style scoped>
	.relative-view {
		position: relative;
		width: 20%;
	}
	.input-arrow {
		position: absolute;
		right: 10rpx;
		top: 25%;
	}
</style>
