Dining_Hall/pages/advanceOrder/index.vue

334 lines
11 KiB
Vue
Raw Normal View History

2025-01-03 10:20:58 +08:00
<template>
<view>
<div class="top-cont flex justify-between align-center">
<div class="flex align-center">
<u-icon name="../../static/images/time.png" size="16"></u-icon>
<span style="margin-left: 5px">{{ newDate }}</span>
</div>
<div class="top-right-cont">
<span class="right-item" :class="{ active: active == 1 }" @click="active = 1">自取</span>
<span class="right-item" :class="{ active: active == 2 }" @click="active = 2">外卖</span>
</div>
</div>
2025-01-03 12:15:58 +08:00
<!-- <div class="top-cont-wrap">
2025-01-03 10:20:58 +08:00
</div>
2025-01-03 12:15:58 +08:00
<div style="height: 55px;"></div> -->
<u-row class="footer-cont" align="top">
<u-col :span="3" class="left-wrap">
<div v-for="(book, index) in cookbook" :key="index">
<div class="left-balance" :class="{ active: current == index }" @click="scrollToDetail(index)">
{{ handleRecipeType(book.recipeType) }}
</div>
</div>
</u-col>
<u-col :span="9">
<div class="right-wrap" v-for="(book, index) in cookbook" :key="index">
<!-- <div class="left-balance" :class="{ active: current == index }" @click="scrollToDetail(index)">
{{ handleRecipeType(book.recipeType) }}
</div> -->
<div
class="right-balance"
:ref="'detail-' + index + '-' + itemIndex"
v-for="(item, itemIndex) in book.recipeDetailList"
:key="itemIndex"
>
<div class="top-name">{{ item.intervalName }}</div>
<div class="cont-list" v-for="(food, foodIndex) in item.mealList">
<div>
<u-image :src="food.imageUrl" width="80px" height="80px" />
</div>
</div>
</div>
</div>
</u-col>
</u-row>
2025-01-03 10:20:58 +08:00
</view>
</template>
<script>
2025-01-03 12:15:58 +08:00
import uImage from '../../uni_modules/uview-ui/components/u--image/u--image.vue'
import URow from '../../uni_modules/uview-ui/components/u-row/u-row.vue'
2025-01-03 10:20:58 +08:00
export default {
2025-01-03 12:15:58 +08:00
components: { uImage, URow },
2025-01-03 10:20:58 +08:00
data() {
return {
current: 0,
newDate: '',
active: 1, // 1 自取 2 外卖
// 菜谱
cookbook: [
{
recipeType: 1, // 菜谱类型(1默认,2按天,3按周,4按月)
// 菜谱详情
recipeDetailList: [
{
intervalName: '午餐', // 餐次名称
// 菜品列表
mealList: [
{
mealName: '西红柿炒鸡蛋', // 菜品名称
imageUrl: 'https://img.yzcdn.cn/vant/apple-1.jpg', // 菜品图片
saleNum: 100,
supplyNum: 100, // 库存
restrictNum: 2, // 限购数量
salePrice: 10.2 // 菜品价格
},
{
mealName: '西红柿炒鸡蛋', // 菜品名称
imageUrl: 'https://img.yzcdn.cn/vant/apple-1.jpg', // 菜品图片
saleNum: 100,
supplyNum: 100, // 库存
restrictNum: 2, // 限购数量
salePrice: 10.2 // 菜品价格
},
{
mealName: '西红柿炒鸡蛋', // 菜品名称
imageUrl: 'https://img.yzcdn.cn/vant/apple-1.jpg', // 菜品图片
saleNum: 100,
supplyNum: 100, // 库存
restrictNum: 2, // 限购数量
salePrice: 10.2 // 菜品价格
},
{
mealName: '西红柿炒鸡蛋', // 菜品名称
imageUrl: 'https://img.yzcdn.cn/vant/apple-1.jpg', // 菜品图片
saleNum: 100,
supplyNum: 100, // 库存
restrictNum: 2, // 限购数量
salePrice: 10.2 // 菜品价格
}
]
}
]
},
{
recipeType: 2, // 菜谱类型(1默认,2按天,3按周,4按月)
// 菜谱详情
recipeDetailList: [
{
intervalName: '晚餐', // 餐次名称
// 菜品列表
mealList: [
{
mealName: '西红柿炒鸡蛋', // 菜品名称
imageUrl: 'https://img.yzcdn.cn/vant/apple-1.jpg', // 菜品图片
saleNum: 100,
supplyNum: 100, // 库存
restrictNum: 2, // 限购数量
salePrice: 10.2 // 菜品价格
},
{
mealName: '西红柿炒鸡蛋', // 菜品名称
imageUrl: 'https://img.yzcdn.cn/vant/apple-1.jpg', // 菜品图片
saleNum: 100,
supplyNum: 100, // 库存
restrictNum: 2, // 限购数量
salePrice: 10.2 // 菜品价格
},
{
mealName: '西红柿炒鸡蛋', // 菜品名称
imageUrl: 'https://img.yzcdn.cn/vant/apple-1.jpg', // 菜品图片
saleNum: 100,
supplyNum: 100, // 库存
restrictNum: 2, // 限购数量
salePrice: 10.2 // 菜品价格
},
{
mealName: '西红柿炒鸡蛋', // 菜品名称
imageUrl: 'https://img.yzcdn.cn/vant/apple-1.jpg', // 菜品图片
saleNum: 100,
supplyNum: 100, // 库存
restrictNum: 2, // 限购数量
salePrice: 10.2 // 菜品价格
}
]
}
]
},
{
recipeType: 3, // 菜谱类型(1默认,2按天,3按周,4按月)
// 菜谱详情
recipeDetailList: [
{
intervalName: '默认', // 餐次名称
// 菜品列表
mealList: [
{
mealName: '西红柿炒鸡蛋', // 菜品名称
imageUrl: 'https://img.yzcdn.cn/vant/apple-1.jpg', // 菜品图片
saleNum: 100,
supplyNum: 100, // 库存
restrictNum: 2, // 限购数量
salePrice: 10.2 // 菜品价格
},
{
mealName: '西红柿炒鸡蛋', // 菜品名称
imageUrl: 'https://img.yzcdn.cn/vant/apple-1.jpg', // 菜品图片
saleNum: 100,
supplyNum: 100, // 库存
restrictNum: 2, // 限购数量
salePrice: 10.2 // 菜品价格
},
{
mealName: '西红柿炒鸡蛋', // 菜品名称
imageUrl: 'https://img.yzcdn.cn/vant/apple-1.jpg', // 菜品图片
saleNum: 100,
supplyNum: 100, // 库存
restrictNum: 2, // 限购数量
salePrice: 10.2 // 菜品价格
},
{
mealName: '西红柿炒鸡蛋', // 菜品名称
imageUrl: 'https://img.yzcdn.cn/vant/apple-1.jpg', // 菜品图片
saleNum: 100,
supplyNum: 100, // 库存
restrictNum: 2, // 限购数量
salePrice: 10.2 // 菜品价格
}
]
}
]
}
]
}
},
onLoad() {
this.getNowFormatDate()
},
methods: {
// 获取当前时间
getNowFormatDate() {
let date = new Date()
let year = date.getFullYear()
let month = (date.getMonth() + 1).toString().padStart(2, '0')
let day = date.getDate().toString().padStart(2, '0')
let week = date.getDay()
let weeks = ['日', '一', '二', '三', '四', '五', '六']
this.newDate = `${month}-${day} 星期${weeks[week]}`
},
// 处理recipeType
handleRecipeType(type) {
if (type === 1) {
return '默认'
} else if (type === 2) {
return '按天'
} else if (type === 3) {
return '按周'
} else if (type === 4) {
return '按月'
}
},
2025-01-03 12:15:58 +08:00
// scrollToDetail(index) {
// console.log('🚀 ~ scrollToDetail ~ index', index)
// this.current = index
// this.$nextTick(() => {
// const detailElement = this.$refs['detail-' + index + '-0'][0]
// if (detailElement) {
// setTimeout(() => {
// detailElement.scrollIntoView({ behavior: 'smooth' })
// }, 100)
// }
// })
// }
// scrollToDetail(index) {
// console.log('🚀 ~ scrollToDetail ~ index', index)
// this.current = index
// this.$nextTick(() => {
// const query = uni.createSelectorQuery().in(this)
// const targetElement = this.$refs['detail-' + index + '-0'][0]
// if (targetElement) {
// query
// .select(`#${targetElement.id}`)
// .boundingClientRect(rect => {
// if (rect) {
// uni.pageScrollTo({
// scrollTop: rect.top + uni.getSystemInfoSync().statusBarHeight, // 需要加上状态栏高度
// duration: 300 // 滚动的时间
// })
// }
// })
// .exec()
// }
// })
// }
2025-01-03 10:20:58 +08:00
}
}
</script>
<style lang="scss" scoped>
page {
/* padding-top: env(safe-area-inset-top); */
background: #f9fbff;
2025-01-03 12:15:58 +08:00
position: relative;
2025-01-03 10:20:58 +08:00
}
.top-cont {
2025-01-03 12:15:58 +08:00
height: 55px;
padding: 0 16px;
2025-01-03 10:20:58 +08:00
background: #fff;
.top-right-cont {
background: rgba(15, 39, 75, 0.05);
border-radius: 11px 11px 11px 11px;
display: flex;
justify-content: space-around;
color: #0f274b;
font-size: 12px;
.right-item {
padding: 3px 10px;
border-radius: 11px 11px 11px 11px;
cursor: pointer;
&.active {
background: linear-gradient(180deg, #ffae82 0%, #ff6816 100%);
color: #fff;
}
}
}
}
2025-01-03 12:15:58 +08:00
.footer-cont {
height: calc(100vh - 115px);
overflow: auto;
}
.left-wrap {
position: fixed;
top: 55px;
height: calc(100vh - 115px);
overflow: auto;
2025-01-03 10:20:58 +08:00
.left-balance {
width: 88px;
height: 44px;
display: flex;
justify-content: center;
align-items: center;
font-weight: 500;
font-size: 14px;
color: #0f274b;
&.active {
background: #fff;
}
}
2025-01-03 12:15:58 +08:00
}
.right-wrap {
margin-left: 88px;
width: calc(100vw - 88px);
overflow: auto;
2025-01-03 10:20:58 +08:00
.right-balance {
padding: 0 8px;
background-color: #fff;
.top-name {
height: 44px;
font-weight: 400;
font-size: 12px;
color: rgba(15, 39, 75, 0.6);
display: flex;
align-items: center;
}
2025-01-03 12:15:58 +08:00
.cont-list {
display: flex;
padding: 8px;
/* border-bottom: 1px solid #f0f0f0; */
}
2025-01-03 10:20:58 +08:00
}
}
</style>