<template>
	<view>
		<view class="order-item" v-for="hotel in hotelList">
			<view class="one-order" @click="gotoHome(hotel)">
				<view class="order--no">
					<view class="order--no__no">
						<view>{{ hotel.name }}</view>
					</view>
					<view class="order--no__status"></view>
				</view>
				<view class="order--room">
					<view class="order--room__pic">
						<u-image :src="getHotelPicPath(hotel.picturePath)" width="180rpx" height="180rpx"></u-image>
					</view>
					<view class="order--room__desc">
						{{ hotel.address || '' }}
					</view>
				</view>
				<view class="order--option"></view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		IMG_BASE_URL
	} from "../../config"
	import {
		mapState,
		mapMutations
	} from 'vuex'
	export default {
		data() {
			return {
				hotelList: [],
			};
		},
		methods: {
			...mapMutations('m_business', ['updateCurrentHotel']),
			async getHotelAndNames() {
				let res = await uni.$http.post('/hotel', {
					isTest: false,
					pageNo: 1,
					pageSize: 999
				})
				this.hotelList = res.data.data.records
			},
			gotoHome(hotel) {
				this.updateCurrentHotel(hotel)
				uni.switchTab({
					url: '/pages/home/home'
				})
			},
			getHotelPicPath(path) {
				return IMG_BASE_URL + '/' + path
			}
		},
		async onLoad() {
			await this.getHotelAndNames()
		},
		// #ifdef MP-WEIXIN
		onShareAppMessage(info) {
			return {
				title: '源享住',
				path: 'pages/login/login',
				imageUrl: "/static/logo.png"
			}
		}
		// #endif
	}
</script>

<style lang="scss">
	page {
		background-color: #EBEAF0;
		position: absolute;

		.top-subsection {
			top: 0;
			position: sticky;
			background-color: #EBEAF0;
			z-index: 99;
		}

		.order-item {
			width: 100%;
			display: flex;
			flex-direction: column;

			.one-order {
				display: flex;
				flex-direction: column;
				background-color: #ffffff;
				margin-top: 2*5rpx;
				margin-left: 2*10rpx;
				margin-right: 2*10rpx;
				margin-bottom: 2*5rpx;
				border-radius: 2*12rpx;

				.order--no {
					display: flex;
					flex-direction: row;
					font-size: 28rpx;
					margin-top: 2*10rpx;
					margin-left: 2*10rpx;
					margin-right: 2*10rpx;
					margin-bottom: 2*5rpx;

					.order--no__no {
						display: flex;
						flex-direction: row;
					}
				}

				.order--room {
					display: flex;
					flex-direction: row;
					background-color: #f1f1f4;
					margin-left: 2*10rpx;
					margin-right: 2*10rpx;
					margin-top: 2*5rpx;
					margin-bottom: 2*5rpx;
					padding-top: 2*12rpx;
					padding-bottom: 2*12rpx;
					border-radius: 2*8rpx;

					.order--room__pic {
						padding-left: 5rpx;
						width: 190rpx;
					}

					.order--room__desc {
						display: flex;
						align-items: center;
						width: 100%;
						padding-left: 20rpx;
					}

					.order--room__price {
						display: flex;
						align-items: center;
						justify-content: end;
						width: 200rpx;
						padding-right: 20rpx;
						color: red;
						font-size: 40rpx;
					}
				}

				.order--duration {
					display: flex;
					flex-direction: row;
					background-color: #f1f1f4;
					margin-left: 2*10rpx;
					margin-right: 2*10rpx;
					margin-top: 2*5rpx;
					margin-bottom: 2*5rpx;
					border-radius: 2*8rpx;

					.order--duration__start {
						display: flex;
						flex-direction: column;
						width: 1000rpx;
						margin-top: 2*5rpx;
						margin-bottom: 2*10rpx;
						margin-left: 2*5rpx;
						margin-right: 2*5rpx;

						.order--duration__start-title {
							display: flex;
							font-size: 28rpx;
							height: 60rpx;
							align-items: center;
						}

						.order--duration__start-date {
							display: flex;
							flex-direction: row;
							justify-content: space-between;
							height: 50rpx;
							align-items: center;
							font-size: 24rpx;
						}
					}

					.order--duration__end {
						display: flex;
						flex-direction: column;
						width: 1000rpx;
						margin-top: 2*5rpx;
						margin-bottom: 2*10rpx;
						margin-left: 2*30rpx;
						margin-right: 2*5rpx;

						.order--duration__end-title {
							display: flex;
							font-size: 28rpx;
							height: 60rpx;
							align-items: center;
						}

						.order--duration__end-date {
							display: flex;
							flex-direction: row;
							justify-content: space-between;
							height: 50rpx;
							align-items: center;
							font-size: 24rpx;
						}
					}

					.order--duration__total {
						width: 100%;
						display: flex;
						align-items: center;
						justify-content: flex-end;
						padding-right: 20rpx;
						font-weight: bold;
					}
				}

				.order--option {
					display: flex;
					flex-direction: row;
					margin-left: 2*10rpx;
					margin-right: 2*10rpx;
					margin-top: 2*5rpx;
					margin-bottom: 2*5rpx;
				}
			}

			.card-item {
				margin-top: 10rpx;
				margin-bottom: 10rpx;
				display: flex;

				.card-item-left {
					width: 140rpx;
				}
			}
		}
	}
</style>