kitchendDevice/pageTwo/me/mymenu.vue

164 lines
3.4 KiB
Vue
Raw Normal View History

2023-09-08 15:17:21 +08:00
<template>
<view class="content">
<!-- 搜索 -->
2025-11-08 16:50:26 +08:00
<view class="search">
<input type="text" placeholder="请输入关键字快速搜索" v-model="name" />
<image src="/static/28.png" @click="handleSearch"></image>
</view>
2023-09-08 15:17:21 +08:00
<!-- 食谱 -->
2025-11-08 16:50:26 +08:00
<view class="footlist footbox" v-if="menuList.length">
<view class="list" v-for="(it,id) in menuList" :key="it" @click="handleDetail(it.id)">
<view class="topimg">
<image :src="it.cover_url" class="img" mode="aspectFill"></image>
2023-09-08 15:17:21 +08:00
</view>
2025-11-08 16:50:26 +08:00
<view class="item">
<view class="title">{{it.title}}</view>
<view class="name">
<image :src="it.create_user_head_pic"></image>
<text class="overflow">{{it.create_user_nickname}}</text>
2025-03-25 10:17:30 +08:00
</view>
2025-11-08 16:50:26 +08:00
<view class="zan" @click="handleZan(it)">
<icon class="iconfont" :class="[it.is_me_like_it=='yes'?'icon-icon3':'icon-icon_collect']">
</icon>
<text>{{it.likes_num}}</text>
2025-03-25 10:17:30 +08:00
</view>
</view>
2023-09-08 15:17:21 +08:00
</view>
2025-03-25 10:17:30 +08:00
<view class="endtext" v-if="!lastPage || page >= lastPage"> 到底了看看别的吧 </view>
</view>
<view v-if="!menuList.length" class="nolist">
<icon class="iconfont icon-wancan"></icon>
<text>还没有记录哦</text>
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"
export default {
data() {
return {
2025-03-25 10:17:30 +08:00
type: "",
name: "",
page: 1,
menuList: [],
lastPage: '',
2023-09-08 15:17:21 +08:00
}
},
components: {
2025-03-25 10:17:30 +08:00
search
2023-09-08 15:17:21 +08:00
},
onLoad(option) {
let that = this
that.type = option.pageName
uni.setNavigationBarTitle({
2025-03-25 10:17:30 +08:00
title: option.pageName
2023-09-08 15:17:21 +08:00
});
2025-04-02 09:49:39 +08:00
},
onShow() {
let that = this
that.name = ""
that.page = 1
that.menuList = []
2025-03-25 10:17:30 +08:00
that.handleCooklist()
},
onReachBottom() {
let that = this
if (!this.lastPage || this.page >= this.lastPage) {
uni.showToast({
title: '没有更多数据!',
icon: 'none'
})
return
}
this.page++
this.handleCooklist(this.page)
2023-09-08 15:17:21 +08:00
},
methods: {
2025-03-25 10:17:30 +08:00
handleCooklist() {
let that = this
let https = that.type == '我的菜谱' ? that.$model.getMyCookbook : that.$model.getUserCollectList
https({
page: that.page,
search_data: that.name
}).then(res => {
if (res.code != 0) return
that.menuList = res.data.content_list
that.lastPage = res.data.page_total
})
},
// 商品详情
handleDetail(id) {
uni.navigateTo({
2025-04-02 09:49:39 +08:00
url: "/pageTwo/me/menudetail?id=" + id + '&title=' + this.type
2025-03-25 10:17:30 +08:00
})
},
2023-09-08 15:17:21 +08:00
// 搜索
2025-11-08 16:50:26 +08:00
handleSearch() {
2025-03-25 10:17:30 +08:00
let that = this
that.page = 1
that.menuList = []
that.lastPage = ""
that.handleCooklist()
2023-09-08 15:17:21 +08:00
}
}
}
</script>
<style lang="scss" scoped>
2025-11-08 16:50:26 +08:00
.content {
background: #fff;
}
.search {
width: 100%;
position: fixed;
left: 0;
top: 0;
padding-bottom: 35px;
padding-top: 10px;
background-color: $maincolor;
input {
width: calc(100% - 40px);
background: #fff;
height: 39px;
line-height: 38px;
border-radius: 10px;
padding: 0 10px;
margin: 0 10px;
}
.input:hover {
box-shadow: 0 1rpx 20rpx #ccc;
}
image {
width: 25px;
height: 25px;
position: absolute;
right: 20px;
top: 18px;
z-index: 99;
}
}
.footlist {
position: relative;
margin-top: 68px;
padding: 15px;
width: calc(100% - 30px);
background: #fff;
border-radius: 15px 15px 0 0;
.item {
background: #f7f7f7 !important;
border-top: 1px solid #f7f7f7;
}
}
2025-03-25 10:17:30 +08:00
</style>