<template>
	<view class="content">
		<view class="info">
			<view class="one">
				<view class="one_1">
					<view class="left">桌号：{{shopInfo.table}}</view>
					<view class="right">人数：{{shopInfo.num}}人</view>
				</view>
				<view class="one_2">
					<view class="left">备注</view>
					<view class="right">
						<input v-model="shopInfo.remark" placeholder="填写备注" />
						<uni-icons color="#C0C0C0" type="forward" size="14"></uni-icons>
					</view>
				</view>
			</view>
			<view class="two">
				<view class="two_1">消费明细</view>
				<view class="two_2">
					<scroll-view scroll-y="true" class="scroll-view">
						<view class="list-scroll-view">
							<view class="list" v-for="(item,index) in list" :key="index">
								<view class="img">
									<image class="image" :src="item.file" mode=""></image>
								</view>
								<view class="info">
									<view class="name textOver">
										<text>{{item.name}}</text>
									</view>
									<view class="spec" v-if="item.spec">
										<text>{{item.spec}}</text>
									</view>
								</view>
								<view class="money">
									<text>¥{{item.price}}</text>
									<text>×{{item.num}}</text>
								</view>
							</view>
						</view>
					</scroll-view>
				</view>
				<view class="two_3">
					共{{shopInfo.numTotal}}件商品，合计：<text>￥</text><text>{{shopInfo.total}}</text>
				</view>
			</view>
		</view>
		<view class="foot">
			<view class="foot_1">
				合计<text>￥</text><text>{{shopInfo.total||0}}</text>
			</view>
			<view class="foot_2">
				<button class="button" @tap.stop="toBuy">下单</button>
			</view>
		</view>
		<uni-popup ref="popup" type="dialog">
			<uni-popup-dialog mode="input" message="成功消息" :duration="2000" :before-close="true" @close="close"
				@confirm="confirm"></uni-popup-dialog>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: "",
				shopInfo: {},
				list: [],
			}
		},
		onLoad: async function(e) {
			const that = this;
			that.$set(that, `id`, e.id);
			that.search();
		},
		onShow() {
			const that = this;
		},
		methods: {
			async search(e) {
				const that = this;
				if (that.id) {
					let res = await that.$api(`order/${that.id}`, 'GET', {});
					if (res.errcode == '0') {
						that.$set(that, `list`, res.data.list)
						that.$set(that, `shopInfo`, res.data)
					}
				}
			},
			// 下单
			toBuy() {
				const that = this;
				that.$refs.popup.open()
			},
			close() {
				const that = this;
				that.$refs.popup.close()
			},
		}
	}
</script>

<style lang="scss">
	.content {
		background-color: #f1f1f1;
		font-family: 12px/1 Tahoma, Helvetica, Arial, "\5b8b\4f53", sans-serif;

		.info {
			display: flex;
			flex-direction: column;
			position: relative;
			flex-grow: 1;
			padding: 2vw;

			.one {
				padding: 2vw;
				background-color: #ffffff;
				border-radius: 4vw;

				.one_1 {
					display: flex;
					justify-content: space-between;
					align-items: center;
					background-color: #ffffff;
					border-radius: 3vw;
					padding: 4vw 2vw;
					border-bottom: 1px solid #f1f1f1;

					.left {
						font-size: 16px;
						font-weight: 600;
					}

					.right {
						font-size: 14px;
					}
				}


				.one_2 {
					display: flex;
					justify-content: space-between;
					align-items: center;
					padding: 3vw 2vw;
					font-size: 14px;

					.right {
						display: flex;
						align-items: flex-end;
						color: #858585;

						/deep/input {
							text-align: right;
						}
					}
				}
			}

			.two {
				margin: 2vw 0;
				padding: 2vw;
				background-color: #ffffff;
				border-radius: 4vw;

				.two_1 {
					padding: 2vw 0;
					font-size: 16px;
					font-weight: 600;
				}

				.two_2 {
					position: relative;
					display: flex;
					flex-direction: column;
					height: 32vh;

					.list {
						display: flex;
						width: 88vw;
						margin: 0 0 2vw 0;
						padding: 2vw;
						box-shadow: 0 0 5px #f1f1f1;
						border-radius: 5px;

						.img {
							width: 30vw;

							.image {
								width: 30vw;
								height: 20vw;
								border-radius: 5px;
							}
						}

						.info {
							width: 40vw;
							padding: 0 0 0 2vw;

							.name {
								font-size: 16px;
							}

							.spec {
								font-size: 12px;
								color: #858585;
							}
						}

						.money {
							display: flex;
							flex-direction: column;
							align-items: flex-end;
							width: 20vw;

							text:first-child {
								font-size: 14px;
								color: #FF8C00;
							}
						}
					}
				}

				.two_3 {
					padding: 3vw;
					text-align: right;
					font-size: 14px;
					color: #858585;
					border-top: 1px solid #f1f1f1;

					text:first-child {
						color: #FF7800;
					}

					text:last-child {
						color: #FF7800;
						font-size: 18px;
					}
				}
			}
		}

		.foot {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 2vw 3vw;
			background-color: #ffffff;
			border-top: 1px solid #f1f1f1;

			.foot_1 {
				font-size: 14px;
				color: #858585;

				text:first-child {
					color: #FF7800;
				}

				text:last-child {
					color: #FF7800;
					font-size: 18px;
				}
			}

			.foot_2 {
				.button {
					background-color: #FF8C00;
					color: #ffffff;
					border-radius: 5vw;
					font-size: 16px;
				}
			}
		}
	}

	.scroll-view {
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;

		.list-scroll-view {
			display: flex;
			flex-direction: column;
		}
	}
</style>
