kitchendDevice/pages/index/index.vue

253 lines
4.8 KiB
Vue
Raw Normal View History

2023-09-08 15:17:21 +08:00
<template>
<view class="content">
<!-- 搜索 -->
<search @handleSearch="handleSearch"></search>
<!-- 轮播 -->
<view class="f_banner footbox" v-if="fimages.length">
<swiper class="swiper" circular="true" previous-margin="15px" next-margin="15px">
2025-03-25 10:17:30 +08:00
<swiper-item v-for="(ite, ind) in fimages" :key="ind" @click="handleDetail(ite.id)">
2023-09-08 15:17:21 +08:00
<image :src="ite.image" mode="aspectFill">
<view class="item">
<view class="title">{{ite.title}}</view>
<view class="name">
2025-03-25 10:17:30 +08:00
<image :src="ite.create_user_head_pic"></image>
<text>{{ite.create_user_nickname}}</text>
2023-09-08 15:17:21 +08:00
</view>
<view class="zan" @click="handleZan(ite)">
2025-03-25 10:17:30 +08:00
<icon class="iconfont"
:class="[ite.is_me_like_it=='yes'?'icon-icon3':'icon-icon_collect']">
</icon>
2023-09-08 15:17:21 +08:00
</view>
</view>
</image>
</swiper-item>
</swiper>
</view>
<!-- 功能 -->
<view class="tools footbox">
2025-03-25 10:17:30 +08:00
<view class="list" v-for="(ite,ind) in tools" :key="ind" @tap="navTo(ite.jump_url)">
2023-09-08 15:17:21 +08:00
<view>
2025-03-25 10:17:30 +08:00
<image :src="ite.icon"></image>
2023-09-08 15:17:21 +08:00
</view>
2025-03-25 10:17:30 +08:00
<text>{{ite.name}}</text>
2023-09-08 15:17:21 +08:00
</view>
</view>
<!-- 食谱 -->
<view class="itemTag footbox">
<view class="tab_list">
2025-03-25 10:17:30 +08:00
<scroll-view class="scroll-menu" scroll-x="true" style="white-space: nowrap;">
<view class="tabbar" v-for="(ite,ind) in menu" :key="ind" @click="handleToggle(ind)">
<view :class="[index ==ind?'active':'']">{{ite.name}}</view>
</view>
</scroll-view>
2023-09-08 15:17:21 +08:00
</view>
2025-03-25 10:17:30 +08:00
<foodList :list="footlist"></foodList>
2023-09-08 15:17:21 +08:00
</view>
</view>
</template>
<script>
2025-03-25 10:17:30 +08:00
import {
mapState
} from "vuex";
2023-09-08 15:17:21 +08:00
import search from "../../components/search.vue"
import foodList from "../../components/list.vue"
export default {
data() {
return {
index: 0,
fimages: [],
2025-03-25 10:17:30 +08:00
list: [],
tools: [],
footlist: [],
2023-09-08 15:17:21 +08:00
}
},
components: {
search,
foodList
},
2025-03-25 10:17:30 +08:00
computed: {
...mapState(["menuList"]),
menu() {
let that = this
return that.menuList
},
},
onLoad() {
2023-09-08 15:17:21 +08:00
let that = this
2025-03-25 10:17:30 +08:00
that.handleHomeInfo()
2023-09-08 15:17:21 +08:00
},
2025-03-25 10:17:30 +08:00
onShow() {},
2023-09-08 15:17:21 +08:00
methods: {
2025-03-25 10:17:30 +08:00
// 首页
handleHomeInfo() {
let that = this
that.$model.getHomeInfo({}).then(res => {
if (res.code != 0) return
that.fimages = res.data.banner
that.tools = res.data.jingang_region
that.handleCookListLabel()
})
},
2023-09-08 15:17:21 +08:00
// 餐食切换
2025-03-25 10:17:30 +08:00
handleToggle(ind) {
2023-09-08 15:17:21 +08:00
let that = this
2025-03-25 10:17:30 +08:00
that.index = ind
that.footlist = []
that.handleCookListLabel()
2023-09-08 15:17:21 +08:00
},
// 商品详情
2025-03-25 10:17:30 +08:00
handleDetail(id) {
2023-09-08 15:17:21 +08:00
uni.navigateTo({
2025-03-25 10:17:30 +08:00
url: "/pageTwo/me/menudetail?id=" + id
})
},
// 菜谱列表
handleCookListLabel() {
let that = this
that.$model.getCookListLabel({
cook_label: that.menu.length ? that.menu[that.index].id : 0,
page: 1,
}).then(res => {
if (res.code != 0) return
that.footlist = res.data.content_list
2023-09-08 15:17:21 +08:00
})
},
// 搜索
handleSearch(ite) {
2025-03-25 10:17:30 +08:00
let that = this
console.log("搜索", ite)
that.page = 1
that.footlist = []
if (ite == '') {
that.index = 0
that.handleCookListLabel()
} else {
that.$model.getHomeSearch({
search_data: ite
}).then(res => {
if (res.code != 0) return
that.index = null
that.footlist = res.data
})
}
2023-09-08 15:17:21 +08:00
},
// 点赞
2025-03-25 10:17:30 +08:00
handleZan() {
},
2023-09-08 15:17:21 +08:00
// 功能页面跳转
navTo(url) {
uni.navigateTo({
url
})
uni.switchTab({
url
})
},
}
}
</script>
<style lang="scss" scoped>
.f_banner {
width: 100% !important;
height: 450rpx;
margin-top: 50px;
/deep/swiper {
height: 450rpx;
}
image {
width: calc(100% - 10px);
height: 100%;
background-size: 100%;
margin: 0 5px;
border-radius: 10px;
}
}
.tools {
width: calc(100% - 30px);
background: #fff;
display: flex;
border-radius: 5px;
margin-top: 35px !important;
justify-content: space-between;
.list {
display: flex;
flex-wrap: wrap;
padding-bottom: 10px;
justify-content: center;
image,
icon {
2025-03-25 10:17:30 +08:00
width: 35px;
height: 35px;
margin-top: 10px;
2023-09-08 15:17:21 +08:00
}
view {
width: 55px;
height: 55px;
background-color: #fff;
margin-top: -20px;
border-radius: 50%;
text-align: center;
margin-bottom: 5px;
}
text {
display: block;
width: 100%;
text-align: center;
}
}
}
.tab_list {
display: flex;
2025-03-25 10:17:30 +08:00
justify-content: space-between;
.scroll-menu {
width: 100%;
white-space: nowrap;
view {
display: inline-block;
padding: 10px ;
text {
display: block;
width: 100%;
text-align: center;
margin-top: 10px;
}
}
}
2023-09-08 15:17:21 +08:00
.tabbar {
padding: 0 10px;
font-size: 16px;
font-weight: bold;
}
.active {
2025-03-25 10:17:30 +08:00
color: $maincolor;
border-bottom: 2px solid $maincolor;
2023-09-08 15:17:21 +08:00
}
}
.itemTag {
2025-03-25 10:17:30 +08:00
margin-top: 0px !important;
2023-09-08 15:17:21 +08:00
}
.t-icon-shipinyinliao2-chengzi {
width: 40px !important;
height: 33px !important;
}
2025-03-25 10:17:30 +08:00
</style>