<template>
	<view class="check-message-detail">
		<view class="content" v-for="item in list" :key="item.id">
			<view class="title">{{item.name}}</view>
			<view class="value">{{item.value}}</view>
		</view>
		<view class="button-area">
			<view class="pass">
				<view class="icon"></view>
				<view class="text" @click="handleClick(item, '已通过')">申请通过</view>
			</view>
			<view class="pass no-pass">
				<view class="icon"></view>
				<view class="text" @click="handleClick(item, '已拒绝')">申请不通过</view>
			</view>
		</view>
		
		<u-modal 
			:show="show" 
			showConfirmButton 
			showCancelButton 
			:content='content'
			:closeOnClickOverlay="true"
			@confirm="confirm"
			@cancel="cancel"
			@close="cancel"
		></u-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false, //控制模态框显隐
				content: '', //模态框显示内容
				list: [
					{
						id: 'odd',
						name: '申请单号',
						value: '1111111111'
					},
					{
						id: 'number',
						name: '申请者工号',
						value: '1111111111'
					},
					{
						id: 'name',
						name: '申请者姓名',
						value: '张三'
					},
					{
						id: 'phone',
						name: '申请者手机号',
						value: '12345678912'
					},
					{
						id: 'visitorName',
						name: '访客姓名',
						value: '12345678912'
					},
					{
						id: 'visitorKey',
						name: '访客身份证',
						value: '123456789126415897'
					},
					{
						id: 'visitorPhone',
						name: '访客联系方式',
						value: '123456789126415897'
					},
					{
						id: 'aim',
						name: '访问目的',
						value: '商务会议'
					},
					{
						id: 'area',
						name: '访问区域',
						value: '一期主楼'
					},
					{
						id: 'time',
						name: '访问时间',
						value: '2022-12-12 05:45:12 ~ 2022-16-78 15:45:36'
					},
					{
						id: 'remark',
						name: '备注',
						value: '1212'
					},
				],
				
			}
		},
		methods: {
			handleClick(value, text) {
				let index = this.list.findIndex(item => item.id === 'odd');
				if(index !== -1) {
					let number = this.list[index].value;
					this.content = `单号${number}访客访客申请${text}`;
					this.show = true;
				} else {
					wx.showToast({
						title: '找不到单号',
						icon: 'none',
						duration: 1000,
					})
				}
			},
			//点击模态框取消按钮
			cancel() {
				this.show = false;
			},
			//点击模态框确认按钮
			confirm() {
				wx.reLaunch({
					url: '/pages/message/message'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.check-message-detail {
		padding: 40rpx;
		.content {
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			align-items: center;
			.title {
				white-space: nowrap;
				margin-right: 60rpx;
			}
		}
		.button-area {
			display: flex;
			flex-direction: row;
			justify-content: center;
			align-items: center;
			margin-top: 60rpx;
			.pass {
				width: fit-content;
				padding: 10rpx 20rpx;
				background-color: green;
				border-radius: 16rpx;
				cursor: pointer;
				margin-right: 60rpx;
			}
			.no-pass {
				background-color: red;
				cursor: pointer;
			}
		}
	}

</style>
