<template>
	<view class="page" :style="{'min-height':h+'px','padding-top':(mt)+'px'}">
		<c-nav-bar title="订单详情" showIcon="true" :titleStyle="titleStyle"></c-nav-bar>
		<view class="content" style="background-color: #F5F8FA;">
			<view class="head">
				<text class="status" v-if="list.orderStatus=='1'">未核销</text>
				<text class="status" v-if="list.orderStatus=='-2'">待支付</text>
				<text class="status" v-if="list.orderStatus=='2'">已核销</text>
				<text class="status" v-if="list.orderStatus=='4'">已取消</text>
				<text class="status" v-if="list.orderStatus=='5'">已退款</text>
				<text>￥</text>
				<text>{{list.orderAmount}}</text>
			</view>
			<view class="ticketInfo">
				<view class="ticketInfo-hander">
					<view class="images">
						<image class="image" :src="list.cover" mode="aspectFill"></image>
					</view>
					<view class="" style="width: 100%; display: flex; flex-wrap: wrap; justify-content: space-between;">
						<view class="name">
							{{list.homestayName}}
						</view>
						<view class="date">
							<text>{{list.comboName}}</text>
						</view>
					</view>
				</view>

				<view class="ticketInfo-demo">
					<u-row customStyle="margin-bottom: 10px">
						<u-col span="3">
							<view class="demo-layout bg-purple">
								套餐说明
							</view>
						</u-col>
						<u-col span="9">
							<view class="demo-layout bg-purple-light">
								{{list.comboExplain}}
							</view>
						</u-col>
					</u-row>
				</view>
			</view>




			<!-- 订单信息 -->
			<view class="orderInfo">
				<view class="tit">订单信息</view>
				<u-cell :border="false">
					<text slot="icon" class="txt">订单编号</text>
					>
					<text slot="title" class="val">{{list.orderCode}}</text>
					<text slot="right-icon" class="icon"
						style="border: 1rpx solid #1372FF; border-radius: 50rpx; box-sizing: border-box; color: #1372FF;padding: 2rpx 10rpx; font-size: 22rpx; font-weight: Regular;"
						@tap="copyOrderNo(list)">复制</text>
				</u-cell>
				<u-cell :border="false">
					<text slot="icon" class="txt">关联房间</text>
					>
					<text slot="title" class="val">{{list.roomNumber==null?'暂无':list.roomNumber}}</text>
				</u-cell>
				<u-cell :border="false">
					<text slot="icon" class="txt">预约时间</text>
					>
					<text slot="title" class="val">{{list.repastTime}}</text>
				</u-cell>
				<u-cell :border="false" v-if="list.orderStatus==2">
					<text slot="icon" class="txt">核销时间</text>
					>
					<text slot="title" class="val">{{list.checkinTime}}</text>
				</u-cell>
				<u-cell :border="false">
					<text slot="icon" class="txt">预约人姓名</text>
					>
					<text slot="title" class="val">{{list.guestName}}</text>
				</u-cell>
				<u-cell :border="false">
					<text slot="icon" class="txt">预约手机号</text>
					>
					<text slot="title" class="val">{{list.guestPhoneCopy}}</text>
					<image style="width: 48rpx;height: 48rpx;" slot="right-icon" src="https://fsy.shengsi.gov.cn/file/20240605/20affd94bb514035b654823fefcaba2e.png" @click="callPhone(list.guestPhone)"></image>
				</u-cell>

				<u-cell :border="false" v-if="list.comboType==2">
					<text slot="icon" class="txt">就餐份数</text>
					>
					<text slot="title" class="val">{{list.num}}</text>
				</u-cell>
				<u-cell :border="false" v-if="list.comboType==1">
					<text slot="icon" class="txt">成人人数</text>
					>
					<text slot="title" class="val">{{list.num}}</text>
				</u-cell>
				<u-cell :border="false" v-if="list.comboType==1">
					<text slot="icon" class="txt">儿童人数</text>
					>
					<text slot="title" class="val">{{list.repastNum}}</text>
				</u-cell>


				<u-cell :border="false">
					<text slot="icon" class="txt">备注</text>
					>
					<text slot="title" class="val">{{list.remarks==null?'':list.remarks}}</text>
				</u-cell>
				<u-cell :border="false">
					<text slot="icon" class="txt">合计金额</text>
					>
					<text slot="title" class="val">{{list.orderAmount}}</text>
				</u-cell>
			</view>

		</view>
		<view class="btns">
			<template v-if="list.orderStatus==1&&isDel!=0">
				<view class="" @click="toStatus0(list)"
					style="color:#fff ; border-color: #1372FF; background-color: #1372FF; width: 100%;">
					确定核销
				</view>
			</template>
			<!-- 		<template v-if="list.orderStatus==-2||list.orderStatus==5||list.orderStatus==4">
				<view class="" style="color:#fff ; border-color: #1372FF; background-color: #1372FF; width: 100%;"
					@click="applyAfterSales(list)">
					删除订单
				</view>
			</template> -->
		</view>
		<u-toast ref="uToast"></u-toast>

	</view>

</template>

<script>
	export default {
		data() {
			return {
				titles: '订单详情',
				h: uni.getSystemInfoSync().windowHeight,
				mt: uni.getSystemInfoSync().statusBarHeight + 44,
				value: 1,
				status: 1,
				id: '',
				list: {},
				bedData: {},
				id: '',
				arriveTime: '',
				arriveTimes: '',
				leaveTime: '',
				leaveTimes: '',
				count: '',
				orderId: '',
				price: '',
				form: {
					initiator: 2,
					orderCode: '',
					status: ''
				},
				num: 0,
				checkInTimeStart: '',
				checkOutTime: '',
				checkInRooms: 0,
				isDel: null,
			}
		},
		onLoad(option) {

			console.log('+++++++++++', JSON.parse(option.obj));
			let obj = JSON.parse(option.obj)
			this.id = obj.orderId
			this.isDel = obj.isDel

			this.getList()
		},
		methods: {
			callPhone(phoneNumber){
				uni.makePhoneCall({
					phoneNumber
				})
			},
			copyOrderNo(no) {
				let that = this;
				// #ifdef H5
				this.$copyText(no).then(res => {
					this.$showToast('复制成功');
				})
				// #endif
				// #ifdef MP-WEIXIN
				uni.setClipboardData({
					data: no,
					success(res) {
						that.$showToast('复制成功');
					},
					fail(err) {
						that.$showToast('复制失败');
					}
				})
				// #endif
			},

			// 获取详情
			getList() {
				this.$api.get(`/merchant/hotel/repast/getRepastOrderInfo/${this.id}`)
					.then(res => {
						this.list = res.data.data;
						if(this.list.guestPhone) this.list.guestPhoneCopy = this.$aesTm.tuomin(this.list.guestPhone,2)
					})
			},
			// 删除
			applyAfterSales(item) {
				let ids = []
				ids.push(item.id)
				this.$api.del('/merchant/hotel/repast', ids).then(res => {
					console.log(res);
					if (res.data.code == 0) {
						uni.navigateTo({
							url: '/pagesMy/orderList/orderList'
						})
					} else this.$showToast(res.data.msg);
				})
			},
			toStatus0(item) {

				// this.$api.get('/merchant/hotel/repast/writeOffOrder/' + res.result)
				// 	.then(res => {
				// 		console.log('0000', res);
				// 		if (res.data.code == 0) {
				// 			uni.setStorageSync('list', res.data.data);

				// 		} else {
				// 			this.$showToast(res.data.msg)
				// 		}
				// 	})
				this.$api.get('/merchant/hotel/repast/writeOffOrder/' + item.orderCode)
					.then(res => {
						if (res.data.code == 0) {
							uni.navigateTo({
								url: '/pages/house/WriteOffResults?price=' + item.orderAmount
							})
						} else {
							this.$showToast(res.data.msg)
						}
					})
			}

		}
	}
</script>

<style lang="scss" scoped>
	.listItemed {
		padding: 13rpx 0;
		font-size: 26rpx;
		color: #666;
		align-items: center;

		.name {
			font-size: 28rpx;
			color: #111111;
			font-weight: bold;
		}

		.verityInfo {
			margin: 30rpx 0;
			line-height: 28rpx;
			height: 28rpx;
		}

		.top {
			margin-bottom: 30rpx;
		}

		.ticketType {
			margin-left: 20rpx;
			font-weight: 400;
			color: #94A9C8;
			line-height: 33rpx;
			height: 33rpx;
			font-size: 24rpx;
			background: #F5F8FA;
			border-radius: 8rpx;
			padding: 4rpx;
		}
	}

	.voucherCode_colse {
		padding: 20rpx;

		.title {

			height: 80rpx;
			font-weight: 600;
			font-size: 31rpx;
			color: #333;
			padding: 20rpx 30rpx;
			line-height: 80rpx;
			background: #fff;
			border-radius: 20rpx;
		}

		.title_info {
			line-height: 80rpx;
			font-weight: 600;
			font-size: 34rpx;
			color: #333;
			padding: 0 10rpx;
		}

		.codeList {
			// margin-top: 19rpx;
			padding: 20rpx;
			background: #fff;
			border-radius: 20rpx;
		}

		.listItem {
			display: flex;
			justify-content: space-between;
			padding: 13rpx 19rpx;
			flex-direction: row;
			font-size: 26rpx;
			color: #666;
			align-items: center;

			.verityInfo {
				margin: 30rpx 0;
				line-height: 28rpx;
				height: 28rpx;
			}

			.top {
				margin-bottom: 30rpx;
			}

			.ticketType {
				margin-left: 20rpx;
				font-weight: 400;
				color: #94A9C8;
				line-height: 33rpx;
				height: 33rpx;
				font-size: 24rpx;
				background: #F5F8FA;
				border-radius: 8rpx;
				padding: 4rpx;
			}


		}
	}

	.ci_bottom {
		text-align: center;
		width: 100%;
		padding: 0 24rpx 30rpx;
		box-sizing: border-box;
		font-weight: 600;
		font-size: 30rpx;
		color: #111111;
		// display: flex;
		// justify-content: space-between;

	}

	.ci_code {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.voucherCode {
		margin: 20rpx 23rpx 0;
		padding: 44rpx 24rpx 20rpx;
		border-radius: 20rpx;
		background-color: #fff;
		z-index: 2;

		.title {
			font-weight: 600;
			font-size: 34rpx;
			color: #333;
		}

		.orange {
			margin: 0 30rpx;
			font-weight: Regular;
			font-size: 24rpx;
			color: #AAAAAA;
		}
	}

	.bottom-list {
		display: flex;
		margin: 37rpx auto;
		justify-content: center;

		.image {
			width: 36rpx;
			height: 36rpx;
			margin: 0 8rpx;

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

		.text {
			font-size: 26rpx;
			color: #999999;
			font-weight: Regular;
		}
	}

	.minus,
	.plus {
		display: flex;
		align-items: center;
		// width: 44rpx;
		// height: 44rpx;
		// line-height: 44rpx;
		padding: 10rpx 10rpx;
		// padding-left: 8rpx;

		border: 1px solid #999;
		border-radius: 6rpx;
		text-align: center;
	}

	page {
		box-sizing: border-box;
		background-color: #F5F8FA;


		.content {
			position: relative;
			z-index: 3;
			padding-bottom: 160rpx;
			background-color: content;

			.hand-title {
				position: absolute;
				left: 20rpx;
				top: 100rpx;
				font-size: 24rpx;
				color: #fff;
			}
		}

	}


	.ticketInfo-demo {
		// border-bottom: 2rpx solid #EFEFEF;
		margin-top: 40rpx;

		.bg-purple {
			font-size: 26rpx;
			color: #808080;
			font-weight: Regular;
		}

		.bg-purple-light {
			font-size: 30rpx;
			color: #111111;
			font-weight: Regular;
		}
	}

	.two-center-two {
		box-sizing: border-box;

		.tit {
			font-size: 32rpx;
			color: #333333;
			margin: 20rpx 0;
		}

		.df-one {
			font-size: 32rpx;
			color: #333333;
			font-weight: bold;

			// .bg-purple-dark {
			// 	margin-left: 140rpx;
			// }

			// .demo-layout {
			// 	margin-left: 30rpx;
			// }
		}

		.df-two {
			border-bottom: 2rpx solid #EFEFEF;

			.bg-purple {
				// margin-right: 100rpx;
				width: 182rpx;
				margin-left: -13rpx;
			}

			.bg-purple-dark {
				// margin-left: 50rpx;
			}

			.bg-purple,
			.bg-purple-dark {
				font-size: 26rpx;
				color: #777777;
				font-weight: Regular;
				text-align: center;

				text {
					margin: 0 8rpx;
				}
			}

			.bg-purple-light {
				font-size: 24rpx;
				color: #666666;
				border: 1rpx solid #666666;
				text-align: center;
				border-radius: 50rpx;
			}

		}
	}


	.prices-content {
		margin: 24rpx 0;

		.txt1 {
			font-size: 32rpx;
			color: #111111;
			font-weight: bold;
		}

		.txt2 {
			margin: 12rpx 0;
			font-size: 26rpx;
			color: #777777;
			font-weight: Regular;
		}

	}



	.orderInfo {
		box-sizing: border-box;
		background-color: #fff;
		border-radius: 16rpx;
		width: 96%;
		margin: 0 auto 20rpx;
		padding: 0 0 30rpx;

		.tit {
			font-size: 32rpx;
			color: #333;
			padding-left: 30rpx;
			padding-top: 40rpx;
			font-weight: 600;
			margin-bottom: 20rpx;
		}

		.txt {
			font-size: 28rpx;
			color: #666;
			width: 140rpx;
		}

		.icon {
			font-size: 28rpx;
			color: #666;
		}

		.val {
			font-size: 28rpx;
			color: #333333;
			margin: 0 20rpx 0 30rpx;
			font-weight: Regular;
		}

	}

	.ticketInfo {
		box-sizing: border-box;
		width: 96%;
		margin: 0 auto 20rpx;
		padding: 44rpx 24rpx 10rpx;
		border-radius: 20rpx;
		position: relative;
		background-color: #fff;
		z-index: 2;

		.ticketInfo-hander {
			display: flex;

			.images {
				width: 136rpx;
				height: 136rpx;
				border-radius: 12rpx;
				margin-right: 20rpx;

				.image {
					border-radius: 12rpx;
					// width: 100%;
					// height: 100%;
					width: 136rpx;
					height: 136rpx;
				}
			}

		}

		.name {
			font-size: 32rpx;
			color: #333;
			font-weight: bold;
			width: 100%;
		}

		.date {
			// padding: 20rpx 0 32rpx;
			padding-top: 30rpx;
			font-size: 28rpx;
			color: #666666;
			font-weight: Regular;
		}



		.topHead {
			width: 96%;
			margin: 0 auto;
			background-color: #F5F8FA;
			padding: 28rpx 0 28rpx 84rpx;
			border-radius: 16rpx;
			position: relative;

			text {
				position: absolute;
				left: 0;
				top: 0;
				z-index: 1;
				border-radius: 16rpx 0 0 16rpx;
				width: 48rpx;
				color: #fff;
				font-size: 20rpx;
				background-color: #484F61;
				text-align: center;
				height: 100%;
				padding: 15rpx 10rpx 0;

			}

			.p {
				font-size: 28rpx;
				color: #333;

				&:nth-of-type(1) {
					font-weight: 600;
					margin-bottom: 16rpx;
				}
			}


		}

		.code {
			margin-top: 40rpx;
			text-align: center;
			position: relative;

			.cover,
			.sx {
				position: absolute;
				background-color: rgba(255, 255, 255, 0.5);
				width: 340rpx;
				height: 340rpx;
				top: 66rpx;
				left: 50%;
				transform: translate(-50%, 0);
			}

			.sx {
				width: 120rpx;
				height: 120rpx;
				top: 150rpx;
				background: transparent;
			}

			.txt {
				font-size: 28rpx;
			}

			image {
				width: 340rpx;
				height: 340rpx;
				margin: 30rpx 0;
			}
		}
	}

	.head {
		box-sizing: border-box;
		padding: 34rpx 24rpx 60rpx;
		display: flex;
		position: relative;
		z-index: 2;

		text {
			color: #111111;

			&:nth-child(1),
			&:nth-child(3) {
				font-size: 44rpx;
			}

			&:nth-child(2) {
				flex: 1;
				text-align: right;
				width: 100px;
				font-size: 36rpx;
			}
		}
	}


	.btns {
		box-sizing: border-box;
		width: 100%;
		position: fixed;
		bottom: 0;
		z-index: 4;
		left: 0;
		display: flex;
		padding: 32rpx 32rpx 50rpx;
		background-color: #fff;
		gap: 0 20rpx;
		box-shadow: 0 -8rpx 16rpx rgba(0, 0, 0, 0.06);


		&>view {
			width: calc(50% - 15rpx);
			height: 80rpx;
			border-radius: 46rpx;
			// border: 1rpx solid #999999;
			line-height: 80rpx;
			text-align: center;
			font-size: 28rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: Bold;
			color: #111111;
			background-color: #F6F6F6;
		}
	}
</style>