menu.vue 6.65 KB
<template>
	<view class="whitebg">
		<swiper class="activeSwiper" circular :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval"
			:duration="duration">
			<swiper-item v-for="(pic,index) in detail.photos?.split(',')" :key="index">
				<image class="cover" mode="aspectFill" :src="pic"></image>
			</swiper-item>
		</swiper>
		<view class="pd20">
		
			<view class="name">{{detail.name}}
			</view>

			<view class="info99">
				<image src="/pages_hotel/hotel/img/tag02.png" class="iconSquera"/>
				<text>{{detail.addName}}</text>
			</view>
			<view class="info99">
				<image src="/pages_hotel/hotel/img/tag03.png" class="iconSquerab"/>
				简介
			</view>
			<view class="info99" v-html="detail.introduction"></view>
		</view>
		
	</view>
	<view class="carPage">
		
		<view class="roomList">
			<view class="room" v-for="r in menu" :key="r.id">
				<view>
					<image class="roomCover" mode="aspectFill" :src="r.photos"></image>
				</view>
				<view style="width: calc(100% - 180rpx);">
					<view class="name"> {{r.name}}</view>
					<view class="tagline" style="margin: 10rpx 0;">
						<text class="tag" v-show="r.category== 0"> 早餐</text>
						<text class="tag" v-show="r.category==1">午餐</text>
						<text class="tag" v-show="r.category==2"> 晚餐</text>
					</view>
					<view class="flexinline">
						配送时间:{{r.psStart}} - {{r.psEnd}}
					</view>
					<view class="flexinline">
						配送地址: {{r.address}}
					</view>
					<view class="flexinline" style="justify-content: space-between;align-items: baseline;">
						<view class="price">¥<text>{{r.foodPrice}}</text></view>
						<button @click="goNext(r)">立即预定</button>
					</view>
				</view>
			</view>
		</view>

<!-- 		<view class="bbfix">
			<view class="subBtn" @click="submit"> 选好了 </view>
		</view> -->
	</view>
</template>

<script setup>
	import {
		reactive,
		toRefs,
		getCurrentInstance
	} from 'vue';
	import * as hotel from '@/common/hotel.js';
	import {
		onShow,
		onLoad,
		onShareAppMessage,
		onShareTimeline,
		onPullDownRefresh
	} from '@dcloudio/uni-app';
	import _ from 'lodash';
	const app = getApp();
	const {
		proxy
	} = getCurrentInstance();
	const data = reactive({
		menu: [],
		money: 0,
		meunNum: 0,
		detail: {}
	});
	const {
		menu,
		meunNum,
		money,detail
	} = toRefs(data);
	let menuId = ''
	let activeId = ''
	onLoad(options => {
		console.log(options)
		menuId = options.id
		activeId = options.activeId
		if ('detail' in options) {
			detail.value = JSON.parse(decodeURIComponent(options.detail));
		}
		getList()
		uni.setNavigationBarTitle({
			title: detail.value.name
		});
	})

	function getList() {
		uni.showLoading({
			title: '加载中'
		});
		hotel.getMenuById(menuId).then(res => {
			menu.value = res.rows
			for (let m of menu.value) {
				m.num = 0
				if (m.category == 0) {
					m.categoryName = '早餐'
				} else if (m.category == 1) {
					m.categoryName = '午餐'
				} else {
					m.categoryName = '晚餐'
				}
			}
			uni.hideLoading();
		})
	}

	function changeNum(e) {
		meunNum.value = e
		let moneyAll = 0
		for (let m of menu.value) {
			m.total = m.foodPrice * m.num
			moneyAll += m.total
		}
		money.value = moneyAll.toFixed(2)
	}
	function goNext(food){
		var food = encodeURIComponent(JSON.stringify(food))
		let path =
			`/pages_hotel/eat/order?activeId=${activeId}&food=${food}&menuId=${menuId}&orderName=${detail.value.name}&address=${detail.value.addName}`;
		uni.navigateTo({
			url: path
		});
	}
	function submit() {
		var foodlist = []
		for (let m of menu.value) {
			var obj = {
				arfId: m.id,
				name: m.name,
				categoryName: m.categoryName,
				category: m.category,
				num: m.num,
				price: m.foodPrice
			}
			if (obj.num > 0) {
				foodlist.push(obj)
			}
		}
		var list = encodeURIComponent(JSON.stringify(foodlist))
		let path =
			`/pages_hotel/eat/order?activeId=${activeId}&money=${money.value}&list=${list}&menuId=${menuId}&&orderName=${detail.value.name}&address=${detail.value.addName}`;
		uni.navigateTo({
			url: path
		});

	}
</script>

<style scoped lang="scss">
		.pd20{padding: 20rpx;}
	.cover{width: 700rpx;height: 393rpx;border-radius: 15rpx;margin: auto;    display: block;}
	swiper{height: 393rpx;}
	.iconSquera{width: 40rpx;height: 40rpx;}
		.iconSquerab{width: 26rpx;height: 26rpx;margin:0 10rpx;}
		.info99{margin: 0 0 20rpx;    display: flex;
	    align-items: center;
	font-size: 24rpx;
	color: #4C5359;}
	.whitebg{background-color: #fff;margin-bottom: 20rpx;
		.tt{line-height: 1;
			border-left: 4rpx solid #1EC886;
			color: #1EC886;
			padding-left: 14rpx;}
	}
	.carPage {
		:deep(.uni-collapse-item) {
			margin: 0;
		}
	}

	.flexTop {
		display: flex;

		&>view {
			width: 50%;
			text-align: center;
		}

		.tt {
			color: #1EC886;
			font-size: 28rpx;
		}
	}

	.roomList {
		padding: 20rpx;
		background: #fff;
		box-sizing: border-box;
	}

	.room {
		display: flex;
		position: relative;
		padding: 30rpx 0;
		border-bottom: 1px solid #DCDCDC;

		&:last-child {
			border-bottom: none;
		}

		.name {
			font-size: 34rpx;
			width: 100%;

			text {
				float: right;
			}
		}

		.orange {
			font-size: 24rpx;
		}

		.po {
			position: absolute;
			right: 0;
			bottom: 20rpx;
			display: flex;
			align-items: flex-end;

			// :deep(.uni-numbox__plus.uni-numbox-btns){
			// 	background: #1EC886!important;
			// 	.uni-numbox--text{color: #fff!important;}
			// }
		}

		.price {
			margin-right: 10rpx;
		}
	}

	.roomCover {
		width: 160rpx;
		margin-right: 20rpx;
		height: 170rpx;
		border-radius: 15rpx;
	}

	.price {
		display: flex;
		align-items: baseline;
		color: #1EC886;

		text {
			color: #1EC886;
			font-size: 55rpx;
		}
	}

	.flexinline {
		display: flex;
		font-size: 24rpx;
		color: #5E5E5E;
		width: 100%;

		text {
			margin-right: 15rpx;
		}
		.price{
			text{margin: 0;}
		}
		button{color: #fff;width: 180rpx;margin: 0;
		height: 50rpx;line-height:50rpx;
		font-size: 26rpx;
		border-radius: 25rpx;
		background: linear-gradient(270deg, #54E1B9, #00CAA6);}
	}

	.bbfix {
		background: #fff;
		height: 150rpx;
		display: flex;
		position: fixed;
		z-index: 89;
		width: 100%;
		bottom: 0;
		align-items: baseline;
		justify-content: space-between;
		border-top: 1rpx solid #dcdcdc;

		.price {
			padding-left: 20rpx;

			text {
				font-weight: bold;
				font-size: 45rpx;
				color: #ff8124;
			}
		}

		.subBtn {
			font-size: 36rpx;
			color: #ffffff;
			background: #ff8124;
			height: 120rpx;
			line-height: 100rpx;
			padding: 0 30rpx;
		}
	}
</style>